babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993
  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. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  410. * @param num the number to convert and pad
  411. * @param length the expected length of the string
  412. * @returns the padded string
  413. */
  414. static PadNumber(num: number, length: number): string;
  415. }
  416. }
  417. declare module "babylonjs/Misc/deepCopier" {
  418. /**
  419. * Class containing a set of static utilities functions for deep copy.
  420. */
  421. export class DeepCopier {
  422. /**
  423. * Tries to copy an object by duplicating every property
  424. * @param source defines the source object
  425. * @param destination defines the target object
  426. * @param doNotCopyList defines a list of properties to avoid
  427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  428. */
  429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  430. }
  431. }
  432. declare module "babylonjs/Misc/precisionDate" {
  433. /**
  434. * Class containing a set of static utilities functions for precision date
  435. */
  436. export class PrecisionDate {
  437. /**
  438. * Gets either window.performance.now() if supported or Date.now() else
  439. */
  440. static get Now(): number;
  441. }
  442. }
  443. declare module "babylonjs/Misc/devTools" {
  444. /** @hidden */
  445. export class _DevTools {
  446. static WarnImport(name: string): string;
  447. }
  448. }
  449. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  450. /**
  451. * Interface used to define the mechanism to get data from the network
  452. */
  453. export interface IWebRequest {
  454. /**
  455. * Returns client's response url
  456. */
  457. responseURL: string;
  458. /**
  459. * Returns client's status
  460. */
  461. status: number;
  462. /**
  463. * Returns client's status as a text
  464. */
  465. statusText: string;
  466. }
  467. }
  468. declare module "babylonjs/Misc/webRequest" {
  469. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  470. import { Nullable } from "babylonjs/types";
  471. /**
  472. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  473. */
  474. export class WebRequest implements IWebRequest {
  475. private _xhr;
  476. /**
  477. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  478. * i.e. when loading files, where the server/service expects an Authorization header
  479. */
  480. static CustomRequestHeaders: {
  481. [key: string]: string;
  482. };
  483. /**
  484. * Add callback functions in this array to update all the requests before they get sent to the network
  485. */
  486. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  487. private _injectCustomRequestHeaders;
  488. /**
  489. * Gets or sets a function to be called when loading progress changes
  490. */
  491. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  492. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  493. /**
  494. * Returns client's state
  495. */
  496. get readyState(): number;
  497. /**
  498. * Returns client's status
  499. */
  500. get status(): number;
  501. /**
  502. * Returns client's status as a text
  503. */
  504. get statusText(): string;
  505. /**
  506. * Returns client's response
  507. */
  508. get response(): any;
  509. /**
  510. * Returns client's response url
  511. */
  512. get responseURL(): string;
  513. /**
  514. * Returns client's response as text
  515. */
  516. get responseText(): string;
  517. /**
  518. * Gets or sets the expected response type
  519. */
  520. get responseType(): XMLHttpRequestResponseType;
  521. set responseType(value: XMLHttpRequestResponseType);
  522. /** @hidden */
  523. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  524. /** @hidden */
  525. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  526. /**
  527. * Cancels any network activity
  528. */
  529. abort(): void;
  530. /**
  531. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  532. * @param body defines an optional request body
  533. */
  534. send(body?: Document | BodyInit | null): void;
  535. /**
  536. * Sets the request method, request URL
  537. * @param method defines the method to use (GET, POST, etc..)
  538. * @param url defines the url to connect with
  539. */
  540. open(method: string, url: string): void;
  541. /**
  542. * Sets the value of a request header.
  543. * @param name The name of the header whose value is to be set
  544. * @param value The value to set as the body of the header
  545. */
  546. setRequestHeader(name: string, value: string): void;
  547. /**
  548. * Get the string containing the text of a particular header's value.
  549. * @param name The name of the header
  550. * @returns The string containing the text of the given header name
  551. */
  552. getResponseHeader(name: string): Nullable<string>;
  553. }
  554. }
  555. declare module "babylonjs/Misc/fileRequest" {
  556. import { Observable } from "babylonjs/Misc/observable";
  557. /**
  558. * File request interface
  559. */
  560. export interface IFileRequest {
  561. /**
  562. * Raised when the request is complete (success or error).
  563. */
  564. onCompleteObservable: Observable<IFileRequest>;
  565. /**
  566. * Aborts the request for a file.
  567. */
  568. abort: () => void;
  569. }
  570. }
  571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  572. /**
  573. * Define options used to create a render target texture
  574. */
  575. export class RenderTargetCreationOptions {
  576. /**
  577. * Specifies is mipmaps must be generated
  578. */
  579. generateMipMaps?: boolean;
  580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  581. generateDepthBuffer?: boolean;
  582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  583. generateStencilBuffer?: boolean;
  584. /** Defines texture type (int by default) */
  585. type?: number;
  586. /** Defines sampling mode (trilinear by default) */
  587. samplingMode?: number;
  588. /** Defines format (RGBA by default) */
  589. format?: number;
  590. }
  591. }
  592. declare module "babylonjs/Engines/constants" {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** 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 */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** 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 */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** 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 */
  688. static readonly GEQUAL: number;
  689. /** 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 */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * 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.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * 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.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1046. import { Nullable } from "babylonjs/types";
  1047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1048. /**
  1049. * This represents the required contract to create a new type of texture loader.
  1050. */
  1051. export interface IInternalTextureLoader {
  1052. /**
  1053. * Defines wether the loader supports cascade loading the different faces.
  1054. */
  1055. supportCascades: boolean;
  1056. /**
  1057. * This returns if the loader support the current file information.
  1058. * @param extension defines the file extension of the file being loaded
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string): boolean;
  1062. /**
  1063. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1064. * @param data contains the texture data
  1065. * @param texture defines the BabylonJS internal texture
  1066. * @param createPolynomials will be true if polynomials have been requested
  1067. * @param onLoad defines the callback to trigger once the texture is ready
  1068. * @param onError defines the callback to trigger in case of error
  1069. */
  1070. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1071. /**
  1072. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param callback defines the method to call once ready to upload
  1076. */
  1077. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Engines/IPipelineContext" {
  1081. /**
  1082. * Class used to store and describe the pipeline context associated with an effect
  1083. */
  1084. export interface IPipelineContext {
  1085. /**
  1086. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1087. */
  1088. isAsync: boolean;
  1089. /**
  1090. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1091. */
  1092. isReady: boolean;
  1093. /** @hidden */
  1094. _getVertexShaderCode(): string | null;
  1095. /** @hidden */
  1096. _getFragmentShaderCode(): string | null;
  1097. /** @hidden */
  1098. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Meshes/dataBuffer" {
  1102. /**
  1103. * Class used to store gfx data (like WebGLBuffer)
  1104. */
  1105. export class DataBuffer {
  1106. /**
  1107. * Gets or sets the number of objects referencing this buffer
  1108. */
  1109. references: number;
  1110. /** Gets or sets the size of the underlying buffer */
  1111. capacity: number;
  1112. /**
  1113. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1114. */
  1115. is32Bits: boolean;
  1116. /**
  1117. * Gets the underlying buffer
  1118. */
  1119. get underlyingResource(): any;
  1120. }
  1121. }
  1122. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1123. /** @hidden */
  1124. export interface IShaderProcessor {
  1125. attributeProcessor?: (attribute: string) => string;
  1126. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1127. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1128. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1129. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1130. lineProcessor?: (line: string, isFragment: boolean) => string;
  1131. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1136. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1155. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1156. /** @hidden */
  1157. export class ShaderCodeNode {
  1158. line: string;
  1159. children: ShaderCodeNode[];
  1160. additionalDefineKey?: string;
  1161. additionalDefineValue?: string;
  1162. isValid(preprocessors: {
  1163. [key: string]: string;
  1164. }): boolean;
  1165. process(preprocessors: {
  1166. [key: string]: string;
  1167. }, options: ProcessingOptions): string;
  1168. }
  1169. }
  1170. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1171. /** @hidden */
  1172. export class ShaderCodeCursor {
  1173. private _lines;
  1174. lineIndex: number;
  1175. get currentLine(): string;
  1176. get canRead(): boolean;
  1177. set lines(value: string[]);
  1178. }
  1179. }
  1180. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1181. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1182. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1183. /** @hidden */
  1184. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1185. process(preprocessors: {
  1186. [key: string]: string;
  1187. }, options: ProcessingOptions): string;
  1188. }
  1189. }
  1190. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1191. /** @hidden */
  1192. export class ShaderDefineExpression {
  1193. isTrue(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1199. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1200. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1201. /** @hidden */
  1202. export class ShaderCodeTestNode extends ShaderCodeNode {
  1203. testExpression: ShaderDefineExpression;
  1204. isValid(preprocessors: {
  1205. [key: string]: string;
  1206. }): boolean;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1210. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1211. /** @hidden */
  1212. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1213. define: string;
  1214. not: boolean;
  1215. constructor(define: string, not?: boolean);
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineOrOperator 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/shaderDefineAndOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1236. leftOperand: ShaderDefineExpression;
  1237. rightOperand: ShaderDefineExpression;
  1238. isTrue(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. operand: string;
  1249. testValue: string;
  1250. constructor(define: string, operand: string, testValue: string);
  1251. isTrue(preprocessors: {
  1252. [key: string]: string;
  1253. }): boolean;
  1254. }
  1255. }
  1256. declare module "babylonjs/Offline/IOfflineProvider" {
  1257. /**
  1258. * Class used to enable access to offline support
  1259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1260. */
  1261. export interface IOfflineProvider {
  1262. /**
  1263. * Gets a boolean indicating if scene must be saved in the database
  1264. */
  1265. enableSceneOffline: boolean;
  1266. /**
  1267. * Gets a boolean indicating if textures must be saved in the database
  1268. */
  1269. enableTexturesOffline: boolean;
  1270. /**
  1271. * Open the offline support and make it available
  1272. * @param successCallback defines the callback to call on success
  1273. * @param errorCallback defines the callback to call on error
  1274. */
  1275. open(successCallback: () => void, errorCallback: () => void): void;
  1276. /**
  1277. * Loads an image from the offline support
  1278. * @param url defines the url to load from
  1279. * @param image defines the target DOM image
  1280. */
  1281. loadImage(url: string, image: HTMLImageElement): void;
  1282. /**
  1283. * Loads a file from offline support
  1284. * @param url defines the URL to load from
  1285. * @param sceneLoaded defines a callback to call on success
  1286. * @param progressCallBack defines a callback to call when progress changed
  1287. * @param errorCallback defines a callback to call on error
  1288. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1289. */
  1290. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1291. }
  1292. }
  1293. declare module "babylonjs/Misc/filesInputStore" {
  1294. /**
  1295. * Class used to help managing file picking and drag'n'drop
  1296. * File Storage
  1297. */
  1298. export class FilesInputStore {
  1299. /**
  1300. * List of files ready to be loaded
  1301. */
  1302. static FilesToLoad: {
  1303. [key: string]: File;
  1304. };
  1305. }
  1306. }
  1307. declare module "babylonjs/Misc/retryStrategy" {
  1308. import { WebRequest } from "babylonjs/Misc/webRequest";
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module "babylonjs/Misc/baseError" {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module "babylonjs/Misc/fileTools" {
  1332. import { WebRequest } from "babylonjs/Misc/webRequest";
  1333. import { Nullable } from "babylonjs/types";
  1334. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1335. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1336. import { BaseError } from "babylonjs/Misc/baseError";
  1337. /** @ignore */
  1338. export class LoadFileError extends BaseError {
  1339. request?: WebRequest;
  1340. file?: File;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. * @param file defines the optional file
  1346. */
  1347. constructor(message: string, object?: WebRequest | File);
  1348. }
  1349. /** @ignore */
  1350. export class RequestFileError extends BaseError {
  1351. request: WebRequest;
  1352. /**
  1353. * Creates a new LoadFileError
  1354. * @param message defines the message of the error
  1355. * @param request defines the optional web request
  1356. */
  1357. constructor(message: string, request: WebRequest);
  1358. }
  1359. /** @ignore */
  1360. export class ReadFileError extends BaseError {
  1361. file: File;
  1362. /**
  1363. * Creates a new ReadFileError
  1364. * @param message defines the message of the error
  1365. * @param file defines the optional file
  1366. */
  1367. constructor(message: string, file: File);
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export class FileTools {
  1373. /**
  1374. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1375. */
  1376. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1377. /**
  1378. * Gets or sets the base URL to use to load assets
  1379. */
  1380. static BaseUrl: string;
  1381. /**
  1382. * Default behaviour for cors in the application.
  1383. * It can be a string if the expected behavior is identical in the entire app.
  1384. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1385. */
  1386. static CorsBehavior: string | ((url: string | string[]) => string);
  1387. /**
  1388. * Gets or sets a function used to pre-process url before using them to load assets
  1389. */
  1390. static PreprocessUrl: (url: string) => string;
  1391. /**
  1392. * Removes unwanted characters from an url
  1393. * @param url defines the url to clean
  1394. * @returns the cleaned url
  1395. */
  1396. private static _CleanUrl;
  1397. /**
  1398. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1399. * @param url define the url we are trying
  1400. * @param element define the dom element where to configure the cors policy
  1401. */
  1402. static SetCorsBehavior(url: string | string[], element: {
  1403. crossOrigin: string | null;
  1404. }): void;
  1405. /**
  1406. * Loads an image as an HTMLImageElement.
  1407. * @param input url string, ArrayBuffer, or Blob to load
  1408. * @param onLoad callback called when the image successfully loads
  1409. * @param onError callback called when the image fails to load
  1410. * @param offlineProvider offline provider for caching
  1411. * @param mimeType optional mime type
  1412. * @returns the HTMLImageElement of the loaded image
  1413. */
  1414. 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>;
  1415. /**
  1416. * Reads a file from a File object
  1417. * @param file defines the file to load
  1418. * @param onSuccess defines the callback to call when data is loaded
  1419. * @param onProgress defines the callback to call during loading process
  1420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1421. * @param onError defines the callback to call when an error occurs
  1422. * @returns a file request object
  1423. */
  1424. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file from a url
  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 offlineProvider defines the offline provider for caching
  1431. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1432. * @param onError callback called when the file fails to load
  1433. * @returns a file request object
  1434. */
  1435. 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;
  1436. /**
  1437. * Loads a file
  1438. * @param url url to load
  1439. * @param onSuccess callback called when the file successfully loads
  1440. * @param onProgress callback called while file is loading (if the server supports this mode)
  1441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1442. * @param onError callback called when the file fails to load
  1443. * @param onOpened callback called when the web request is opened
  1444. * @returns a file request object
  1445. */
  1446. 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;
  1447. /**
  1448. * Checks if the loaded document was accessed via `file:`-Protocol.
  1449. * @returns boolean
  1450. */
  1451. static IsFileURL(): boolean;
  1452. }
  1453. }
  1454. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1455. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1456. import { WebRequest } from "babylonjs/Misc/webRequest";
  1457. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1458. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1459. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1460. /** @hidden */
  1461. export class ShaderProcessor {
  1462. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1463. private static _ProcessPrecision;
  1464. private static _ExtractOperation;
  1465. private static _BuildSubExpression;
  1466. private static _BuildExpression;
  1467. private static _MoveCursorWithinIf;
  1468. private static _MoveCursor;
  1469. private static _EvaluatePreProcessors;
  1470. private static _PreparePreProcessors;
  1471. private static _ProcessShaderConversion;
  1472. private static _ProcessIncludes;
  1473. /**
  1474. * Loads a file from a url
  1475. * @param url url to load
  1476. * @param onSuccess callback called when the file successfully loads
  1477. * @param onProgress callback called while file is loading (if the server supports this mode)
  1478. * @param offlineProvider defines the offline provider for caching
  1479. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1480. * @param onError callback called when the file fails to load
  1481. * @returns a file request object
  1482. * @hidden
  1483. */
  1484. 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;
  1485. }
  1486. }
  1487. declare module "babylonjs/Maths/math.like" {
  1488. import { float, int, DeepImmutable } from "babylonjs/types";
  1489. /**
  1490. * @hidden
  1491. */
  1492. export interface IColor4Like {
  1493. r: float;
  1494. g: float;
  1495. b: float;
  1496. a: float;
  1497. }
  1498. /**
  1499. * @hidden
  1500. */
  1501. export interface IColor3Like {
  1502. r: float;
  1503. g: float;
  1504. b: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IVector4Like {
  1510. x: float;
  1511. y: float;
  1512. z: float;
  1513. w: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IVector3Like {
  1519. x: float;
  1520. y: float;
  1521. z: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector2Like {
  1527. x: float;
  1528. y: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IMatrixLike {
  1534. toArray(): DeepImmutable<Float32Array>;
  1535. updateFlag: int;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IViewportLike {
  1541. x: float;
  1542. y: float;
  1543. width: float;
  1544. height: float;
  1545. }
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IPlaneLike {
  1550. normal: IVector3Like;
  1551. d: float;
  1552. normalize(): void;
  1553. }
  1554. }
  1555. declare module "babylonjs/Materials/iEffectFallbacks" {
  1556. import { Effect } from "babylonjs/Materials/effect";
  1557. /**
  1558. * Interface used to define common properties for effect fallbacks
  1559. */
  1560. export interface IEffectFallbacks {
  1561. /**
  1562. * Removes the defines that should be removed when falling back.
  1563. * @param currentDefines defines the current define statements for the shader.
  1564. * @param effect defines the current effect we try to compile
  1565. * @returns The resulting defines with defines of the current rank removed.
  1566. */
  1567. reduce(currentDefines: string, effect: Effect): string;
  1568. /**
  1569. * Removes the fallback from the bound mesh.
  1570. */
  1571. unBindMesh(): void;
  1572. /**
  1573. * Checks to see if more fallbacks are still availible.
  1574. */
  1575. hasMoreFallbacks: boolean;
  1576. }
  1577. }
  1578. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1579. /**
  1580. * Class used to evalaute queries containing `and` and `or` operators
  1581. */
  1582. export class AndOrNotEvaluator {
  1583. /**
  1584. * Evaluate a query
  1585. * @param query defines the query to evaluate
  1586. * @param evaluateCallback defines the callback used to filter result
  1587. * @returns true if the query matches
  1588. */
  1589. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1590. private static _HandleParenthesisContent;
  1591. private static _SimplifyNegation;
  1592. }
  1593. }
  1594. declare module "babylonjs/Misc/tags" {
  1595. /**
  1596. * Class used to store custom tags
  1597. */
  1598. export class Tags {
  1599. /**
  1600. * Adds support for tags on the given object
  1601. * @param obj defines the object to use
  1602. */
  1603. static EnableFor(obj: any): void;
  1604. /**
  1605. * Removes tags support
  1606. * @param obj defines the object to use
  1607. */
  1608. static DisableFor(obj: any): void;
  1609. /**
  1610. * Gets a boolean indicating if the given object has tags
  1611. * @param obj defines the object to use
  1612. * @returns a boolean
  1613. */
  1614. static HasTags(obj: any): boolean;
  1615. /**
  1616. * Gets the tags available on a given object
  1617. * @param obj defines the object to use
  1618. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1619. * @returns the tags
  1620. */
  1621. static GetTags(obj: any, asString?: boolean): any;
  1622. /**
  1623. * Adds tags to an object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1626. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1627. */
  1628. static AddTagsTo(obj: any, tagsString: string): void;
  1629. /**
  1630. * @hidden
  1631. */
  1632. static _AddTagTo(obj: any, tag: string): void;
  1633. /**
  1634. * Removes specific tags from a specific object
  1635. * @param obj defines the object to use
  1636. * @param tagsString defines the tags to remove
  1637. */
  1638. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1639. /**
  1640. * @hidden
  1641. */
  1642. static _RemoveTagFrom(obj: any, tag: string): void;
  1643. /**
  1644. * Defines if tags hosted on an object match a given query
  1645. * @param obj defines the object to use
  1646. * @param tagsQuery defines the tag query
  1647. * @returns a boolean
  1648. */
  1649. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1650. }
  1651. }
  1652. declare module "babylonjs/Maths/math.scalar" {
  1653. /**
  1654. * Scalar computation library
  1655. */
  1656. export class Scalar {
  1657. /**
  1658. * Two pi constants convenient for computation.
  1659. */
  1660. static TwoPi: number;
  1661. /**
  1662. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1663. * @param a number
  1664. * @param b number
  1665. * @param epsilon (default = 1.401298E-45)
  1666. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1667. */
  1668. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1669. /**
  1670. * Returns a string : the upper case translation of the number i to hexadecimal.
  1671. * @param i number
  1672. * @returns the upper case translation of the number i to hexadecimal.
  1673. */
  1674. static ToHex(i: number): string;
  1675. /**
  1676. * Returns -1 if value is negative and +1 is value is positive.
  1677. * @param value the value
  1678. * @returns the value itself if it's equal to zero.
  1679. */
  1680. static Sign(value: number): number;
  1681. /**
  1682. * Returns the value itself if it's between min and max.
  1683. * Returns min if the value is lower than min.
  1684. * Returns max if the value is greater than max.
  1685. * @param value the value to clmap
  1686. * @param min the min value to clamp to (default: 0)
  1687. * @param max the max value to clamp to (default: 1)
  1688. * @returns the clamped value
  1689. */
  1690. static Clamp(value: number, min?: number, max?: number): number;
  1691. /**
  1692. * the log2 of value.
  1693. * @param value the value to compute log2 of
  1694. * @returns the log2 of value.
  1695. */
  1696. static Log2(value: number): number;
  1697. /**
  1698. * Loops the value, so that it is never larger than length and never smaller than 0.
  1699. *
  1700. * This is similar to the modulo operator but it works with floating point numbers.
  1701. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1702. * With t = 5 and length = 2.5, the result would be 0.0.
  1703. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1704. * @param value the value
  1705. * @param length the length
  1706. * @returns the looped value
  1707. */
  1708. static Repeat(value: number, length: number): number;
  1709. /**
  1710. * Normalize the value between 0.0 and 1.0 using min and max values
  1711. * @param value value to normalize
  1712. * @param min max to normalize between
  1713. * @param max min to normalize between
  1714. * @returns the normalized value
  1715. */
  1716. static Normalize(value: number, min: number, max: number): number;
  1717. /**
  1718. * Denormalize the value from 0.0 and 1.0 using min and max values
  1719. * @param normalized value to denormalize
  1720. * @param min max to denormalize between
  1721. * @param max min to denormalize between
  1722. * @returns the denormalized value
  1723. */
  1724. static Denormalize(normalized: number, min: number, max: number): number;
  1725. /**
  1726. * Calculates the shortest difference between two given angles given in degrees.
  1727. * @param current current angle in degrees
  1728. * @param target target angle in degrees
  1729. * @returns the delta
  1730. */
  1731. static DeltaAngle(current: number, target: number): number;
  1732. /**
  1733. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1734. * @param tx value
  1735. * @param length length
  1736. * @returns The returned value will move back and forth between 0 and length
  1737. */
  1738. static PingPong(tx: number, length: number): number;
  1739. /**
  1740. * Interpolates between min and max with smoothing at the limits.
  1741. *
  1742. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1743. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1744. * @param from from
  1745. * @param to to
  1746. * @param tx value
  1747. * @returns the smooth stepped value
  1748. */
  1749. static SmoothStep(from: number, to: number, tx: number): number;
  1750. /**
  1751. * Moves a value current towards target.
  1752. *
  1753. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1754. * Negative values of maxDelta pushes the value away from target.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting value
  1759. */
  1760. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1763. *
  1764. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1765. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1766. * @param current current value
  1767. * @param target target value
  1768. * @param maxDelta max distance to move
  1769. * @returns resulting angle
  1770. */
  1771. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1772. /**
  1773. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1774. * @param start start value
  1775. * @param end target value
  1776. * @param amount amount to lerp between
  1777. * @returns the lerped value
  1778. */
  1779. static Lerp(start: number, end: number, amount: number): number;
  1780. /**
  1781. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1783. * @param start start value
  1784. * @param end target value
  1785. * @param amount amount to lerp between
  1786. * @returns the lerped value
  1787. */
  1788. static LerpAngle(start: number, end: number, amount: number): number;
  1789. /**
  1790. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1791. * @param a start value
  1792. * @param b target value
  1793. * @param value value between a and b
  1794. * @returns the inverseLerp value
  1795. */
  1796. static InverseLerp(a: number, b: number, value: number): number;
  1797. /**
  1798. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1799. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1800. * @param value1 spline value
  1801. * @param tangent1 spline value
  1802. * @param value2 spline value
  1803. * @param tangent2 spline value
  1804. * @param amount input value
  1805. * @returns hermite result
  1806. */
  1807. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1808. /**
  1809. * Returns a random float number between and min and max values
  1810. * @param min min value of random
  1811. * @param max max value of random
  1812. * @returns random value
  1813. */
  1814. static RandomRange(min: number, max: number): number;
  1815. /**
  1816. * This function returns percentage of a number in a given range.
  1817. *
  1818. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1819. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1820. * @param number to convert to percentage
  1821. * @param min min range
  1822. * @param max max range
  1823. * @returns the percentage
  1824. */
  1825. static RangeToPercent(number: number, min: number, max: number): number;
  1826. /**
  1827. * This function returns number that corresponds to the percentage in a given range.
  1828. *
  1829. * PercentToRange(0.34,0,100) will return 34.
  1830. * @param percent to convert to number
  1831. * @param min min range
  1832. * @param max max range
  1833. * @returns the number
  1834. */
  1835. static PercentToRange(percent: number, min: number, max: number): number;
  1836. /**
  1837. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1838. * @param angle The angle to normalize in radian.
  1839. * @return The converted angle.
  1840. */
  1841. static NormalizeRadians(angle: number): number;
  1842. }
  1843. }
  1844. declare module "babylonjs/Maths/math.constants" {
  1845. /**
  1846. * Constant used to convert a value to gamma space
  1847. * @ignorenaming
  1848. */
  1849. export const ToGammaSpace: number;
  1850. /**
  1851. * Constant used to convert a value to linear space
  1852. * @ignorenaming
  1853. */
  1854. export const ToLinearSpace = 2.2;
  1855. /**
  1856. * Constant used to define the minimal number value in Babylon.js
  1857. * @ignorenaming
  1858. */
  1859. let Epsilon: number;
  1860. export { Epsilon };
  1861. }
  1862. declare module "babylonjs/Maths/math.viewport" {
  1863. /**
  1864. * Class used to represent a viewport on screen
  1865. */
  1866. export class Viewport {
  1867. /** viewport left coordinate */
  1868. x: number;
  1869. /** viewport top coordinate */
  1870. y: number;
  1871. /**viewport width */
  1872. width: number;
  1873. /** viewport height */
  1874. height: number;
  1875. /**
  1876. * Creates a Viewport object located at (x, y) and sized (width, height)
  1877. * @param x defines viewport left coordinate
  1878. * @param y defines viewport top coordinate
  1879. * @param width defines the viewport width
  1880. * @param height defines the viewport height
  1881. */
  1882. constructor(
  1883. /** viewport left coordinate */
  1884. x: number,
  1885. /** viewport top coordinate */
  1886. y: number,
  1887. /**viewport width */
  1888. width: number,
  1889. /** viewport height */
  1890. height: number);
  1891. /**
  1892. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1893. * @param renderWidth defines the rendering width
  1894. * @param renderHeight defines the rendering height
  1895. * @returns a new Viewport
  1896. */
  1897. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1898. /**
  1899. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @param ref defines the target viewport
  1903. * @returns the current viewport
  1904. */
  1905. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1906. /**
  1907. * Returns a new Viewport copied from the current one
  1908. * @returns a new Viewport
  1909. */
  1910. clone(): Viewport;
  1911. }
  1912. }
  1913. declare module "babylonjs/Misc/arrayTools" {
  1914. /**
  1915. * Class containing a set of static utilities functions for arrays.
  1916. */
  1917. export class ArrayTools {
  1918. /**
  1919. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1920. * @param size the number of element to construct and put in the array
  1921. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1922. * @returns a new array filled with new objects
  1923. */
  1924. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1925. }
  1926. }
  1927. declare module "babylonjs/Maths/math.vector" {
  1928. import { Viewport } from "babylonjs/Maths/math.viewport";
  1929. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1930. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1931. /**
  1932. * Class representing a vector containing 2 coordinates
  1933. */
  1934. export class Vector2 {
  1935. /** defines the first coordinate */
  1936. x: number;
  1937. /** defines the second coordinate */
  1938. y: number;
  1939. /**
  1940. * Creates a new Vector2 from the given x and y coordinates
  1941. * @param x defines the first coordinate
  1942. * @param y defines the second coordinate
  1943. */
  1944. constructor(
  1945. /** defines the first coordinate */
  1946. x?: number,
  1947. /** defines the second coordinate */
  1948. y?: number);
  1949. /**
  1950. * Gets a string with the Vector2 coordinates
  1951. * @returns a string with the Vector2 coordinates
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Gets class name
  1956. * @returns the string "Vector2"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Gets current vector hash code
  1961. * @returns the Vector2 hash code as a number
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1966. * @param array defines the source array
  1967. * @param index defines the offset in source array
  1968. * @returns the current Vector2
  1969. */
  1970. toArray(array: FloatArray, index?: number): Vector2;
  1971. /**
  1972. * Copy the current vector to an array
  1973. * @returns a new array with 2 elements: the Vector2 coordinates.
  1974. */
  1975. asArray(): number[];
  1976. /**
  1977. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1978. * @param source defines the source Vector2
  1979. * @returns the current updated Vector2
  1980. */
  1981. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Sets the Vector2 coordinates with the given floats
  1984. * @param x defines the first coordinate
  1985. * @param y defines the second coordinate
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFromFloats(x: number, y: number): Vector2;
  1989. /**
  1990. * Sets the Vector2 coordinates with the given floats
  1991. * @param x defines the first coordinate
  1992. * @param y defines the second coordinate
  1993. * @returns the current updated Vector2
  1994. */
  1995. set(x: number, y: number): Vector2;
  1996. /**
  1997. * Add another vector with the current one
  1998. * @param otherVector defines the other vector
  1999. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2000. */
  2001. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2002. /**
  2003. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2004. * @param otherVector defines the other vector
  2005. * @param result defines the target vector
  2006. * @returns the unmodified current Vector2
  2007. */
  2008. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2009. /**
  2010. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2011. * @param otherVector defines the other vector
  2012. * @returns the current updated Vector2
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2015. /**
  2016. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2
  2019. */
  2020. addVector3(otherVector: Vector3): Vector2;
  2021. /**
  2022. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2023. * @param otherVector defines the other vector
  2024. * @returns a new Vector2
  2025. */
  2026. subtract(otherVector: Vector2): Vector2;
  2027. /**
  2028. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2029. * @param otherVector defines the other vector
  2030. * @param result defines the target vector
  2031. * @returns the unmodified current Vector2
  2032. */
  2033. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2034. /**
  2035. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns the current updated Vector2
  2038. */
  2039. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2040. /**
  2041. * Multiplies in place the current Vector2 coordinates by the given ones
  2042. * @param otherVector defines the other vector
  2043. * @returns the current updated Vector2
  2044. */
  2045. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2046. /**
  2047. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @returns a new Vector2
  2050. */
  2051. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2052. /**
  2053. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2054. * @param otherVector defines the other vector
  2055. * @param result defines the target vector
  2056. * @returns the unmodified current Vector2
  2057. */
  2058. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2059. /**
  2060. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2061. * @param x defines the first coordinate
  2062. * @param y defines the second coordinate
  2063. * @returns a new Vector2
  2064. */
  2065. multiplyByFloats(x: number, y: number): Vector2;
  2066. /**
  2067. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2068. * @param otherVector defines the other vector
  2069. * @returns a new Vector2
  2070. */
  2071. divide(otherVector: Vector2): Vector2;
  2072. /**
  2073. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2074. * @param otherVector defines the other vector
  2075. * @param result defines the target vector
  2076. * @returns the unmodified current Vector2
  2077. */
  2078. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2079. /**
  2080. * Divides the current Vector2 coordinates by the given ones
  2081. * @param otherVector defines the other vector
  2082. * @returns the current updated Vector2
  2083. */
  2084. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2085. /**
  2086. * Gets a new Vector2 with current Vector2 negated coordinates
  2087. * @returns a new Vector2
  2088. */
  2089. negate(): Vector2;
  2090. /**
  2091. * Negate this vector in place
  2092. * @returns this
  2093. */
  2094. negateInPlace(): Vector2;
  2095. /**
  2096. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2097. * @param result defines the Vector3 object where to store the result
  2098. * @returns the current Vector2
  2099. */
  2100. negateToRef(result: Vector2): Vector2;
  2101. /**
  2102. * Multiply the Vector2 coordinates by scale
  2103. * @param scale defines the scaling factor
  2104. * @returns the current updated Vector2
  2105. */
  2106. scaleInPlace(scale: number): Vector2;
  2107. /**
  2108. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2109. * @param scale defines the scaling factor
  2110. * @returns a new Vector2
  2111. */
  2112. scale(scale: number): Vector2;
  2113. /**
  2114. * Scale the current Vector2 values by a factor to a given Vector2
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector2 object where to store the result
  2117. * @returns the unmodified current Vector2
  2118. */
  2119. scaleToRef(scale: number, result: Vector2): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2122. * @param scale defines the scale factor
  2123. * @param result defines the Vector2 object where to store the result
  2124. * @returns the unmodified current Vector2
  2125. */
  2126. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Gets a boolean if two vectors are equals
  2129. * @param otherVector defines the other vector
  2130. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2131. */
  2132. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2133. /**
  2134. * Gets a boolean if two vectors are equals (using an epsilon value)
  2135. * @param otherVector defines the other vector
  2136. * @param epsilon defines the minimal distance to consider equality
  2137. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2138. */
  2139. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2140. /**
  2141. * Gets a new Vector2 from current Vector2 floored values
  2142. * @returns a new Vector2
  2143. */
  2144. floor(): Vector2;
  2145. /**
  2146. * Gets a new Vector2 from current Vector2 floored values
  2147. * @returns a new Vector2
  2148. */
  2149. fract(): Vector2;
  2150. /**
  2151. * Gets the length of the vector
  2152. * @returns the vector length (float)
  2153. */
  2154. length(): number;
  2155. /**
  2156. * Gets the vector squared length
  2157. * @returns the vector squared length (float)
  2158. */
  2159. lengthSquared(): number;
  2160. /**
  2161. * Normalize the vector
  2162. * @returns the current updated Vector2
  2163. */
  2164. normalize(): Vector2;
  2165. /**
  2166. * Gets a new Vector2 copied from the Vector2
  2167. * @returns a new Vector2
  2168. */
  2169. clone(): Vector2;
  2170. /**
  2171. * Gets a new Vector2(0, 0)
  2172. * @returns a new Vector2
  2173. */
  2174. static Zero(): Vector2;
  2175. /**
  2176. * Gets a new Vector2(1, 1)
  2177. * @returns a new Vector2
  2178. */
  2179. static One(): Vector2;
  2180. /**
  2181. * Gets a new Vector2 set from the given index element of the given array
  2182. * @param array defines the data source
  2183. * @param offset defines the offset in the data source
  2184. * @returns a new Vector2
  2185. */
  2186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2187. /**
  2188. * Sets "result" from the given index element of the given array
  2189. * @param array defines the data source
  2190. * @param offset defines the offset in the data source
  2191. * @param result defines the target vector
  2192. */
  2193. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2194. /**
  2195. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2196. * @param value1 defines 1st point of control
  2197. * @param value2 defines 2nd point of control
  2198. * @param value3 defines 3rd point of control
  2199. * @param value4 defines 4th point of control
  2200. * @param amount defines the interpolation factor
  2201. * @returns a new Vector2
  2202. */
  2203. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2204. /**
  2205. * 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".
  2206. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2207. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2208. * @param value defines the value to clamp
  2209. * @param min defines the lower limit
  2210. * @param max defines the upper limit
  2211. * @returns a new Vector2
  2212. */
  2213. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2214. /**
  2215. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2216. * @param value1 defines the 1st control point
  2217. * @param tangent1 defines the outgoing tangent
  2218. * @param value2 defines the 2nd control point
  2219. * @param tangent2 defines the incoming tangent
  2220. * @param amount defines the interpolation factor
  2221. * @returns a new Vector2
  2222. */
  2223. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2224. /**
  2225. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2226. * @param start defines the start vector
  2227. * @param end defines the end vector
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Gets the dot product of the vector "left" and the vector "right"
  2234. * @param left defines first vector
  2235. * @param right defines second vector
  2236. * @returns the dot product (float)
  2237. */
  2238. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2239. /**
  2240. * Returns a new Vector2 equal to the normalized given vector
  2241. * @param vector defines the vector to normalize
  2242. * @returns a new Vector2
  2243. */
  2244. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2247. * @param left defines 1st vector
  2248. * @param right defines 2nd vector
  2249. * @returns a new Vector2
  2250. */
  2251. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2254. * @param left defines 1st vector
  2255. * @param right defines 2nd vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2261. * @param vector defines the vector to transform
  2262. * @param transformation defines the matrix to apply
  2263. * @returns a new Vector2
  2264. */
  2265. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2266. /**
  2267. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @param result defines the target vector
  2271. */
  2272. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2273. /**
  2274. * Determines if a given vector is included in a triangle
  2275. * @param p defines the vector to test
  2276. * @param p0 defines 1st triangle point
  2277. * @param p1 defines 2nd triangle point
  2278. * @param p2 defines 3rd triangle point
  2279. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2280. */
  2281. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2282. /**
  2283. * Gets the distance between the vectors "value1" and "value2"
  2284. * @param value1 defines first vector
  2285. * @param value2 defines second vector
  2286. * @returns the distance between vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2289. /**
  2290. * Returns the squared distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the squared distance between vectors
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns a new Vector2
  2301. */
  2302. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2303. /**
  2304. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2305. * @param p defines the middle point
  2306. * @param segA defines one point of the segment
  2307. * @param segB defines the other point of the segment
  2308. * @returns the shortest distance
  2309. */
  2310. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2311. }
  2312. /**
  2313. * Class used to store (x,y,z) vector representation
  2314. * A Vector3 is the main object used in 3D geometry
  2315. * It can represent etiher the coordinates of a point the space, either a direction
  2316. * Reminder: js uses a left handed forward facing system
  2317. */
  2318. export class Vector3 {
  2319. /**
  2320. * Defines the first coordinates (on X axis)
  2321. */
  2322. x: number;
  2323. /**
  2324. * Defines the second coordinates (on Y axis)
  2325. */
  2326. y: number;
  2327. /**
  2328. * Defines the third coordinates (on Z axis)
  2329. */
  2330. z: number;
  2331. private static _UpReadOnly;
  2332. private static _ZeroReadOnly;
  2333. /**
  2334. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2335. * @param x defines the first coordinates (on X axis)
  2336. * @param y defines the second coordinates (on Y axis)
  2337. * @param z defines the third coordinates (on Z axis)
  2338. */
  2339. constructor(
  2340. /**
  2341. * Defines the first coordinates (on X axis)
  2342. */
  2343. x?: number,
  2344. /**
  2345. * Defines the second coordinates (on Y axis)
  2346. */
  2347. y?: number,
  2348. /**
  2349. * Defines the third coordinates (on Z axis)
  2350. */
  2351. z?: number);
  2352. /**
  2353. * Creates a string representation of the Vector3
  2354. * @returns a string with the Vector3 coordinates.
  2355. */
  2356. toString(): string;
  2357. /**
  2358. * Gets the class name
  2359. * @returns the string "Vector3"
  2360. */
  2361. getClassName(): string;
  2362. /**
  2363. * Creates the Vector3 hash code
  2364. * @returns a number which tends to be unique between Vector3 instances
  2365. */
  2366. getHashCode(): number;
  2367. /**
  2368. * Creates an array containing three elements : the coordinates of the Vector3
  2369. * @returns a new array of numbers
  2370. */
  2371. asArray(): number[];
  2372. /**
  2373. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2374. * @param array defines the destination array
  2375. * @param index defines the offset in the destination array
  2376. * @returns the current Vector3
  2377. */
  2378. toArray(array: FloatArray, index?: number): Vector3;
  2379. /**
  2380. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2381. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2382. */
  2383. toQuaternion(): Quaternion;
  2384. /**
  2385. * Adds the given vector to the current Vector3
  2386. * @param otherVector defines the second operand
  2387. * @returns the current updated Vector3
  2388. */
  2389. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2390. /**
  2391. * Adds the given coordinates to the current Vector3
  2392. * @param x defines the x coordinate of the operand
  2393. * @param y defines the y coordinate of the operand
  2394. * @param z defines the z coordinate of the operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2398. /**
  2399. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2400. * @param otherVector defines the second operand
  2401. * @returns the resulting Vector3
  2402. */
  2403. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2404. /**
  2405. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2406. * @param otherVector defines the second operand
  2407. * @param result defines the Vector3 object where to store the result
  2408. * @returns the current Vector3
  2409. */
  2410. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2411. /**
  2412. * Subtract the given vector from the current Vector3
  2413. * @param otherVector defines the second operand
  2414. * @returns the current updated Vector3
  2415. */
  2416. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2417. /**
  2418. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2419. * @param otherVector defines the second operand
  2420. * @returns the resulting Vector3
  2421. */
  2422. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2423. /**
  2424. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2425. * @param otherVector defines the second operand
  2426. * @param result defines the Vector3 object where to store the result
  2427. * @returns the current Vector3
  2428. */
  2429. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2430. /**
  2431. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2432. * @param x defines the x coordinate of the operand
  2433. * @param y defines the y coordinate of the operand
  2434. * @param z defines the z coordinate of the operand
  2435. * @returns the resulting Vector3
  2436. */
  2437. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2438. /**
  2439. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2447. /**
  2448. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2449. * @returns a new Vector3
  2450. */
  2451. negate(): Vector3;
  2452. /**
  2453. * Negate this vector in place
  2454. * @returns this
  2455. */
  2456. negateInPlace(): Vector3;
  2457. /**
  2458. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the current Vector3
  2461. */
  2462. negateToRef(result: Vector3): Vector3;
  2463. /**
  2464. * Multiplies the Vector3 coordinates by the float "scale"
  2465. * @param scale defines the multiplier factor
  2466. * @returns the current updated Vector3
  2467. */
  2468. scaleInPlace(scale: number): Vector3;
  2469. /**
  2470. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2471. * @param scale defines the multiplier factor
  2472. * @returns a new Vector3
  2473. */
  2474. scale(scale: number): Vector3;
  2475. /**
  2476. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2477. * @param scale defines the multiplier factor
  2478. * @param result defines the Vector3 object where to store the result
  2479. * @returns the current Vector3
  2480. */
  2481. scaleToRef(scale: number, result: Vector3): Vector3;
  2482. /**
  2483. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2484. * @param scale defines the scale factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the unmodified current Vector3
  2487. */
  2488. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2491. * @param otherVector defines the second operand
  2492. * @returns true if both vectors are equals
  2493. */
  2494. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2495. /**
  2496. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2497. * @param otherVector defines the second operand
  2498. * @param epsilon defines the minimal distance to define values as equals
  2499. * @returns true if both vectors are distant less than epsilon
  2500. */
  2501. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 coordinates equals the given floats
  2504. * @param x defines the x coordinate of the operand
  2505. * @param y defines the y coordinate of the operand
  2506. * @param z defines the z coordinate of the operand
  2507. * @returns true if both vectors are equals
  2508. */
  2509. equalsToFloats(x: number, y: number, z: number): boolean;
  2510. /**
  2511. * Multiplies the current Vector3 coordinates by the given ones
  2512. * @param otherVector defines the second operand
  2513. * @returns the current updated Vector3
  2514. */
  2515. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2516. /**
  2517. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2518. * @param otherVector defines the second operand
  2519. * @returns the new Vector3
  2520. */
  2521. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2524. * @param otherVector defines the second operand
  2525. * @param result defines the Vector3 object where to store the result
  2526. * @returns the current Vector3
  2527. */
  2528. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2529. /**
  2530. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2531. * @param x defines the x coordinate of the operand
  2532. * @param y defines the y coordinate of the operand
  2533. * @param z defines the z coordinate of the operand
  2534. * @returns the new Vector3
  2535. */
  2536. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2537. /**
  2538. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2539. * @param otherVector defines the second operand
  2540. * @returns the new Vector3
  2541. */
  2542. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2543. /**
  2544. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2545. * @param otherVector defines the second operand
  2546. * @param result defines the Vector3 object where to store the result
  2547. * @returns the current Vector3
  2548. */
  2549. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones.
  2552. * @param otherVector defines the second operand
  2553. * @returns the current updated Vector3
  2554. */
  2555. divideInPlace(otherVector: Vector3): Vector3;
  2556. /**
  2557. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2558. * @param other defines the second operand
  2559. * @returns the current updated Vector3
  2560. */
  2561. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2562. /**
  2563. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2564. * @param other defines the second operand
  2565. * @returns the current updated Vector3
  2566. */
  2567. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2568. /**
  2569. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2570. * @param x defines the x coordinate of the operand
  2571. * @param y defines the y coordinate of the operand
  2572. * @param z defines the z coordinate of the operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2576. /**
  2577. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2586. * Check if is non uniform within a certain amount of decimal places to account for this
  2587. * @param epsilon the amount the values can differ
  2588. * @returns if the the vector is non uniform to a certain number of decimal places
  2589. */
  2590. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2591. /**
  2592. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2593. */
  2594. get isNonUniform(): boolean;
  2595. /**
  2596. * Gets a new Vector3 from current Vector3 floored values
  2597. * @returns a new Vector3
  2598. */
  2599. floor(): Vector3;
  2600. /**
  2601. * Gets a new Vector3 from current Vector3 floored values
  2602. * @returns a new Vector3
  2603. */
  2604. fract(): Vector3;
  2605. /**
  2606. * Gets the length of the Vector3
  2607. * @returns the length of the Vector3
  2608. */
  2609. length(): number;
  2610. /**
  2611. * Gets the squared length of the Vector3
  2612. * @returns squared length of the Vector3
  2613. */
  2614. lengthSquared(): number;
  2615. /**
  2616. * Normalize the current Vector3.
  2617. * Please note that this is an in place operation.
  2618. * @returns the current updated Vector3
  2619. */
  2620. normalize(): Vector3;
  2621. /**
  2622. * Reorders the x y z properties of the vector in place
  2623. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2624. * @returns the current updated vector
  2625. */
  2626. reorderInPlace(order: string): this;
  2627. /**
  2628. * Rotates the vector around 0,0,0 by a quaternion
  2629. * @param quaternion the rotation quaternion
  2630. * @param result vector to store the result
  2631. * @returns the resulting vector
  2632. */
  2633. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2634. /**
  2635. * Rotates a vector around a given point
  2636. * @param quaternion the rotation quaternion
  2637. * @param point the point to rotate around
  2638. * @param result vector to store the result
  2639. * @returns the resulting vector
  2640. */
  2641. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2642. /**
  2643. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2644. * The cross product is then orthogonal to both current and "other"
  2645. * @param other defines the right operand
  2646. * @returns the cross product
  2647. */
  2648. cross(other: Vector3): Vector3;
  2649. /**
  2650. * Normalize the current Vector3 with the given input length.
  2651. * Please note that this is an in place operation.
  2652. * @param len the length of the vector
  2653. * @returns the current updated Vector3
  2654. */
  2655. normalizeFromLength(len: number): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 to a new vector
  2658. * @returns the new Vector3
  2659. */
  2660. normalizeToNew(): Vector3;
  2661. /**
  2662. * Normalize the current Vector3 to the reference
  2663. * @param reference define the Vector3 to update
  2664. * @returns the updated Vector3
  2665. */
  2666. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Creates a new Vector3 copied from the current Vector3
  2669. * @returns the new Vector3
  2670. */
  2671. clone(): Vector3;
  2672. /**
  2673. * Copies the given vector coordinates to the current Vector3 ones
  2674. * @param source defines the source Vector3
  2675. * @returns the current updated Vector3
  2676. */
  2677. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Copies the given floats to the current Vector3 coordinates
  2680. * @param x defines the x coordinate of the operand
  2681. * @param y defines the y coordinate of the operand
  2682. * @param z defines the z coordinate of the operand
  2683. * @returns the current updated Vector3
  2684. */
  2685. copyFromFloats(x: number, y: number, z: number): Vector3;
  2686. /**
  2687. * Copies the given floats to the current Vector3 coordinates
  2688. * @param x defines the x coordinate of the operand
  2689. * @param y defines the y coordinate of the operand
  2690. * @param z defines the z coordinate of the operand
  2691. * @returns the current updated Vector3
  2692. */
  2693. set(x: number, y: number, z: number): Vector3;
  2694. /**
  2695. * Copies the given float to the current Vector3 coordinates
  2696. * @param v defines the x, y and z coordinates of the operand
  2697. * @returns the current updated Vector3
  2698. */
  2699. setAll(v: number): Vector3;
  2700. /**
  2701. * Get the clip factor between two vectors
  2702. * @param vector0 defines the first operand
  2703. * @param vector1 defines the second operand
  2704. * @param axis defines the axis to use
  2705. * @param size defines the size along the axis
  2706. * @returns the clip factor
  2707. */
  2708. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2709. /**
  2710. * Get angle between two vectors
  2711. * @param vector0 angle between vector0 and vector1
  2712. * @param vector1 angle between vector0 and vector1
  2713. * @param normal direction of the normal
  2714. * @return the angle between vector0 and vector1
  2715. */
  2716. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2717. /**
  2718. * Returns a new Vector3 set from the index "offset" of the given array
  2719. * @param array defines the source array
  2720. * @param offset defines the offset in the source array
  2721. * @returns the new Vector3
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. * @deprecated Please use FromArray instead.
  2730. */
  2731. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2732. /**
  2733. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2734. * @param array defines the source array
  2735. * @param offset defines the offset in the source array
  2736. * @param result defines the Vector3 where to store the result
  2737. */
  2738. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2741. * @param array defines the source array
  2742. * @param offset defines the offset in the source array
  2743. * @param result defines the Vector3 where to store the result
  2744. * @deprecated Please use FromArrayToRef instead.
  2745. */
  2746. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2747. /**
  2748. * Sets the given vector "result" with the given floats.
  2749. * @param x defines the x coordinate of the source
  2750. * @param y defines the y coordinate of the source
  2751. * @param z defines the z coordinate of the source
  2752. * @param result defines the Vector3 where to store the result
  2753. */
  2754. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2755. /**
  2756. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2757. * @returns a new empty Vector3
  2758. */
  2759. static Zero(): Vector3;
  2760. /**
  2761. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2762. * @returns a new unit Vector3
  2763. */
  2764. static One(): Vector3;
  2765. /**
  2766. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2767. * @returns a new up Vector3
  2768. */
  2769. static Up(): Vector3;
  2770. /**
  2771. * Gets a up Vector3 that must not be updated
  2772. */
  2773. static get UpReadOnly(): DeepImmutable<Vector3>;
  2774. /**
  2775. * Gets a zero Vector3 that must not be updated
  2776. */
  2777. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2778. /**
  2779. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2780. * @returns a new down Vector3
  2781. */
  2782. static Down(): Vector3;
  2783. /**
  2784. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2785. * @returns a new forward Vector3
  2786. */
  2787. static Forward(): Vector3;
  2788. /**
  2789. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2790. * @returns a new forward Vector3
  2791. */
  2792. static Backward(): Vector3;
  2793. /**
  2794. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2795. * @returns a new right Vector3
  2796. */
  2797. static Right(): Vector3;
  2798. /**
  2799. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2800. * @returns a new left Vector3
  2801. */
  2802. static Left(): Vector3;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2805. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the transformed Vector3
  2809. */
  2810. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2813. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2821. * This method computes tranformed coordinates only, not transformed direction vectors
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2831. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2832. * @param vector defines the Vector3 to transform
  2833. * @param transformation defines the transformation matrix
  2834. * @returns the new Vector3
  2835. */
  2836. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2837. /**
  2838. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2839. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2840. * @param vector defines the Vector3 to transform
  2841. * @param transformation defines the transformation matrix
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2847. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2848. * @param x define the x coordinate of the source vector
  2849. * @param y define the y coordinate of the source vector
  2850. * @param z define the z coordinate of the source vector
  2851. * @param transformation defines the transformation matrix
  2852. * @param result defines the Vector3 where to store the result
  2853. */
  2854. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2855. /**
  2856. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2857. * @param value1 defines the first control point
  2858. * @param value2 defines the second control point
  2859. * @param value3 defines the third control point
  2860. * @param value4 defines the fourth control point
  2861. * @param amount defines the amount on the spline to use
  2862. * @returns the new Vector3
  2863. */
  2864. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2865. /**
  2866. * 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"
  2867. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2868. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2869. * @param value defines the current value
  2870. * @param min defines the lower range value
  2871. * @param max defines the upper range value
  2872. * @returns the new Vector3
  2873. */
  2874. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2875. /**
  2876. * 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"
  2877. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2878. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2879. * @param value defines the current value
  2880. * @param min defines the lower range value
  2881. * @param max defines the upper range value
  2882. * @param result defines the Vector3 where to store the result
  2883. */
  2884. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2885. /**
  2886. * Checks if a given vector is inside a specific range
  2887. * @param v defines the vector to test
  2888. * @param min defines the minimum range
  2889. * @param max defines the maximum range
  2890. */
  2891. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2892. /**
  2893. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2894. * @param value1 defines the first control point
  2895. * @param tangent1 defines the first tangent vector
  2896. * @param value2 defines the second control point
  2897. * @param tangent2 defines the second tangent vector
  2898. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2899. * @returns the new Vector3
  2900. */
  2901. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2902. /**
  2903. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2904. * @param start defines the start value
  2905. * @param end defines the end value
  2906. * @param amount max defines amount between both (between 0 and 1)
  2907. * @returns the new Vector3
  2908. */
  2909. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2910. /**
  2911. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2912. * @param start defines the start value
  2913. * @param end defines the end value
  2914. * @param amount max defines amount between both (between 0 and 1)
  2915. * @param result defines the Vector3 where to store the result
  2916. */
  2917. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2918. /**
  2919. * Returns the dot product (float) between the vectors "left" and "right"
  2920. * @param left defines the left operand
  2921. * @param right defines the right operand
  2922. * @returns the dot product
  2923. */
  2924. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2925. /**
  2926. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2927. * The cross product is then orthogonal to both "left" and "right"
  2928. * @param left defines the left operand
  2929. * @param right defines the right operand
  2930. * @returns the cross product
  2931. */
  2932. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2933. /**
  2934. * Sets the given vector "result" with the cross product of "left" and "right"
  2935. * The cross product is then orthogonal to both "left" and "right"
  2936. * @param left defines the left operand
  2937. * @param right defines the right operand
  2938. * @param result defines the Vector3 where to store the result
  2939. */
  2940. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2941. /**
  2942. * Returns a new Vector3 as the normalization of the given vector
  2943. * @param vector defines the Vector3 to normalize
  2944. * @returns the new Vector3
  2945. */
  2946. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2947. /**
  2948. * Sets the given vector "result" with the normalization of the given first vector
  2949. * @param vector defines the Vector3 to normalize
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2953. /**
  2954. * Project a Vector3 onto screen space
  2955. * @param vector defines the Vector3 to project
  2956. * @param world defines the world matrix to use
  2957. * @param transform defines the transform (view x projection) matrix to use
  2958. * @param viewport defines the screen viewport to use
  2959. * @returns the new Vector3
  2960. */
  2961. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2962. /** @hidden */
  2963. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param source defines the screen space Vector3 to use
  2967. * @param viewportWidth defines the current width of the viewport
  2968. * @param viewportHeight defines the current height of the viewport
  2969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2970. * @param transform defines the transform (view x projection) matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: 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. * @returns the new Vector3
  2983. */
  2984. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param source defines the screen space Vector3 to use
  2988. * @param viewportWidth defines the current width of the viewport
  2989. * @param viewportHeight defines the current height of the viewport
  2990. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2991. * @param view defines the view matrix to use
  2992. * @param projection defines the projection matrix to use
  2993. * @param result defines the Vector3 where to store the result
  2994. */
  2995. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2996. /**
  2997. * Unproject from screen space to object space
  2998. * @param sourceX defines the screen space x coordinate to use
  2999. * @param sourceY defines the screen space y coordinate to use
  3000. * @param sourceZ defines the screen space z coordinate to use
  3001. * @param viewportWidth defines the current width of the viewport
  3002. * @param viewportHeight defines the current height of the viewport
  3003. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3004. * @param view defines the view matrix to use
  3005. * @param projection defines the projection matrix to use
  3006. * @param result defines the Vector3 where to store the result
  3007. */
  3008. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3009. /**
  3010. * Gets the minimal coordinate values between two Vector3
  3011. * @param left defines the first operand
  3012. * @param right defines the second operand
  3013. * @returns the new Vector3
  3014. */
  3015. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3016. /**
  3017. * Gets the maximal coordinate values between two Vector3
  3018. * @param left defines the first operand
  3019. * @param right defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Returns the distance between the vectors "value1" and "value2"
  3025. * @param value1 defines the first operand
  3026. * @param value2 defines the second operand
  3027. * @returns the distance
  3028. */
  3029. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3030. /**
  3031. * Returns the squared distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the squared distance
  3035. */
  3036. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns a new Vector3 located at the center between "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the new Vector3
  3042. */
  3043. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3046. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3047. * to something in order to rotate it from its local system to the given target system
  3048. * Note: axis1, axis2 and axis3 are normalized during this operation
  3049. * @param axis1 defines the first axis
  3050. * @param axis2 defines the second axis
  3051. * @param axis3 defines the third axis
  3052. * @returns a new Vector3
  3053. */
  3054. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3057. * @param axis1 defines the first axis
  3058. * @param axis2 defines the second axis
  3059. * @param axis3 defines the third axis
  3060. * @param ref defines the Vector3 where to store the result
  3061. */
  3062. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3063. }
  3064. /**
  3065. * Vector4 class created for EulerAngle class conversion to Quaternion
  3066. */
  3067. export class Vector4 {
  3068. /** x value of the vector */
  3069. x: number;
  3070. /** y value of the vector */
  3071. y: number;
  3072. /** z value of the vector */
  3073. z: number;
  3074. /** w value of the vector */
  3075. w: number;
  3076. /**
  3077. * Creates a Vector4 object from the given floats.
  3078. * @param x x value of the vector
  3079. * @param y y value of the vector
  3080. * @param z z value of the vector
  3081. * @param w w value of the vector
  3082. */
  3083. constructor(
  3084. /** x value of the vector */
  3085. x: number,
  3086. /** y value of the vector */
  3087. y: number,
  3088. /** z value of the vector */
  3089. z: number,
  3090. /** w value of the vector */
  3091. w: number);
  3092. /**
  3093. * Returns the string with the Vector4 coordinates.
  3094. * @returns a string containing all the vector values
  3095. */
  3096. toString(): string;
  3097. /**
  3098. * Returns the string "Vector4".
  3099. * @returns "Vector4"
  3100. */
  3101. getClassName(): string;
  3102. /**
  3103. * Returns the Vector4 hash code.
  3104. * @returns a unique hash code
  3105. */
  3106. getHashCode(): number;
  3107. /**
  3108. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3109. * @returns the resulting array
  3110. */
  3111. asArray(): number[];
  3112. /**
  3113. * Populates the given array from the given index with the Vector4 coordinates.
  3114. * @param array array to populate
  3115. * @param index index of the array to start at (default: 0)
  3116. * @returns the Vector4.
  3117. */
  3118. toArray(array: FloatArray, index?: number): Vector4;
  3119. /**
  3120. * Adds the given vector to the current Vector4.
  3121. * @param otherVector the vector to add
  3122. * @returns the updated Vector4.
  3123. */
  3124. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3125. /**
  3126. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3127. * @param otherVector the vector to add
  3128. * @returns the resulting vector
  3129. */
  3130. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3131. /**
  3132. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3133. * @param otherVector the vector to add
  3134. * @param result the vector to store the result
  3135. * @returns the current Vector4.
  3136. */
  3137. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3138. /**
  3139. * Subtract in place the given vector from the current Vector4.
  3140. * @param otherVector the vector to subtract
  3141. * @returns the updated Vector4.
  3142. */
  3143. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3144. /**
  3145. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3146. * @param otherVector the vector to add
  3147. * @returns the new vector with the result
  3148. */
  3149. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3150. /**
  3151. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3152. * @param otherVector the vector to subtract
  3153. * @param result the vector to store the result
  3154. * @returns the current Vector4.
  3155. */
  3156. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3157. /**
  3158. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3159. */
  3160. /**
  3161. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3162. * @param x value to subtract
  3163. * @param y value to subtract
  3164. * @param z value to subtract
  3165. * @param w value to subtract
  3166. * @returns new vector containing the result
  3167. */
  3168. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3169. /**
  3170. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3171. * @param x value to subtract
  3172. * @param y value to subtract
  3173. * @param z value to subtract
  3174. * @param w value to subtract
  3175. * @param result the vector to store the result in
  3176. * @returns the current Vector4.
  3177. */
  3178. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3179. /**
  3180. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3181. * @returns a new vector with the negated values
  3182. */
  3183. negate(): Vector4;
  3184. /**
  3185. * Negate this vector in place
  3186. * @returns this
  3187. */
  3188. negateInPlace(): Vector4;
  3189. /**
  3190. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3191. * @param result defines the Vector3 object where to store the result
  3192. * @returns the current Vector4
  3193. */
  3194. negateToRef(result: Vector4): Vector4;
  3195. /**
  3196. * Multiplies the current Vector4 coordinates by scale (float).
  3197. * @param scale the number to scale with
  3198. * @returns the updated Vector4.
  3199. */
  3200. scaleInPlace(scale: number): Vector4;
  3201. /**
  3202. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3203. * @param scale the number to scale with
  3204. * @returns a new vector with the result
  3205. */
  3206. scale(scale: number): Vector4;
  3207. /**
  3208. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3209. * @param scale the number to scale with
  3210. * @param result a vector to store the result in
  3211. * @returns the current Vector4.
  3212. */
  3213. scaleToRef(scale: number, result: Vector4): Vector4;
  3214. /**
  3215. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3216. * @param scale defines the scale factor
  3217. * @param result defines the Vector4 object where to store the result
  3218. * @returns the unmodified current Vector4
  3219. */
  3220. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3223. * @param otherVector the vector to compare against
  3224. * @returns true if they are equal
  3225. */
  3226. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3227. /**
  3228. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3229. * @param otherVector vector to compare against
  3230. * @param epsilon (Default: very small number)
  3231. * @returns true if they are equal
  3232. */
  3233. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3234. /**
  3235. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3236. * @param x x value to compare against
  3237. * @param y y value to compare against
  3238. * @param z z value to compare against
  3239. * @param w w value to compare against
  3240. * @returns true if equal
  3241. */
  3242. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3243. /**
  3244. * Multiplies in place the current Vector4 by the given one.
  3245. * @param otherVector vector to multiple with
  3246. * @returns the updated Vector4.
  3247. */
  3248. multiplyInPlace(otherVector: Vector4): Vector4;
  3249. /**
  3250. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3251. * @param otherVector vector to multiple with
  3252. * @returns resulting new vector
  3253. */
  3254. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3255. /**
  3256. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3257. * @param otherVector vector to multiple with
  3258. * @param result vector to store the result
  3259. * @returns the current Vector4.
  3260. */
  3261. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3264. * @param x x value multiply with
  3265. * @param y y value multiply with
  3266. * @param z z value multiply with
  3267. * @param w w value multiply with
  3268. * @returns resulting new vector
  3269. */
  3270. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3271. /**
  3272. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3273. * @param otherVector vector to devide with
  3274. * @returns resulting new vector
  3275. */
  3276. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3277. /**
  3278. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3279. * @param otherVector vector to devide with
  3280. * @param result vector to store the result
  3281. * @returns the current Vector4.
  3282. */
  3283. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3284. /**
  3285. * Divides the current Vector3 coordinates by the given ones.
  3286. * @param otherVector vector to devide with
  3287. * @returns the updated Vector3.
  3288. */
  3289. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3290. /**
  3291. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3292. * @param other defines the second operand
  3293. * @returns the current updated Vector4
  3294. */
  3295. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3296. /**
  3297. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3298. * @param other defines the second operand
  3299. * @returns the current updated Vector4
  3300. */
  3301. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Gets a new Vector4 from current Vector4 floored values
  3304. * @returns a new Vector4
  3305. */
  3306. floor(): Vector4;
  3307. /**
  3308. * Gets a new Vector4 from current Vector3 floored values
  3309. * @returns a new Vector4
  3310. */
  3311. fract(): Vector4;
  3312. /**
  3313. * Returns the Vector4 length (float).
  3314. * @returns the length
  3315. */
  3316. length(): number;
  3317. /**
  3318. * Returns the Vector4 squared length (float).
  3319. * @returns the length squared
  3320. */
  3321. lengthSquared(): number;
  3322. /**
  3323. * Normalizes in place the Vector4.
  3324. * @returns the updated Vector4.
  3325. */
  3326. normalize(): Vector4;
  3327. /**
  3328. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3329. * @returns this converted to a new vector3
  3330. */
  3331. toVector3(): Vector3;
  3332. /**
  3333. * Returns a new Vector4 copied from the current one.
  3334. * @returns the new cloned vector
  3335. */
  3336. clone(): Vector4;
  3337. /**
  3338. * Updates the current Vector4 with the given one coordinates.
  3339. * @param source the source vector to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to copy from
  3346. * @param y float to copy from
  3347. * @param z float to copy from
  3348. * @param w float to copy from
  3349. * @returns the updated Vector4.
  3350. */
  3351. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Updates the current Vector4 coordinates with the given floats.
  3354. * @param x float to set from
  3355. * @param y float to set from
  3356. * @param z float to set from
  3357. * @param w float to set from
  3358. * @returns the updated Vector4.
  3359. */
  3360. set(x: number, y: number, z: number, w: number): Vector4;
  3361. /**
  3362. * Copies the given float to the current Vector3 coordinates
  3363. * @param v defines the x, y, z and w coordinates of the operand
  3364. * @returns the current updated Vector3
  3365. */
  3366. setAll(v: number): Vector4;
  3367. /**
  3368. * Returns a new Vector4 set from the starting index of the given array.
  3369. * @param array the array to pull values from
  3370. * @param offset the offset into the array to start at
  3371. * @returns the new vector
  3372. */
  3373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3374. /**
  3375. * Updates the given vector "result" from the starting index of the given array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @param result the vector to store the result in
  3379. */
  3380. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given Float32Array.
  3383. * @param array the array to pull values from
  3384. * @param offset the offset into the array to start at
  3385. * @param result the vector to store the result in
  3386. */
  3387. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" coordinates from the given floats.
  3390. * @param x float to set from
  3391. * @param y float to set from
  3392. * @param z float to set from
  3393. * @param w float to set from
  3394. * @param result the vector to the floats in
  3395. */
  3396. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3397. /**
  3398. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3399. * @returns the new vector
  3400. */
  3401. static Zero(): Vector4;
  3402. /**
  3403. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3404. * @returns the new vector
  3405. */
  3406. static One(): Vector4;
  3407. /**
  3408. * Returns a new normalized Vector4 from the given one.
  3409. * @param vector the vector to normalize
  3410. * @returns the vector
  3411. */
  3412. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3413. /**
  3414. * Updates the given vector "result" from the normalization of the given one.
  3415. * @param vector the vector to normalize
  3416. * @param result the vector to store the result in
  3417. */
  3418. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3419. /**
  3420. * Returns a vector with the minimum values from the left and right vectors
  3421. * @param left left vector to minimize
  3422. * @param right right vector to minimize
  3423. * @returns a new vector with the minimum of the left and right vector values
  3424. */
  3425. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3426. /**
  3427. * Returns a vector with the maximum values from the left and right vectors
  3428. * @param left left vector to maximize
  3429. * @param right right vector to maximize
  3430. * @returns a new vector with the maximum of the left and right vector values
  3431. */
  3432. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns the distance (float) between the vectors "value1" and "value2".
  3435. * @param value1 value to calulate the distance between
  3436. * @param value2 value to calulate the distance between
  3437. * @return the distance between the two vectors
  3438. */
  3439. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3440. /**
  3441. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the distance between
  3443. * @param value2 value to calulate the distance between
  3444. * @return the distance between the two vectors squared
  3445. */
  3446. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the center between
  3450. * @param value2 value to calulate the center between
  3451. * @return the center between the two vectors
  3452. */
  3453. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3454. /**
  3455. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3456. * This methods computes transformed normalized direction vectors only.
  3457. * @param vector the vector to transform
  3458. * @param transformation the transformation matrix to apply
  3459. * @returns the new vector
  3460. */
  3461. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3462. /**
  3463. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3464. * This methods computes transformed normalized direction vectors only.
  3465. * @param vector the vector to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the result in
  3468. */
  3469. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3472. * This methods computes transformed normalized direction vectors only.
  3473. * @param x value to transform
  3474. * @param y value to transform
  3475. * @param z value to transform
  3476. * @param w value to transform
  3477. * @param transformation the transformation matrix to apply
  3478. * @param result the vector to store the results in
  3479. */
  3480. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3481. /**
  3482. * Creates a new Vector4 from a Vector3
  3483. * @param source defines the source data
  3484. * @param w defines the 4th component (default is 0)
  3485. * @returns a new Vector4
  3486. */
  3487. static FromVector3(source: Vector3, w?: number): Vector4;
  3488. }
  3489. /**
  3490. * Class used to store quaternion data
  3491. * @see https://en.wikipedia.org/wiki/Quaternion
  3492. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3493. */
  3494. export class Quaternion {
  3495. /** defines the first component (0 by default) */
  3496. x: number;
  3497. /** defines the second component (0 by default) */
  3498. y: number;
  3499. /** defines the third component (0 by default) */
  3500. z: number;
  3501. /** defines the fourth component (1.0 by default) */
  3502. w: number;
  3503. /**
  3504. * Creates a new Quaternion from the given floats
  3505. * @param x defines the first component (0 by default)
  3506. * @param y defines the second component (0 by default)
  3507. * @param z defines the third component (0 by default)
  3508. * @param w defines the fourth component (1.0 by default)
  3509. */
  3510. constructor(
  3511. /** defines the first component (0 by default) */
  3512. x?: number,
  3513. /** defines the second component (0 by default) */
  3514. y?: number,
  3515. /** defines the third component (0 by default) */
  3516. z?: number,
  3517. /** defines the fourth component (1.0 by default) */
  3518. w?: number);
  3519. /**
  3520. * Gets a string representation for the current quaternion
  3521. * @returns a string with the Quaternion coordinates
  3522. */
  3523. toString(): string;
  3524. /**
  3525. * Gets the class name of the quaternion
  3526. * @returns the string "Quaternion"
  3527. */
  3528. getClassName(): string;
  3529. /**
  3530. * Gets a hash code for this quaternion
  3531. * @returns the quaternion hash code
  3532. */
  3533. getHashCode(): number;
  3534. /**
  3535. * Copy the quaternion to an array
  3536. * @returns a new array populated with 4 elements from the quaternion coordinates
  3537. */
  3538. asArray(): number[];
  3539. /**
  3540. * Check if two quaternions are equals
  3541. * @param otherQuaternion defines the second operand
  3542. * @return true if the current quaternion and the given one coordinates are strictly equals
  3543. */
  3544. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3545. /**
  3546. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3547. * @param otherQuaternion defines the other quaternion
  3548. * @param epsilon defines the minimal distance to consider equality
  3549. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3550. */
  3551. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3552. /**
  3553. * Clone the current quaternion
  3554. * @returns a new quaternion copied from the current one
  3555. */
  3556. clone(): Quaternion;
  3557. /**
  3558. * Copy a quaternion to the current one
  3559. * @param other defines the other quaternion
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Updates the current quaternion with the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Updates the current quaternion from the given float coordinates
  3574. * @param x defines the x coordinate
  3575. * @param y defines the y coordinate
  3576. * @param z defines the z coordinate
  3577. * @param w defines the w coordinate
  3578. * @returns the updated current quaternion
  3579. */
  3580. set(x: number, y: number, z: number, w: number): Quaternion;
  3581. /**
  3582. * Adds two quaternions
  3583. * @param other defines the second operand
  3584. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3585. */
  3586. add(other: DeepImmutable<Quaternion>): Quaternion;
  3587. /**
  3588. * Add a quaternion to the current one
  3589. * @param other defines the quaternion to add
  3590. * @returns the current quaternion
  3591. */
  3592. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3593. /**
  3594. * Subtract two quaternions
  3595. * @param other defines the second operand
  3596. * @returns a new quaternion as the subtraction result of the given one from the current one
  3597. */
  3598. subtract(other: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies the current quaternion by a scale factor
  3601. * @param value defines the scale factor
  3602. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3603. */
  3604. scale(value: number): Quaternion;
  3605. /**
  3606. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3607. * @param scale defines the scale factor
  3608. * @param result defines the Quaternion object where to store the result
  3609. * @returns the unmodified current quaternion
  3610. */
  3611. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3612. /**
  3613. * Multiplies in place the current quaternion by a scale factor
  3614. * @param value defines the scale factor
  3615. * @returns the current modified quaternion
  3616. */
  3617. scaleInPlace(value: number): Quaternion;
  3618. /**
  3619. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3620. * @param scale defines the scale factor
  3621. * @param result defines the Quaternion object where to store the result
  3622. * @returns the unmodified current quaternion
  3623. */
  3624. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3625. /**
  3626. * Multiplies two quaternions
  3627. * @param q1 defines the second operand
  3628. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3629. */
  3630. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3631. /**
  3632. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3633. * @param q1 defines the second operand
  3634. * @param result defines the target quaternion
  3635. * @returns the current quaternion
  3636. */
  3637. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3638. /**
  3639. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @returns the currentupdated quaternion
  3642. */
  3643. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3644. /**
  3645. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3646. * @param ref defines the target quaternion
  3647. * @returns the current quaternion
  3648. */
  3649. conjugateToRef(ref: Quaternion): Quaternion;
  3650. /**
  3651. * Conjugates in place (1-q) the current quaternion
  3652. * @returns the current updated quaternion
  3653. */
  3654. conjugateInPlace(): Quaternion;
  3655. /**
  3656. * Conjugates in place (1-q) the current quaternion
  3657. * @returns a new quaternion
  3658. */
  3659. conjugate(): Quaternion;
  3660. /**
  3661. * Gets length of current quaternion
  3662. * @returns the quaternion length (float)
  3663. */
  3664. length(): number;
  3665. /**
  3666. * Normalize in place the current quaternion
  3667. * @returns the current updated quaternion
  3668. */
  3669. normalize(): Quaternion;
  3670. /**
  3671. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3672. * @param order is a reserved parameter and is ignore for now
  3673. * @returns a new Vector3 containing the Euler angles
  3674. */
  3675. toEulerAngles(order?: string): Vector3;
  3676. /**
  3677. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3678. * @param result defines the vector which will be filled with the Euler angles
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns the current unchanged quaternion
  3681. */
  3682. toEulerAnglesToRef(result: Vector3): Quaternion;
  3683. /**
  3684. * Updates the given rotation matrix with the current quaternion values
  3685. * @param result defines the target matrix
  3686. * @returns the current unchanged quaternion
  3687. */
  3688. toRotationMatrix(result: Matrix): Quaternion;
  3689. /**
  3690. * Updates the current quaternion from the given rotation matrix values
  3691. * @param matrix defines the source matrix
  3692. * @returns the current updated quaternion
  3693. */
  3694. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3695. /**
  3696. * Creates a new quaternion from a rotation matrix
  3697. * @param matrix defines the source matrix
  3698. * @returns a new quaternion created from the given rotation matrix values
  3699. */
  3700. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3701. /**
  3702. * Updates the given quaternion with the given rotation matrix values
  3703. * @param matrix defines the source matrix
  3704. * @param result defines the target quaternion
  3705. */
  3706. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3707. /**
  3708. * Returns the dot product (float) between the quaternions "left" and "right"
  3709. * @param left defines the left operand
  3710. * @param right defines the right operand
  3711. * @returns the dot product
  3712. */
  3713. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3714. /**
  3715. * Checks if the two quaternions are close to each other
  3716. * @param quat0 defines the first quaternion to check
  3717. * @param quat1 defines the second quaternion to check
  3718. * @returns true if the two quaternions are close to each other
  3719. */
  3720. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3721. /**
  3722. * Creates an empty quaternion
  3723. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3724. */
  3725. static Zero(): Quaternion;
  3726. /**
  3727. * Inverse a given quaternion
  3728. * @param q defines the source quaternion
  3729. * @returns a new quaternion as the inverted current quaternion
  3730. */
  3731. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3732. /**
  3733. * Inverse a given quaternion
  3734. * @param q defines the source quaternion
  3735. * @param result the quaternion the result will be stored in
  3736. * @returns the result quaternion
  3737. */
  3738. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates an identity quaternion
  3741. * @returns the identity quaternion
  3742. */
  3743. static Identity(): Quaternion;
  3744. /**
  3745. * Gets a boolean indicating if the given quaternion is identity
  3746. * @param quaternion defines the quaternion to check
  3747. * @returns true if the quaternion is identity
  3748. */
  3749. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3750. /**
  3751. * Creates a quaternion from a rotation around an axis
  3752. * @param axis defines the axis to use
  3753. * @param angle defines the angle to use
  3754. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3755. */
  3756. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3757. /**
  3758. * Creates a rotation around an axis and stores it into the given quaternion
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @param result defines the target quaternion
  3762. * @returns the target quaternion
  3763. */
  3764. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3765. /**
  3766. * Creates a new quaternion from data stored into an array
  3767. * @param array defines the data source
  3768. * @param offset defines the offset in the source array where the data starts
  3769. * @returns a new quaternion
  3770. */
  3771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3772. /**
  3773. * Updates the given quaternion "result" from the starting index of the given array.
  3774. * @param array the array to pull values from
  3775. * @param offset the offset into the array to start at
  3776. * @param result the quaternion to store the result in
  3777. */
  3778. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3779. /**
  3780. * Create a quaternion from Euler rotation angles
  3781. * @param x Pitch
  3782. * @param y Yaw
  3783. * @param z Roll
  3784. * @returns the new Quaternion
  3785. */
  3786. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3787. /**
  3788. * Updates a quaternion from Euler rotation angles
  3789. * @param x Pitch
  3790. * @param y Yaw
  3791. * @param z Roll
  3792. * @param result the quaternion to store the result
  3793. * @returns the updated quaternion
  3794. */
  3795. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3796. /**
  3797. * Create a quaternion from Euler rotation vector
  3798. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3799. * @returns the new Quaternion
  3800. */
  3801. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * Updates a quaternion from Euler rotation vector
  3804. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3805. * @param result the quaternion to store the result
  3806. * @returns the updated quaternion
  3807. */
  3808. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3811. * @param yaw defines the rotation around Y axis
  3812. * @param pitch defines the rotation around X axis
  3813. * @param roll defines the rotation around Z axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3817. /**
  3818. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3819. * @param yaw defines the rotation around Y axis
  3820. * @param pitch defines the rotation around X axis
  3821. * @param roll defines the rotation around Z axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3825. /**
  3826. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3827. * @param alpha defines the rotation around first axis
  3828. * @param beta defines the rotation around second axis
  3829. * @param gamma defines the rotation around third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3833. /**
  3834. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3835. * @param alpha defines the rotation around first axis
  3836. * @param beta defines the rotation around second axis
  3837. * @param gamma defines the rotation around third axis
  3838. * @param result defines the target quaternion
  3839. */
  3840. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3841. /**
  3842. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3843. * @param axis1 defines the first axis
  3844. * @param axis2 defines the second axis
  3845. * @param axis3 defines the third axis
  3846. * @returns the new quaternion
  3847. */
  3848. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3849. /**
  3850. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3851. * @param axis1 defines the first axis
  3852. * @param axis2 defines the second axis
  3853. * @param axis3 defines the third axis
  3854. * @param ref defines the target quaternion
  3855. */
  3856. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3857. /**
  3858. * Interpolates between two quaternions
  3859. * @param left defines first quaternion
  3860. * @param right defines second quaternion
  3861. * @param amount defines the gradient to use
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. /**
  3866. * Interpolates between two quaternions and stores it into a target quaternion
  3867. * @param left defines first quaternion
  3868. * @param right defines second quaternion
  3869. * @param amount defines the gradient to use
  3870. * @param result defines the target quaternion
  3871. */
  3872. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3873. /**
  3874. * Interpolate between two quaternions using Hermite interpolation
  3875. * @param value1 defines first quaternion
  3876. * @param tangent1 defines the incoming tangent
  3877. * @param value2 defines second quaternion
  3878. * @param tangent2 defines the outgoing tangent
  3879. * @param amount defines the target quaternion
  3880. * @returns the new interpolated quaternion
  3881. */
  3882. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3883. }
  3884. /**
  3885. * Class used to store matrix data (4x4)
  3886. */
  3887. export class Matrix {
  3888. private static _updateFlagSeed;
  3889. private static _identityReadOnly;
  3890. private _isIdentity;
  3891. private _isIdentityDirty;
  3892. private _isIdentity3x2;
  3893. private _isIdentity3x2Dirty;
  3894. /**
  3895. * Gets the update flag of the matrix which is an unique number for the matrix.
  3896. * It will be incremented every time the matrix data change.
  3897. * You can use it to speed the comparison between two versions of the same matrix.
  3898. */
  3899. updateFlag: number;
  3900. private readonly _m;
  3901. /**
  3902. * Gets the internal data of the matrix
  3903. */
  3904. get m(): DeepImmutable<Float32Array>;
  3905. /** @hidden */
  3906. _markAsUpdated(): void;
  3907. /** @hidden */
  3908. private _updateIdentityStatus;
  3909. /**
  3910. * Creates an empty matrix (filled with zeros)
  3911. */
  3912. constructor();
  3913. /**
  3914. * Check if the current matrix is identity
  3915. * @returns true is the matrix is the identity matrix
  3916. */
  3917. isIdentity(): boolean;
  3918. /**
  3919. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3920. * @returns true is the matrix is the identity matrix
  3921. */
  3922. isIdentityAs3x2(): boolean;
  3923. /**
  3924. * Gets the determinant of the matrix
  3925. * @returns the matrix determinant
  3926. */
  3927. determinant(): number;
  3928. /**
  3929. * Returns the matrix as a Float32Array
  3930. * @returns the matrix underlying array
  3931. */
  3932. toArray(): DeepImmutable<Float32Array>;
  3933. /**
  3934. * Returns the matrix as a Float32Array
  3935. * @returns the matrix underlying array.
  3936. */
  3937. asArray(): DeepImmutable<Float32Array>;
  3938. /**
  3939. * Inverts the current matrix in place
  3940. * @returns the current inverted matrix
  3941. */
  3942. invert(): Matrix;
  3943. /**
  3944. * Sets all the matrix elements to zero
  3945. * @returns the current matrix
  3946. */
  3947. reset(): Matrix;
  3948. /**
  3949. * Adds the current matrix with a second one
  3950. * @param other defines the matrix to add
  3951. * @returns a new matrix as the addition of the current matrix and the given one
  3952. */
  3953. add(other: DeepImmutable<Matrix>): Matrix;
  3954. /**
  3955. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3956. * @param other defines the matrix to add
  3957. * @param result defines the target matrix
  3958. * @returns the current matrix
  3959. */
  3960. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3961. /**
  3962. * Adds in place the given matrix to the current matrix
  3963. * @param other defines the second operand
  3964. * @returns the current updated matrix
  3965. */
  3966. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3967. /**
  3968. * Sets the given matrix to the current inverted Matrix
  3969. * @param other defines the target matrix
  3970. * @returns the unmodified current matrix
  3971. */
  3972. invertToRef(other: Matrix): Matrix;
  3973. /**
  3974. * add a value at the specified position in the current Matrix
  3975. * @param index the index of the value within the matrix. between 0 and 15.
  3976. * @param value the value to be added
  3977. * @returns the current updated matrix
  3978. */
  3979. addAtIndex(index: number, value: number): Matrix;
  3980. /**
  3981. * mutiply the specified position in the current Matrix by a value
  3982. * @param index the index of the value within the matrix. between 0 and 15.
  3983. * @param value the value to be added
  3984. * @returns the current updated matrix
  3985. */
  3986. multiplyAtIndex(index: number, value: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector (using 3 floats) in the current matrix
  3989. * @param x defines the 1st component of the translation
  3990. * @param y defines the 2nd component of the translation
  3991. * @param z defines the 3rd component of the translation
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3995. /**
  3996. * Adds the translation vector (using 3 floats) in the current matrix
  3997. * @param x defines the 1st component of the translation
  3998. * @param y defines the 2nd component of the translation
  3999. * @param z defines the 3rd component of the translation
  4000. * @returns the current updated matrix
  4001. */
  4002. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4003. /**
  4004. * Inserts the translation vector in the current matrix
  4005. * @param vector3 defines the translation to insert
  4006. * @returns the current updated matrix
  4007. */
  4008. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4009. /**
  4010. * Gets the translation value of the current matrix
  4011. * @returns a new Vector3 as the extracted translation from the matrix
  4012. */
  4013. getTranslation(): Vector3;
  4014. /**
  4015. * Fill a Vector3 with the extracted translation from the matrix
  4016. * @param result defines the Vector3 where to store the translation
  4017. * @returns the current matrix
  4018. */
  4019. getTranslationToRef(result: Vector3): Matrix;
  4020. /**
  4021. * Remove rotation and scaling part from the matrix
  4022. * @returns the updated matrix
  4023. */
  4024. removeRotationAndScaling(): Matrix;
  4025. /**
  4026. * Multiply two matrices
  4027. * @param other defines the second operand
  4028. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4029. */
  4030. multiply(other: DeepImmutable<Matrix>): Matrix;
  4031. /**
  4032. * Copy the current matrix from the given one
  4033. * @param other defines the source matrix
  4034. * @returns the current updated matrix
  4035. */
  4036. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4037. /**
  4038. * Populates the given array from the starting index with the current matrix values
  4039. * @param array defines the target array
  4040. * @param offset defines the offset in the target array where to start storing values
  4041. * @returns the current matrix
  4042. */
  4043. copyToArray(array: Float32Array, offset?: number): Matrix;
  4044. /**
  4045. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4046. * @param other defines the second operand
  4047. * @param result defines the matrix where to store the multiplication
  4048. * @returns the current matrix
  4049. */
  4050. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4051. /**
  4052. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4053. * @param other defines the second operand
  4054. * @param result defines the array where to store the multiplication
  4055. * @param offset defines the offset in the target array where to start storing values
  4056. * @returns the current matrix
  4057. */
  4058. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4059. /**
  4060. * Check equality between this matrix and a second one
  4061. * @param value defines the second matrix to compare
  4062. * @returns true is the current matrix and the given one values are strictly equal
  4063. */
  4064. equals(value: DeepImmutable<Matrix>): boolean;
  4065. /**
  4066. * Clone the current matrix
  4067. * @returns a new matrix from the current matrix
  4068. */
  4069. clone(): Matrix;
  4070. /**
  4071. * Returns the name of the current matrix class
  4072. * @returns the string "Matrix"
  4073. */
  4074. getClassName(): string;
  4075. /**
  4076. * Gets the hash code of the current matrix
  4077. * @returns the hash code
  4078. */
  4079. getHashCode(): number;
  4080. /**
  4081. * Decomposes the current Matrix into a translation, rotation and scaling components
  4082. * @param scale defines the scale vector3 given as a reference to update
  4083. * @param rotation defines the rotation quaternion given as a reference to update
  4084. * @param translation defines the translation vector3 given as a reference to update
  4085. * @returns true if operation was successful
  4086. */
  4087. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4088. /**
  4089. * Gets specific row of the matrix
  4090. * @param index defines the number of the row to get
  4091. * @returns the index-th row of the current matrix as a new Vector4
  4092. */
  4093. getRow(index: number): Nullable<Vector4>;
  4094. /**
  4095. * Sets the index-th row of the current matrix to the vector4 values
  4096. * @param index defines the number of the row to set
  4097. * @param row defines the target vector4
  4098. * @returns the updated current matrix
  4099. */
  4100. setRow(index: number, row: Vector4): Matrix;
  4101. /**
  4102. * Compute the transpose of the matrix
  4103. * @returns the new transposed matrix
  4104. */
  4105. transpose(): Matrix;
  4106. /**
  4107. * Compute the transpose of the matrix and store it in a given matrix
  4108. * @param result defines the target matrix
  4109. * @returns the current matrix
  4110. */
  4111. transposeToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Sets the index-th row of the current matrix with the given 4 x float values
  4114. * @param index defines the row index
  4115. * @param x defines the x component to set
  4116. * @param y defines the y component to set
  4117. * @param z defines the z component to set
  4118. * @param w defines the w component to set
  4119. * @returns the updated current matrix
  4120. */
  4121. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4122. /**
  4123. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4124. * @param scale defines the scale factor
  4125. * @returns a new matrix
  4126. */
  4127. scale(scale: number): Matrix;
  4128. /**
  4129. * Scale the current matrix values by a factor to a given result matrix
  4130. * @param scale defines the scale factor
  4131. * @param result defines the matrix to store the result
  4132. * @returns the current matrix
  4133. */
  4134. scaleToRef(scale: number, result: Matrix): Matrix;
  4135. /**
  4136. * Scale the current matrix values by a factor and add the result to a given matrix
  4137. * @param scale defines the scale factor
  4138. * @param result defines the Matrix to store the result
  4139. * @returns the current matrix
  4140. */
  4141. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4142. /**
  4143. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4144. * @param ref matrix to store the result
  4145. */
  4146. toNormalMatrix(ref: Matrix): void;
  4147. /**
  4148. * Gets only rotation part of the current matrix
  4149. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4150. */
  4151. getRotationMatrix(): Matrix;
  4152. /**
  4153. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4154. * @param result defines the target matrix to store data to
  4155. * @returns the current matrix
  4156. */
  4157. getRotationMatrixToRef(result: Matrix): Matrix;
  4158. /**
  4159. * Toggles model matrix from being right handed to left handed in place and vice versa
  4160. */
  4161. toggleModelMatrixHandInPlace(): void;
  4162. /**
  4163. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleProjectionMatrixHandInPlace(): void;
  4166. /**
  4167. * Creates a matrix from an array
  4168. * @param array defines the source array
  4169. * @param offset defines an offset in the source array
  4170. * @returns a new Matrix set from the starting index of the given array
  4171. */
  4172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4173. /**
  4174. * Copy the content of an array into a given matrix
  4175. * @param array defines the source array
  4176. * @param offset defines an offset in the source array
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4180. /**
  4181. * Stores an array into a matrix after having multiplied each component by a given factor
  4182. * @param array defines the source array
  4183. * @param offset defines the offset in the source array
  4184. * @param scale defines the scaling factor
  4185. * @param result defines the target matrix
  4186. */
  4187. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4188. /**
  4189. * Gets an identity matrix that must not be updated
  4190. */
  4191. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4192. /**
  4193. * Stores a list of values (16) inside a given matrix
  4194. * @param initialM11 defines 1st value of 1st row
  4195. * @param initialM12 defines 2nd value of 1st row
  4196. * @param initialM13 defines 3rd value of 1st row
  4197. * @param initialM14 defines 4th value of 1st row
  4198. * @param initialM21 defines 1st value of 2nd row
  4199. * @param initialM22 defines 2nd value of 2nd row
  4200. * @param initialM23 defines 3rd value of 2nd row
  4201. * @param initialM24 defines 4th value of 2nd row
  4202. * @param initialM31 defines 1st value of 3rd row
  4203. * @param initialM32 defines 2nd value of 3rd row
  4204. * @param initialM33 defines 3rd value of 3rd row
  4205. * @param initialM34 defines 4th value of 3rd row
  4206. * @param initialM41 defines 1st value of 4th row
  4207. * @param initialM42 defines 2nd value of 4th row
  4208. * @param initialM43 defines 3rd value of 4th row
  4209. * @param initialM44 defines 4th value of 4th row
  4210. * @param result defines the target matrix
  4211. */
  4212. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4213. /**
  4214. * Creates new matrix from a list of values (16)
  4215. * @param initialM11 defines 1st value of 1st row
  4216. * @param initialM12 defines 2nd value of 1st row
  4217. * @param initialM13 defines 3rd value of 1st row
  4218. * @param initialM14 defines 4th value of 1st row
  4219. * @param initialM21 defines 1st value of 2nd row
  4220. * @param initialM22 defines 2nd value of 2nd row
  4221. * @param initialM23 defines 3rd value of 2nd row
  4222. * @param initialM24 defines 4th value of 2nd row
  4223. * @param initialM31 defines 1st value of 3rd row
  4224. * @param initialM32 defines 2nd value of 3rd row
  4225. * @param initialM33 defines 3rd value of 3rd row
  4226. * @param initialM34 defines 4th value of 3rd row
  4227. * @param initialM41 defines 1st value of 4th row
  4228. * @param initialM42 defines 2nd value of 4th row
  4229. * @param initialM43 defines 3rd value of 4th row
  4230. * @param initialM44 defines 4th value of 4th row
  4231. * @returns the new matrix
  4232. */
  4233. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4234. /**
  4235. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4236. * @param scale defines the scale vector3
  4237. * @param rotation defines the rotation quaternion
  4238. * @param translation defines the translation vector3
  4239. * @returns a new matrix
  4240. */
  4241. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4242. /**
  4243. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4244. * @param scale defines the scale vector3
  4245. * @param rotation defines the rotation quaternion
  4246. * @param translation defines the translation vector3
  4247. * @param result defines the target matrix
  4248. */
  4249. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4250. /**
  4251. * Creates a new identity matrix
  4252. * @returns a new identity matrix
  4253. */
  4254. static Identity(): Matrix;
  4255. /**
  4256. * Creates a new identity matrix and stores the result in a given matrix
  4257. * @param result defines the target matrix
  4258. */
  4259. static IdentityToRef(result: Matrix): void;
  4260. /**
  4261. * Creates a new zero matrix
  4262. * @returns a new zero matrix
  4263. */
  4264. static Zero(): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the X axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationX(angle: number): Matrix;
  4271. /**
  4272. * Creates a new matrix as the invert of a given matrix
  4273. * @param source defines the source matrix
  4274. * @returns the new matrix
  4275. */
  4276. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationXToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Y axis
  4285. * @param angle defines the angle (in radians) to use
  4286. * @return the new matrix
  4287. */
  4288. static RotationY(angle: number): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4291. * @param angle defines the angle (in radians) to use
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Z axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationZ(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationZToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the given axis
  4309. * @param axis defines the axis to use
  4310. * @param angle defines the angle (in radians) to use
  4311. * @return the new matrix
  4312. */
  4313. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4314. /**
  4315. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4316. * @param axis defines the axis to use
  4317. * @param angle defines the angle (in radians) to use
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4321. /**
  4322. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4323. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4324. * @param from defines the vector to align
  4325. * @param to defines the vector to align to
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4329. /**
  4330. * Creates a rotation matrix
  4331. * @param yaw defines the yaw angle in radians (Y axis)
  4332. * @param pitch defines the pitch angle in radians (X axis)
  4333. * @param roll defines the roll angle in radians (X axis)
  4334. * @returns the new rotation matrix
  4335. */
  4336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4337. /**
  4338. * Creates a rotation matrix and stores it in a given matrix
  4339. * @param yaw defines the yaw angle in radians (Y axis)
  4340. * @param pitch defines the pitch angle in radians (X axis)
  4341. * @param roll defines the roll angle in radians (X axis)
  4342. * @param result defines the target matrix
  4343. */
  4344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4345. /**
  4346. * Creates a scaling matrix
  4347. * @param x defines the scale factor on X axis
  4348. * @param y defines the scale factor on Y axis
  4349. * @param z defines the scale factor on Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Scaling(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a scaling matrix and stores it in a given matrix
  4355. * @param x defines the scale factor on X axis
  4356. * @param y defines the scale factor on Y axis
  4357. * @param z defines the scale factor on Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Creates a translation matrix
  4363. * @param x defines the translation on X axis
  4364. * @param y defines the translation on Y axis
  4365. * @param z defines the translationon Z axis
  4366. * @returns the new matrix
  4367. */
  4368. static Translation(x: number, y: number, z: number): Matrix;
  4369. /**
  4370. * Creates a translation matrix and stores it in a given matrix
  4371. * @param x defines the translation on X axis
  4372. * @param y defines the translation on Y axis
  4373. * @param z defines the translationon Z axis
  4374. * @param result defines the target matrix
  4375. */
  4376. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4377. /**
  4378. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4379. * @param startValue defines the start value
  4380. * @param endValue defines the end value
  4381. * @param gradient defines the gradient factor
  4382. * @returns the new matrix
  4383. */
  4384. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4385. /**
  4386. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4387. * @param startValue defines the start value
  4388. * @param endValue defines the end value
  4389. * @param gradient defines the gradient factor
  4390. * @param result defines the Matrix object where to store data
  4391. */
  4392. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * Builds a new matrix whose values are computed by:
  4395. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4396. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4397. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4398. * @param startValue defines the first matrix
  4399. * @param endValue defines the second matrix
  4400. * @param gradient defines the gradient between the two matrices
  4401. * @returns the new matrix
  4402. */
  4403. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4404. /**
  4405. * Update a matrix to values which are computed by:
  4406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4409. * @param startValue defines the first matrix
  4410. * @param endValue defines the second matrix
  4411. * @param gradient defines the gradient between the two matrices
  4412. * @param result defines the target matrix
  4413. */
  4414. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4415. /**
  4416. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4417. * This function works in left handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4426. * This function works in left handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4435. * This function works in right handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @returns the new matrix
  4440. */
  4441. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @param result defines the target matrix
  4449. */
  4450. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param width defines the viewport width
  4454. * @param height defines the viewport height
  4455. * @param znear defines the near clip plane
  4456. * @param zfar defines the far clip plane
  4457. * @returns a new matrix as a left-handed orthographic projection matrix
  4458. */
  4459. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4460. /**
  4461. * Store a left-handed orthographic projection to a given matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Create a left-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a right-handed orthographic projection matrix
  4493. * @param left defines the viewport left coordinate
  4494. * @param right defines the viewport right coordinate
  4495. * @param bottom defines the viewport bottom coordinate
  4496. * @param top defines the viewport top coordinate
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a right-handed orthographic projection matrix
  4500. */
  4501. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a right-handed orthographic projection into a given matrix
  4504. * @param left defines the viewport left coordinate
  4505. * @param right defines the viewport right coordinate
  4506. * @param bottom defines the viewport bottom coordinate
  4507. * @param top defines the viewport top coordinate
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @param result defines the target matrix
  4511. */
  4512. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4513. /**
  4514. * Creates a left-handed perspective projection matrix
  4515. * @param width defines the viewport width
  4516. * @param height defines the viewport height
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @returns a new matrix as a left-handed perspective projection matrix
  4520. */
  4521. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a left-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Creates a right-handed perspective projection matrix
  4553. * @param fov defines the horizontal field of view
  4554. * @param aspect defines the aspect ratio
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a right-handed perspective projection matrix
  4558. */
  4559. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Stores a right-handed perspective projection into a given matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4568. */
  4569. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4570. /**
  4571. * Stores a right-handed perspective projection into a given matrix
  4572. * @param fov defines the horizontal field of view
  4573. * @param aspect defines the aspect ratio
  4574. * @param znear defines the near clip plane
  4575. * @param zfar not used as infinity is used as far clip
  4576. * @param result defines the target matrix
  4577. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4578. */
  4579. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4580. /**
  4581. * Stores a perspective projection for WebVR info a given matrix
  4582. * @param fov defines the field of view
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @param result defines the target matrix
  4586. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4587. */
  4588. static PerspectiveFovWebVRToRef(fov: {
  4589. upDegrees: number;
  4590. downDegrees: number;
  4591. leftDegrees: number;
  4592. rightDegrees: number;
  4593. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4594. /**
  4595. * Computes a complete transformation matrix
  4596. * @param viewport defines the viewport to use
  4597. * @param world defines the world matrix
  4598. * @param view defines the view matrix
  4599. * @param projection defines the projection matrix
  4600. * @param zmin defines the near clip plane
  4601. * @param zmax defines the far clip plane
  4602. * @returns the transformation matrix
  4603. */
  4604. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4605. /**
  4606. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4607. * @param matrix defines the matrix to use
  4608. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4609. */
  4610. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4611. /**
  4612. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4613. * @param matrix defines the matrix to use
  4614. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4615. */
  4616. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4617. /**
  4618. * Compute the transpose of a given matrix
  4619. * @param matrix defines the matrix to transpose
  4620. * @returns the new matrix
  4621. */
  4622. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4623. /**
  4624. * Compute the transpose of a matrix and store it in a target matrix
  4625. * @param matrix defines the matrix to transpose
  4626. * @param result defines the target matrix
  4627. */
  4628. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4629. /**
  4630. * Computes a reflection matrix from a plane
  4631. * @param plane defines the reflection plane
  4632. * @returns a new matrix
  4633. */
  4634. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4635. /**
  4636. * Computes a reflection matrix from a plane
  4637. * @param plane defines the reflection plane
  4638. * @param result defines the target matrix
  4639. */
  4640. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4641. /**
  4642. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4643. * @param xaxis defines the value of the 1st axis
  4644. * @param yaxis defines the value of the 2nd axis
  4645. * @param zaxis defines the value of the 3rd axis
  4646. * @param result defines the target matrix
  4647. */
  4648. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4649. /**
  4650. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4651. * @param quat defines the quaternion to use
  4652. * @param result defines the target matrix
  4653. */
  4654. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4655. }
  4656. /**
  4657. * @hidden
  4658. */
  4659. export class TmpVectors {
  4660. static Vector2: Vector2[];
  4661. static Vector3: Vector3[];
  4662. static Vector4: Vector4[];
  4663. static Quaternion: Quaternion[];
  4664. static Matrix: Matrix[];
  4665. }
  4666. }
  4667. declare module "babylonjs/Maths/math.path" {
  4668. import { DeepImmutable, Nullable } from "babylonjs/types";
  4669. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4670. /**
  4671. * Defines potential orientation for back face culling
  4672. */
  4673. export enum Orientation {
  4674. /**
  4675. * Clockwise
  4676. */
  4677. CW = 0,
  4678. /** Counter clockwise */
  4679. CCW = 1
  4680. }
  4681. /** Class used to represent a Bezier curve */
  4682. export class BezierCurve {
  4683. /**
  4684. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4685. * @param t defines the time
  4686. * @param x1 defines the left coordinate on X axis
  4687. * @param y1 defines the left coordinate on Y axis
  4688. * @param x2 defines the right coordinate on X axis
  4689. * @param y2 defines the right coordinate on Y axis
  4690. * @returns the interpolated value
  4691. */
  4692. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4693. }
  4694. /**
  4695. * Defines angle representation
  4696. */
  4697. export class Angle {
  4698. private _radians;
  4699. /**
  4700. * Creates an Angle object of "radians" radians (float).
  4701. * @param radians the angle in radians
  4702. */
  4703. constructor(radians: number);
  4704. /**
  4705. * Get value in degrees
  4706. * @returns the Angle value in degrees (float)
  4707. */
  4708. degrees(): number;
  4709. /**
  4710. * Get value in radians
  4711. * @returns the Angle value in radians (float)
  4712. */
  4713. radians(): number;
  4714. /**
  4715. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4716. * @param a defines first vector
  4717. * @param b defines second vector
  4718. * @returns a new Angle
  4719. */
  4720. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4721. /**
  4722. * Gets a new Angle object from the given float in radians
  4723. * @param radians defines the angle value in radians
  4724. * @returns a new Angle
  4725. */
  4726. static FromRadians(radians: number): Angle;
  4727. /**
  4728. * Gets a new Angle object from the given float in degrees
  4729. * @param degrees defines the angle value in degrees
  4730. * @returns a new Angle
  4731. */
  4732. static FromDegrees(degrees: number): Angle;
  4733. }
  4734. /**
  4735. * This represents an arc in a 2d space.
  4736. */
  4737. export class Arc2 {
  4738. /** Defines the start point of the arc */
  4739. startPoint: Vector2;
  4740. /** Defines the mid point of the arc */
  4741. midPoint: Vector2;
  4742. /** Defines the end point of the arc */
  4743. endPoint: Vector2;
  4744. /**
  4745. * Defines the center point of the arc.
  4746. */
  4747. centerPoint: Vector2;
  4748. /**
  4749. * Defines the radius of the arc.
  4750. */
  4751. radius: number;
  4752. /**
  4753. * Defines the angle of the arc (from mid point to end point).
  4754. */
  4755. angle: Angle;
  4756. /**
  4757. * Defines the start angle of the arc (from start point to middle point).
  4758. */
  4759. startAngle: Angle;
  4760. /**
  4761. * Defines the orientation of the arc (clock wise/counter clock wise).
  4762. */
  4763. orientation: Orientation;
  4764. /**
  4765. * Creates an Arc object from the three given points : start, middle and end.
  4766. * @param startPoint Defines the start point of the arc
  4767. * @param midPoint Defines the midlle point of the arc
  4768. * @param endPoint Defines the end point of the arc
  4769. */
  4770. constructor(
  4771. /** Defines the start point of the arc */
  4772. startPoint: Vector2,
  4773. /** Defines the mid point of the arc */
  4774. midPoint: Vector2,
  4775. /** Defines the end point of the arc */
  4776. endPoint: Vector2);
  4777. }
  4778. /**
  4779. * Represents a 2D path made up of multiple 2D points
  4780. */
  4781. export class Path2 {
  4782. private _points;
  4783. private _length;
  4784. /**
  4785. * If the path start and end point are the same
  4786. */
  4787. closed: boolean;
  4788. /**
  4789. * Creates a Path2 object from the starting 2D coordinates x and y.
  4790. * @param x the starting points x value
  4791. * @param y the starting points y value
  4792. */
  4793. constructor(x: number, y: number);
  4794. /**
  4795. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4796. * @param x the added points x value
  4797. * @param y the added points y value
  4798. * @returns the updated Path2.
  4799. */
  4800. addLineTo(x: number, y: number): Path2;
  4801. /**
  4802. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4803. * @param midX middle point x value
  4804. * @param midY middle point y value
  4805. * @param endX end point x value
  4806. * @param endY end point y value
  4807. * @param numberOfSegments (default: 36)
  4808. * @returns the updated Path2.
  4809. */
  4810. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4811. /**
  4812. * Closes the Path2.
  4813. * @returns the Path2.
  4814. */
  4815. close(): Path2;
  4816. /**
  4817. * Gets the sum of the distance between each sequential point in the path
  4818. * @returns the Path2 total length (float).
  4819. */
  4820. length(): number;
  4821. /**
  4822. * Gets the points which construct the path
  4823. * @returns the Path2 internal array of points.
  4824. */
  4825. getPoints(): Vector2[];
  4826. /**
  4827. * Retreives the point at the distance aways from the starting point
  4828. * @param normalizedLengthPosition the length along the path to retreive the point from
  4829. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4830. */
  4831. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4832. /**
  4833. * Creates a new path starting from an x and y position
  4834. * @param x starting x value
  4835. * @param y starting y value
  4836. * @returns a new Path2 starting at the coordinates (x, y).
  4837. */
  4838. static StartingAt(x: number, y: number): Path2;
  4839. }
  4840. /**
  4841. * Represents a 3D path made up of multiple 3D points
  4842. */
  4843. export class Path3D {
  4844. /**
  4845. * an array of Vector3, the curve axis of the Path3D
  4846. */
  4847. path: Vector3[];
  4848. private _curve;
  4849. private _distances;
  4850. private _tangents;
  4851. private _normals;
  4852. private _binormals;
  4853. private _raw;
  4854. private _alignTangentsWithPath;
  4855. private readonly _pointAtData;
  4856. /**
  4857. * new Path3D(path, normal, raw)
  4858. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4859. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4860. * @param path an array of Vector3, the curve axis of the Path3D
  4861. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4862. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4864. */
  4865. constructor(
  4866. /**
  4867. * an array of Vector3, the curve axis of the Path3D
  4868. */
  4869. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4870. /**
  4871. * Returns the Path3D array of successive Vector3 designing its curve.
  4872. * @returns the Path3D array of successive Vector3 designing its curve.
  4873. */
  4874. getCurve(): Vector3[];
  4875. /**
  4876. * Returns the Path3D array of successive Vector3 designing its curve.
  4877. * @returns the Path3D array of successive Vector3 designing its curve.
  4878. */
  4879. getPoints(): Vector3[];
  4880. /**
  4881. * @returns the computed length (float) of the path.
  4882. */
  4883. length(): number;
  4884. /**
  4885. * Returns an array populated with tangent vectors on each Path3D curve point.
  4886. * @returns an array populated with tangent vectors on each Path3D curve point.
  4887. */
  4888. getTangents(): Vector3[];
  4889. /**
  4890. * Returns an array populated with normal vectors on each Path3D curve point.
  4891. * @returns an array populated with normal vectors on each Path3D curve point.
  4892. */
  4893. getNormals(): Vector3[];
  4894. /**
  4895. * Returns an array populated with binormal vectors on each Path3D curve point.
  4896. * @returns an array populated with binormal vectors on each Path3D curve point.
  4897. */
  4898. getBinormals(): Vector3[];
  4899. /**
  4900. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4901. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4902. */
  4903. getDistances(): number[];
  4904. /**
  4905. * Returns an interpolated point along this path
  4906. * @param position the position of the point along this path, from 0.0 to 1.0
  4907. * @returns a new Vector3 as the point
  4908. */
  4909. getPointAt(position: number): Vector3;
  4910. /**
  4911. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4914. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4915. */
  4916. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4921. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4922. */
  4923. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4924. /**
  4925. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4926. * @param position the position of the point along this path, from 0.0 to 1.0
  4927. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4928. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4929. */
  4930. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4931. /**
  4932. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4933. * @param position the position of the point along this path, from 0.0 to 1.0
  4934. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4935. */
  4936. getDistanceAt(position: number): number;
  4937. /**
  4938. * Returns the array index of the previous point of an interpolated point along this path
  4939. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4940. * @returns the array index
  4941. */
  4942. getPreviousPointIndexAt(position: number): number;
  4943. /**
  4944. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4945. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4946. * @returns the sub position
  4947. */
  4948. getSubPositionAt(position: number): number;
  4949. /**
  4950. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4951. * @param target the vector of which to get the closest position to
  4952. * @returns the position of the closest virtual point on this path to the target vector
  4953. */
  4954. getClosestPositionTo(target: Vector3): number;
  4955. /**
  4956. * Returns a sub path (slice) of this path
  4957. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4958. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4959. * @returns a sub path (slice) of this path
  4960. */
  4961. slice(start?: number, end?: number): Path3D;
  4962. /**
  4963. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4964. * @param path path which all values are copied into the curves points
  4965. * @param firstNormal which should be projected onto the curve
  4966. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4967. * @returns the same object updated.
  4968. */
  4969. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4970. private _compute;
  4971. private _getFirstNonNullVector;
  4972. private _getLastNonNullVector;
  4973. private _normalVector;
  4974. /**
  4975. * Updates the point at data for an interpolated point along this curve
  4976. * @param position the position of the point along this curve, from 0.0 to 1.0
  4977. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4978. * @returns the (updated) point at data
  4979. */
  4980. private _updatePointAtData;
  4981. /**
  4982. * Updates the point at data from the specified parameters
  4983. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4984. * @param point the interpolated point
  4985. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4986. */
  4987. private _setPointAtData;
  4988. /**
  4989. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4990. */
  4991. private _updateInterpolationMatrix;
  4992. }
  4993. /**
  4994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4995. * A Curve3 is designed from a series of successive Vector3.
  4996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4997. */
  4998. export class Curve3 {
  4999. private _points;
  5000. private _length;
  5001. /**
  5002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5004. * @param v1 (Vector3) the control point
  5005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5006. * @param nbPoints (integer) the wanted number of points in the curve
  5007. * @returns the created Curve3
  5008. */
  5009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5010. /**
  5011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5013. * @param v1 (Vector3) the first control point
  5014. * @param v2 (Vector3) the second control point
  5015. * @param v3 (Vector3) the end point of the Cubic Bezier
  5016. * @param nbPoints (integer) the wanted number of points in the curve
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5020. /**
  5021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5022. * @param p1 (Vector3) the origin point of the Hermite Spline
  5023. * @param t1 (Vector3) the tangent vector at the origin point
  5024. * @param p2 (Vector3) the end point of the Hermite Spline
  5025. * @param t2 (Vector3) the tangent vector at the end point
  5026. * @param nbPoints (integer) the wanted number of points in the curve
  5027. * @returns the created Curve3
  5028. */
  5029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5030. /**
  5031. * Returns a Curve3 object along a CatmullRom Spline curve :
  5032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5033. * @param nbPoints (integer) the wanted number of points between each curve control points
  5034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5035. * @returns the created Curve3
  5036. */
  5037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5038. /**
  5039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5040. * A Curve3 is designed from a series of successive Vector3.
  5041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5042. * @param points points which make up the curve
  5043. */
  5044. constructor(points: Vector3[]);
  5045. /**
  5046. * @returns the Curve3 stored array of successive Vector3
  5047. */
  5048. getPoints(): Vector3[];
  5049. /**
  5050. * @returns the computed length (float) of the curve.
  5051. */
  5052. length(): number;
  5053. /**
  5054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5056. * curveA and curveB keep unchanged.
  5057. * @param curve the curve to continue from this curve
  5058. * @returns the newly constructed curve
  5059. */
  5060. continue(curve: DeepImmutable<Curve3>): Curve3;
  5061. private _computeLength;
  5062. }
  5063. }
  5064. declare module "babylonjs/Animations/easing" {
  5065. /**
  5066. * This represents the main contract an easing function should follow.
  5067. * Easing functions are used throughout the animation system.
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export interface IEasingFunction {
  5071. /**
  5072. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5073. * of the easing function.
  5074. * The link below provides some of the most common examples of easing functions.
  5075. * @see https://easings.net/
  5076. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5077. * @returns the corresponding value on the curve defined by the easing function
  5078. */
  5079. ease(gradient: number): number;
  5080. }
  5081. /**
  5082. * Base class used for every default easing function.
  5083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5084. */
  5085. export class EasingFunction implements IEasingFunction {
  5086. /**
  5087. * Interpolation follows the mathematical formula associated with the easing function.
  5088. */
  5089. static readonly EASINGMODE_EASEIN: number;
  5090. /**
  5091. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEOUT: number;
  5094. /**
  5095. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5096. */
  5097. static readonly EASINGMODE_EASEINOUT: number;
  5098. private _easingMode;
  5099. /**
  5100. * Sets the easing mode of the current function.
  5101. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5102. */
  5103. setEasingMode(easingMode: number): void;
  5104. /**
  5105. * Gets the current easing mode.
  5106. * @returns the easing mode
  5107. */
  5108. getEasingMode(): number;
  5109. /**
  5110. * @hidden
  5111. */
  5112. easeInCore(gradient: number): number;
  5113. /**
  5114. * Given an input gradient between 0 and 1, this returns the corresponding value
  5115. * of the easing function.
  5116. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5117. * @returns the corresponding value on the curve defined by the easing function
  5118. */
  5119. ease(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a circle shape (see link below).
  5123. * @see https://easings.net/#easeInCirc
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CircleEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a ease back shape (see link below).
  5132. * @see https://easings.net/#easeInBack
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class BackEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the amplitude of the function */
  5137. amplitude: number;
  5138. /**
  5139. * Instantiates a back ease easing
  5140. * @see https://easings.net/#easeInBack
  5141. * @param amplitude Defines the amplitude of the function
  5142. */
  5143. constructor(
  5144. /** Defines the amplitude of the function */
  5145. amplitude?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a bouncing shape (see link below).
  5151. * @see https://easings.net/#easeInBounce
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class BounceEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the number of bounces */
  5156. bounces: number;
  5157. /** Defines the amplitude of the bounce */
  5158. bounciness: number;
  5159. /**
  5160. * Instantiates a bounce easing
  5161. * @see https://easings.net/#easeInBounce
  5162. * @param bounces Defines the number of bounces
  5163. * @param bounciness Defines the amplitude of the bounce
  5164. */
  5165. constructor(
  5166. /** Defines the number of bounces */
  5167. bounces?: number,
  5168. /** Defines the amplitude of the bounce */
  5169. bounciness?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 3 shape (see link below).
  5175. * @see https://easings.net/#easeInCubic
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class CubicEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an elastic shape (see link below).
  5184. * @see https://easings.net/#easeInElastic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the number of oscillations*/
  5189. oscillations: number;
  5190. /** Defines the amplitude of the oscillations*/
  5191. springiness: number;
  5192. /**
  5193. * Instantiates an elastic easing function
  5194. * @see https://easings.net/#easeInElastic
  5195. * @param oscillations Defines the number of oscillations
  5196. * @param springiness Defines the amplitude of the oscillations
  5197. */
  5198. constructor(
  5199. /** Defines the number of oscillations*/
  5200. oscillations?: number,
  5201. /** Defines the amplitude of the oscillations*/
  5202. springiness?: number);
  5203. /** @hidden */
  5204. easeInCore(gradient: number): number;
  5205. }
  5206. /**
  5207. * Easing function with an exponential shape (see link below).
  5208. * @see https://easings.net/#easeInExpo
  5209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5212. /** Defines the exponent of the function */
  5213. exponent: number;
  5214. /**
  5215. * Instantiates an exponential easing function
  5216. * @see https://easings.net/#easeInExpo
  5217. * @param exponent Defines the exponent of the function
  5218. */
  5219. constructor(
  5220. /** Defines the exponent of the function */
  5221. exponent?: number);
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a power shape (see link below).
  5227. * @see https://easings.net/#easeInQuad
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class PowerEase extends EasingFunction implements IEasingFunction {
  5231. /** Defines the power of the function */
  5232. power: number;
  5233. /**
  5234. * Instantiates an power base easing function
  5235. * @see https://easings.net/#easeInQuad
  5236. * @param power Defines the power of the function
  5237. */
  5238. constructor(
  5239. /** Defines the power of the function */
  5240. power?: number);
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 2 shape (see link below).
  5246. * @see https://easings.net/#easeInQuad
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 4 shape (see link below).
  5255. * @see https://easings.net/#easeInQuart
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 5 shape (see link below).
  5264. * @see https://easings.net/#easeInQuint
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a sin shape (see link below).
  5273. * @see https://easings.net/#easeInSine
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class SineEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a bezier shape (see link below).
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the x component of the start tangent in the bezier curve */
  5287. x1: number;
  5288. /** Defines the y component of the start tangent in the bezier curve */
  5289. y1: number;
  5290. /** Defines the x component of the end tangent in the bezier curve */
  5291. x2: number;
  5292. /** Defines the y component of the end tangent in the bezier curve */
  5293. y2: number;
  5294. /**
  5295. * Instantiates a bezier function
  5296. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5297. * @param x1 Defines the x component of the start tangent in the bezier curve
  5298. * @param y1 Defines the y component of the start tangent in the bezier curve
  5299. * @param x2 Defines the x component of the end tangent in the bezier curve
  5300. * @param y2 Defines the y component of the end tangent in the bezier curve
  5301. */
  5302. constructor(
  5303. /** Defines the x component of the start tangent in the bezier curve */
  5304. x1?: number,
  5305. /** Defines the y component of the start tangent in the bezier curve */
  5306. y1?: number,
  5307. /** Defines the x component of the end tangent in the bezier curve */
  5308. x2?: number,
  5309. /** Defines the y component of the end tangent in the bezier curve */
  5310. y2?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. }
  5315. declare module "babylonjs/Maths/math.color" {
  5316. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5317. /**
  5318. * Class used to hold a RBG color
  5319. */
  5320. export class Color3 {
  5321. /**
  5322. * Defines the red component (between 0 and 1, default is 0)
  5323. */
  5324. r: number;
  5325. /**
  5326. * Defines the green component (between 0 and 1, default is 0)
  5327. */
  5328. g: number;
  5329. /**
  5330. * Defines the blue component (between 0 and 1, default is 0)
  5331. */
  5332. b: number;
  5333. /**
  5334. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5335. * @param r defines the red component (between 0 and 1, default is 0)
  5336. * @param g defines the green component (between 0 and 1, default is 0)
  5337. * @param b defines the blue component (between 0 and 1, default is 0)
  5338. */
  5339. constructor(
  5340. /**
  5341. * Defines the red component (between 0 and 1, default is 0)
  5342. */
  5343. r?: number,
  5344. /**
  5345. * Defines the green component (between 0 and 1, default is 0)
  5346. */
  5347. g?: number,
  5348. /**
  5349. * Defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. b?: number);
  5352. /**
  5353. * Creates a string with the Color3 current values
  5354. * @returns the string representation of the Color3 object
  5355. */
  5356. toString(): string;
  5357. /**
  5358. * Returns the string "Color3"
  5359. * @returns "Color3"
  5360. */
  5361. getClassName(): string;
  5362. /**
  5363. * Compute the Color3 hash code
  5364. * @returns an unique number that can be used to hash Color3 objects
  5365. */
  5366. getHashCode(): number;
  5367. /**
  5368. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5369. * @param array defines the array where to store the r,g,b components
  5370. * @param index defines an optional index in the target array to define where to start storing values
  5371. * @returns the current Color3 object
  5372. */
  5373. toArray(array: FloatArray, index?: number): Color3;
  5374. /**
  5375. * Returns a new Color4 object from the current Color3 and the given alpha
  5376. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5377. * @returns a new Color4 object
  5378. */
  5379. toColor4(alpha?: number): Color4;
  5380. /**
  5381. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5382. * @returns the new array
  5383. */
  5384. asArray(): number[];
  5385. /**
  5386. * Returns the luminance value
  5387. * @returns a float value
  5388. */
  5389. toLuminance(): number;
  5390. /**
  5391. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5392. * @param otherColor defines the second operand
  5393. * @returns the new Color3 object
  5394. */
  5395. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5396. /**
  5397. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5398. * @param otherColor defines the second operand
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the current Color3
  5401. */
  5402. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5403. /**
  5404. * Determines equality between Color3 objects
  5405. * @param otherColor defines the second operand
  5406. * @returns true if the rgb values are equal to the given ones
  5407. */
  5408. equals(otherColor: DeepImmutable<Color3>): boolean;
  5409. /**
  5410. * Determines equality between the current Color3 object and a set of r,b,g values
  5411. * @param r defines the red component to check
  5412. * @param g defines the green component to check
  5413. * @param b defines the blue component to check
  5414. * @returns true if the rgb values are equal to the given ones
  5415. */
  5416. equalsFloats(r: number, g: number, b: number): boolean;
  5417. /**
  5418. * Multiplies in place each rgb value by scale
  5419. * @param scale defines the scaling factor
  5420. * @returns the updated Color3
  5421. */
  5422. scale(scale: number): Color3;
  5423. /**
  5424. * Multiplies the rgb values by scale and stores the result into "result"
  5425. * @param scale defines the scaling factor
  5426. * @param result defines the Color3 object where to store the result
  5427. * @returns the unmodified current Color3
  5428. */
  5429. scaleToRef(scale: number, result: Color3): Color3;
  5430. /**
  5431. * Scale the current Color3 values by a factor and add the result to a given Color3
  5432. * @param scale defines the scale factor
  5433. * @param result defines color to store the result into
  5434. * @returns the unmodified current Color3
  5435. */
  5436. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5437. /**
  5438. * Clamps the rgb values by the min and max values and stores the result into "result"
  5439. * @param min defines minimum clamping value (default is 0)
  5440. * @param max defines maximum clamping value (default is 1)
  5441. * @param result defines color to store the result into
  5442. * @returns the original Color3
  5443. */
  5444. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5445. /**
  5446. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5447. * @param otherColor defines the second operand
  5448. * @returns the new Color3
  5449. */
  5450. add(otherColor: DeepImmutable<Color3>): Color3;
  5451. /**
  5452. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5453. * @param otherColor defines the second operand
  5454. * @param result defines Color3 object to store the result into
  5455. * @returns the unmodified current Color3
  5456. */
  5457. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5458. /**
  5459. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5460. * @param otherColor defines the second operand
  5461. * @returns the new Color3
  5462. */
  5463. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5466. * @param otherColor defines the second operand
  5467. * @param result defines Color3 object to store the result into
  5468. * @returns the unmodified current Color3
  5469. */
  5470. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5471. /**
  5472. * Copy the current object
  5473. * @returns a new Color3 copied the current one
  5474. */
  5475. clone(): Color3;
  5476. /**
  5477. * Copies the rgb values from the source in the current Color3
  5478. * @param source defines the source Color3 object
  5479. * @returns the updated Color3 object
  5480. */
  5481. copyFrom(source: DeepImmutable<Color3>): Color3;
  5482. /**
  5483. * Updates the Color3 rgb values from the given floats
  5484. * @param r defines the red component to read from
  5485. * @param g defines the green component to read from
  5486. * @param b defines the blue component to read from
  5487. * @returns the current Color3 object
  5488. */
  5489. copyFromFloats(r: number, g: number, b: number): Color3;
  5490. /**
  5491. * Updates the Color3 rgb values from the given floats
  5492. * @param r defines the red component to read from
  5493. * @param g defines the green component to read from
  5494. * @param b defines the blue component to read from
  5495. * @returns the current Color3 object
  5496. */
  5497. set(r: number, g: number, b: number): Color3;
  5498. /**
  5499. * Compute the Color3 hexadecimal code as a string
  5500. * @returns a string containing the hexadecimal representation of the Color3 object
  5501. */
  5502. toHexString(): string;
  5503. /**
  5504. * Computes a new Color3 converted from the current one to linear space
  5505. * @returns a new Color3 object
  5506. */
  5507. toLinearSpace(): Color3;
  5508. /**
  5509. * Converts current color in rgb space to HSV values
  5510. * @returns a new color3 representing the HSV values
  5511. */
  5512. toHSV(): Color3;
  5513. /**
  5514. * Converts current color in rgb space to HSV values
  5515. * @param result defines the Color3 where to store the HSV values
  5516. */
  5517. toHSVToRef(result: Color3): void;
  5518. /**
  5519. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5520. * @param convertedColor defines the Color3 object where to store the linear space version
  5521. * @returns the unmodified Color3
  5522. */
  5523. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5524. /**
  5525. * Computes a new Color3 converted from the current one to gamma space
  5526. * @returns a new Color3 object
  5527. */
  5528. toGammaSpace(): Color3;
  5529. /**
  5530. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5531. * @param convertedColor defines the Color3 object where to store the gamma space version
  5532. * @returns the unmodified Color3
  5533. */
  5534. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5535. private static _BlackReadOnly;
  5536. /**
  5537. * Convert Hue, saturation and value to a Color3 (RGB)
  5538. * @param hue defines the hue
  5539. * @param saturation defines the saturation
  5540. * @param value defines the value
  5541. * @param result defines the Color3 where to store the RGB values
  5542. */
  5543. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5544. /**
  5545. * Creates a new Color3 from the string containing valid hexadecimal values
  5546. * @param hex defines a string containing valid hexadecimal values
  5547. * @returns a new Color3 object
  5548. */
  5549. static FromHexString(hex: string): Color3;
  5550. /**
  5551. * Creates a new Color3 from the starting index of the given array
  5552. * @param array defines the source array
  5553. * @param offset defines an offset in the source array
  5554. * @returns a new Color3 object
  5555. */
  5556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5557. /**
  5558. * Creates a new Color3 from integer values (< 256)
  5559. * @param r defines the red component to read from (value between 0 and 255)
  5560. * @param g defines the green component to read from (value between 0 and 255)
  5561. * @param b defines the blue component to read from (value between 0 and 255)
  5562. * @returns a new Color3 object
  5563. */
  5564. static FromInts(r: number, g: number, b: number): Color3;
  5565. /**
  5566. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5567. * @param start defines the start Color3 value
  5568. * @param end defines the end Color3 value
  5569. * @param amount defines the gradient value between start and end
  5570. * @returns a new Color3 object
  5571. */
  5572. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5573. /**
  5574. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5575. * @param left defines the start value
  5576. * @param right defines the end value
  5577. * @param amount defines the gradient factor
  5578. * @param result defines the Color3 object where to store the result
  5579. */
  5580. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5581. /**
  5582. * Returns a Color3 value containing a red color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Red(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a green color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Green(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a blue color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Blue(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a black color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Black(): Color3;
  5601. /**
  5602. * Gets a Color3 value containing a black color that must not be updated
  5603. */
  5604. static get BlackReadOnly(): DeepImmutable<Color3>;
  5605. /**
  5606. * Returns a Color3 value containing a white color
  5607. * @returns a new Color3 object
  5608. */
  5609. static White(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a purple color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Purple(): Color3;
  5615. /**
  5616. * Returns a Color3 value containing a magenta color
  5617. * @returns a new Color3 object
  5618. */
  5619. static Magenta(): Color3;
  5620. /**
  5621. * Returns a Color3 value containing a yellow color
  5622. * @returns a new Color3 object
  5623. */
  5624. static Yellow(): Color3;
  5625. /**
  5626. * Returns a Color3 value containing a gray color
  5627. * @returns a new Color3 object
  5628. */
  5629. static Gray(): Color3;
  5630. /**
  5631. * Returns a Color3 value containing a teal color
  5632. * @returns a new Color3 object
  5633. */
  5634. static Teal(): Color3;
  5635. /**
  5636. * Returns a Color3 value containing a random color
  5637. * @returns a new Color3 object
  5638. */
  5639. static Random(): Color3;
  5640. }
  5641. /**
  5642. * Class used to hold a RBGA color
  5643. */
  5644. export class Color4 {
  5645. /**
  5646. * Defines the red component (between 0 and 1, default is 0)
  5647. */
  5648. r: number;
  5649. /**
  5650. * Defines the green component (between 0 and 1, default is 0)
  5651. */
  5652. g: number;
  5653. /**
  5654. * Defines the blue component (between 0 and 1, default is 0)
  5655. */
  5656. b: number;
  5657. /**
  5658. * Defines the alpha component (between 0 and 1, default is 1)
  5659. */
  5660. a: number;
  5661. /**
  5662. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5663. * @param r defines the red component (between 0 and 1, default is 0)
  5664. * @param g defines the green component (between 0 and 1, default is 0)
  5665. * @param b defines the blue component (between 0 and 1, default is 0)
  5666. * @param a defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. constructor(
  5669. /**
  5670. * Defines the red component (between 0 and 1, default is 0)
  5671. */
  5672. r?: number,
  5673. /**
  5674. * Defines the green component (between 0 and 1, default is 0)
  5675. */
  5676. g?: number,
  5677. /**
  5678. * Defines the blue component (between 0 and 1, default is 0)
  5679. */
  5680. b?: number,
  5681. /**
  5682. * Defines the alpha component (between 0 and 1, default is 1)
  5683. */
  5684. a?: number);
  5685. /**
  5686. * Adds in place the given Color4 values to the current Color4 object
  5687. * @param right defines the second operand
  5688. * @returns the current updated Color4 object
  5689. */
  5690. addInPlace(right: DeepImmutable<Color4>): Color4;
  5691. /**
  5692. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5693. * @returns the new array
  5694. */
  5695. asArray(): number[];
  5696. /**
  5697. * Stores from the starting index in the given array the Color4 successive values
  5698. * @param array defines the array where to store the r,g,b components
  5699. * @param index defines an optional index in the target array to define where to start storing values
  5700. * @returns the current Color4 object
  5701. */
  5702. toArray(array: number[], index?: number): Color4;
  5703. /**
  5704. * Determines equality between Color4 objects
  5705. * @param otherColor defines the second operand
  5706. * @returns true if the rgba values are equal to the given ones
  5707. */
  5708. equals(otherColor: DeepImmutable<Color4>): boolean;
  5709. /**
  5710. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5711. * @param right defines the second operand
  5712. * @returns a new Color4 object
  5713. */
  5714. add(right: DeepImmutable<Color4>): Color4;
  5715. /**
  5716. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5717. * @param right defines the second operand
  5718. * @returns a new Color4 object
  5719. */
  5720. subtract(right: DeepImmutable<Color4>): Color4;
  5721. /**
  5722. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5723. * @param right defines the second operand
  5724. * @param result defines the Color4 object where to store the result
  5725. * @returns the current Color4 object
  5726. */
  5727. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5728. /**
  5729. * Creates a new Color4 with the current Color4 values multiplied by scale
  5730. * @param scale defines the scaling factor to apply
  5731. * @returns a new Color4 object
  5732. */
  5733. scale(scale: number): Color4;
  5734. /**
  5735. * Multiplies the current Color4 values by scale and stores the result in "result"
  5736. * @param scale defines the scaling factor to apply
  5737. * @param result defines the Color4 object where to store the result
  5738. * @returns the current unmodified Color4
  5739. */
  5740. scaleToRef(scale: number, result: Color4): Color4;
  5741. /**
  5742. * Scale the current Color4 values by a factor and add the result to a given Color4
  5743. * @param scale defines the scale factor
  5744. * @param result defines the Color4 object where to store the result
  5745. * @returns the unmodified current Color4
  5746. */
  5747. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5748. /**
  5749. * Clamps the rgb values by the min and max values and stores the result into "result"
  5750. * @param min defines minimum clamping value (default is 0)
  5751. * @param max defines maximum clamping value (default is 1)
  5752. * @param result defines color to store the result into.
  5753. * @returns the cuurent Color4
  5754. */
  5755. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5756. /**
  5757. * Multipy an Color4 value by another and return a new Color4 object
  5758. * @param color defines the Color4 value to multiply by
  5759. * @returns a new Color4 object
  5760. */
  5761. multiply(color: Color4): Color4;
  5762. /**
  5763. * Multipy a Color4 value by another and push the result in a reference value
  5764. * @param color defines the Color4 value to multiply by
  5765. * @param result defines the Color4 to fill the result in
  5766. * @returns the result Color4
  5767. */
  5768. multiplyToRef(color: Color4, result: Color4): Color4;
  5769. /**
  5770. * Creates a string with the Color4 current values
  5771. * @returns the string representation of the Color4 object
  5772. */
  5773. toString(): string;
  5774. /**
  5775. * Returns the string "Color4"
  5776. * @returns "Color4"
  5777. */
  5778. getClassName(): string;
  5779. /**
  5780. * Compute the Color4 hash code
  5781. * @returns an unique number that can be used to hash Color4 objects
  5782. */
  5783. getHashCode(): number;
  5784. /**
  5785. * Creates a new Color4 copied from the current one
  5786. * @returns a new Color4 object
  5787. */
  5788. clone(): Color4;
  5789. /**
  5790. * Copies the given Color4 values into the current one
  5791. * @param source defines the source Color4 object
  5792. * @returns the current updated Color4 object
  5793. */
  5794. copyFrom(source: Color4): Color4;
  5795. /**
  5796. * Copies the given float values into the current one
  5797. * @param r defines the red component to read from
  5798. * @param g defines the green component to read from
  5799. * @param b defines the blue component to read from
  5800. * @param a defines the alpha component to read from
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. set(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Compute the Color4 hexadecimal code as a string
  5815. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5816. * @returns a string containing the hexadecimal representation of the Color4 object
  5817. */
  5818. toHexString(returnAsColor3?: boolean): string;
  5819. /**
  5820. * Computes a new Color4 converted from the current one to linear space
  5821. * @returns a new Color4 object
  5822. */
  5823. toLinearSpace(): Color4;
  5824. /**
  5825. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5826. * @param convertedColor defines the Color4 object where to store the linear space version
  5827. * @returns the unmodified Color4
  5828. */
  5829. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5830. /**
  5831. * Computes a new Color4 converted from the current one to gamma space
  5832. * @returns a new Color4 object
  5833. */
  5834. toGammaSpace(): Color4;
  5835. /**
  5836. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5837. * @param convertedColor defines the Color4 object where to store the gamma space version
  5838. * @returns the unmodified Color4
  5839. */
  5840. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5841. /**
  5842. * Creates a new Color4 from the string containing valid hexadecimal values
  5843. * @param hex defines a string containing valid hexadecimal values
  5844. * @returns a new Color4 object
  5845. */
  5846. static FromHexString(hex: string): Color4;
  5847. /**
  5848. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5849. * @param left defines the start value
  5850. * @param right defines the end value
  5851. * @param amount defines the gradient factor
  5852. * @returns a new Color4 object
  5853. */
  5854. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5855. /**
  5856. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5857. * @param left defines the start value
  5858. * @param right defines the end value
  5859. * @param amount defines the gradient factor
  5860. * @param result defines the Color4 object where to store data
  5861. */
  5862. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5863. /**
  5864. * Creates a new Color4 from a Color3 and an alpha value
  5865. * @param color3 defines the source Color3 to read from
  5866. * @param alpha defines the alpha component (1.0 by default)
  5867. * @returns a new Color4 object
  5868. */
  5869. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5870. /**
  5871. * Creates a new Color4 from the starting index element of the given array
  5872. * @param array defines the source array to read from
  5873. * @param offset defines the offset in the source array
  5874. * @returns a new Color4 object
  5875. */
  5876. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5877. /**
  5878. * Creates a new Color3 from integer values (< 256)
  5879. * @param r defines the red component to read from (value between 0 and 255)
  5880. * @param g defines the green component to read from (value between 0 and 255)
  5881. * @param b defines the blue component to read from (value between 0 and 255)
  5882. * @param a defines the alpha component to read from (value between 0 and 255)
  5883. * @returns a new Color3 object
  5884. */
  5885. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5886. /**
  5887. * Check the content of a given array and convert it to an array containing RGBA data
  5888. * If the original array was already containing count * 4 values then it is returned directly
  5889. * @param colors defines the array to check
  5890. * @param count defines the number of RGBA data to expect
  5891. * @returns an array containing count * 4 values (RGBA)
  5892. */
  5893. static CheckColors4(colors: number[], count: number): number[];
  5894. }
  5895. /**
  5896. * @hidden
  5897. */
  5898. export class TmpColors {
  5899. static Color3: Color3[];
  5900. static Color4: Color4[];
  5901. }
  5902. }
  5903. declare module "babylonjs/Animations/animationKey" {
  5904. /**
  5905. * Defines an interface which represents an animation key frame
  5906. */
  5907. export interface IAnimationKey {
  5908. /**
  5909. * Frame of the key frame
  5910. */
  5911. frame: number;
  5912. /**
  5913. * Value at the specifies key frame
  5914. */
  5915. value: any;
  5916. /**
  5917. * The input tangent for the cubic hermite spline
  5918. */
  5919. inTangent?: any;
  5920. /**
  5921. * The output tangent for the cubic hermite spline
  5922. */
  5923. outTangent?: any;
  5924. /**
  5925. * The animation interpolation type
  5926. */
  5927. interpolation?: AnimationKeyInterpolation;
  5928. }
  5929. /**
  5930. * Enum for the animation key frame interpolation type
  5931. */
  5932. export enum AnimationKeyInterpolation {
  5933. /**
  5934. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5935. */
  5936. STEP = 1
  5937. }
  5938. }
  5939. declare module "babylonjs/Animations/animationRange" {
  5940. /**
  5941. * Represents the range of an animation
  5942. */
  5943. export class AnimationRange {
  5944. /**The name of the animation range**/
  5945. name: string;
  5946. /**The starting frame of the animation */
  5947. from: number;
  5948. /**The ending frame of the animation*/
  5949. to: number;
  5950. /**
  5951. * Initializes the range of an animation
  5952. * @param name The name of the animation range
  5953. * @param from The starting frame of the animation
  5954. * @param to The ending frame of the animation
  5955. */
  5956. constructor(
  5957. /**The name of the animation range**/
  5958. name: string,
  5959. /**The starting frame of the animation */
  5960. from: number,
  5961. /**The ending frame of the animation*/
  5962. to: number);
  5963. /**
  5964. * Makes a copy of the animation range
  5965. * @returns A copy of the animation range
  5966. */
  5967. clone(): AnimationRange;
  5968. }
  5969. }
  5970. declare module "babylonjs/Animations/animationEvent" {
  5971. /**
  5972. * Composed of a frame, and an action function
  5973. */
  5974. export class AnimationEvent {
  5975. /** The frame for which the event is triggered **/
  5976. frame: number;
  5977. /** The event to perform when triggered **/
  5978. action: (currentFrame: number) => void;
  5979. /** Specifies if the event should be triggered only once**/
  5980. onlyOnce?: boolean | undefined;
  5981. /**
  5982. * Specifies if the animation event is done
  5983. */
  5984. isDone: boolean;
  5985. /**
  5986. * Initializes the animation event
  5987. * @param frame The frame for which the event is triggered
  5988. * @param action The event to perform when triggered
  5989. * @param onlyOnce Specifies if the event should be triggered only once
  5990. */
  5991. constructor(
  5992. /** The frame for which the event is triggered **/
  5993. frame: number,
  5994. /** The event to perform when triggered **/
  5995. action: (currentFrame: number) => void,
  5996. /** Specifies if the event should be triggered only once**/
  5997. onlyOnce?: boolean | undefined);
  5998. /** @hidden */
  5999. _clone(): AnimationEvent;
  6000. }
  6001. }
  6002. declare module "babylonjs/Behaviors/behavior" {
  6003. import { Nullable } from "babylonjs/types";
  6004. /**
  6005. * Interface used to define a behavior
  6006. */
  6007. export interface Behavior<T> {
  6008. /** gets or sets behavior's name */
  6009. name: string;
  6010. /**
  6011. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6012. */
  6013. init(): void;
  6014. /**
  6015. * Called when the behavior is attached to a target
  6016. * @param target defines the target where the behavior is attached to
  6017. */
  6018. attach(target: T): void;
  6019. /**
  6020. * Called when the behavior is detached from its target
  6021. */
  6022. detach(): void;
  6023. }
  6024. /**
  6025. * Interface implemented by classes supporting behaviors
  6026. */
  6027. export interface IBehaviorAware<T> {
  6028. /**
  6029. * Attach a behavior
  6030. * @param behavior defines the behavior to attach
  6031. * @returns the current host
  6032. */
  6033. addBehavior(behavior: Behavior<T>): T;
  6034. /**
  6035. * Remove a behavior from the current object
  6036. * @param behavior defines the behavior to detach
  6037. * @returns the current host
  6038. */
  6039. removeBehavior(behavior: Behavior<T>): T;
  6040. /**
  6041. * Gets a behavior using its name to search
  6042. * @param name defines the name to search
  6043. * @returns the behavior or null if not found
  6044. */
  6045. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6046. }
  6047. }
  6048. declare module "babylonjs/Misc/smartArray" {
  6049. /**
  6050. * Defines an array and its length.
  6051. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6052. */
  6053. export interface ISmartArrayLike<T> {
  6054. /**
  6055. * The data of the array.
  6056. */
  6057. data: Array<T>;
  6058. /**
  6059. * The active length of the array.
  6060. */
  6061. length: number;
  6062. }
  6063. /**
  6064. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6065. */
  6066. export class SmartArray<T> implements ISmartArrayLike<T> {
  6067. /**
  6068. * The full set of data from the array.
  6069. */
  6070. data: Array<T>;
  6071. /**
  6072. * The active length of the array.
  6073. */
  6074. length: number;
  6075. protected _id: number;
  6076. /**
  6077. * Instantiates a Smart Array.
  6078. * @param capacity defines the default capacity of the array.
  6079. */
  6080. constructor(capacity: number);
  6081. /**
  6082. * Pushes a value at the end of the active data.
  6083. * @param value defines the object to push in the array.
  6084. */
  6085. push(value: T): void;
  6086. /**
  6087. * Iterates over the active data and apply the lambda to them.
  6088. * @param func defines the action to apply on each value.
  6089. */
  6090. forEach(func: (content: T) => void): void;
  6091. /**
  6092. * Sorts the full sets of data.
  6093. * @param compareFn defines the comparison function to apply.
  6094. */
  6095. sort(compareFn: (a: T, b: T) => number): void;
  6096. /**
  6097. * Resets the active data to an empty array.
  6098. */
  6099. reset(): void;
  6100. /**
  6101. * Releases all the data from the array as well as the array.
  6102. */
  6103. dispose(): void;
  6104. /**
  6105. * Concats the active data with a given array.
  6106. * @param array defines the data to concatenate with.
  6107. */
  6108. concat(array: any): void;
  6109. /**
  6110. * Returns the position of a value in the active data.
  6111. * @param value defines the value to find the index for
  6112. * @returns the index if found in the active data otherwise -1
  6113. */
  6114. indexOf(value: T): number;
  6115. /**
  6116. * Returns whether an element is part of the active data.
  6117. * @param value defines the value to look for
  6118. * @returns true if found in the active data otherwise false
  6119. */
  6120. contains(value: T): boolean;
  6121. private static _GlobalId;
  6122. }
  6123. /**
  6124. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6125. * The data in this array can only be present once
  6126. */
  6127. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6128. private _duplicateId;
  6129. /**
  6130. * Pushes a value at the end of the active data.
  6131. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6132. * @param value defines the object to push in the array.
  6133. */
  6134. push(value: T): void;
  6135. /**
  6136. * Pushes a value at the end of the active data.
  6137. * If the data is already present, it won t be added again
  6138. * @param value defines the object to push in the array.
  6139. * @returns true if added false if it was already present
  6140. */
  6141. pushNoDuplicate(value: T): boolean;
  6142. /**
  6143. * Resets the active data to an empty array.
  6144. */
  6145. reset(): void;
  6146. /**
  6147. * Concats the active data with a given array.
  6148. * This ensures no dupplicate will be present in the result.
  6149. * @param array defines the data to concatenate with.
  6150. */
  6151. concatWithNoDuplicate(array: any): void;
  6152. }
  6153. }
  6154. declare module "babylonjs/Cameras/cameraInputsManager" {
  6155. import { Nullable } from "babylonjs/types";
  6156. import { Camera } from "babylonjs/Cameras/camera";
  6157. /**
  6158. * @ignore
  6159. * This is a list of all the different input types that are available in the application.
  6160. * Fo instance: ArcRotateCameraGamepadInput...
  6161. */
  6162. export var CameraInputTypes: {};
  6163. /**
  6164. * This is the contract to implement in order to create a new input class.
  6165. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6166. */
  6167. export interface ICameraInput<TCamera extends Camera> {
  6168. /**
  6169. * Defines the camera the input is attached to.
  6170. */
  6171. camera: Nullable<TCamera>;
  6172. /**
  6173. * Gets the class name of the current intput.
  6174. * @returns the class name
  6175. */
  6176. getClassName(): string;
  6177. /**
  6178. * Get the friendly name associated with the input class.
  6179. * @returns the input friendly name
  6180. */
  6181. getSimpleName(): string;
  6182. /**
  6183. * Attach the input controls to a specific dom element to get the input from.
  6184. * @param element Defines the element the controls should be listened from
  6185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6186. */
  6187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6188. /**
  6189. * Detach the current controls from the specified dom element.
  6190. * @param element Defines the element to stop listening the inputs from
  6191. */
  6192. detachControl(element: Nullable<HTMLElement>): void;
  6193. /**
  6194. * Update the current camera state depending on the inputs that have been used this frame.
  6195. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6196. */
  6197. checkInputs?: () => void;
  6198. }
  6199. /**
  6200. * Represents a map of input types to input instance or input index to input instance.
  6201. */
  6202. export interface CameraInputsMap<TCamera extends Camera> {
  6203. /**
  6204. * Accessor to the input by input type.
  6205. */
  6206. [name: string]: ICameraInput<TCamera>;
  6207. /**
  6208. * Accessor to the input by input index.
  6209. */
  6210. [idx: number]: ICameraInput<TCamera>;
  6211. }
  6212. /**
  6213. * This represents the input manager used within a camera.
  6214. * It helps dealing with all the different kind of input attached to a camera.
  6215. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6216. */
  6217. export class CameraInputsManager<TCamera extends Camera> {
  6218. /**
  6219. * Defines the list of inputs attahed to the camera.
  6220. */
  6221. attached: CameraInputsMap<TCamera>;
  6222. /**
  6223. * Defines the dom element the camera is collecting inputs from.
  6224. * This is null if the controls have not been attached.
  6225. */
  6226. attachedElement: Nullable<HTMLElement>;
  6227. /**
  6228. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6229. */
  6230. noPreventDefault: boolean;
  6231. /**
  6232. * Defined the camera the input manager belongs to.
  6233. */
  6234. camera: TCamera;
  6235. /**
  6236. * Update the current camera state depending on the inputs that have been used this frame.
  6237. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6238. */
  6239. checkInputs: () => void;
  6240. /**
  6241. * Instantiate a new Camera Input Manager.
  6242. * @param camera Defines the camera the input manager blongs to
  6243. */
  6244. constructor(camera: TCamera);
  6245. /**
  6246. * Add an input method to a camera
  6247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6248. * @param input camera input method
  6249. */
  6250. add(input: ICameraInput<TCamera>): void;
  6251. /**
  6252. * Remove a specific input method from a camera
  6253. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6254. * @param inputToRemove camera input method
  6255. */
  6256. remove(inputToRemove: ICameraInput<TCamera>): void;
  6257. /**
  6258. * Remove a specific input type from a camera
  6259. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6260. * @param inputType the type of the input to remove
  6261. */
  6262. removeByType(inputType: string): void;
  6263. private _addCheckInputs;
  6264. /**
  6265. * Attach the input controls to the currently attached dom element to listen the events from.
  6266. * @param input Defines the input to attach
  6267. */
  6268. attachInput(input: ICameraInput<TCamera>): void;
  6269. /**
  6270. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6271. * @param element Defines the dom element to collect the events from
  6272. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6273. */
  6274. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6275. /**
  6276. * Detach the current manager inputs controls from a specific dom element.
  6277. * @param element Defines the dom element to collect the events from
  6278. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6279. */
  6280. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6281. /**
  6282. * Rebuild the dynamic inputCheck function from the current list of
  6283. * defined inputs in the manager.
  6284. */
  6285. rebuildInputCheck(): void;
  6286. /**
  6287. * Remove all attached input methods from a camera
  6288. */
  6289. clear(): void;
  6290. /**
  6291. * Serialize the current input manager attached to a camera.
  6292. * This ensures than once parsed,
  6293. * the input associated to the camera will be identical to the current ones
  6294. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6295. */
  6296. serialize(serializedCamera: any): void;
  6297. /**
  6298. * Parses an input manager serialized JSON to restore the previous list of inputs
  6299. * and states associated to a camera.
  6300. * @param parsedCamera Defines the JSON to parse
  6301. */
  6302. parse(parsedCamera: any): void;
  6303. }
  6304. }
  6305. declare module "babylonjs/Meshes/buffer" {
  6306. import { Nullable, DataArray } from "babylonjs/types";
  6307. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6308. /**
  6309. * Class used to store data that will be store in GPU memory
  6310. */
  6311. export class Buffer {
  6312. private _engine;
  6313. private _buffer;
  6314. /** @hidden */
  6315. _data: Nullable<DataArray>;
  6316. private _updatable;
  6317. private _instanced;
  6318. private _divisor;
  6319. /**
  6320. * Gets the byte stride.
  6321. */
  6322. readonly byteStride: number;
  6323. /**
  6324. * Constructor
  6325. * @param engine the engine
  6326. * @param data the data to use for this buffer
  6327. * @param updatable whether the data is updatable
  6328. * @param stride the stride (optional)
  6329. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6330. * @param instanced whether the buffer is instanced (optional)
  6331. * @param useBytes set to true if the stride in in bytes (optional)
  6332. * @param divisor sets an optional divisor for instances (1 by default)
  6333. */
  6334. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6335. /**
  6336. * Create a new VertexBuffer based on the current buffer
  6337. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6338. * @param offset defines offset in the buffer (0 by default)
  6339. * @param size defines the size in floats of attributes (position is 3 for instance)
  6340. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6341. * @param instanced defines if the vertex buffer contains indexed data
  6342. * @param useBytes defines if the offset and stride are in bytes *
  6343. * @param divisor sets an optional divisor for instances (1 by default)
  6344. * @returns the new vertex buffer
  6345. */
  6346. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6347. /**
  6348. * Gets a boolean indicating if the Buffer is updatable?
  6349. * @returns true if the buffer is updatable
  6350. */
  6351. isUpdatable(): boolean;
  6352. /**
  6353. * Gets current buffer's data
  6354. * @returns a DataArray or null
  6355. */
  6356. getData(): Nullable<DataArray>;
  6357. /**
  6358. * Gets underlying native buffer
  6359. * @returns underlying native buffer
  6360. */
  6361. getBuffer(): Nullable<DataBuffer>;
  6362. /**
  6363. * Gets the stride in float32 units (i.e. byte stride / 4).
  6364. * May not be an integer if the byte stride is not divisible by 4.
  6365. * @returns the stride in float32 units
  6366. * @deprecated Please use byteStride instead.
  6367. */
  6368. getStrideSize(): number;
  6369. /**
  6370. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6371. * @param data defines the data to store
  6372. */
  6373. create(data?: Nullable<DataArray>): void;
  6374. /** @hidden */
  6375. _rebuild(): void;
  6376. /**
  6377. * Update current buffer data
  6378. * @param data defines the data to store
  6379. */
  6380. update(data: DataArray): void;
  6381. /**
  6382. * Updates the data directly.
  6383. * @param data the new data
  6384. * @param offset the new offset
  6385. * @param vertexCount the vertex count (optional)
  6386. * @param useBytes set to true if the offset is in bytes
  6387. */
  6388. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6389. /**
  6390. * Release all resources
  6391. */
  6392. dispose(): void;
  6393. }
  6394. /**
  6395. * Specialized buffer used to store vertex data
  6396. */
  6397. export class VertexBuffer {
  6398. /** @hidden */
  6399. _buffer: Buffer;
  6400. private _kind;
  6401. private _size;
  6402. private _ownsBuffer;
  6403. private _instanced;
  6404. private _instanceDivisor;
  6405. /**
  6406. * The byte type.
  6407. */
  6408. static readonly BYTE: number;
  6409. /**
  6410. * The unsigned byte type.
  6411. */
  6412. static readonly UNSIGNED_BYTE: number;
  6413. /**
  6414. * The short type.
  6415. */
  6416. static readonly SHORT: number;
  6417. /**
  6418. * The unsigned short type.
  6419. */
  6420. static readonly UNSIGNED_SHORT: number;
  6421. /**
  6422. * The integer type.
  6423. */
  6424. static readonly INT: number;
  6425. /**
  6426. * The unsigned integer type.
  6427. */
  6428. static readonly UNSIGNED_INT: number;
  6429. /**
  6430. * The float type.
  6431. */
  6432. static readonly FLOAT: number;
  6433. /**
  6434. * Gets or sets the instance divisor when in instanced mode
  6435. */
  6436. get instanceDivisor(): number;
  6437. set instanceDivisor(value: number);
  6438. /**
  6439. * Gets the byte stride.
  6440. */
  6441. readonly byteStride: number;
  6442. /**
  6443. * Gets the byte offset.
  6444. */
  6445. readonly byteOffset: number;
  6446. /**
  6447. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6448. */
  6449. readonly normalized: boolean;
  6450. /**
  6451. * Gets the data type of each component in the array.
  6452. */
  6453. readonly type: number;
  6454. /**
  6455. * Constructor
  6456. * @param engine the engine
  6457. * @param data the data to use for this vertex buffer
  6458. * @param kind the vertex buffer kind
  6459. * @param updatable whether the data is updatable
  6460. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6461. * @param stride the stride (optional)
  6462. * @param instanced whether the buffer is instanced (optional)
  6463. * @param offset the offset of the data (optional)
  6464. * @param size the number of components (optional)
  6465. * @param type the type of the component (optional)
  6466. * @param normalized whether the data contains normalized data (optional)
  6467. * @param useBytes set to true if stride and offset are in bytes (optional)
  6468. * @param divisor defines the instance divisor to use (1 by default)
  6469. */
  6470. 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);
  6471. /** @hidden */
  6472. _rebuild(): void;
  6473. /**
  6474. * Returns the kind of the VertexBuffer (string)
  6475. * @returns a string
  6476. */
  6477. getKind(): string;
  6478. /**
  6479. * Gets a boolean indicating if the VertexBuffer is updatable?
  6480. * @returns true if the buffer is updatable
  6481. */
  6482. isUpdatable(): boolean;
  6483. /**
  6484. * Gets current buffer's data
  6485. * @returns a DataArray or null
  6486. */
  6487. getData(): Nullable<DataArray>;
  6488. /**
  6489. * Gets underlying native buffer
  6490. * @returns underlying native buffer
  6491. */
  6492. getBuffer(): Nullable<DataBuffer>;
  6493. /**
  6494. * Gets the stride in float32 units (i.e. byte stride / 4).
  6495. * May not be an integer if the byte stride is not divisible by 4.
  6496. * @returns the stride in float32 units
  6497. * @deprecated Please use byteStride instead.
  6498. */
  6499. getStrideSize(): number;
  6500. /**
  6501. * Returns the offset as a multiple of the type byte length.
  6502. * @returns the offset in bytes
  6503. * @deprecated Please use byteOffset instead.
  6504. */
  6505. getOffset(): number;
  6506. /**
  6507. * Returns the number of components per vertex attribute (integer)
  6508. * @returns the size in float
  6509. */
  6510. getSize(): number;
  6511. /**
  6512. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6513. * @returns true if this buffer is instanced
  6514. */
  6515. getIsInstanced(): boolean;
  6516. /**
  6517. * Returns the instancing divisor, zero for non-instanced (integer).
  6518. * @returns a number
  6519. */
  6520. getInstanceDivisor(): number;
  6521. /**
  6522. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6523. * @param data defines the data to store
  6524. */
  6525. create(data?: DataArray): void;
  6526. /**
  6527. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6528. * This function will create a new buffer if the current one is not updatable
  6529. * @param data defines the data to store
  6530. */
  6531. update(data: DataArray): void;
  6532. /**
  6533. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6534. * Returns the directly updated WebGLBuffer.
  6535. * @param data the new data
  6536. * @param offset the new offset
  6537. * @param useBytes set to true if the offset is in bytes
  6538. */
  6539. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6540. /**
  6541. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6542. */
  6543. dispose(): void;
  6544. /**
  6545. * Enumerates each value of this vertex buffer as numbers.
  6546. * @param count the number of values to enumerate
  6547. * @param callback the callback function called for each value
  6548. */
  6549. forEach(count: number, callback: (value: number, index: number) => void): void;
  6550. /**
  6551. * Positions
  6552. */
  6553. static readonly PositionKind: string;
  6554. /**
  6555. * Normals
  6556. */
  6557. static readonly NormalKind: string;
  6558. /**
  6559. * Tangents
  6560. */
  6561. static readonly TangentKind: string;
  6562. /**
  6563. * Texture coordinates
  6564. */
  6565. static readonly UVKind: string;
  6566. /**
  6567. * Texture coordinates 2
  6568. */
  6569. static readonly UV2Kind: string;
  6570. /**
  6571. * Texture coordinates 3
  6572. */
  6573. static readonly UV3Kind: string;
  6574. /**
  6575. * Texture coordinates 4
  6576. */
  6577. static readonly UV4Kind: string;
  6578. /**
  6579. * Texture coordinates 5
  6580. */
  6581. static readonly UV5Kind: string;
  6582. /**
  6583. * Texture coordinates 6
  6584. */
  6585. static readonly UV6Kind: string;
  6586. /**
  6587. * Colors
  6588. */
  6589. static readonly ColorKind: string;
  6590. /**
  6591. * Matrix indices (for bones)
  6592. */
  6593. static readonly MatricesIndicesKind: string;
  6594. /**
  6595. * Matrix weights (for bones)
  6596. */
  6597. static readonly MatricesWeightsKind: string;
  6598. /**
  6599. * Additional matrix indices (for bones)
  6600. */
  6601. static readonly MatricesIndicesExtraKind: string;
  6602. /**
  6603. * Additional matrix weights (for bones)
  6604. */
  6605. static readonly MatricesWeightsExtraKind: string;
  6606. /**
  6607. * Deduces the stride given a kind.
  6608. * @param kind The kind string to deduce
  6609. * @returns The deduced stride
  6610. */
  6611. static DeduceStride(kind: string): number;
  6612. /**
  6613. * Gets the byte length of the given type.
  6614. * @param type the type
  6615. * @returns the number of bytes
  6616. */
  6617. static GetTypeByteLength(type: number): number;
  6618. /**
  6619. * Enumerates each value of the given parameters as numbers.
  6620. * @param data the data to enumerate
  6621. * @param byteOffset the byte offset of the data
  6622. * @param byteStride the byte stride of the data
  6623. * @param componentCount the number of components per element
  6624. * @param componentType the type of the component
  6625. * @param count the number of values to enumerate
  6626. * @param normalized whether the data is normalized
  6627. * @param callback the callback function called for each value
  6628. */
  6629. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6630. private static _GetFloatValue;
  6631. }
  6632. }
  6633. declare module "babylonjs/Collisions/intersectionInfo" {
  6634. import { Nullable } from "babylonjs/types";
  6635. /**
  6636. * @hidden
  6637. */
  6638. export class IntersectionInfo {
  6639. bu: Nullable<number>;
  6640. bv: Nullable<number>;
  6641. distance: number;
  6642. faceId: number;
  6643. subMeshId: number;
  6644. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6645. }
  6646. }
  6647. declare module "babylonjs/Maths/math.plane" {
  6648. import { DeepImmutable } from "babylonjs/types";
  6649. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6650. /**
  6651. * Represens a plane by the equation ax + by + cz + d = 0
  6652. */
  6653. export class Plane {
  6654. private static _TmpMatrix;
  6655. /**
  6656. * Normal of the plane (a,b,c)
  6657. */
  6658. normal: Vector3;
  6659. /**
  6660. * d component of the plane
  6661. */
  6662. d: number;
  6663. /**
  6664. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6665. * @param a a component of the plane
  6666. * @param b b component of the plane
  6667. * @param c c component of the plane
  6668. * @param d d component of the plane
  6669. */
  6670. constructor(a: number, b: number, c: number, d: number);
  6671. /**
  6672. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6673. */
  6674. asArray(): number[];
  6675. /**
  6676. * @returns a new plane copied from the current Plane.
  6677. */
  6678. clone(): Plane;
  6679. /**
  6680. * @returns the string "Plane".
  6681. */
  6682. getClassName(): string;
  6683. /**
  6684. * @returns the Plane hash code.
  6685. */
  6686. getHashCode(): number;
  6687. /**
  6688. * Normalize the current Plane in place.
  6689. * @returns the updated Plane.
  6690. */
  6691. normalize(): Plane;
  6692. /**
  6693. * Applies a transformation the plane and returns the result
  6694. * @param transformation the transformation matrix to be applied to the plane
  6695. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6696. */
  6697. transform(transformation: DeepImmutable<Matrix>): Plane;
  6698. /**
  6699. * Calcualtte the dot product between the point and the plane normal
  6700. * @param point point to calculate the dot product with
  6701. * @returns the dot product (float) of the point coordinates and the plane normal.
  6702. */
  6703. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6704. /**
  6705. * Updates the current Plane from the plane defined by the three given points.
  6706. * @param point1 one of the points used to contruct the plane
  6707. * @param point2 one of the points used to contruct the plane
  6708. * @param point3 one of the points used to contruct the plane
  6709. * @returns the updated Plane.
  6710. */
  6711. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6712. /**
  6713. * Checks if the plane is facing a given direction
  6714. * @param direction the direction to check if the plane is facing
  6715. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6716. * @returns True is the vector "direction" is the same side than the plane normal.
  6717. */
  6718. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6719. /**
  6720. * Calculates the distance to a point
  6721. * @param point point to calculate distance to
  6722. * @returns the signed distance (float) from the given point to the Plane.
  6723. */
  6724. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6725. /**
  6726. * Creates a plane from an array
  6727. * @param array the array to create a plane from
  6728. * @returns a new Plane from the given array.
  6729. */
  6730. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6731. /**
  6732. * Creates a plane from three points
  6733. * @param point1 point used to create the plane
  6734. * @param point2 point used to create the plane
  6735. * @param point3 point used to create the plane
  6736. * @returns a new Plane defined by the three given points.
  6737. */
  6738. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6739. /**
  6740. * Creates a plane from an origin point and a normal
  6741. * @param origin origin of the plane to be constructed
  6742. * @param normal normal of the plane to be constructed
  6743. * @returns a new Plane the normal vector to this plane at the given origin point.
  6744. * Note : the vector "normal" is updated because normalized.
  6745. */
  6746. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6747. /**
  6748. * Calculates the distance from a plane and a point
  6749. * @param origin origin of the plane to be constructed
  6750. * @param normal normal of the plane to be constructed
  6751. * @param point point to calculate distance to
  6752. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6753. */
  6754. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6755. }
  6756. }
  6757. declare module "babylonjs/Culling/boundingSphere" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6760. import { Plane } from "babylonjs/Maths/math.plane";
  6761. /**
  6762. * Class used to store bounding sphere information
  6763. */
  6764. export class BoundingSphere {
  6765. /**
  6766. * Gets the center of the bounding sphere in local space
  6767. */
  6768. readonly center: Vector3;
  6769. /**
  6770. * Radius of the bounding sphere in local space
  6771. */
  6772. radius: number;
  6773. /**
  6774. * Gets the center of the bounding sphere in world space
  6775. */
  6776. readonly centerWorld: Vector3;
  6777. /**
  6778. * Radius of the bounding sphere in world space
  6779. */
  6780. radiusWorld: number;
  6781. /**
  6782. * Gets the minimum vector in local space
  6783. */
  6784. readonly minimum: Vector3;
  6785. /**
  6786. * Gets the maximum vector in local space
  6787. */
  6788. readonly maximum: Vector3;
  6789. private _worldMatrix;
  6790. private static readonly TmpVector3;
  6791. /**
  6792. * Creates a new bounding sphere
  6793. * @param min defines the minimum vector (in local space)
  6794. * @param max defines the maximum vector (in local space)
  6795. * @param worldMatrix defines the new world matrix
  6796. */
  6797. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6798. /**
  6799. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6800. * @param min defines the new minimum vector (in local space)
  6801. * @param max defines the new maximum vector (in local space)
  6802. * @param worldMatrix defines the new world matrix
  6803. */
  6804. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6805. /**
  6806. * Scale the current bounding sphere by applying a scale factor
  6807. * @param factor defines the scale factor to apply
  6808. * @returns the current bounding box
  6809. */
  6810. scale(factor: number): BoundingSphere;
  6811. /**
  6812. * Gets the world matrix of the bounding box
  6813. * @returns a matrix
  6814. */
  6815. getWorldMatrix(): DeepImmutable<Matrix>;
  6816. /** @hidden */
  6817. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6818. /**
  6819. * Tests if the bounding sphere is intersecting the frustum planes
  6820. * @param frustumPlanes defines the frustum planes to test
  6821. * @returns true if there is an intersection
  6822. */
  6823. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6824. /**
  6825. * Tests if the bounding sphere center is in between the frustum planes.
  6826. * Used for optimistic fast inclusion.
  6827. * @param frustumPlanes defines the frustum planes to test
  6828. * @returns true if the sphere center is in between the frustum planes
  6829. */
  6830. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6831. /**
  6832. * Tests if a point is inside the bounding sphere
  6833. * @param point defines the point to test
  6834. * @returns true if the point is inside the bounding sphere
  6835. */
  6836. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6837. /**
  6838. * Checks if two sphere intersct
  6839. * @param sphere0 sphere 0
  6840. * @param sphere1 sphere 1
  6841. * @returns true if the speres intersect
  6842. */
  6843. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6844. }
  6845. }
  6846. declare module "babylonjs/Culling/boundingBox" {
  6847. import { DeepImmutable } from "babylonjs/types";
  6848. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6849. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6850. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6851. import { Plane } from "babylonjs/Maths/math.plane";
  6852. /**
  6853. * Class used to store bounding box information
  6854. */
  6855. export class BoundingBox implements ICullable {
  6856. /**
  6857. * Gets the 8 vectors representing the bounding box in local space
  6858. */
  6859. readonly vectors: Vector3[];
  6860. /**
  6861. * Gets the center of the bounding box in local space
  6862. */
  6863. readonly center: Vector3;
  6864. /**
  6865. * Gets the center of the bounding box in world space
  6866. */
  6867. readonly centerWorld: Vector3;
  6868. /**
  6869. * Gets the extend size in local space
  6870. */
  6871. readonly extendSize: Vector3;
  6872. /**
  6873. * Gets the extend size in world space
  6874. */
  6875. readonly extendSizeWorld: Vector3;
  6876. /**
  6877. * Gets the OBB (object bounding box) directions
  6878. */
  6879. readonly directions: Vector3[];
  6880. /**
  6881. * Gets the 8 vectors representing the bounding box in world space
  6882. */
  6883. readonly vectorsWorld: Vector3[];
  6884. /**
  6885. * Gets the minimum vector in world space
  6886. */
  6887. readonly minimumWorld: Vector3;
  6888. /**
  6889. * Gets the maximum vector in world space
  6890. */
  6891. readonly maximumWorld: Vector3;
  6892. /**
  6893. * Gets the minimum vector in local space
  6894. */
  6895. readonly minimum: Vector3;
  6896. /**
  6897. * Gets the maximum vector in local space
  6898. */
  6899. readonly maximum: Vector3;
  6900. private _worldMatrix;
  6901. private static readonly TmpVector3;
  6902. /**
  6903. * @hidden
  6904. */
  6905. _tag: number;
  6906. /**
  6907. * Creates a new bounding box
  6908. * @param min defines the minimum vector (in local space)
  6909. * @param max defines the maximum vector (in local space)
  6910. * @param worldMatrix defines the new world matrix
  6911. */
  6912. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6913. /**
  6914. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6915. * @param min defines the new minimum vector (in local space)
  6916. * @param max defines the new maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6920. /**
  6921. * Scale the current bounding box by applying a scale factor
  6922. * @param factor defines the scale factor to apply
  6923. * @returns the current bounding box
  6924. */
  6925. scale(factor: number): BoundingBox;
  6926. /**
  6927. * Gets the world matrix of the bounding box
  6928. * @returns a matrix
  6929. */
  6930. getWorldMatrix(): DeepImmutable<Matrix>;
  6931. /** @hidden */
  6932. _update(world: DeepImmutable<Matrix>): void;
  6933. /**
  6934. * Tests if the bounding box is intersecting the frustum planes
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @returns true if there is an intersection
  6937. */
  6938. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if the bounding box is entirely inside the frustum planes
  6941. * @param frustumPlanes defines the frustum planes to test
  6942. * @returns true if there is an inclusion
  6943. */
  6944. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6945. /**
  6946. * Tests if a point is inside the bounding box
  6947. * @param point defines the point to test
  6948. * @returns true if the point is inside the bounding box
  6949. */
  6950. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6951. /**
  6952. * Tests if the bounding box intersects with a bounding sphere
  6953. * @param sphere defines the sphere to test
  6954. * @returns true if there is an intersection
  6955. */
  6956. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6957. /**
  6958. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6959. * @param min defines the min vector to use
  6960. * @param max defines the max vector to use
  6961. * @returns true if there is an intersection
  6962. */
  6963. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6964. /**
  6965. * Tests if two bounding boxes are intersections
  6966. * @param box0 defines the first box to test
  6967. * @param box1 defines the second box to test
  6968. * @returns true if there is an intersection
  6969. */
  6970. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6971. /**
  6972. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6973. * @param minPoint defines the minimum vector of the bounding box
  6974. * @param maxPoint defines the maximum vector of the bounding box
  6975. * @param sphereCenter defines the sphere center
  6976. * @param sphereRadius defines the sphere radius
  6977. * @returns true if there is an intersection
  6978. */
  6979. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6980. /**
  6981. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6982. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6983. * @param frustumPlanes defines the frustum planes to test
  6984. * @return true if there is an inclusion
  6985. */
  6986. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6987. /**
  6988. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6989. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6990. * @param frustumPlanes defines the frustum planes to test
  6991. * @return true if there is an intersection
  6992. */
  6993. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6994. }
  6995. }
  6996. declare module "babylonjs/Collisions/collider" {
  6997. import { Nullable, IndicesArray } from "babylonjs/types";
  6998. import { Vector3 } from "babylonjs/Maths/math.vector";
  6999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7000. import { Plane } from "babylonjs/Maths/math.plane";
  7001. /** @hidden */
  7002. export class Collider {
  7003. /** Define if a collision was found */
  7004. collisionFound: boolean;
  7005. /**
  7006. * Define last intersection point in local space
  7007. */
  7008. intersectionPoint: Vector3;
  7009. /**
  7010. * Define last collided mesh
  7011. */
  7012. collidedMesh: Nullable<AbstractMesh>;
  7013. private _collisionPoint;
  7014. private _planeIntersectionPoint;
  7015. private _tempVector;
  7016. private _tempVector2;
  7017. private _tempVector3;
  7018. private _tempVector4;
  7019. private _edge;
  7020. private _baseToVertex;
  7021. private _destinationPoint;
  7022. private _slidePlaneNormal;
  7023. private _displacementVector;
  7024. /** @hidden */
  7025. _radius: Vector3;
  7026. /** @hidden */
  7027. _retry: number;
  7028. private _velocity;
  7029. private _basePoint;
  7030. private _epsilon;
  7031. /** @hidden */
  7032. _velocityWorldLength: number;
  7033. /** @hidden */
  7034. _basePointWorld: Vector3;
  7035. private _velocityWorld;
  7036. private _normalizedVelocity;
  7037. /** @hidden */
  7038. _initialVelocity: Vector3;
  7039. /** @hidden */
  7040. _initialPosition: Vector3;
  7041. private _nearestDistance;
  7042. private _collisionMask;
  7043. get collisionMask(): number;
  7044. set collisionMask(mask: number);
  7045. /**
  7046. * Gets the plane normal used to compute the sliding response (in local space)
  7047. */
  7048. get slidePlaneNormal(): Vector3;
  7049. /** @hidden */
  7050. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7051. /** @hidden */
  7052. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7053. /** @hidden */
  7054. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7055. /** @hidden */
  7056. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7057. /** @hidden */
  7058. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7059. /** @hidden */
  7060. _getResponse(pos: Vector3, vel: Vector3): void;
  7061. }
  7062. }
  7063. declare module "babylonjs/Culling/boundingInfo" {
  7064. import { DeepImmutable } from "babylonjs/types";
  7065. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7066. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7067. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7068. import { Plane } from "babylonjs/Maths/math.plane";
  7069. import { Collider } from "babylonjs/Collisions/collider";
  7070. /**
  7071. * Interface for cullable objects
  7072. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7073. */
  7074. export interface ICullable {
  7075. /**
  7076. * Checks if the object or part of the object is in the frustum
  7077. * @param frustumPlanes Camera near/planes
  7078. * @returns true if the object is in frustum otherwise false
  7079. */
  7080. isInFrustum(frustumPlanes: Plane[]): boolean;
  7081. /**
  7082. * Checks if a cullable object (mesh...) is in the camera frustum
  7083. * Unlike isInFrustum this cheks the full bounding box
  7084. * @param frustumPlanes Camera near/planes
  7085. * @returns true if the object is in frustum otherwise false
  7086. */
  7087. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7088. }
  7089. /**
  7090. * Info for a bounding data of a mesh
  7091. */
  7092. export class BoundingInfo implements ICullable {
  7093. /**
  7094. * Bounding box for the mesh
  7095. */
  7096. readonly boundingBox: BoundingBox;
  7097. /**
  7098. * Bounding sphere for the mesh
  7099. */
  7100. readonly boundingSphere: BoundingSphere;
  7101. private _isLocked;
  7102. private static readonly TmpVector3;
  7103. /**
  7104. * Constructs bounding info
  7105. * @param minimum min vector of the bounding box/sphere
  7106. * @param maximum max vector of the bounding box/sphere
  7107. * @param worldMatrix defines the new world matrix
  7108. */
  7109. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7110. /**
  7111. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7112. * @param min defines the new minimum vector (in local space)
  7113. * @param max defines the new maximum vector (in local space)
  7114. * @param worldMatrix defines the new world matrix
  7115. */
  7116. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7117. /**
  7118. * min vector of the bounding box/sphere
  7119. */
  7120. get minimum(): Vector3;
  7121. /**
  7122. * max vector of the bounding box/sphere
  7123. */
  7124. get maximum(): Vector3;
  7125. /**
  7126. * If the info is locked and won't be updated to avoid perf overhead
  7127. */
  7128. get isLocked(): boolean;
  7129. set isLocked(value: boolean);
  7130. /**
  7131. * Updates the bounding sphere and box
  7132. * @param world world matrix to be used to update
  7133. */
  7134. update(world: DeepImmutable<Matrix>): void;
  7135. /**
  7136. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7137. * @param center New center of the bounding info
  7138. * @param extend New extend of the bounding info
  7139. * @returns the current bounding info
  7140. */
  7141. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7142. /**
  7143. * Scale the current bounding info by applying a scale factor
  7144. * @param factor defines the scale factor to apply
  7145. * @returns the current bounding info
  7146. */
  7147. scale(factor: number): BoundingInfo;
  7148. /**
  7149. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7150. * @param frustumPlanes defines the frustum to test
  7151. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7152. * @returns true if the bounding info is in the frustum planes
  7153. */
  7154. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7155. /**
  7156. * Gets the world distance between the min and max points of the bounding box
  7157. */
  7158. get diagonalLength(): number;
  7159. /**
  7160. * Checks if a cullable object (mesh...) is in the camera frustum
  7161. * Unlike isInFrustum this cheks the full bounding box
  7162. * @param frustumPlanes Camera near/planes
  7163. * @returns true if the object is in frustum otherwise false
  7164. */
  7165. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7166. /** @hidden */
  7167. _checkCollision(collider: Collider): boolean;
  7168. /**
  7169. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7170. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7171. * @param point the point to check intersection with
  7172. * @returns if the point intersects
  7173. */
  7174. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7175. /**
  7176. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7177. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7178. * @param boundingInfo the bounding info to check intersection with
  7179. * @param precise if the intersection should be done using OBB
  7180. * @returns if the bounding info intersects
  7181. */
  7182. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7183. }
  7184. }
  7185. declare module "babylonjs/Maths/math.functions" {
  7186. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7187. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7188. /**
  7189. * Extracts minimum and maximum values from a list of indexed positions
  7190. * @param positions defines the positions to use
  7191. * @param indices defines the indices to the positions
  7192. * @param indexStart defines the start index
  7193. * @param indexCount defines the end index
  7194. * @param bias defines bias value to add to the result
  7195. * @return minimum and maximum values
  7196. */
  7197. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7198. minimum: Vector3;
  7199. maximum: Vector3;
  7200. };
  7201. /**
  7202. * Extracts minimum and maximum values from a list of positions
  7203. * @param positions defines the positions to use
  7204. * @param start defines the start index in the positions array
  7205. * @param count defines the number of positions to handle
  7206. * @param bias defines bias value to add to the result
  7207. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7208. * @return minimum and maximum values
  7209. */
  7210. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7211. minimum: Vector3;
  7212. maximum: Vector3;
  7213. };
  7214. }
  7215. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7216. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7217. /** @hidden */
  7218. export class WebGLDataBuffer extends DataBuffer {
  7219. private _buffer;
  7220. constructor(resource: WebGLBuffer);
  7221. get underlyingResource(): any;
  7222. }
  7223. }
  7224. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7225. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7226. import { Nullable } from "babylonjs/types";
  7227. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7228. /** @hidden */
  7229. export class WebGLPipelineContext implements IPipelineContext {
  7230. engine: ThinEngine;
  7231. program: Nullable<WebGLProgram>;
  7232. context?: WebGLRenderingContext;
  7233. vertexShader?: WebGLShader;
  7234. fragmentShader?: WebGLShader;
  7235. isParallelCompiled: boolean;
  7236. onCompiled?: () => void;
  7237. transformFeedback?: WebGLTransformFeedback | null;
  7238. vertexCompilationError: Nullable<string>;
  7239. fragmentCompilationError: Nullable<string>;
  7240. programLinkError: Nullable<string>;
  7241. programValidationError: Nullable<string>;
  7242. get isAsync(): boolean;
  7243. get isReady(): boolean;
  7244. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7245. _getVertexShaderCode(): string | null;
  7246. _getFragmentShaderCode(): string | null;
  7247. }
  7248. }
  7249. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7250. import { FloatArray, Nullable } from "babylonjs/types";
  7251. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7252. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7253. module "babylonjs/Engines/thinEngine" {
  7254. interface ThinEngine {
  7255. /**
  7256. * Create an uniform buffer
  7257. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7258. * @param elements defines the content of the uniform buffer
  7259. * @returns the webGL uniform buffer
  7260. */
  7261. createUniformBuffer(elements: FloatArray): DataBuffer;
  7262. /**
  7263. * Create a dynamic uniform buffer
  7264. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7265. * @param elements defines the content of the uniform buffer
  7266. * @returns the webGL uniform buffer
  7267. */
  7268. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7269. /**
  7270. * Update an existing uniform buffer
  7271. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7272. * @param uniformBuffer defines the target uniform buffer
  7273. * @param elements defines the content to update
  7274. * @param offset defines the offset in the uniform buffer where update should start
  7275. * @param count defines the size of the data to update
  7276. */
  7277. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7278. /**
  7279. * Bind an uniform buffer to the current webGL context
  7280. * @param buffer defines the buffer to bind
  7281. */
  7282. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7283. /**
  7284. * Bind a buffer to the current webGL context at a given location
  7285. * @param buffer defines the buffer to bind
  7286. * @param location defines the index where to bind the buffer
  7287. */
  7288. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7289. /**
  7290. * Bind a specific block at a given index in a specific shader program
  7291. * @param pipelineContext defines the pipeline context to use
  7292. * @param blockName defines the block name
  7293. * @param index defines the index where to bind the block
  7294. */
  7295. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7296. }
  7297. }
  7298. }
  7299. declare module "babylonjs/Materials/uniformBuffer" {
  7300. import { Nullable, FloatArray } from "babylonjs/types";
  7301. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7302. import { Engine } from "babylonjs/Engines/engine";
  7303. import { Effect } from "babylonjs/Materials/effect";
  7304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7305. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7306. import { Color3 } from "babylonjs/Maths/math.color";
  7307. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7308. /**
  7309. * Uniform buffer objects.
  7310. *
  7311. * Handles blocks of uniform on the GPU.
  7312. *
  7313. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7314. *
  7315. * For more information, please refer to :
  7316. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7317. */
  7318. export class UniformBuffer {
  7319. private _engine;
  7320. private _buffer;
  7321. private _data;
  7322. private _bufferData;
  7323. private _dynamic?;
  7324. private _uniformLocations;
  7325. private _uniformSizes;
  7326. private _uniformLocationPointer;
  7327. private _needSync;
  7328. private _noUBO;
  7329. private _currentEffect;
  7330. /** @hidden */
  7331. _alreadyBound: boolean;
  7332. private static _MAX_UNIFORM_SIZE;
  7333. private static _tempBuffer;
  7334. /**
  7335. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7336. * This is dynamic to allow compat with webgl 1 and 2.
  7337. * You will need to pass the name of the uniform as well as the value.
  7338. */
  7339. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7340. /**
  7341. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7342. * This is dynamic to allow compat with webgl 1 and 2.
  7343. * You will need to pass the name of the uniform as well as the value.
  7344. */
  7345. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7346. /**
  7347. * Lambda to Update a single float in a uniform buffer.
  7348. * This is dynamic to allow compat with webgl 1 and 2.
  7349. * You will need to pass the name of the uniform as well as the value.
  7350. */
  7351. updateFloat: (name: string, x: number) => void;
  7352. /**
  7353. * Lambda to Update a vec2 of float in a uniform buffer.
  7354. * This is dynamic to allow compat with webgl 1 and 2.
  7355. * You will need to pass the name of the uniform as well as the value.
  7356. */
  7357. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7358. /**
  7359. * Lambda to Update a vec3 of float in a uniform buffer.
  7360. * This is dynamic to allow compat with webgl 1 and 2.
  7361. * You will need to pass the name of the uniform as well as the value.
  7362. */
  7363. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7364. /**
  7365. * Lambda to Update a vec4 of float in a uniform buffer.
  7366. * This is dynamic to allow compat with webgl 1 and 2.
  7367. * You will need to pass the name of the uniform as well as the value.
  7368. */
  7369. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7370. /**
  7371. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix: (name: string, mat: Matrix) => void;
  7376. /**
  7377. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateVector3: (name: string, vector: Vector3) => void;
  7382. /**
  7383. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateVector4: (name: string, vector: Vector4) => void;
  7388. /**
  7389. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7400. /**
  7401. * Instantiates a new Uniform buffer objects.
  7402. *
  7403. * Handles blocks of uniform on the GPU.
  7404. *
  7405. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7406. *
  7407. * For more information, please refer to :
  7408. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7409. * @param engine Define the engine the buffer is associated with
  7410. * @param data Define the data contained in the buffer
  7411. * @param dynamic Define if the buffer is updatable
  7412. */
  7413. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7414. /**
  7415. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7416. * or just falling back on setUniformXXX calls.
  7417. */
  7418. get useUbo(): boolean;
  7419. /**
  7420. * Indicates if the WebGL underlying uniform buffer is in sync
  7421. * with the javascript cache data.
  7422. */
  7423. get isSync(): boolean;
  7424. /**
  7425. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7426. * Also, a dynamic UniformBuffer will disable cache verification and always
  7427. * update the underlying WebGL uniform buffer to the GPU.
  7428. * @returns if Dynamic, otherwise false
  7429. */
  7430. isDynamic(): boolean;
  7431. /**
  7432. * The data cache on JS side.
  7433. * @returns the underlying data as a float array
  7434. */
  7435. getData(): Float32Array;
  7436. /**
  7437. * The underlying WebGL Uniform buffer.
  7438. * @returns the webgl buffer
  7439. */
  7440. getBuffer(): Nullable<DataBuffer>;
  7441. /**
  7442. * std140 layout specifies how to align data within an UBO structure.
  7443. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7444. * for specs.
  7445. */
  7446. private _fillAlignment;
  7447. /**
  7448. * Adds an uniform in the buffer.
  7449. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7450. * for the layout to be correct !
  7451. * @param name Name of the uniform, as used in the uniform block in the shader.
  7452. * @param size Data size, or data directly.
  7453. */
  7454. addUniform(name: string, size: number | number[]): void;
  7455. /**
  7456. * Adds a Matrix 4x4 to the uniform buffer.
  7457. * @param name Name of the uniform, as used in the uniform block in the shader.
  7458. * @param mat A 4x4 matrix.
  7459. */
  7460. addMatrix(name: string, mat: Matrix): void;
  7461. /**
  7462. * Adds a vec2 to the uniform buffer.
  7463. * @param name Name of the uniform, as used in the uniform block in the shader.
  7464. * @param x Define the x component value of the vec2
  7465. * @param y Define the y component value of the vec2
  7466. */
  7467. addFloat2(name: string, x: number, y: 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 x Define the x component value of the vec3
  7472. * @param y Define the y component value of the vec3
  7473. * @param z Define the z component value of the vec3
  7474. */
  7475. addFloat3(name: string, x: number, y: number, z: number): void;
  7476. /**
  7477. * Adds a vec3 to the uniform buffer.
  7478. * @param name Name of the uniform, as used in the uniform block in the shader.
  7479. * @param color Define the vec3 from a Color
  7480. */
  7481. addColor3(name: string, color: Color3): void;
  7482. /**
  7483. * Adds a vec4 to the uniform buffer.
  7484. * @param name Name of the uniform, as used in the uniform block in the shader.
  7485. * @param color Define the rgb components from a Color
  7486. * @param alpha Define the a component of the vec4
  7487. */
  7488. addColor4(name: string, color: Color3, alpha: number): void;
  7489. /**
  7490. * Adds a vec3 to the uniform buffer.
  7491. * @param name Name of the uniform, as used in the uniform block in the shader.
  7492. * @param vector Define the vec3 components from a Vector
  7493. */
  7494. addVector3(name: string, vector: Vector3): void;
  7495. /**
  7496. * Adds a Matrix 3x3 to the uniform buffer.
  7497. * @param name Name of the uniform, as used in the uniform block in the shader.
  7498. */
  7499. addMatrix3x3(name: string): void;
  7500. /**
  7501. * Adds a Matrix 2x2 to the uniform buffer.
  7502. * @param name Name of the uniform, as used in the uniform block in the shader.
  7503. */
  7504. addMatrix2x2(name: string): void;
  7505. /**
  7506. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7507. */
  7508. create(): void;
  7509. /** @hidden */
  7510. _rebuild(): void;
  7511. /**
  7512. * Updates the WebGL Uniform Buffer on the GPU.
  7513. * If the `dynamic` flag is set to true, no cache comparison is done.
  7514. * Otherwise, the buffer will be updated only if the cache differs.
  7515. */
  7516. update(): void;
  7517. /**
  7518. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7519. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7520. * @param data Define the flattened data
  7521. * @param size Define the size of the data.
  7522. */
  7523. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7524. private _valueCache;
  7525. private _cacheMatrix;
  7526. private _updateMatrix3x3ForUniform;
  7527. private _updateMatrix3x3ForEffect;
  7528. private _updateMatrix2x2ForEffect;
  7529. private _updateMatrix2x2ForUniform;
  7530. private _updateFloatForEffect;
  7531. private _updateFloatForUniform;
  7532. private _updateFloat2ForEffect;
  7533. private _updateFloat2ForUniform;
  7534. private _updateFloat3ForEffect;
  7535. private _updateFloat3ForUniform;
  7536. private _updateFloat4ForEffect;
  7537. private _updateFloat4ForUniform;
  7538. private _updateMatrixForEffect;
  7539. private _updateMatrixForUniform;
  7540. private _updateVector3ForEffect;
  7541. private _updateVector3ForUniform;
  7542. private _updateVector4ForEffect;
  7543. private _updateVector4ForUniform;
  7544. private _updateColor3ForEffect;
  7545. private _updateColor3ForUniform;
  7546. private _updateColor4ForEffect;
  7547. private _updateColor4ForUniform;
  7548. /**
  7549. * Sets a sampler uniform on the effect.
  7550. * @param name Define the name of the sampler.
  7551. * @param texture Define the texture to set in the sampler
  7552. */
  7553. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7554. /**
  7555. * Directly updates the value of the uniform in the cache AND on the GPU.
  7556. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7557. * @param data Define the flattened data
  7558. */
  7559. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7560. /**
  7561. * Binds this uniform buffer to an effect.
  7562. * @param effect Define the effect to bind the buffer to
  7563. * @param name Name of the uniform block in the shader.
  7564. */
  7565. bindToEffect(effect: Effect, name: string): void;
  7566. /**
  7567. * Disposes the uniform buffer.
  7568. */
  7569. dispose(): void;
  7570. }
  7571. }
  7572. declare module "babylonjs/Misc/iInspectable" {
  7573. /**
  7574. * Enum that determines the text-wrapping mode to use.
  7575. */
  7576. export enum InspectableType {
  7577. /**
  7578. * Checkbox for booleans
  7579. */
  7580. Checkbox = 0,
  7581. /**
  7582. * Sliders for numbers
  7583. */
  7584. Slider = 1,
  7585. /**
  7586. * Vector3
  7587. */
  7588. Vector3 = 2,
  7589. /**
  7590. * Quaternions
  7591. */
  7592. Quaternion = 3,
  7593. /**
  7594. * Color3
  7595. */
  7596. Color3 = 4,
  7597. /**
  7598. * String
  7599. */
  7600. String = 5
  7601. }
  7602. /**
  7603. * Interface used to define custom inspectable properties.
  7604. * This interface is used by the inspector to display custom property grids
  7605. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7606. */
  7607. export interface IInspectable {
  7608. /**
  7609. * Gets the label to display
  7610. */
  7611. label: string;
  7612. /**
  7613. * Gets the name of the property to edit
  7614. */
  7615. propertyName: string;
  7616. /**
  7617. * Gets the type of the editor to use
  7618. */
  7619. type: InspectableType;
  7620. /**
  7621. * Gets the minimum value of the property when using in "slider" mode
  7622. */
  7623. min?: number;
  7624. /**
  7625. * Gets the maximum value of the property when using in "slider" mode
  7626. */
  7627. max?: number;
  7628. /**
  7629. * Gets the setp to use when using in "slider" mode
  7630. */
  7631. step?: number;
  7632. }
  7633. }
  7634. declare module "babylonjs/Misc/timingTools" {
  7635. /**
  7636. * Class used to provide helper for timing
  7637. */
  7638. export class TimingTools {
  7639. /**
  7640. * Polyfill for setImmediate
  7641. * @param action defines the action to execute after the current execution block
  7642. */
  7643. static SetImmediate(action: () => void): void;
  7644. }
  7645. }
  7646. declare module "babylonjs/Misc/instantiationTools" {
  7647. /**
  7648. * Class used to enable instatition of objects by class name
  7649. */
  7650. export class InstantiationTools {
  7651. /**
  7652. * Use this object to register external classes like custom textures or material
  7653. * to allow the laoders to instantiate them
  7654. */
  7655. static RegisteredExternalClasses: {
  7656. [key: string]: Object;
  7657. };
  7658. /**
  7659. * Tries to instantiate a new object from a given class name
  7660. * @param className defines the class name to instantiate
  7661. * @returns the new object or null if the system was not able to do the instantiation
  7662. */
  7663. static Instantiate(className: string): any;
  7664. }
  7665. }
  7666. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7667. /**
  7668. * Define options used to create a depth texture
  7669. */
  7670. export class DepthTextureCreationOptions {
  7671. /** Specifies whether or not a stencil should be allocated in the texture */
  7672. generateStencil?: boolean;
  7673. /** Specifies whether or not bilinear filtering is enable on the texture */
  7674. bilinearFiltering?: boolean;
  7675. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7676. comparisonFunction?: number;
  7677. /** Specifies if the created texture is a cube texture */
  7678. isCube?: boolean;
  7679. }
  7680. }
  7681. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7682. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7683. import { Nullable } from "babylonjs/types";
  7684. import { Scene } from "babylonjs/scene";
  7685. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7686. module "babylonjs/Engines/thinEngine" {
  7687. interface ThinEngine {
  7688. /**
  7689. * Creates a depth stencil cube texture.
  7690. * This is only available in WebGL 2.
  7691. * @param size The size of face edge in the cube texture.
  7692. * @param options The options defining the cube texture.
  7693. * @returns The cube texture
  7694. */
  7695. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7696. /**
  7697. * Creates a cube texture
  7698. * @param rootUrl defines the url where the files to load is located
  7699. * @param scene defines the current scene
  7700. * @param files defines the list of files to load (1 per face)
  7701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7702. * @param onLoad defines an optional callback raised when the texture is loaded
  7703. * @param onError defines an optional callback raised if there is an issue to load the texture
  7704. * @param format defines the format of the data
  7705. * @param forcedExtension defines the extension to use to pick the right loader
  7706. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7707. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7708. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7709. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7710. * @returns the cube texture as an InternalTexture
  7711. */
  7712. 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;
  7713. /**
  7714. * Creates a cube texture
  7715. * @param rootUrl defines the url where the files to load is located
  7716. * @param scene defines the current scene
  7717. * @param files defines the list of files to load (1 per face)
  7718. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7719. * @param onLoad defines an optional callback raised when the texture is loaded
  7720. * @param onError defines an optional callback raised if there is an issue to load the texture
  7721. * @param format defines the format of the data
  7722. * @param forcedExtension defines the extension to use to pick the right loader
  7723. * @returns the cube texture as an InternalTexture
  7724. */
  7725. 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;
  7726. /**
  7727. * Creates a cube texture
  7728. * @param rootUrl defines the url where the files to load is located
  7729. * @param scene defines the current scene
  7730. * @param files defines the list of files to load (1 per face)
  7731. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7732. * @param onLoad defines an optional callback raised when the texture is loaded
  7733. * @param onError defines an optional callback raised if there is an issue to load the texture
  7734. * @param format defines the format of the data
  7735. * @param forcedExtension defines the extension to use to pick the right loader
  7736. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7737. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7738. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7739. * @returns the cube texture as an InternalTexture
  7740. */
  7741. 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;
  7742. /** @hidden */
  7743. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7744. /** @hidden */
  7745. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7746. /** @hidden */
  7747. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7748. /** @hidden */
  7749. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7750. /**
  7751. * @hidden
  7752. */
  7753. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7754. }
  7755. }
  7756. }
  7757. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7758. import { Nullable } from "babylonjs/types";
  7759. import { Scene } from "babylonjs/scene";
  7760. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7761. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7762. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7763. import { Observable } from "babylonjs/Misc/observable";
  7764. /**
  7765. * Class for creating a cube texture
  7766. */
  7767. export class CubeTexture extends BaseTexture {
  7768. private _delayedOnLoad;
  7769. /**
  7770. * Observable triggered once the texture has been loaded.
  7771. */
  7772. onLoadObservable: Observable<CubeTexture>;
  7773. /**
  7774. * The url of the texture
  7775. */
  7776. url: string;
  7777. /**
  7778. * Gets or sets the center of the bounding box associated with the cube texture.
  7779. * It must define where the camera used to render the texture was set
  7780. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7781. */
  7782. boundingBoxPosition: Vector3;
  7783. private _boundingBoxSize;
  7784. /**
  7785. * Gets or sets the size of the bounding box associated with the cube texture
  7786. * When defined, the cubemap will switch to local mode
  7787. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7788. * @example https://www.babylonjs-playground.com/#RNASML
  7789. */
  7790. set boundingBoxSize(value: Vector3);
  7791. /**
  7792. * Returns the bounding box size
  7793. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7794. */
  7795. get boundingBoxSize(): Vector3;
  7796. protected _rotationY: number;
  7797. /**
  7798. * Sets texture matrix rotation angle around Y axis in radians.
  7799. */
  7800. set rotationY(value: number);
  7801. /**
  7802. * Gets texture matrix rotation angle around Y axis radians.
  7803. */
  7804. get rotationY(): number;
  7805. /**
  7806. * Are mip maps generated for this texture or not.
  7807. */
  7808. get noMipmap(): boolean;
  7809. private _noMipmap;
  7810. private _files;
  7811. protected _forcedExtension: Nullable<string>;
  7812. private _extensions;
  7813. private _textureMatrix;
  7814. private _format;
  7815. private _createPolynomials;
  7816. /** @hidden */
  7817. _prefiltered: boolean;
  7818. /**
  7819. * Creates a cube texture from an array of image urls
  7820. * @param files defines an array of image urls
  7821. * @param scene defines the hosting scene
  7822. * @param noMipmap specifies if mip maps are not used
  7823. * @returns a cube texture
  7824. */
  7825. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7826. /**
  7827. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7828. * @param url defines the url of the prefiltered texture
  7829. * @param scene defines the scene the texture is attached to
  7830. * @param forcedExtension defines the extension of the file if different from the url
  7831. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7832. * @return the prefiltered texture
  7833. */
  7834. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7835. /**
  7836. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7837. * as prefiltered data.
  7838. * @param rootUrl defines the url of the texture or the root name of the six images
  7839. * @param scene defines the scene the texture is attached to
  7840. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7841. * @param noMipmap defines if mipmaps should be created or not
  7842. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7843. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7844. * @param onError defines a callback triggered in case of error during load
  7845. * @param format defines the internal format to use for the texture once loaded
  7846. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7847. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7848. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7849. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7850. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7851. * @return the cube texture
  7852. */
  7853. 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);
  7854. /**
  7855. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7856. */
  7857. get isPrefiltered(): boolean;
  7858. /**
  7859. * Get the current class name of the texture useful for serialization or dynamic coding.
  7860. * @returns "CubeTexture"
  7861. */
  7862. getClassName(): string;
  7863. /**
  7864. * Update the url (and optional buffer) of this texture if url was null during construction.
  7865. * @param url the url of the texture
  7866. * @param forcedExtension defines the extension to use
  7867. * @param onLoad callback called when the texture is loaded (defaults to null)
  7868. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7869. */
  7870. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7871. /**
  7872. * Delays loading of the cube texture
  7873. * @param forcedExtension defines the extension to use
  7874. */
  7875. delayLoad(forcedExtension?: string): void;
  7876. /**
  7877. * Returns the reflection texture matrix
  7878. * @returns the reflection texture matrix
  7879. */
  7880. getReflectionTextureMatrix(): Matrix;
  7881. /**
  7882. * Sets the reflection texture matrix
  7883. * @param value Reflection texture matrix
  7884. */
  7885. setReflectionTextureMatrix(value: Matrix): void;
  7886. /**
  7887. * Parses text to create a cube texture
  7888. * @param parsedTexture define the serialized text to read from
  7889. * @param scene defines the hosting scene
  7890. * @param rootUrl defines the root url of the cube texture
  7891. * @returns a cube texture
  7892. */
  7893. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7894. /**
  7895. * Makes a clone, or deep copy, of the cube texture
  7896. * @returns a new cube texture
  7897. */
  7898. clone(): CubeTexture;
  7899. }
  7900. }
  7901. declare module "babylonjs/Materials/materialDefines" {
  7902. /**
  7903. * Manages the defines for the Material
  7904. */
  7905. export class MaterialDefines {
  7906. /** @hidden */
  7907. protected _keys: string[];
  7908. private _isDirty;
  7909. /** @hidden */
  7910. _renderId: number;
  7911. /** @hidden */
  7912. _areLightsDirty: boolean;
  7913. /** @hidden */
  7914. _areLightsDisposed: boolean;
  7915. /** @hidden */
  7916. _areAttributesDirty: boolean;
  7917. /** @hidden */
  7918. _areTexturesDirty: boolean;
  7919. /** @hidden */
  7920. _areFresnelDirty: boolean;
  7921. /** @hidden */
  7922. _areMiscDirty: boolean;
  7923. /** @hidden */
  7924. _areImageProcessingDirty: boolean;
  7925. /** @hidden */
  7926. _normals: boolean;
  7927. /** @hidden */
  7928. _uvs: boolean;
  7929. /** @hidden */
  7930. _needNormals: boolean;
  7931. /** @hidden */
  7932. _needUVs: boolean;
  7933. [id: string]: any;
  7934. /**
  7935. * Specifies if the material needs to be re-calculated
  7936. */
  7937. get isDirty(): boolean;
  7938. /**
  7939. * Marks the material to indicate that it has been re-calculated
  7940. */
  7941. markAsProcessed(): void;
  7942. /**
  7943. * Marks the material to indicate that it needs to be re-calculated
  7944. */
  7945. markAsUnprocessed(): void;
  7946. /**
  7947. * Marks the material to indicate all of its defines need to be re-calculated
  7948. */
  7949. markAllAsDirty(): void;
  7950. /**
  7951. * Marks the material to indicate that image processing needs to be re-calculated
  7952. */
  7953. markAsImageProcessingDirty(): void;
  7954. /**
  7955. * Marks the material to indicate the lights need to be re-calculated
  7956. * @param disposed Defines whether the light is dirty due to dispose or not
  7957. */
  7958. markAsLightDirty(disposed?: boolean): void;
  7959. /**
  7960. * Marks the attribute state as changed
  7961. */
  7962. markAsAttributesDirty(): void;
  7963. /**
  7964. * Marks the texture state as changed
  7965. */
  7966. markAsTexturesDirty(): void;
  7967. /**
  7968. * Marks the fresnel state as changed
  7969. */
  7970. markAsFresnelDirty(): void;
  7971. /**
  7972. * Marks the misc state as changed
  7973. */
  7974. markAsMiscDirty(): void;
  7975. /**
  7976. * Rebuilds the material defines
  7977. */
  7978. rebuild(): void;
  7979. /**
  7980. * Specifies if two material defines are equal
  7981. * @param other - A material define instance to compare to
  7982. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7983. */
  7984. isEqual(other: MaterialDefines): boolean;
  7985. /**
  7986. * Clones this instance's defines to another instance
  7987. * @param other - material defines to clone values to
  7988. */
  7989. cloneTo(other: MaterialDefines): void;
  7990. /**
  7991. * Resets the material define values
  7992. */
  7993. reset(): void;
  7994. /**
  7995. * Converts the material define values to a string
  7996. * @returns - String of material define information
  7997. */
  7998. toString(): string;
  7999. }
  8000. }
  8001. declare module "babylonjs/Materials/colorCurves" {
  8002. import { Effect } from "babylonjs/Materials/effect";
  8003. /**
  8004. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8005. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8006. * 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;
  8007. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8008. */
  8009. export class ColorCurves {
  8010. private _dirty;
  8011. private _tempColor;
  8012. private _globalCurve;
  8013. private _highlightsCurve;
  8014. private _midtonesCurve;
  8015. private _shadowsCurve;
  8016. private _positiveCurve;
  8017. private _negativeCurve;
  8018. private _globalHue;
  8019. private _globalDensity;
  8020. private _globalSaturation;
  8021. private _globalExposure;
  8022. /**
  8023. * Gets the global Hue value.
  8024. * 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).
  8025. */
  8026. get globalHue(): number;
  8027. /**
  8028. * Sets the global Hue value.
  8029. * 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).
  8030. */
  8031. set globalHue(value: number);
  8032. /**
  8033. * Gets the global Density value.
  8034. * 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.
  8035. * Values less than zero provide a filter of opposite hue.
  8036. */
  8037. get globalDensity(): number;
  8038. /**
  8039. * Sets the global Density value.
  8040. * 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.
  8041. * Values less than zero provide a filter of opposite hue.
  8042. */
  8043. set globalDensity(value: number);
  8044. /**
  8045. * Gets the global Saturation value.
  8046. * 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.
  8047. */
  8048. get globalSaturation(): number;
  8049. /**
  8050. * Sets the global Saturation value.
  8051. * 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.
  8052. */
  8053. set globalSaturation(value: number);
  8054. /**
  8055. * Gets the global Exposure value.
  8056. * 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.
  8057. */
  8058. get globalExposure(): number;
  8059. /**
  8060. * Sets the global Exposure value.
  8061. * 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.
  8062. */
  8063. set globalExposure(value: number);
  8064. private _highlightsHue;
  8065. private _highlightsDensity;
  8066. private _highlightsSaturation;
  8067. private _highlightsExposure;
  8068. /**
  8069. * Gets the highlights Hue value.
  8070. * 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).
  8071. */
  8072. get highlightsHue(): number;
  8073. /**
  8074. * Sets the highlights Hue value.
  8075. * 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).
  8076. */
  8077. set highlightsHue(value: number);
  8078. /**
  8079. * Gets the highlights Density value.
  8080. * 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.
  8081. * Values less than zero provide a filter of opposite hue.
  8082. */
  8083. get highlightsDensity(): number;
  8084. /**
  8085. * Sets the highlights Density value.
  8086. * 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.
  8087. * Values less than zero provide a filter of opposite hue.
  8088. */
  8089. set highlightsDensity(value: number);
  8090. /**
  8091. * Gets the highlights Saturation value.
  8092. * 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.
  8093. */
  8094. get highlightsSaturation(): number;
  8095. /**
  8096. * Sets the highlights Saturation value.
  8097. * 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.
  8098. */
  8099. set highlightsSaturation(value: number);
  8100. /**
  8101. * Gets the highlights Exposure value.
  8102. * 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.
  8103. */
  8104. get highlightsExposure(): number;
  8105. /**
  8106. * Sets the highlights Exposure value.
  8107. * 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.
  8108. */
  8109. set highlightsExposure(value: number);
  8110. private _midtonesHue;
  8111. private _midtonesDensity;
  8112. private _midtonesSaturation;
  8113. private _midtonesExposure;
  8114. /**
  8115. * Gets the midtones Hue value.
  8116. * 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).
  8117. */
  8118. get midtonesHue(): number;
  8119. /**
  8120. * Sets the midtones Hue value.
  8121. * 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).
  8122. */
  8123. set midtonesHue(value: number);
  8124. /**
  8125. * Gets the midtones Density value.
  8126. * 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.
  8127. * Values less than zero provide a filter of opposite hue.
  8128. */
  8129. get midtonesDensity(): number;
  8130. /**
  8131. * Sets the midtones Density value.
  8132. * 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.
  8133. * Values less than zero provide a filter of opposite hue.
  8134. */
  8135. set midtonesDensity(value: number);
  8136. /**
  8137. * Gets the midtones Saturation value.
  8138. * 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.
  8139. */
  8140. get midtonesSaturation(): number;
  8141. /**
  8142. * Sets the midtones Saturation value.
  8143. * 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.
  8144. */
  8145. set midtonesSaturation(value: number);
  8146. /**
  8147. * Gets the midtones Exposure value.
  8148. * 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.
  8149. */
  8150. get midtonesExposure(): number;
  8151. /**
  8152. * Sets the midtones Exposure value.
  8153. * 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.
  8154. */
  8155. set midtonesExposure(value: number);
  8156. private _shadowsHue;
  8157. private _shadowsDensity;
  8158. private _shadowsSaturation;
  8159. private _shadowsExposure;
  8160. /**
  8161. * Gets the shadows Hue value.
  8162. * 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).
  8163. */
  8164. get shadowsHue(): number;
  8165. /**
  8166. * Sets the shadows Hue value.
  8167. * 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).
  8168. */
  8169. set shadowsHue(value: number);
  8170. /**
  8171. * Gets the shadows Density value.
  8172. * 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.
  8173. * Values less than zero provide a filter of opposite hue.
  8174. */
  8175. get shadowsDensity(): number;
  8176. /**
  8177. * Sets the shadows Density value.
  8178. * 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.
  8179. * Values less than zero provide a filter of opposite hue.
  8180. */
  8181. set shadowsDensity(value: number);
  8182. /**
  8183. * Gets the shadows Saturation value.
  8184. * 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.
  8185. */
  8186. get shadowsSaturation(): number;
  8187. /**
  8188. * Sets the shadows Saturation value.
  8189. * 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.
  8190. */
  8191. set shadowsSaturation(value: number);
  8192. /**
  8193. * Gets the shadows Exposure value.
  8194. * 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.
  8195. */
  8196. get shadowsExposure(): number;
  8197. /**
  8198. * Sets the shadows Exposure value.
  8199. * 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.
  8200. */
  8201. set shadowsExposure(value: number);
  8202. /**
  8203. * Returns the class name
  8204. * @returns The class name
  8205. */
  8206. getClassName(): string;
  8207. /**
  8208. * Binds the color curves to the shader.
  8209. * @param colorCurves The color curve to bind
  8210. * @param effect The effect to bind to
  8211. * @param positiveUniform The positive uniform shader parameter
  8212. * @param neutralUniform The neutral uniform shader parameter
  8213. * @param negativeUniform The negative uniform shader parameter
  8214. */
  8215. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8216. /**
  8217. * Prepare the list of uniforms associated with the ColorCurves effects.
  8218. * @param uniformsList The list of uniforms used in the effect
  8219. */
  8220. static PrepareUniforms(uniformsList: string[]): void;
  8221. /**
  8222. * Returns color grading data based on a hue, density, saturation and exposure value.
  8223. * @param filterHue The hue of the color filter.
  8224. * @param filterDensity The density of the color filter.
  8225. * @param saturation The saturation.
  8226. * @param exposure The exposure.
  8227. * @param result The result data container.
  8228. */
  8229. private getColorGradingDataToRef;
  8230. /**
  8231. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8232. * @param value The input slider value in range [-100,100].
  8233. * @returns Adjusted value.
  8234. */
  8235. private static applyColorGradingSliderNonlinear;
  8236. /**
  8237. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8238. * @param hue The hue (H) input.
  8239. * @param saturation The saturation (S) input.
  8240. * @param brightness The brightness (B) input.
  8241. * @result An RGBA color represented as Vector4.
  8242. */
  8243. private static fromHSBToRef;
  8244. /**
  8245. * Returns a value clamped between min and max
  8246. * @param value The value to clamp
  8247. * @param min The minimum of value
  8248. * @param max The maximum of value
  8249. * @returns The clamped value.
  8250. */
  8251. private static clamp;
  8252. /**
  8253. * Clones the current color curve instance.
  8254. * @return The cloned curves
  8255. */
  8256. clone(): ColorCurves;
  8257. /**
  8258. * Serializes the current color curve instance to a json representation.
  8259. * @return a JSON representation
  8260. */
  8261. serialize(): any;
  8262. /**
  8263. * Parses the color curve from a json representation.
  8264. * @param source the JSON source to parse
  8265. * @return The parsed curves
  8266. */
  8267. static Parse(source: any): ColorCurves;
  8268. }
  8269. }
  8270. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8271. import { Observable } from "babylonjs/Misc/observable";
  8272. import { Nullable } from "babylonjs/types";
  8273. import { Color4 } from "babylonjs/Maths/math.color";
  8274. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8275. import { Effect } from "babylonjs/Materials/effect";
  8276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8277. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8278. /**
  8279. * Interface to follow in your material defines to integrate easily the
  8280. * Image proccessing functions.
  8281. * @hidden
  8282. */
  8283. export interface IImageProcessingConfigurationDefines {
  8284. IMAGEPROCESSING: boolean;
  8285. VIGNETTE: boolean;
  8286. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8287. VIGNETTEBLENDMODEOPAQUE: boolean;
  8288. TONEMAPPING: boolean;
  8289. TONEMAPPING_ACES: boolean;
  8290. CONTRAST: boolean;
  8291. EXPOSURE: boolean;
  8292. COLORCURVES: boolean;
  8293. COLORGRADING: boolean;
  8294. COLORGRADING3D: boolean;
  8295. SAMPLER3DGREENDEPTH: boolean;
  8296. SAMPLER3DBGRMAP: boolean;
  8297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8298. }
  8299. /**
  8300. * @hidden
  8301. */
  8302. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8303. IMAGEPROCESSING: boolean;
  8304. VIGNETTE: boolean;
  8305. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8306. VIGNETTEBLENDMODEOPAQUE: boolean;
  8307. TONEMAPPING: boolean;
  8308. TONEMAPPING_ACES: boolean;
  8309. CONTRAST: boolean;
  8310. COLORCURVES: boolean;
  8311. COLORGRADING: boolean;
  8312. COLORGRADING3D: boolean;
  8313. SAMPLER3DGREENDEPTH: boolean;
  8314. SAMPLER3DBGRMAP: boolean;
  8315. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8316. EXPOSURE: boolean;
  8317. constructor();
  8318. }
  8319. /**
  8320. * This groups together the common properties used for image processing either in direct forward pass
  8321. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8322. * or not.
  8323. */
  8324. export class ImageProcessingConfiguration {
  8325. /**
  8326. * Default tone mapping applied in BabylonJS.
  8327. */
  8328. static readonly TONEMAPPING_STANDARD: number;
  8329. /**
  8330. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8331. * to other engines rendering to increase portability.
  8332. */
  8333. static readonly TONEMAPPING_ACES: number;
  8334. /**
  8335. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8336. */
  8337. colorCurves: Nullable<ColorCurves>;
  8338. private _colorCurvesEnabled;
  8339. /**
  8340. * Gets wether the color curves effect is enabled.
  8341. */
  8342. get colorCurvesEnabled(): boolean;
  8343. /**
  8344. * Sets wether the color curves effect is enabled.
  8345. */
  8346. set colorCurvesEnabled(value: boolean);
  8347. private _colorGradingTexture;
  8348. /**
  8349. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8350. */
  8351. get colorGradingTexture(): Nullable<BaseTexture>;
  8352. /**
  8353. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8354. */
  8355. set colorGradingTexture(value: Nullable<BaseTexture>);
  8356. private _colorGradingEnabled;
  8357. /**
  8358. * Gets wether the color grading effect is enabled.
  8359. */
  8360. get colorGradingEnabled(): boolean;
  8361. /**
  8362. * Sets wether the color grading effect is enabled.
  8363. */
  8364. set colorGradingEnabled(value: boolean);
  8365. private _colorGradingWithGreenDepth;
  8366. /**
  8367. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8368. */
  8369. get colorGradingWithGreenDepth(): boolean;
  8370. /**
  8371. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8372. */
  8373. set colorGradingWithGreenDepth(value: boolean);
  8374. private _colorGradingBGR;
  8375. /**
  8376. * Gets wether the color grading texture contains BGR values.
  8377. */
  8378. get colorGradingBGR(): boolean;
  8379. /**
  8380. * Sets wether the color grading texture contains BGR values.
  8381. */
  8382. set colorGradingBGR(value: boolean);
  8383. /** @hidden */
  8384. _exposure: number;
  8385. /**
  8386. * Gets the Exposure used in the effect.
  8387. */
  8388. get exposure(): number;
  8389. /**
  8390. * Sets the Exposure used in the effect.
  8391. */
  8392. set exposure(value: number);
  8393. private _toneMappingEnabled;
  8394. /**
  8395. * Gets wether the tone mapping effect is enabled.
  8396. */
  8397. get toneMappingEnabled(): boolean;
  8398. /**
  8399. * Sets wether the tone mapping effect is enabled.
  8400. */
  8401. set toneMappingEnabled(value: boolean);
  8402. private _toneMappingType;
  8403. /**
  8404. * Gets the type of tone mapping effect.
  8405. */
  8406. get toneMappingType(): number;
  8407. /**
  8408. * Sets the type of tone mapping effect used in BabylonJS.
  8409. */
  8410. set toneMappingType(value: number);
  8411. protected _contrast: number;
  8412. /**
  8413. * Gets the contrast used in the effect.
  8414. */
  8415. get contrast(): number;
  8416. /**
  8417. * Sets the contrast used in the effect.
  8418. */
  8419. set contrast(value: number);
  8420. /**
  8421. * Vignette stretch size.
  8422. */
  8423. vignetteStretch: number;
  8424. /**
  8425. * Vignette centre X Offset.
  8426. */
  8427. vignetteCentreX: number;
  8428. /**
  8429. * Vignette centre Y Offset.
  8430. */
  8431. vignetteCentreY: number;
  8432. /**
  8433. * Vignette weight or intensity of the vignette effect.
  8434. */
  8435. vignetteWeight: number;
  8436. /**
  8437. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8438. * if vignetteEnabled is set to true.
  8439. */
  8440. vignetteColor: Color4;
  8441. /**
  8442. * Camera field of view used by the Vignette effect.
  8443. */
  8444. vignetteCameraFov: number;
  8445. private _vignetteBlendMode;
  8446. /**
  8447. * Gets the vignette blend mode allowing different kind of effect.
  8448. */
  8449. get vignetteBlendMode(): number;
  8450. /**
  8451. * Sets the vignette blend mode allowing different kind of effect.
  8452. */
  8453. set vignetteBlendMode(value: number);
  8454. private _vignetteEnabled;
  8455. /**
  8456. * Gets wether the vignette effect is enabled.
  8457. */
  8458. get vignetteEnabled(): boolean;
  8459. /**
  8460. * Sets wether the vignette effect is enabled.
  8461. */
  8462. set vignetteEnabled(value: boolean);
  8463. private _applyByPostProcess;
  8464. /**
  8465. * Gets wether the image processing is applied through a post process or not.
  8466. */
  8467. get applyByPostProcess(): boolean;
  8468. /**
  8469. * Sets wether the image processing is applied through a post process or not.
  8470. */
  8471. set applyByPostProcess(value: boolean);
  8472. private _isEnabled;
  8473. /**
  8474. * Gets wether the image processing is enabled or not.
  8475. */
  8476. get isEnabled(): boolean;
  8477. /**
  8478. * Sets wether the image processing is enabled or not.
  8479. */
  8480. set isEnabled(value: boolean);
  8481. /**
  8482. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8483. */
  8484. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8485. /**
  8486. * Method called each time the image processing information changes requires to recompile the effect.
  8487. */
  8488. protected _updateParameters(): void;
  8489. /**
  8490. * Gets the current class name.
  8491. * @return "ImageProcessingConfiguration"
  8492. */
  8493. getClassName(): string;
  8494. /**
  8495. * Prepare the list of uniforms associated with the Image Processing effects.
  8496. * @param uniforms The list of uniforms used in the effect
  8497. * @param defines the list of defines currently in use
  8498. */
  8499. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8500. /**
  8501. * Prepare the list of samplers associated with the Image Processing effects.
  8502. * @param samplersList The list of uniforms used in the effect
  8503. * @param defines the list of defines currently in use
  8504. */
  8505. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8506. /**
  8507. * Prepare the list of defines associated to the shader.
  8508. * @param defines the list of defines to complete
  8509. * @param forPostProcess Define if we are currently in post process mode or not
  8510. */
  8511. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8512. /**
  8513. * Returns true if all the image processing information are ready.
  8514. * @returns True if ready, otherwise, false
  8515. */
  8516. isReady(): boolean;
  8517. /**
  8518. * Binds the image processing to the shader.
  8519. * @param effect The effect to bind to
  8520. * @param overrideAspectRatio Override the aspect ratio of the effect
  8521. */
  8522. bind(effect: Effect, overrideAspectRatio?: number): void;
  8523. /**
  8524. * Clones the current image processing instance.
  8525. * @return The cloned image processing
  8526. */
  8527. clone(): ImageProcessingConfiguration;
  8528. /**
  8529. * Serializes the current image processing instance to a json representation.
  8530. * @return a JSON representation
  8531. */
  8532. serialize(): any;
  8533. /**
  8534. * Parses the image processing from a json representation.
  8535. * @param source the JSON source to parse
  8536. * @return The parsed image processing
  8537. */
  8538. static Parse(source: any): ImageProcessingConfiguration;
  8539. private static _VIGNETTEMODE_MULTIPLY;
  8540. private static _VIGNETTEMODE_OPAQUE;
  8541. /**
  8542. * Used to apply the vignette as a mix with the pixel color.
  8543. */
  8544. static get VIGNETTEMODE_MULTIPLY(): number;
  8545. /**
  8546. * Used to apply the vignette as a replacement of the pixel color.
  8547. */
  8548. static get VIGNETTEMODE_OPAQUE(): number;
  8549. }
  8550. }
  8551. declare module "babylonjs/Shaders/postprocess.vertex" {
  8552. /** @hidden */
  8553. export var postprocessVertexShader: {
  8554. name: string;
  8555. shader: string;
  8556. };
  8557. }
  8558. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8559. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8560. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8561. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8562. module "babylonjs/Engines/thinEngine" {
  8563. interface ThinEngine {
  8564. /**
  8565. * Creates a new render target texture
  8566. * @param size defines the size of the texture
  8567. * @param options defines the options used to create the texture
  8568. * @returns a new render target texture stored in an InternalTexture
  8569. */
  8570. createRenderTargetTexture(size: number | {
  8571. width: number;
  8572. height: number;
  8573. layers?: number;
  8574. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8575. /**
  8576. * Creates a depth stencil texture.
  8577. * This is only available in WebGL 2 or with the depth texture extension available.
  8578. * @param size The size of face edge in the texture.
  8579. * @param options The options defining the texture.
  8580. * @returns The texture
  8581. */
  8582. createDepthStencilTexture(size: number | {
  8583. width: number;
  8584. height: number;
  8585. layers?: number;
  8586. }, options: DepthTextureCreationOptions): InternalTexture;
  8587. /** @hidden */
  8588. _createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. }
  8594. }
  8595. }
  8596. declare module "babylonjs/Maths/math.axis" {
  8597. import { Vector3 } from "babylonjs/Maths/math.vector";
  8598. /** Defines supported spaces */
  8599. export enum Space {
  8600. /** Local (object) space */
  8601. LOCAL = 0,
  8602. /** World space */
  8603. WORLD = 1,
  8604. /** Bone space */
  8605. BONE = 2
  8606. }
  8607. /** Defines the 3 main axes */
  8608. export class Axis {
  8609. /** X axis */
  8610. static X: Vector3;
  8611. /** Y axis */
  8612. static Y: Vector3;
  8613. /** Z axis */
  8614. static Z: Vector3;
  8615. }
  8616. }
  8617. declare module "babylonjs/Cameras/targetCamera" {
  8618. import { Nullable } from "babylonjs/types";
  8619. import { Camera } from "babylonjs/Cameras/camera";
  8620. import { Scene } from "babylonjs/scene";
  8621. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8622. /**
  8623. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8624. * This is the base of the follow, arc rotate cameras and Free camera
  8625. * @see http://doc.babylonjs.com/features/cameras
  8626. */
  8627. export class TargetCamera extends Camera {
  8628. private static _RigCamTransformMatrix;
  8629. private static _TargetTransformMatrix;
  8630. private static _TargetFocalPoint;
  8631. /**
  8632. * Define the current direction the camera is moving to
  8633. */
  8634. cameraDirection: Vector3;
  8635. /**
  8636. * Define the current rotation the camera is rotating to
  8637. */
  8638. cameraRotation: Vector2;
  8639. /**
  8640. * When set, the up vector of the camera will be updated by the rotation of the camera
  8641. */
  8642. updateUpVectorFromRotation: boolean;
  8643. private _tmpQuaternion;
  8644. /**
  8645. * Define the current rotation of the camera
  8646. */
  8647. rotation: Vector3;
  8648. /**
  8649. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8650. */
  8651. rotationQuaternion: Quaternion;
  8652. /**
  8653. * Define the current speed of the camera
  8654. */
  8655. speed: number;
  8656. /**
  8657. * Add constraint to the camera to prevent it to move freely in all directions and
  8658. * around all axis.
  8659. */
  8660. noRotationConstraint: boolean;
  8661. /**
  8662. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8663. * panning
  8664. */
  8665. invertRotation: boolean;
  8666. /**
  8667. * Speed multiplier for inverse camera panning
  8668. */
  8669. inverseRotationSpeed: number;
  8670. /**
  8671. * Define the current target of the camera as an object or a position.
  8672. */
  8673. lockedTarget: any;
  8674. /** @hidden */
  8675. _currentTarget: Vector3;
  8676. /** @hidden */
  8677. _initialFocalDistance: number;
  8678. /** @hidden */
  8679. _viewMatrix: Matrix;
  8680. /** @hidden */
  8681. _camMatrix: Matrix;
  8682. /** @hidden */
  8683. _cameraTransformMatrix: Matrix;
  8684. /** @hidden */
  8685. _cameraRotationMatrix: Matrix;
  8686. /** @hidden */
  8687. _referencePoint: Vector3;
  8688. /** @hidden */
  8689. _transformedReferencePoint: Vector3;
  8690. protected _globalCurrentTarget: Vector3;
  8691. protected _globalCurrentUpVector: Vector3;
  8692. /** @hidden */
  8693. _reset: () => void;
  8694. private _defaultUp;
  8695. /**
  8696. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8697. * This is the base of the follow, arc rotate cameras and Free camera
  8698. * @see http://doc.babylonjs.com/features/cameras
  8699. * @param name Defines the name of the camera in the scene
  8700. * @param position Defines the start position of the camera in the scene
  8701. * @param scene Defines the scene the camera belongs to
  8702. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8703. */
  8704. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8705. /**
  8706. * Gets the position in front of the camera at a given distance.
  8707. * @param distance The distance from the camera we want the position to be
  8708. * @returns the position
  8709. */
  8710. getFrontPosition(distance: number): Vector3;
  8711. /** @hidden */
  8712. _getLockedTargetPosition(): Nullable<Vector3>;
  8713. private _storedPosition;
  8714. private _storedRotation;
  8715. private _storedRotationQuaternion;
  8716. /**
  8717. * Store current camera state of the camera (fov, position, rotation, etc..)
  8718. * @returns the camera
  8719. */
  8720. storeState(): Camera;
  8721. /**
  8722. * Restored camera state. You must call storeState() first
  8723. * @returns whether it was successful or not
  8724. * @hidden
  8725. */
  8726. _restoreStateValues(): boolean;
  8727. /** @hidden */
  8728. _initCache(): void;
  8729. /** @hidden */
  8730. _updateCache(ignoreParentClass?: boolean): void;
  8731. /** @hidden */
  8732. _isSynchronizedViewMatrix(): boolean;
  8733. /** @hidden */
  8734. _computeLocalCameraSpeed(): number;
  8735. /**
  8736. * Defines the target the camera should look at.
  8737. * @param target Defines the new target as a Vector or a mesh
  8738. */
  8739. setTarget(target: Vector3): void;
  8740. /**
  8741. * Return the current target position of the camera. This value is expressed in local space.
  8742. * @returns the target position
  8743. */
  8744. getTarget(): Vector3;
  8745. /** @hidden */
  8746. _decideIfNeedsToMove(): boolean;
  8747. /** @hidden */
  8748. _updatePosition(): void;
  8749. /** @hidden */
  8750. _checkInputs(): void;
  8751. protected _updateCameraRotationMatrix(): void;
  8752. /**
  8753. * 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)
  8754. * @returns the current camera
  8755. */
  8756. private _rotateUpVectorWithCameraRotationMatrix;
  8757. private _cachedRotationZ;
  8758. private _cachedQuaternionRotationZ;
  8759. /** @hidden */
  8760. _getViewMatrix(): Matrix;
  8761. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8762. /**
  8763. * @hidden
  8764. */
  8765. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8766. /**
  8767. * @hidden
  8768. */
  8769. _updateRigCameras(): void;
  8770. private _getRigCamPositionAndTarget;
  8771. /**
  8772. * Gets the current object class name.
  8773. * @return the class name
  8774. */
  8775. getClassName(): string;
  8776. }
  8777. }
  8778. declare module "babylonjs/Events/keyboardEvents" {
  8779. /**
  8780. * Gather the list of keyboard event types as constants.
  8781. */
  8782. export class KeyboardEventTypes {
  8783. /**
  8784. * The keydown event is fired when a key becomes active (pressed).
  8785. */
  8786. static readonly KEYDOWN: number;
  8787. /**
  8788. * The keyup event is fired when a key has been released.
  8789. */
  8790. static readonly KEYUP: number;
  8791. }
  8792. /**
  8793. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8794. */
  8795. export class KeyboardInfo {
  8796. /**
  8797. * Defines the type of event (KeyboardEventTypes)
  8798. */
  8799. type: number;
  8800. /**
  8801. * Defines the related dom event
  8802. */
  8803. event: KeyboardEvent;
  8804. /**
  8805. * Instantiates a new keyboard info.
  8806. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8807. * @param type Defines the type of event (KeyboardEventTypes)
  8808. * @param event Defines the related dom event
  8809. */
  8810. constructor(
  8811. /**
  8812. * Defines the type of event (KeyboardEventTypes)
  8813. */
  8814. type: number,
  8815. /**
  8816. * Defines the related dom event
  8817. */
  8818. event: KeyboardEvent);
  8819. }
  8820. /**
  8821. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8822. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8823. */
  8824. export class KeyboardInfoPre extends KeyboardInfo {
  8825. /**
  8826. * Defines the type of event (KeyboardEventTypes)
  8827. */
  8828. type: number;
  8829. /**
  8830. * Defines the related dom event
  8831. */
  8832. event: KeyboardEvent;
  8833. /**
  8834. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8835. */
  8836. skipOnPointerObservable: boolean;
  8837. /**
  8838. * Instantiates a new keyboard pre info.
  8839. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8840. * @param type Defines the type of event (KeyboardEventTypes)
  8841. * @param event Defines the related dom event
  8842. */
  8843. constructor(
  8844. /**
  8845. * Defines the type of event (KeyboardEventTypes)
  8846. */
  8847. type: number,
  8848. /**
  8849. * Defines the related dom event
  8850. */
  8851. event: KeyboardEvent);
  8852. }
  8853. }
  8854. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8855. import { Nullable } from "babylonjs/types";
  8856. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8857. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8858. /**
  8859. * Manage the keyboard inputs to control the movement of a free camera.
  8860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8861. */
  8862. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8863. /**
  8864. * Defines the camera the input is attached to.
  8865. */
  8866. camera: FreeCamera;
  8867. /**
  8868. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8869. */
  8870. keysUp: number[];
  8871. /**
  8872. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8873. */
  8874. keysUpward: number[];
  8875. /**
  8876. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8877. */
  8878. keysDown: number[];
  8879. /**
  8880. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8881. */
  8882. keysDownward: number[];
  8883. /**
  8884. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8885. */
  8886. keysLeft: number[];
  8887. /**
  8888. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8889. */
  8890. keysRight: number[];
  8891. private _keys;
  8892. private _onCanvasBlurObserver;
  8893. private _onKeyboardObserver;
  8894. private _engine;
  8895. private _scene;
  8896. /**
  8897. * Attach the input controls to a specific dom element to get the input from.
  8898. * @param element Defines the element the controls should be listened from
  8899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8900. */
  8901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8902. /**
  8903. * Detach the current controls from the specified dom element.
  8904. * @param element Defines the element to stop listening the inputs from
  8905. */
  8906. detachControl(element: Nullable<HTMLElement>): void;
  8907. /**
  8908. * Update the current camera state depending on the inputs that have been used this frame.
  8909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8910. */
  8911. checkInputs(): void;
  8912. /**
  8913. * Gets the class name of the current intput.
  8914. * @returns the class name
  8915. */
  8916. getClassName(): string;
  8917. /** @hidden */
  8918. _onLostFocus(): void;
  8919. /**
  8920. * Get the friendly name associated with the input class.
  8921. * @returns the input friendly name
  8922. */
  8923. getSimpleName(): string;
  8924. }
  8925. }
  8926. declare module "babylonjs/Lights/shadowLight" {
  8927. import { Camera } from "babylonjs/Cameras/camera";
  8928. import { Scene } from "babylonjs/scene";
  8929. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8931. import { Light } from "babylonjs/Lights/light";
  8932. /**
  8933. * Interface describing all the common properties and methods a shadow light needs to implement.
  8934. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8935. * as well as binding the different shadow properties to the effects.
  8936. */
  8937. export interface IShadowLight extends Light {
  8938. /**
  8939. * The light id in the scene (used in scene.findLighById for instance)
  8940. */
  8941. id: string;
  8942. /**
  8943. * The position the shdow will be casted from.
  8944. */
  8945. position: Vector3;
  8946. /**
  8947. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8948. */
  8949. direction: Vector3;
  8950. /**
  8951. * The transformed position. Position of the light in world space taking parenting in account.
  8952. */
  8953. transformedPosition: Vector3;
  8954. /**
  8955. * The transformed direction. Direction of the light in world space taking parenting in account.
  8956. */
  8957. transformedDirection: Vector3;
  8958. /**
  8959. * The friendly name of the light in the scene.
  8960. */
  8961. name: string;
  8962. /**
  8963. * Defines the shadow projection clipping minimum z value.
  8964. */
  8965. shadowMinZ: number;
  8966. /**
  8967. * Defines the shadow projection clipping maximum z value.
  8968. */
  8969. shadowMaxZ: number;
  8970. /**
  8971. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8972. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8973. */
  8974. computeTransformedInformation(): boolean;
  8975. /**
  8976. * Gets the scene the light belongs to.
  8977. * @returns The scene
  8978. */
  8979. getScene(): Scene;
  8980. /**
  8981. * Callback defining a custom Projection Matrix Builder.
  8982. * This can be used to override the default projection matrix computation.
  8983. */
  8984. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8985. /**
  8986. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8987. * @param matrix The materix to updated with the projection information
  8988. * @param viewMatrix The transform matrix of the light
  8989. * @param renderList The list of mesh to render in the map
  8990. * @returns The current light
  8991. */
  8992. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8993. /**
  8994. * Gets the current depth scale used in ESM.
  8995. * @returns The scale
  8996. */
  8997. getDepthScale(): number;
  8998. /**
  8999. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9000. * @returns true if a cube texture needs to be use
  9001. */
  9002. needCube(): boolean;
  9003. /**
  9004. * Detects if the projection matrix requires to be recomputed this frame.
  9005. * @returns true if it requires to be recomputed otherwise, false.
  9006. */
  9007. needProjectionMatrixCompute(): boolean;
  9008. /**
  9009. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9010. */
  9011. forceProjectionMatrixCompute(): void;
  9012. /**
  9013. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9014. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9015. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9016. */
  9017. getShadowDirection(faceIndex?: number): Vector3;
  9018. /**
  9019. * Gets the minZ used for shadow according to both the scene and the light.
  9020. * @param activeCamera The camera we are returning the min for
  9021. * @returns the depth min z
  9022. */
  9023. getDepthMinZ(activeCamera: Camera): number;
  9024. /**
  9025. * Gets the maxZ used for shadow according to both the scene and the light.
  9026. * @param activeCamera The camera we are returning the max for
  9027. * @returns the depth max z
  9028. */
  9029. getDepthMaxZ(activeCamera: Camera): number;
  9030. }
  9031. /**
  9032. * Base implementation IShadowLight
  9033. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9034. */
  9035. export abstract class ShadowLight extends Light implements IShadowLight {
  9036. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9037. protected _position: Vector3;
  9038. protected _setPosition(value: Vector3): void;
  9039. /**
  9040. * Sets the position the shadow will be casted from. Also use as the light position for both
  9041. * point and spot lights.
  9042. */
  9043. get position(): Vector3;
  9044. /**
  9045. * Sets the position the shadow will be casted from. Also use as the light position for both
  9046. * point and spot lights.
  9047. */
  9048. set position(value: Vector3);
  9049. protected _direction: Vector3;
  9050. protected _setDirection(value: Vector3): void;
  9051. /**
  9052. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9053. * Also use as the light direction on spot and directional lights.
  9054. */
  9055. get direction(): Vector3;
  9056. /**
  9057. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9058. * Also use as the light direction on spot and directional lights.
  9059. */
  9060. set direction(value: Vector3);
  9061. protected _shadowMinZ: number;
  9062. /**
  9063. * Gets the shadow projection clipping minimum z value.
  9064. */
  9065. get shadowMinZ(): number;
  9066. /**
  9067. * Sets the shadow projection clipping minimum z value.
  9068. */
  9069. set shadowMinZ(value: number);
  9070. protected _shadowMaxZ: number;
  9071. /**
  9072. * Sets the shadow projection clipping maximum z value.
  9073. */
  9074. get shadowMaxZ(): number;
  9075. /**
  9076. * Gets the shadow projection clipping maximum z value.
  9077. */
  9078. set shadowMaxZ(value: number);
  9079. /**
  9080. * Callback defining a custom Projection Matrix Builder.
  9081. * This can be used to override the default projection matrix computation.
  9082. */
  9083. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9084. /**
  9085. * The transformed position. Position of the light in world space taking parenting in account.
  9086. */
  9087. transformedPosition: Vector3;
  9088. /**
  9089. * The transformed direction. Direction of the light in world space taking parenting in account.
  9090. */
  9091. transformedDirection: Vector3;
  9092. private _needProjectionMatrixCompute;
  9093. /**
  9094. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9095. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9096. */
  9097. computeTransformedInformation(): boolean;
  9098. /**
  9099. * Return the depth scale used for the shadow map.
  9100. * @returns the depth scale.
  9101. */
  9102. getDepthScale(): number;
  9103. /**
  9104. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9105. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9106. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9107. */
  9108. getShadowDirection(faceIndex?: number): Vector3;
  9109. /**
  9110. * Returns the ShadowLight absolute position in the World.
  9111. * @returns the position vector in world space
  9112. */
  9113. getAbsolutePosition(): Vector3;
  9114. /**
  9115. * Sets the ShadowLight direction toward the passed target.
  9116. * @param target The point to target in local space
  9117. * @returns the updated ShadowLight direction
  9118. */
  9119. setDirectionToTarget(target: Vector3): Vector3;
  9120. /**
  9121. * Returns the light rotation in euler definition.
  9122. * @returns the x y z rotation in local space.
  9123. */
  9124. getRotation(): Vector3;
  9125. /**
  9126. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9127. * @returns true if a cube texture needs to be use
  9128. */
  9129. needCube(): boolean;
  9130. /**
  9131. * Detects if the projection matrix requires to be recomputed this frame.
  9132. * @returns true if it requires to be recomputed otherwise, false.
  9133. */
  9134. needProjectionMatrixCompute(): boolean;
  9135. /**
  9136. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9137. */
  9138. forceProjectionMatrixCompute(): void;
  9139. /** @hidden */
  9140. _initCache(): void;
  9141. /** @hidden */
  9142. _isSynchronized(): boolean;
  9143. /**
  9144. * Computes the world matrix of the node
  9145. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9146. * @returns the world matrix
  9147. */
  9148. computeWorldMatrix(force?: boolean): Matrix;
  9149. /**
  9150. * Gets the minZ used for shadow according to both the scene and the light.
  9151. * @param activeCamera The camera we are returning the min for
  9152. * @returns the depth min z
  9153. */
  9154. getDepthMinZ(activeCamera: Camera): number;
  9155. /**
  9156. * Gets the maxZ used for shadow according to both the scene and the light.
  9157. * @param activeCamera The camera we are returning the max for
  9158. * @returns the depth max z
  9159. */
  9160. getDepthMaxZ(activeCamera: Camera): number;
  9161. /**
  9162. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9163. * @param matrix The materix to updated with the projection information
  9164. * @param viewMatrix The transform matrix of the light
  9165. * @param renderList The list of mesh to render in the map
  9166. * @returns The current light
  9167. */
  9168. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9169. }
  9170. }
  9171. declare module "babylonjs/Materials/effectFallbacks" {
  9172. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9173. import { Effect } from "babylonjs/Materials/effect";
  9174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9175. /**
  9176. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9177. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9178. */
  9179. export class EffectFallbacks implements IEffectFallbacks {
  9180. private _defines;
  9181. private _currentRank;
  9182. private _maxRank;
  9183. private _mesh;
  9184. /**
  9185. * Removes the fallback from the bound mesh.
  9186. */
  9187. unBindMesh(): void;
  9188. /**
  9189. * Adds a fallback on the specified property.
  9190. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9191. * @param define The name of the define in the shader
  9192. */
  9193. addFallback(rank: number, define: string): void;
  9194. /**
  9195. * Sets the mesh to use CPU skinning when needing to fallback.
  9196. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9197. * @param mesh The mesh to use the fallbacks.
  9198. */
  9199. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9200. /**
  9201. * Checks to see if more fallbacks are still availible.
  9202. */
  9203. get hasMoreFallbacks(): boolean;
  9204. /**
  9205. * Removes the defines that should be removed when falling back.
  9206. * @param currentDefines defines the current define statements for the shader.
  9207. * @param effect defines the current effect we try to compile
  9208. * @returns The resulting defines with defines of the current rank removed.
  9209. */
  9210. reduce(currentDefines: string, effect: Effect): string;
  9211. }
  9212. }
  9213. declare module "babylonjs/Materials/materialHelper" {
  9214. import { Nullable } from "babylonjs/types";
  9215. import { Scene } from "babylonjs/scene";
  9216. import { Engine } from "babylonjs/Engines/engine";
  9217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9218. import { Light } from "babylonjs/Lights/light";
  9219. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9220. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9222. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9223. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9224. /**
  9225. * "Static Class" containing the most commonly used helper while dealing with material for
  9226. * rendering purpose.
  9227. *
  9228. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9229. *
  9230. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9231. */
  9232. export class MaterialHelper {
  9233. /**
  9234. * Bind the current view position to an effect.
  9235. * @param effect The effect to be bound
  9236. * @param scene The scene the eyes position is used from
  9237. */
  9238. static BindEyePosition(effect: Effect, scene: Scene): void;
  9239. /**
  9240. * Helps preparing the defines values about the UVs in used in the effect.
  9241. * UVs are shared as much as we can accross channels in the shaders.
  9242. * @param texture The texture we are preparing the UVs for
  9243. * @param defines The defines to update
  9244. * @param key The channel key "diffuse", "specular"... used in the shader
  9245. */
  9246. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9247. /**
  9248. * Binds a texture matrix value to its corrsponding uniform
  9249. * @param texture The texture to bind the matrix for
  9250. * @param uniformBuffer The uniform buffer receivin the data
  9251. * @param key The channel key "diffuse", "specular"... used in the shader
  9252. */
  9253. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9254. /**
  9255. * Gets the current status of the fog (should it be enabled?)
  9256. * @param mesh defines the mesh to evaluate for fog support
  9257. * @param scene defines the hosting scene
  9258. * @returns true if fog must be enabled
  9259. */
  9260. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9261. /**
  9262. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9263. * @param mesh defines the current mesh
  9264. * @param scene defines the current scene
  9265. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9266. * @param pointsCloud defines if point cloud rendering has to be turned on
  9267. * @param fogEnabled defines if fog has to be turned on
  9268. * @param alphaTest defines if alpha testing has to be turned on
  9269. * @param defines defines the current list of defines
  9270. */
  9271. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9272. /**
  9273. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9274. * @param scene defines the current scene
  9275. * @param engine defines the current engine
  9276. * @param defines specifies the list of active defines
  9277. * @param useInstances defines if instances have to be turned on
  9278. * @param useClipPlane defines if clip plane have to be turned on
  9279. */
  9280. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9281. /**
  9282. * Prepares the defines for bones
  9283. * @param mesh The mesh containing the geometry data we will draw
  9284. * @param defines The defines to update
  9285. */
  9286. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9287. /**
  9288. * Prepares the defines for morph targets
  9289. * @param mesh The mesh containing the geometry data we will draw
  9290. * @param defines The defines to update
  9291. */
  9292. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9293. /**
  9294. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9295. * @param mesh The mesh containing the geometry data we will draw
  9296. * @param defines The defines to update
  9297. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9298. * @param useBones Precise whether bones should be used or not (override mesh info)
  9299. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9300. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9301. * @returns false if defines are considered not dirty and have not been checked
  9302. */
  9303. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9304. /**
  9305. * Prepares the defines related to multiview
  9306. * @param scene The scene we are intending to draw
  9307. * @param defines The defines to update
  9308. */
  9309. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9310. /**
  9311. * Prepares the defines related to the light information passed in parameter
  9312. * @param scene The scene we are intending to draw
  9313. * @param mesh The mesh the effect is compiling for
  9314. * @param light The light the effect is compiling for
  9315. * @param lightIndex The index of the light
  9316. * @param defines The defines to update
  9317. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9318. * @param state Defines the current state regarding what is needed (normals, etc...)
  9319. */
  9320. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9321. needNormals: boolean;
  9322. needRebuild: boolean;
  9323. shadowEnabled: boolean;
  9324. specularEnabled: boolean;
  9325. lightmapMode: boolean;
  9326. }): void;
  9327. /**
  9328. * Prepares the defines related to the light information passed in parameter
  9329. * @param scene The scene we are intending to draw
  9330. * @param mesh The mesh the effect is compiling for
  9331. * @param defines The defines to update
  9332. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9333. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9334. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9335. * @returns true if normals will be required for the rest of the effect
  9336. */
  9337. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9338. /**
  9339. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9340. * @param lightIndex defines the light index
  9341. * @param uniformsList The uniform list
  9342. * @param samplersList The sampler list
  9343. * @param projectedLightTexture defines if projected texture must be used
  9344. * @param uniformBuffersList defines an optional list of uniform buffers
  9345. */
  9346. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9347. /**
  9348. * Prepares the uniforms and samplers list to be used in the effect
  9349. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9350. * @param samplersList The sampler list
  9351. * @param defines The defines helping in the list generation
  9352. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9353. */
  9354. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9355. /**
  9356. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9357. * @param defines The defines to update while falling back
  9358. * @param fallbacks The authorized effect fallbacks
  9359. * @param maxSimultaneousLights The maximum number of lights allowed
  9360. * @param rank the current rank of the Effect
  9361. * @returns The newly affected rank
  9362. */
  9363. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9364. private static _TmpMorphInfluencers;
  9365. /**
  9366. * Prepares the list of attributes required for morph targets according to the effect defines.
  9367. * @param attribs The current list of supported attribs
  9368. * @param mesh The mesh to prepare the morph targets attributes for
  9369. * @param influencers The number of influencers
  9370. */
  9371. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9372. /**
  9373. * Prepares the list of attributes required for morph targets according to the effect defines.
  9374. * @param attribs The current list of supported attribs
  9375. * @param mesh The mesh to prepare the morph targets attributes for
  9376. * @param defines The current Defines of the effect
  9377. */
  9378. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9379. /**
  9380. * Prepares the list of attributes required for bones according to the effect defines.
  9381. * @param attribs The current list of supported attribs
  9382. * @param mesh The mesh to prepare the bones attributes for
  9383. * @param defines The current Defines of the effect
  9384. * @param fallbacks The current efffect fallback strategy
  9385. */
  9386. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9387. /**
  9388. * Check and prepare the list of attributes required for instances according to the effect defines.
  9389. * @param attribs The current list of supported attribs
  9390. * @param defines The current MaterialDefines of the effect
  9391. */
  9392. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9393. /**
  9394. * Add the list of attributes required for instances to the attribs array.
  9395. * @param attribs The current list of supported attribs
  9396. */
  9397. static PushAttributesForInstances(attribs: string[]): void;
  9398. /**
  9399. * Binds the light information to the effect.
  9400. * @param light The light containing the generator
  9401. * @param effect The effect we are binding the data to
  9402. * @param lightIndex The light index in the effect used to render
  9403. */
  9404. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9405. /**
  9406. * Binds the lights information from the scene to the effect for the given mesh.
  9407. * @param light Light to bind
  9408. * @param lightIndex Light index
  9409. * @param scene The scene where the light belongs to
  9410. * @param effect The effect we are binding the data to
  9411. * @param useSpecular Defines if specular is supported
  9412. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9413. */
  9414. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9415. /**
  9416. * Binds the lights information from the scene to the effect for the given mesh.
  9417. * @param scene The scene the lights belongs to
  9418. * @param mesh The mesh we are binding the information to render
  9419. * @param effect The effect we are binding the data to
  9420. * @param defines The generated defines for the effect
  9421. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9422. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9423. */
  9424. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9425. private static _tempFogColor;
  9426. /**
  9427. * Binds the fog information from the scene to the effect for the given mesh.
  9428. * @param scene The scene the lights belongs to
  9429. * @param mesh The mesh we are binding the information to render
  9430. * @param effect The effect we are binding the data to
  9431. * @param linearSpace Defines if the fog effect is applied in linear space
  9432. */
  9433. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9434. /**
  9435. * Binds the bones information from the mesh to the effect.
  9436. * @param mesh The mesh we are binding the information to render
  9437. * @param effect The effect we are binding the data to
  9438. */
  9439. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9440. /**
  9441. * Binds the morph targets information from the mesh to the effect.
  9442. * @param abstractMesh The mesh we are binding the information to render
  9443. * @param effect The effect we are binding the data to
  9444. */
  9445. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9446. /**
  9447. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9448. * @param defines The generated defines used in the effect
  9449. * @param effect The effect we are binding the data to
  9450. * @param scene The scene we are willing to render with logarithmic scale for
  9451. */
  9452. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9453. /**
  9454. * Binds the clip plane information from the scene to the effect.
  9455. * @param scene The scene the clip plane information are extracted from
  9456. * @param effect The effect we are binding the data to
  9457. */
  9458. static BindClipPlane(effect: Effect, scene: Scene): void;
  9459. }
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9462. /** @hidden */
  9463. export var packingFunctions: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9469. /** @hidden */
  9470. export var clipPlaneFragmentDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9476. /** @hidden */
  9477. export var clipPlaneFragment: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9483. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9484. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9485. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9486. /** @hidden */
  9487. export var shadowMapPixelShader: {
  9488. name: string;
  9489. shader: string;
  9490. };
  9491. }
  9492. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9493. /** @hidden */
  9494. export var bonesDeclaration: {
  9495. name: string;
  9496. shader: string;
  9497. };
  9498. }
  9499. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9500. /** @hidden */
  9501. export var morphTargetsVertexGlobalDeclaration: {
  9502. name: string;
  9503. shader: string;
  9504. };
  9505. }
  9506. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9507. /** @hidden */
  9508. export var morphTargetsVertexDeclaration: {
  9509. name: string;
  9510. shader: string;
  9511. };
  9512. }
  9513. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9514. /** @hidden */
  9515. export var instancesDeclaration: {
  9516. name: string;
  9517. shader: string;
  9518. };
  9519. }
  9520. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9521. /** @hidden */
  9522. export var helperFunctions: {
  9523. name: string;
  9524. shader: string;
  9525. };
  9526. }
  9527. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9528. /** @hidden */
  9529. export var clipPlaneVertexDeclaration: {
  9530. name: string;
  9531. shader: string;
  9532. };
  9533. }
  9534. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9535. /** @hidden */
  9536. export var morphTargetsVertex: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9542. /** @hidden */
  9543. export var instancesVertex: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9549. /** @hidden */
  9550. export var bonesVertex: {
  9551. name: string;
  9552. shader: string;
  9553. };
  9554. }
  9555. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9556. /** @hidden */
  9557. export var clipPlaneVertex: {
  9558. name: string;
  9559. shader: string;
  9560. };
  9561. }
  9562. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9563. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9564. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9565. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9566. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9568. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9569. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9570. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9571. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9572. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9573. /** @hidden */
  9574. export var shadowMapVertexShader: {
  9575. name: string;
  9576. shader: string;
  9577. };
  9578. }
  9579. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9580. /** @hidden */
  9581. export var depthBoxBlurPixelShader: {
  9582. name: string;
  9583. shader: string;
  9584. };
  9585. }
  9586. declare module "babylonjs/Culling/ray" {
  9587. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9588. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9590. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9591. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9592. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9593. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9594. import { Plane } from "babylonjs/Maths/math.plane";
  9595. /**
  9596. * Class representing a ray with position and direction
  9597. */
  9598. export class Ray {
  9599. /** origin point */
  9600. origin: Vector3;
  9601. /** direction */
  9602. direction: Vector3;
  9603. /** length of the ray */
  9604. length: number;
  9605. private static readonly TmpVector3;
  9606. private _tmpRay;
  9607. /**
  9608. * Creates a new ray
  9609. * @param origin origin point
  9610. * @param direction direction
  9611. * @param length length of the ray
  9612. */
  9613. constructor(
  9614. /** origin point */
  9615. origin: Vector3,
  9616. /** direction */
  9617. direction: Vector3,
  9618. /** length of the ray */
  9619. length?: number);
  9620. /**
  9621. * Checks if the ray intersects a box
  9622. * @param minimum bound of the box
  9623. * @param maximum bound of the box
  9624. * @param intersectionTreshold extra extend to be added to the box in all direction
  9625. * @returns if the box was hit
  9626. */
  9627. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9628. /**
  9629. * Checks if the ray intersects a box
  9630. * @param box the bounding box to check
  9631. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9632. * @returns if the box was hit
  9633. */
  9634. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9635. /**
  9636. * If the ray hits a sphere
  9637. * @param sphere the bounding sphere to check
  9638. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9639. * @returns true if it hits the sphere
  9640. */
  9641. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9642. /**
  9643. * If the ray hits a triange
  9644. * @param vertex0 triangle vertex
  9645. * @param vertex1 triangle vertex
  9646. * @param vertex2 triangle vertex
  9647. * @returns intersection information if hit
  9648. */
  9649. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9650. /**
  9651. * Checks if ray intersects a plane
  9652. * @param plane the plane to check
  9653. * @returns the distance away it was hit
  9654. */
  9655. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9656. /**
  9657. * Calculate the intercept of a ray on a given axis
  9658. * @param axis to check 'x' | 'y' | 'z'
  9659. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9660. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9661. */
  9662. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9663. /**
  9664. * Checks if ray intersects a mesh
  9665. * @param mesh the mesh to check
  9666. * @param fastCheck if only the bounding box should checked
  9667. * @returns picking info of the intersecton
  9668. */
  9669. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9670. /**
  9671. * Checks if ray intersects a mesh
  9672. * @param meshes the meshes to check
  9673. * @param fastCheck if only the bounding box should checked
  9674. * @param results array to store result in
  9675. * @returns Array of picking infos
  9676. */
  9677. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9678. private _comparePickingInfo;
  9679. private static smallnum;
  9680. private static rayl;
  9681. /**
  9682. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9683. * @param sega the first point of the segment to test the intersection against
  9684. * @param segb the second point of the segment to test the intersection against
  9685. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9686. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9687. */
  9688. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9689. /**
  9690. * Update the ray from viewport position
  9691. * @param x position
  9692. * @param y y position
  9693. * @param viewportWidth viewport width
  9694. * @param viewportHeight viewport height
  9695. * @param world world matrix
  9696. * @param view view matrix
  9697. * @param projection projection matrix
  9698. * @returns this ray updated
  9699. */
  9700. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9701. /**
  9702. * Creates a ray with origin and direction of 0,0,0
  9703. * @returns the new ray
  9704. */
  9705. static Zero(): Ray;
  9706. /**
  9707. * Creates a new ray from screen space and viewport
  9708. * @param x position
  9709. * @param y y position
  9710. * @param viewportWidth viewport width
  9711. * @param viewportHeight viewport height
  9712. * @param world world matrix
  9713. * @param view view matrix
  9714. * @param projection projection matrix
  9715. * @returns new ray
  9716. */
  9717. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9718. /**
  9719. * 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
  9720. * transformed to the given world matrix.
  9721. * @param origin The origin point
  9722. * @param end The end point
  9723. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9724. * @returns the new ray
  9725. */
  9726. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9727. /**
  9728. * Transforms a ray by a matrix
  9729. * @param ray ray to transform
  9730. * @param matrix matrix to apply
  9731. * @returns the resulting new ray
  9732. */
  9733. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9734. /**
  9735. * Transforms a ray by a matrix
  9736. * @param ray ray to transform
  9737. * @param matrix matrix to apply
  9738. * @param result ray to store result in
  9739. */
  9740. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9741. /**
  9742. * Unproject a ray from screen space to object space
  9743. * @param sourceX defines the screen space x coordinate to use
  9744. * @param sourceY defines the screen space y coordinate to use
  9745. * @param viewportWidth defines the current width of the viewport
  9746. * @param viewportHeight defines the current height of the viewport
  9747. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9748. * @param view defines the view matrix to use
  9749. * @param projection defines the projection matrix to use
  9750. */
  9751. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9752. }
  9753. /**
  9754. * Type used to define predicate used to select faces when a mesh intersection is detected
  9755. */
  9756. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9757. module "babylonjs/scene" {
  9758. interface Scene {
  9759. /** @hidden */
  9760. _tempPickingRay: Nullable<Ray>;
  9761. /** @hidden */
  9762. _cachedRayForTransform: Ray;
  9763. /** @hidden */
  9764. _pickWithRayInverseMatrix: Matrix;
  9765. /** @hidden */
  9766. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9767. /** @hidden */
  9768. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9769. }
  9770. }
  9771. }
  9772. declare module "babylonjs/sceneComponent" {
  9773. import { Scene } from "babylonjs/scene";
  9774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9775. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9776. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9777. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9778. import { Nullable } from "babylonjs/types";
  9779. import { Camera } from "babylonjs/Cameras/camera";
  9780. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9781. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9782. import { AbstractScene } from "babylonjs/abstractScene";
  9783. import { Mesh } from "babylonjs/Meshes/mesh";
  9784. /**
  9785. * Groups all the scene component constants in one place to ease maintenance.
  9786. * @hidden
  9787. */
  9788. export class SceneComponentConstants {
  9789. static readonly NAME_EFFECTLAYER: string;
  9790. static readonly NAME_LAYER: string;
  9791. static readonly NAME_LENSFLARESYSTEM: string;
  9792. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9793. static readonly NAME_PARTICLESYSTEM: string;
  9794. static readonly NAME_GAMEPAD: string;
  9795. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9796. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9797. static readonly NAME_DEPTHRENDERER: string;
  9798. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9799. static readonly NAME_SPRITE: string;
  9800. static readonly NAME_OUTLINERENDERER: string;
  9801. static readonly NAME_PROCEDURALTEXTURE: string;
  9802. static readonly NAME_SHADOWGENERATOR: string;
  9803. static readonly NAME_OCTREE: string;
  9804. static readonly NAME_PHYSICSENGINE: string;
  9805. static readonly NAME_AUDIO: string;
  9806. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9807. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9808. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9809. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9810. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9811. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9812. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9813. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9814. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9815. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9816. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9817. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9818. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9819. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9820. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9821. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9822. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9823. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9824. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9825. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9826. static readonly STEP_AFTERRENDER_AUDIO: number;
  9827. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9828. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9829. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9830. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9831. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9832. static readonly STEP_POINTERMOVE_SPRITE: number;
  9833. static readonly STEP_POINTERDOWN_SPRITE: number;
  9834. static readonly STEP_POINTERUP_SPRITE: number;
  9835. }
  9836. /**
  9837. * This represents a scene component.
  9838. *
  9839. * This is used to decouple the dependency the scene is having on the different workloads like
  9840. * layers, post processes...
  9841. */
  9842. export interface ISceneComponent {
  9843. /**
  9844. * The name of the component. Each component must have a unique name.
  9845. */
  9846. name: string;
  9847. /**
  9848. * The scene the component belongs to.
  9849. */
  9850. scene: Scene;
  9851. /**
  9852. * Register the component to one instance of a scene.
  9853. */
  9854. register(): void;
  9855. /**
  9856. * Rebuilds the elements related to this component in case of
  9857. * context lost for instance.
  9858. */
  9859. rebuild(): void;
  9860. /**
  9861. * Disposes the component and the associated ressources.
  9862. */
  9863. dispose(): void;
  9864. }
  9865. /**
  9866. * This represents a SERIALIZABLE scene component.
  9867. *
  9868. * This extends Scene Component to add Serialization methods on top.
  9869. */
  9870. export interface ISceneSerializableComponent extends ISceneComponent {
  9871. /**
  9872. * Adds all the elements from the container to the scene
  9873. * @param container the container holding the elements
  9874. */
  9875. addFromContainer(container: AbstractScene): void;
  9876. /**
  9877. * Removes all the elements in the container from the scene
  9878. * @param container contains the elements to remove
  9879. * @param dispose if the removed element should be disposed (default: false)
  9880. */
  9881. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9882. /**
  9883. * Serializes the component data to the specified json object
  9884. * @param serializationObject The object to serialize to
  9885. */
  9886. serialize(serializationObject: any): void;
  9887. }
  9888. /**
  9889. * Strong typing of a Mesh related stage step action
  9890. */
  9891. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9892. /**
  9893. * Strong typing of a Evaluate Sub Mesh related stage step action
  9894. */
  9895. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9896. /**
  9897. * Strong typing of a Active Mesh related stage step action
  9898. */
  9899. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9900. /**
  9901. * Strong typing of a Camera related stage step action
  9902. */
  9903. export type CameraStageAction = (camera: Camera) => void;
  9904. /**
  9905. * Strong typing of a Camera Frame buffer related stage step action
  9906. */
  9907. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9908. /**
  9909. * Strong typing of a Render Target related stage step action
  9910. */
  9911. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9912. /**
  9913. * Strong typing of a RenderingGroup related stage step action
  9914. */
  9915. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9916. /**
  9917. * Strong typing of a Mesh Render related stage step action
  9918. */
  9919. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9920. /**
  9921. * Strong typing of a simple stage step action
  9922. */
  9923. export type SimpleStageAction = () => void;
  9924. /**
  9925. * Strong typing of a render target action.
  9926. */
  9927. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9928. /**
  9929. * Strong typing of a pointer move action.
  9930. */
  9931. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9932. /**
  9933. * Strong typing of a pointer up/down action.
  9934. */
  9935. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9936. /**
  9937. * Representation of a stage in the scene (Basically a list of ordered steps)
  9938. * @hidden
  9939. */
  9940. export class Stage<T extends Function> extends Array<{
  9941. index: number;
  9942. component: ISceneComponent;
  9943. action: T;
  9944. }> {
  9945. /**
  9946. * Hide ctor from the rest of the world.
  9947. * @param items The items to add.
  9948. */
  9949. private constructor();
  9950. /**
  9951. * Creates a new Stage.
  9952. * @returns A new instance of a Stage
  9953. */
  9954. static Create<T extends Function>(): Stage<T>;
  9955. /**
  9956. * Registers a step in an ordered way in the targeted stage.
  9957. * @param index Defines the position to register the step in
  9958. * @param component Defines the component attached to the step
  9959. * @param action Defines the action to launch during the step
  9960. */
  9961. registerStep(index: number, component: ISceneComponent, action: T): void;
  9962. /**
  9963. * Clears all the steps from the stage.
  9964. */
  9965. clear(): void;
  9966. }
  9967. }
  9968. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9969. import { Nullable } from "babylonjs/types";
  9970. import { Observable } from "babylonjs/Misc/observable";
  9971. import { Scene } from "babylonjs/scene";
  9972. import { Sprite } from "babylonjs/Sprites/sprite";
  9973. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9974. import { Ray } from "babylonjs/Culling/ray";
  9975. import { Camera } from "babylonjs/Cameras/camera";
  9976. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9977. import { ISceneComponent } from "babylonjs/sceneComponent";
  9978. module "babylonjs/scene" {
  9979. interface Scene {
  9980. /** @hidden */
  9981. _pointerOverSprite: Nullable<Sprite>;
  9982. /** @hidden */
  9983. _pickedDownSprite: Nullable<Sprite>;
  9984. /** @hidden */
  9985. _tempSpritePickingRay: Nullable<Ray>;
  9986. /**
  9987. * All of the sprite managers added to this scene
  9988. * @see http://doc.babylonjs.com/babylon101/sprites
  9989. */
  9990. spriteManagers: Array<ISpriteManager>;
  9991. /**
  9992. * An event triggered when sprites rendering is about to start
  9993. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9994. */
  9995. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9996. /**
  9997. * An event triggered when sprites rendering is done
  9998. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9999. */
  10000. onAfterSpritesRenderingObservable: Observable<Scene>;
  10001. /** @hidden */
  10002. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10003. /** Launch a ray to try to pick a sprite in the scene
  10004. * @param x position on screen
  10005. * @param y position on screen
  10006. * @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
  10007. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10008. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10009. * @returns a PickingInfo
  10010. */
  10011. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10012. /** Use the given ray to pick a sprite in the scene
  10013. * @param ray The ray (in world space) to use to pick meshes
  10014. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10015. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10016. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10017. * @returns a PickingInfo
  10018. */
  10019. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10020. /** @hidden */
  10021. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10022. /** Launch a ray to try to pick sprites in the scene
  10023. * @param x position on screen
  10024. * @param y position on screen
  10025. * @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
  10026. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10027. * @returns a PickingInfo array
  10028. */
  10029. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10030. /** Use the given ray to pick sprites in the scene
  10031. * @param ray The ray (in world space) to use to pick meshes
  10032. * @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
  10033. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10034. * @returns a PickingInfo array
  10035. */
  10036. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10037. /**
  10038. * Force the sprite under the pointer
  10039. * @param sprite defines the sprite to use
  10040. */
  10041. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10042. /**
  10043. * Gets the sprite under the pointer
  10044. * @returns a Sprite or null if no sprite is under the pointer
  10045. */
  10046. getPointerOverSprite(): Nullable<Sprite>;
  10047. }
  10048. }
  10049. /**
  10050. * Defines the sprite scene component responsible to manage sprites
  10051. * in a given scene.
  10052. */
  10053. export class SpriteSceneComponent implements ISceneComponent {
  10054. /**
  10055. * The component name helpfull to identify the component in the list of scene components.
  10056. */
  10057. readonly name: string;
  10058. /**
  10059. * The scene the component belongs to.
  10060. */
  10061. scene: Scene;
  10062. /** @hidden */
  10063. private _spritePredicate;
  10064. /**
  10065. * Creates a new instance of the component for the given scene
  10066. * @param scene Defines the scene to register the component in
  10067. */
  10068. constructor(scene: Scene);
  10069. /**
  10070. * Registers the component in a given scene
  10071. */
  10072. register(): void;
  10073. /**
  10074. * Rebuilds the elements related to this component in case of
  10075. * context lost for instance.
  10076. */
  10077. rebuild(): void;
  10078. /**
  10079. * Disposes the component and the associated ressources.
  10080. */
  10081. dispose(): void;
  10082. private _pickSpriteButKeepRay;
  10083. private _pointerMove;
  10084. private _pointerDown;
  10085. private _pointerUp;
  10086. }
  10087. }
  10088. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10089. /** @hidden */
  10090. export var fogFragmentDeclaration: {
  10091. name: string;
  10092. shader: string;
  10093. };
  10094. }
  10095. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10096. /** @hidden */
  10097. export var fogFragment: {
  10098. name: string;
  10099. shader: string;
  10100. };
  10101. }
  10102. declare module "babylonjs/Shaders/sprites.fragment" {
  10103. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10104. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10105. /** @hidden */
  10106. export var spritesPixelShader: {
  10107. name: string;
  10108. shader: string;
  10109. };
  10110. }
  10111. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10112. /** @hidden */
  10113. export var fogVertexDeclaration: {
  10114. name: string;
  10115. shader: string;
  10116. };
  10117. }
  10118. declare module "babylonjs/Shaders/sprites.vertex" {
  10119. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10120. /** @hidden */
  10121. export var spritesVertexShader: {
  10122. name: string;
  10123. shader: string;
  10124. };
  10125. }
  10126. declare module "babylonjs/Sprites/spriteManager" {
  10127. import { IDisposable, Scene } from "babylonjs/scene";
  10128. import { Nullable } from "babylonjs/types";
  10129. import { Observable } from "babylonjs/Misc/observable";
  10130. import { Sprite } from "babylonjs/Sprites/sprite";
  10131. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10132. import { Camera } from "babylonjs/Cameras/camera";
  10133. import { Texture } from "babylonjs/Materials/Textures/texture";
  10134. import "babylonjs/Shaders/sprites.fragment";
  10135. import "babylonjs/Shaders/sprites.vertex";
  10136. import { Ray } from "babylonjs/Culling/ray";
  10137. /**
  10138. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10139. */
  10140. export interface ISpriteManager extends IDisposable {
  10141. /**
  10142. * Restricts the camera to viewing objects with the same layerMask.
  10143. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10144. */
  10145. layerMask: number;
  10146. /**
  10147. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10148. */
  10149. isPickable: boolean;
  10150. /**
  10151. * Specifies the rendering group id for this mesh (0 by default)
  10152. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10153. */
  10154. renderingGroupId: number;
  10155. /**
  10156. * Defines the list of sprites managed by the manager.
  10157. */
  10158. sprites: Array<Sprite>;
  10159. /**
  10160. * Tests the intersection of a sprite with a specific ray.
  10161. * @param ray The ray we are sending to test the collision
  10162. * @param camera The camera space we are sending rays in
  10163. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10164. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10165. * @returns picking info or null.
  10166. */
  10167. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10168. /**
  10169. * Intersects the sprites with a ray
  10170. * @param ray defines the ray to intersect with
  10171. * @param camera defines the current active camera
  10172. * @param predicate defines a predicate used to select candidate sprites
  10173. * @returns null if no hit or a PickingInfo array
  10174. */
  10175. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10176. /**
  10177. * Renders the list of sprites on screen.
  10178. */
  10179. render(): void;
  10180. }
  10181. /**
  10182. * Class used to manage multiple sprites on the same spritesheet
  10183. * @see http://doc.babylonjs.com/babylon101/sprites
  10184. */
  10185. export class SpriteManager implements ISpriteManager {
  10186. /** defines the manager's name */
  10187. name: string;
  10188. /** Gets the list of sprites */
  10189. sprites: Sprite[];
  10190. /** Gets or sets the rendering group id (0 by default) */
  10191. renderingGroupId: number;
  10192. /** Gets or sets camera layer mask */
  10193. layerMask: number;
  10194. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10195. fogEnabled: boolean;
  10196. /** Gets or sets a boolean indicating if the sprites are pickable */
  10197. isPickable: boolean;
  10198. /** Defines the default width of a cell in the spritesheet */
  10199. cellWidth: number;
  10200. /** Defines the default height of a cell in the spritesheet */
  10201. cellHeight: number;
  10202. /** Associative array from JSON sprite data file */
  10203. private _cellData;
  10204. /** Array of sprite names from JSON sprite data file */
  10205. private _spriteMap;
  10206. /** True when packed cell data from JSON file is ready*/
  10207. private _packedAndReady;
  10208. /**
  10209. * An event triggered when the manager is disposed.
  10210. */
  10211. onDisposeObservable: Observable<SpriteManager>;
  10212. private _onDisposeObserver;
  10213. /**
  10214. * Callback called when the manager is disposed
  10215. */
  10216. set onDispose(callback: () => void);
  10217. private _capacity;
  10218. private _fromPacked;
  10219. private _spriteTexture;
  10220. private _epsilon;
  10221. private _scene;
  10222. private _vertexData;
  10223. private _buffer;
  10224. private _vertexBuffers;
  10225. private _indexBuffer;
  10226. private _effectBase;
  10227. private _effectFog;
  10228. /**
  10229. * Gets or sets the spritesheet texture
  10230. */
  10231. get texture(): Texture;
  10232. set texture(value: Texture);
  10233. private _blendMode;
  10234. /**
  10235. * Blend mode use to render the particle, it can be any of
  10236. * the static Constants.ALPHA_x properties provided in this class.
  10237. * Default value is Constants.ALPHA_COMBINE
  10238. */
  10239. get blendMode(): number;
  10240. set blendMode(blendMode: number);
  10241. /** Disables writing to the depth buffer when rendering the sprites.
  10242. * It can be handy to disable depth writing when using textures without alpha channel
  10243. * and setting some specific blend modes.
  10244. */
  10245. disableDepthWrite: boolean;
  10246. /**
  10247. * Creates a new sprite manager
  10248. * @param name defines the manager's name
  10249. * @param imgUrl defines the sprite sheet url
  10250. * @param capacity defines the maximum allowed number of sprites
  10251. * @param cellSize defines the size of a sprite cell
  10252. * @param scene defines the hosting scene
  10253. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10254. * @param samplingMode defines the smapling mode to use with spritesheet
  10255. * @param fromPacked set to false; do not alter
  10256. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10257. */
  10258. constructor(
  10259. /** defines the manager's name */
  10260. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10261. private _makePacked;
  10262. private _appendSpriteVertex;
  10263. /**
  10264. * Intersects the sprites with a ray
  10265. * @param ray defines the ray to intersect with
  10266. * @param camera defines the current active camera
  10267. * @param predicate defines a predicate used to select candidate sprites
  10268. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10269. * @returns null if no hit or a PickingInfo
  10270. */
  10271. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10272. /**
  10273. * Intersects the sprites with a ray
  10274. * @param ray defines the ray to intersect with
  10275. * @param camera defines the current active camera
  10276. * @param predicate defines a predicate used to select candidate sprites
  10277. * @returns null if no hit or a PickingInfo array
  10278. */
  10279. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10280. /**
  10281. * Render all child sprites
  10282. */
  10283. render(): void;
  10284. /**
  10285. * Release associated resources
  10286. */
  10287. dispose(): void;
  10288. }
  10289. }
  10290. declare module "babylonjs/Misc/gradients" {
  10291. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10292. /** Interface used by value gradients (color, factor, ...) */
  10293. export interface IValueGradient {
  10294. /**
  10295. * Gets or sets the gradient value (between 0 and 1)
  10296. */
  10297. gradient: number;
  10298. }
  10299. /** Class used to store color4 gradient */
  10300. export class ColorGradient implements IValueGradient {
  10301. /**
  10302. * Gets or sets the gradient value (between 0 and 1)
  10303. */
  10304. gradient: number;
  10305. /**
  10306. * Gets or sets first associated color
  10307. */
  10308. color1: Color4;
  10309. /**
  10310. * Gets or sets second associated color
  10311. */
  10312. color2?: Color4 | undefined;
  10313. /**
  10314. * Creates a new color4 gradient
  10315. * @param gradient gets or sets the gradient value (between 0 and 1)
  10316. * @param color1 gets or sets first associated color
  10317. * @param color2 gets or sets first second color
  10318. */
  10319. constructor(
  10320. /**
  10321. * Gets or sets the gradient value (between 0 and 1)
  10322. */
  10323. gradient: number,
  10324. /**
  10325. * Gets or sets first associated color
  10326. */
  10327. color1: Color4,
  10328. /**
  10329. * Gets or sets second associated color
  10330. */
  10331. color2?: Color4 | undefined);
  10332. /**
  10333. * Will get a color picked randomly between color1 and color2.
  10334. * If color2 is undefined then color1 will be used
  10335. * @param result defines the target Color4 to store the result in
  10336. */
  10337. getColorToRef(result: Color4): void;
  10338. }
  10339. /** Class used to store color 3 gradient */
  10340. export class Color3Gradient implements IValueGradient {
  10341. /**
  10342. * Gets or sets the gradient value (between 0 and 1)
  10343. */
  10344. gradient: number;
  10345. /**
  10346. * Gets or sets the associated color
  10347. */
  10348. color: Color3;
  10349. /**
  10350. * Creates a new color3 gradient
  10351. * @param gradient gets or sets the gradient value (between 0 and 1)
  10352. * @param color gets or sets associated color
  10353. */
  10354. constructor(
  10355. /**
  10356. * Gets or sets the gradient value (between 0 and 1)
  10357. */
  10358. gradient: number,
  10359. /**
  10360. * Gets or sets the associated color
  10361. */
  10362. color: Color3);
  10363. }
  10364. /** Class used to store factor gradient */
  10365. export class FactorGradient implements IValueGradient {
  10366. /**
  10367. * Gets or sets the gradient value (between 0 and 1)
  10368. */
  10369. gradient: number;
  10370. /**
  10371. * Gets or sets first associated factor
  10372. */
  10373. factor1: number;
  10374. /**
  10375. * Gets or sets second associated factor
  10376. */
  10377. factor2?: number | undefined;
  10378. /**
  10379. * Creates a new factor gradient
  10380. * @param gradient gets or sets the gradient value (between 0 and 1)
  10381. * @param factor1 gets or sets first associated factor
  10382. * @param factor2 gets or sets second associated factor
  10383. */
  10384. constructor(
  10385. /**
  10386. * Gets or sets the gradient value (between 0 and 1)
  10387. */
  10388. gradient: number,
  10389. /**
  10390. * Gets or sets first associated factor
  10391. */
  10392. factor1: number,
  10393. /**
  10394. * Gets or sets second associated factor
  10395. */
  10396. factor2?: number | undefined);
  10397. /**
  10398. * Will get a number picked randomly between factor1 and factor2.
  10399. * If factor2 is undefined then factor1 will be used
  10400. * @returns the picked number
  10401. */
  10402. getFactor(): number;
  10403. }
  10404. /**
  10405. * Helper used to simplify some generic gradient tasks
  10406. */
  10407. export class GradientHelper {
  10408. /**
  10409. * Gets the current gradient from an array of IValueGradient
  10410. * @param ratio defines the current ratio to get
  10411. * @param gradients defines the array of IValueGradient
  10412. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10413. */
  10414. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10415. }
  10416. }
  10417. declare module "babylonjs/Maths/math.size" {
  10418. /**
  10419. * Interface for the size containing width and height
  10420. */
  10421. export interface ISize {
  10422. /**
  10423. * Width
  10424. */
  10425. width: number;
  10426. /**
  10427. * Heighht
  10428. */
  10429. height: number;
  10430. }
  10431. /**
  10432. * Size containing widht and height
  10433. */
  10434. export class Size implements ISize {
  10435. /**
  10436. * Width
  10437. */
  10438. width: number;
  10439. /**
  10440. * Height
  10441. */
  10442. height: number;
  10443. /**
  10444. * Creates a Size object from the given width and height (floats).
  10445. * @param width width of the new size
  10446. * @param height height of the new size
  10447. */
  10448. constructor(width: number, height: number);
  10449. /**
  10450. * Returns a string with the Size width and height
  10451. * @returns a string with the Size width and height
  10452. */
  10453. toString(): string;
  10454. /**
  10455. * "Size"
  10456. * @returns the string "Size"
  10457. */
  10458. getClassName(): string;
  10459. /**
  10460. * Returns the Size hash code.
  10461. * @returns a hash code for a unique width and height
  10462. */
  10463. getHashCode(): number;
  10464. /**
  10465. * Updates the current size from the given one.
  10466. * @param src the given size
  10467. */
  10468. copyFrom(src: Size): void;
  10469. /**
  10470. * Updates in place the current Size from the given floats.
  10471. * @param width width of the new size
  10472. * @param height height of the new size
  10473. * @returns the updated Size.
  10474. */
  10475. copyFromFloats(width: number, height: number): Size;
  10476. /**
  10477. * Updates in place the current Size from the given floats.
  10478. * @param width width to set
  10479. * @param height height to set
  10480. * @returns the updated Size.
  10481. */
  10482. set(width: number, height: number): Size;
  10483. /**
  10484. * Multiplies the width and height by numbers
  10485. * @param w factor to multiple the width by
  10486. * @param h factor to multiple the height by
  10487. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10488. */
  10489. multiplyByFloats(w: number, h: number): Size;
  10490. /**
  10491. * Clones the size
  10492. * @returns a new Size copied from the given one.
  10493. */
  10494. clone(): Size;
  10495. /**
  10496. * True if the current Size and the given one width and height are strictly equal.
  10497. * @param other the other size to compare against
  10498. * @returns True if the current Size and the given one width and height are strictly equal.
  10499. */
  10500. equals(other: Size): boolean;
  10501. /**
  10502. * The surface of the Size : width * height (float).
  10503. */
  10504. get surface(): number;
  10505. /**
  10506. * Create a new size of zero
  10507. * @returns a new Size set to (0.0, 0.0)
  10508. */
  10509. static Zero(): Size;
  10510. /**
  10511. * Sums the width and height of two sizes
  10512. * @param otherSize size to add to this size
  10513. * @returns a new Size set as the addition result of the current Size and the given one.
  10514. */
  10515. add(otherSize: Size): Size;
  10516. /**
  10517. * Subtracts the width and height of two
  10518. * @param otherSize size to subtract to this size
  10519. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10520. */
  10521. subtract(otherSize: Size): Size;
  10522. /**
  10523. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10524. * @param start starting size to lerp between
  10525. * @param end end size to lerp between
  10526. * @param amount amount to lerp between the start and end values
  10527. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10528. */
  10529. static Lerp(start: Size, end: Size, amount: number): Size;
  10530. }
  10531. }
  10532. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10533. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10534. import { Nullable } from "babylonjs/types";
  10535. module "babylonjs/Engines/thinEngine" {
  10536. interface ThinEngine {
  10537. /**
  10538. * Creates a dynamic texture
  10539. * @param width defines the width of the texture
  10540. * @param height defines the height of the texture
  10541. * @param generateMipMaps defines if the engine should generate the mip levels
  10542. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10543. * @returns the dynamic texture inside an InternalTexture
  10544. */
  10545. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10546. /**
  10547. * Update the content of a dynamic texture
  10548. * @param texture defines the texture to update
  10549. * @param canvas defines the canvas containing the source
  10550. * @param invertY defines if data must be stored with Y axis inverted
  10551. * @param premulAlpha defines if alpha is stored as premultiplied
  10552. * @param format defines the format of the data
  10553. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10554. */
  10555. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10556. }
  10557. }
  10558. }
  10559. declare module "babylonjs/Misc/canvasGenerator" {
  10560. /**
  10561. * Helper class used to generate a canvas to manipulate images
  10562. */
  10563. export class CanvasGenerator {
  10564. /**
  10565. * Create a new canvas (or offscreen canvas depending on the context)
  10566. * @param width defines the expected width
  10567. * @param height defines the expected height
  10568. * @return a new canvas or offscreen canvas
  10569. */
  10570. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10571. }
  10572. }
  10573. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10574. import { Scene } from "babylonjs/scene";
  10575. import { Texture } from "babylonjs/Materials/Textures/texture";
  10576. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10577. /**
  10578. * A class extending Texture allowing drawing on a texture
  10579. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10580. */
  10581. export class DynamicTexture extends Texture {
  10582. private _generateMipMaps;
  10583. private _canvas;
  10584. private _context;
  10585. private _engine;
  10586. /**
  10587. * Creates a DynamicTexture
  10588. * @param name defines the name of the texture
  10589. * @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
  10590. * @param scene defines the scene where you want the texture
  10591. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10592. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10593. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10594. */
  10595. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10596. /**
  10597. * Get the current class name of the texture useful for serialization or dynamic coding.
  10598. * @returns "DynamicTexture"
  10599. */
  10600. getClassName(): string;
  10601. /**
  10602. * Gets the current state of canRescale
  10603. */
  10604. get canRescale(): boolean;
  10605. private _recreate;
  10606. /**
  10607. * Scales the texture
  10608. * @param ratio the scale factor to apply to both width and height
  10609. */
  10610. scale(ratio: number): void;
  10611. /**
  10612. * Resizes the texture
  10613. * @param width the new width
  10614. * @param height the new height
  10615. */
  10616. scaleTo(width: number, height: number): void;
  10617. /**
  10618. * Gets the context of the canvas used by the texture
  10619. * @returns the canvas context of the dynamic texture
  10620. */
  10621. getContext(): CanvasRenderingContext2D;
  10622. /**
  10623. * Clears the texture
  10624. */
  10625. clear(): void;
  10626. /**
  10627. * Updates the texture
  10628. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10629. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10630. */
  10631. update(invertY?: boolean, premulAlpha?: boolean): void;
  10632. /**
  10633. * Draws text onto the texture
  10634. * @param text defines the text to be drawn
  10635. * @param x defines the placement of the text from the left
  10636. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10637. * @param font defines the font to be used with font-style, font-size, font-name
  10638. * @param color defines the color used for the text
  10639. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10640. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10641. * @param update defines whether texture is immediately update (default is true)
  10642. */
  10643. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10644. /**
  10645. * Clones the texture
  10646. * @returns the clone of the texture.
  10647. */
  10648. clone(): DynamicTexture;
  10649. /**
  10650. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10651. * @returns a serialized dynamic texture object
  10652. */
  10653. serialize(): any;
  10654. /** @hidden */
  10655. _rebuild(): void;
  10656. }
  10657. }
  10658. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10659. import { Nullable } from "babylonjs/types";
  10660. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10661. import { Scene } from "babylonjs/scene";
  10662. module "babylonjs/Engines/engine" {
  10663. interface Engine {
  10664. /**
  10665. * Creates a raw texture
  10666. * @param data defines the data to store in the texture
  10667. * @param width defines the width of the texture
  10668. * @param height defines the height of the texture
  10669. * @param format defines the format of the data
  10670. * @param generateMipMaps defines if the engine should generate the mip levels
  10671. * @param invertY defines if data must be stored with Y axis inverted
  10672. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10673. * @param compression defines the compression used (null by default)
  10674. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10675. * @returns the raw texture inside an InternalTexture
  10676. */
  10677. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10678. /**
  10679. * Update a raw texture
  10680. * @param texture defines the texture to update
  10681. * @param data defines the data to store in the texture
  10682. * @param format defines the format of the data
  10683. * @param invertY defines if data must be stored with Y axis inverted
  10684. */
  10685. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10686. /**
  10687. * Update a raw texture
  10688. * @param texture defines the texture to update
  10689. * @param data defines the data to store in the texture
  10690. * @param format defines the format of the data
  10691. * @param invertY defines if data must be stored with Y axis inverted
  10692. * @param compression defines the compression used (null by default)
  10693. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10694. */
  10695. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10696. /**
  10697. * Creates a new raw cube texture
  10698. * @param data defines the array of data to use to create each face
  10699. * @param size defines the size of the textures
  10700. * @param format defines the format of the data
  10701. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10702. * @param generateMipMaps defines if the engine should generate the mip levels
  10703. * @param invertY defines if data must be stored with Y axis inverted
  10704. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10705. * @param compression defines the compression used (null by default)
  10706. * @returns the cube texture as an InternalTexture
  10707. */
  10708. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10709. /**
  10710. * Update a raw cube texture
  10711. * @param texture defines the texture to udpdate
  10712. * @param data defines the data to store
  10713. * @param format defines the data format
  10714. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10715. * @param invertY defines if data must be stored with Y axis inverted
  10716. */
  10717. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10718. /**
  10719. * Update a raw cube texture
  10720. * @param texture defines the texture to udpdate
  10721. * @param data defines the data to store
  10722. * @param format defines the data format
  10723. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10724. * @param invertY defines if data must be stored with Y axis inverted
  10725. * @param compression defines the compression used (null by default)
  10726. */
  10727. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10728. /**
  10729. * Update a raw cube texture
  10730. * @param texture defines the texture to udpdate
  10731. * @param data defines the data to store
  10732. * @param format defines the data format
  10733. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10734. * @param invertY defines if data must be stored with Y axis inverted
  10735. * @param compression defines the compression used (null by default)
  10736. * @param level defines which level of the texture to update
  10737. */
  10738. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10739. /**
  10740. * Creates a new raw cube texture from a specified url
  10741. * @param url defines the url where the data is located
  10742. * @param scene defines the current scene
  10743. * @param size defines the size of the textures
  10744. * @param format defines the format of the data
  10745. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10746. * @param noMipmap defines if the engine should avoid generating the mip levels
  10747. * @param callback defines a callback used to extract texture data from loaded data
  10748. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10749. * @param onLoad defines a callback called when texture is loaded
  10750. * @param onError defines a callback called if there is an error
  10751. * @returns the cube texture as an InternalTexture
  10752. */
  10753. 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;
  10754. /**
  10755. * Creates a new raw cube texture from a specified url
  10756. * @param url defines the url where the data is located
  10757. * @param scene defines the current scene
  10758. * @param size defines the size of the textures
  10759. * @param format defines the format of the data
  10760. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10761. * @param noMipmap defines if the engine should avoid generating the mip levels
  10762. * @param callback defines a callback used to extract texture data from loaded data
  10763. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10764. * @param onLoad defines a callback called when texture is loaded
  10765. * @param onError defines a callback called if there is an error
  10766. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10767. * @param invertY defines if data must be stored with Y axis inverted
  10768. * @returns the cube texture as an InternalTexture
  10769. */
  10770. 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;
  10771. /**
  10772. * Creates a new raw 3D texture
  10773. * @param data defines the data used to create the texture
  10774. * @param width defines the width of the texture
  10775. * @param height defines the height of the texture
  10776. * @param depth defines the depth of the texture
  10777. * @param format defines the format of the texture
  10778. * @param generateMipMaps defines if the engine must generate mip levels
  10779. * @param invertY defines if data must be stored with Y axis inverted
  10780. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10781. * @param compression defines the compressed used (can be null)
  10782. * @param textureType defines the compressed used (can be null)
  10783. * @returns a new raw 3D texture (stored in an InternalTexture)
  10784. */
  10785. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10786. /**
  10787. * Update a raw 3D texture
  10788. * @param texture defines the texture to update
  10789. * @param data defines the data to store
  10790. * @param format defines the data format
  10791. * @param invertY defines if data must be stored with Y axis inverted
  10792. */
  10793. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10794. /**
  10795. * Update a raw 3D texture
  10796. * @param texture defines the texture to update
  10797. * @param data defines the data to store
  10798. * @param format defines the data format
  10799. * @param invertY defines if data must be stored with Y axis inverted
  10800. * @param compression defines the used compression (can be null)
  10801. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10802. */
  10803. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10804. /**
  10805. * Creates a new raw 2D array texture
  10806. * @param data defines the data used to create the texture
  10807. * @param width defines the width of the texture
  10808. * @param height defines the height of the texture
  10809. * @param depth defines the number of layers of the texture
  10810. * @param format defines the format of the texture
  10811. * @param generateMipMaps defines if the engine must generate mip levels
  10812. * @param invertY defines if data must be stored with Y axis inverted
  10813. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10814. * @param compression defines the compressed used (can be null)
  10815. * @param textureType defines the compressed used (can be null)
  10816. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10817. */
  10818. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10819. /**
  10820. * Update a raw 2D array texture
  10821. * @param texture defines the texture to update
  10822. * @param data defines the data to store
  10823. * @param format defines the data format
  10824. * @param invertY defines if data must be stored with Y axis inverted
  10825. */
  10826. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10827. /**
  10828. * Update a raw 2D array texture
  10829. * @param texture defines the texture to update
  10830. * @param data defines the data to store
  10831. * @param format defines the data format
  10832. * @param invertY defines if data must be stored with Y axis inverted
  10833. * @param compression defines the used compression (can be null)
  10834. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10835. */
  10836. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10837. }
  10838. }
  10839. }
  10840. declare module "babylonjs/Materials/Textures/rawTexture" {
  10841. import { Scene } from "babylonjs/scene";
  10842. import { Texture } from "babylonjs/Materials/Textures/texture";
  10843. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10844. /**
  10845. * Raw texture can help creating a texture directly from an array of data.
  10846. * This can be super useful if you either get the data from an uncompressed source or
  10847. * if you wish to create your texture pixel by pixel.
  10848. */
  10849. export class RawTexture extends Texture {
  10850. /**
  10851. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10852. */
  10853. format: number;
  10854. private _engine;
  10855. /**
  10856. * Instantiates a new RawTexture.
  10857. * Raw texture can help creating a texture directly from an array of data.
  10858. * This can be super useful if you either get the data from an uncompressed source or
  10859. * if you wish to create your texture pixel by pixel.
  10860. * @param data define the array of data to use to create the texture
  10861. * @param width define the width of the texture
  10862. * @param height define the height of the texture
  10863. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10864. * @param scene define the scene the texture belongs to
  10865. * @param generateMipMaps define whether mip maps should be generated or not
  10866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10868. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10869. */
  10870. constructor(data: ArrayBufferView, width: number, height: number,
  10871. /**
  10872. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10873. */
  10874. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10875. /**
  10876. * Updates the texture underlying data.
  10877. * @param data Define the new data of the texture
  10878. */
  10879. update(data: ArrayBufferView): void;
  10880. /**
  10881. * Creates a luminance texture from some data.
  10882. * @param data Define the texture data
  10883. * @param width Define the width of the texture
  10884. * @param height Define the height of the texture
  10885. * @param scene Define the scene the texture belongs to
  10886. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10887. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10888. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10889. * @returns the luminance texture
  10890. */
  10891. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10892. /**
  10893. * Creates a luminance alpha texture from some data.
  10894. * @param data Define the texture data
  10895. * @param width Define the width of the texture
  10896. * @param height Define the height of the texture
  10897. * @param scene Define the scene the texture belongs to
  10898. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10899. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10900. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10901. * @returns the luminance alpha texture
  10902. */
  10903. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10904. /**
  10905. * Creates an alpha texture from some data.
  10906. * @param data Define the texture data
  10907. * @param width Define the width of the texture
  10908. * @param height Define the height of the texture
  10909. * @param scene Define the scene the texture belongs to
  10910. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10911. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10912. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10913. * @returns the alpha texture
  10914. */
  10915. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10916. /**
  10917. * Creates a RGB texture from some data.
  10918. * @param data Define the texture data
  10919. * @param width Define the width of the texture
  10920. * @param height Define the height of the texture
  10921. * @param scene Define the scene the texture belongs to
  10922. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10923. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10924. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10925. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10926. * @returns the RGB alpha texture
  10927. */
  10928. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10929. /**
  10930. * Creates a RGBA texture from some data.
  10931. * @param data Define the texture data
  10932. * @param width Define the width of the texture
  10933. * @param height Define the height of the texture
  10934. * @param scene Define the scene the texture belongs to
  10935. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10936. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10937. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10938. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10939. * @returns the RGBA texture
  10940. */
  10941. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10942. /**
  10943. * Creates a R texture from some data.
  10944. * @param data Define the texture data
  10945. * @param width Define the width of the texture
  10946. * @param height Define the height of the texture
  10947. * @param scene Define the scene the texture belongs to
  10948. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10949. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10950. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10951. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10952. * @returns the R texture
  10953. */
  10954. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10955. }
  10956. }
  10957. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10958. import { Scene } from "babylonjs/scene";
  10959. import { ISceneComponent } from "babylonjs/sceneComponent";
  10960. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10961. module "babylonjs/abstractScene" {
  10962. interface AbstractScene {
  10963. /**
  10964. * The list of procedural textures added to the scene
  10965. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10966. */
  10967. proceduralTextures: Array<ProceduralTexture>;
  10968. }
  10969. }
  10970. /**
  10971. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10972. * in a given scene.
  10973. */
  10974. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10975. /**
  10976. * The component name helpfull to identify the component in the list of scene components.
  10977. */
  10978. readonly name: string;
  10979. /**
  10980. * The scene the component belongs to.
  10981. */
  10982. scene: Scene;
  10983. /**
  10984. * Creates a new instance of the component for the given scene
  10985. * @param scene Defines the scene to register the component in
  10986. */
  10987. constructor(scene: Scene);
  10988. /**
  10989. * Registers the component in a given scene
  10990. */
  10991. register(): void;
  10992. /**
  10993. * Rebuilds the elements related to this component in case of
  10994. * context lost for instance.
  10995. */
  10996. rebuild(): void;
  10997. /**
  10998. * Disposes the component and the associated ressources.
  10999. */
  11000. dispose(): void;
  11001. private _beforeClear;
  11002. }
  11003. }
  11004. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11006. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11007. module "babylonjs/Engines/thinEngine" {
  11008. interface ThinEngine {
  11009. /**
  11010. * Creates a new render target cube texture
  11011. * @param size defines the size of the texture
  11012. * @param options defines the options used to create the texture
  11013. * @returns a new render target cube texture stored in an InternalTexture
  11014. */
  11015. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11016. }
  11017. }
  11018. }
  11019. declare module "babylonjs/Shaders/procedural.vertex" {
  11020. /** @hidden */
  11021. export var proceduralVertexShader: {
  11022. name: string;
  11023. shader: string;
  11024. };
  11025. }
  11026. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11027. import { Observable } from "babylonjs/Misc/observable";
  11028. import { Nullable } from "babylonjs/types";
  11029. import { Scene } from "babylonjs/scene";
  11030. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11031. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11032. import { Effect } from "babylonjs/Materials/effect";
  11033. import { Texture } from "babylonjs/Materials/Textures/texture";
  11034. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11035. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11036. import "babylonjs/Shaders/procedural.vertex";
  11037. /**
  11038. * 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.
  11039. * This is the base class of any Procedural texture and contains most of the shareable code.
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11041. */
  11042. export class ProceduralTexture extends Texture {
  11043. isCube: boolean;
  11044. /**
  11045. * Define if the texture is enabled or not (disabled texture will not render)
  11046. */
  11047. isEnabled: boolean;
  11048. /**
  11049. * Define if the texture must be cleared before rendering (default is true)
  11050. */
  11051. autoClear: boolean;
  11052. /**
  11053. * Callback called when the texture is generated
  11054. */
  11055. onGenerated: () => void;
  11056. /**
  11057. * Event raised when the texture is generated
  11058. */
  11059. onGeneratedObservable: Observable<ProceduralTexture>;
  11060. /** @hidden */
  11061. _generateMipMaps: boolean;
  11062. /** @hidden **/
  11063. _effect: Effect;
  11064. /** @hidden */
  11065. _textures: {
  11066. [key: string]: Texture;
  11067. };
  11068. /** @hidden */
  11069. protected _fallbackTexture: Nullable<Texture>;
  11070. private _size;
  11071. private _currentRefreshId;
  11072. private _frameId;
  11073. private _refreshRate;
  11074. private _vertexBuffers;
  11075. private _indexBuffer;
  11076. private _uniforms;
  11077. private _samplers;
  11078. private _fragment;
  11079. private _floats;
  11080. private _ints;
  11081. private _floatsArrays;
  11082. private _colors3;
  11083. private _colors4;
  11084. private _vectors2;
  11085. private _vectors3;
  11086. private _matrices;
  11087. private _fallbackTextureUsed;
  11088. private _engine;
  11089. private _cachedDefines;
  11090. private _contentUpdateId;
  11091. private _contentData;
  11092. /**
  11093. * Instantiates a new procedural texture.
  11094. * 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.
  11095. * This is the base class of any Procedural texture and contains most of the shareable code.
  11096. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11097. * @param name Define the name of the texture
  11098. * @param size Define the size of the texture to create
  11099. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11100. * @param scene Define the scene the texture belongs to
  11101. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11102. * @param generateMipMaps Define if the texture should creates mip maps or not
  11103. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11104. */
  11105. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11106. /**
  11107. * The effect that is created when initializing the post process.
  11108. * @returns The created effect corresponding the the postprocess.
  11109. */
  11110. getEffect(): Effect;
  11111. /**
  11112. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11113. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11114. */
  11115. getContent(): Nullable<ArrayBufferView>;
  11116. private _createIndexBuffer;
  11117. /** @hidden */
  11118. _rebuild(): void;
  11119. /**
  11120. * Resets the texture in order to recreate its associated resources.
  11121. * This can be called in case of context loss
  11122. */
  11123. reset(): void;
  11124. protected _getDefines(): string;
  11125. /**
  11126. * Is the texture ready to be used ? (rendered at least once)
  11127. * @returns true if ready, otherwise, false.
  11128. */
  11129. isReady(): boolean;
  11130. /**
  11131. * Resets the refresh counter of the texture and start bak from scratch.
  11132. * Could be useful to regenerate the texture if it is setup to render only once.
  11133. */
  11134. resetRefreshCounter(): void;
  11135. /**
  11136. * Set the fragment shader to use in order to render the texture.
  11137. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11138. */
  11139. setFragment(fragment: any): void;
  11140. /**
  11141. * Define the refresh rate of the texture or the rendering frequency.
  11142. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11143. */
  11144. get refreshRate(): number;
  11145. set refreshRate(value: number);
  11146. /** @hidden */
  11147. _shouldRender(): boolean;
  11148. /**
  11149. * Get the size the texture is rendering at.
  11150. * @returns the size (texture is always squared)
  11151. */
  11152. getRenderSize(): number;
  11153. /**
  11154. * Resize the texture to new value.
  11155. * @param size Define the new size the texture should have
  11156. * @param generateMipMaps Define whether the new texture should create mip maps
  11157. */
  11158. resize(size: number, generateMipMaps: boolean): void;
  11159. private _checkUniform;
  11160. /**
  11161. * Set a texture in the shader program used to render.
  11162. * @param name Define the name of the uniform samplers as defined in the shader
  11163. * @param texture Define the texture to bind to this sampler
  11164. * @return the texture itself allowing "fluent" like uniform updates
  11165. */
  11166. setTexture(name: string, texture: Texture): ProceduralTexture;
  11167. /**
  11168. * Set a float in the shader.
  11169. * @param name Define the name of the uniform as defined in the shader
  11170. * @param value Define the value to give to the uniform
  11171. * @return the texture itself allowing "fluent" like uniform updates
  11172. */
  11173. setFloat(name: string, value: number): ProceduralTexture;
  11174. /**
  11175. * Set a int in the shader.
  11176. * @param name Define the name of the uniform as defined in the shader
  11177. * @param value Define the value to give to the uniform
  11178. * @return the texture itself allowing "fluent" like uniform updates
  11179. */
  11180. setInt(name: string, value: number): ProceduralTexture;
  11181. /**
  11182. * Set an array of floats in the shader.
  11183. * @param name Define the name of the uniform as defined in the shader
  11184. * @param value Define the value to give to the uniform
  11185. * @return the texture itself allowing "fluent" like uniform updates
  11186. */
  11187. setFloats(name: string, value: number[]): ProceduralTexture;
  11188. /**
  11189. * Set a vec3 in the shader from a Color3.
  11190. * @param name Define the name of the uniform as defined in the shader
  11191. * @param value Define the value to give to the uniform
  11192. * @return the texture itself allowing "fluent" like uniform updates
  11193. */
  11194. setColor3(name: string, value: Color3): ProceduralTexture;
  11195. /**
  11196. * Set a vec4 in the shader from a Color4.
  11197. * @param name Define the name of the uniform as defined in the shader
  11198. * @param value Define the value to give to the uniform
  11199. * @return the texture itself allowing "fluent" like uniform updates
  11200. */
  11201. setColor4(name: string, value: Color4): ProceduralTexture;
  11202. /**
  11203. * Set a vec2 in the shader from a Vector2.
  11204. * @param name Define the name of the uniform as defined in the shader
  11205. * @param value Define the value to give to the uniform
  11206. * @return the texture itself allowing "fluent" like uniform updates
  11207. */
  11208. setVector2(name: string, value: Vector2): ProceduralTexture;
  11209. /**
  11210. * Set a vec3 in the shader from a Vector3.
  11211. * @param name Define the name of the uniform as defined in the shader
  11212. * @param value Define the value to give to the uniform
  11213. * @return the texture itself allowing "fluent" like uniform updates
  11214. */
  11215. setVector3(name: string, value: Vector3): ProceduralTexture;
  11216. /**
  11217. * Set a mat4 in the shader from a MAtrix.
  11218. * @param name Define the name of the uniform as defined in the shader
  11219. * @param value Define the value to give to the uniform
  11220. * @return the texture itself allowing "fluent" like uniform updates
  11221. */
  11222. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11223. /**
  11224. * Render the texture to its associated render target.
  11225. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11226. */
  11227. render(useCameraPostProcess?: boolean): void;
  11228. /**
  11229. * Clone the texture.
  11230. * @returns the cloned texture
  11231. */
  11232. clone(): ProceduralTexture;
  11233. /**
  11234. * Dispose the texture and release its asoociated resources.
  11235. */
  11236. dispose(): void;
  11237. }
  11238. }
  11239. declare module "babylonjs/Particles/baseParticleSystem" {
  11240. import { Nullable } from "babylonjs/types";
  11241. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11243. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11244. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11245. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11246. import { Scene } from "babylonjs/scene";
  11247. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11248. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11249. import { Texture } from "babylonjs/Materials/Textures/texture";
  11250. import { Color4 } from "babylonjs/Maths/math.color";
  11251. import { Animation } from "babylonjs/Animations/animation";
  11252. /**
  11253. * This represents the base class for particle system in Babylon.
  11254. * 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.
  11255. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11256. * @example https://doc.babylonjs.com/babylon101/particles
  11257. */
  11258. export class BaseParticleSystem {
  11259. /**
  11260. * Source color is added to the destination color without alpha affecting the result
  11261. */
  11262. static BLENDMODE_ONEONE: number;
  11263. /**
  11264. * Blend current color and particle color using particle’s alpha
  11265. */
  11266. static BLENDMODE_STANDARD: number;
  11267. /**
  11268. * Add current color and particle color multiplied by particle’s alpha
  11269. */
  11270. static BLENDMODE_ADD: number;
  11271. /**
  11272. * Multiply current color with particle color
  11273. */
  11274. static BLENDMODE_MULTIPLY: number;
  11275. /**
  11276. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11277. */
  11278. static BLENDMODE_MULTIPLYADD: number;
  11279. /**
  11280. * List of animations used by the particle system.
  11281. */
  11282. animations: Animation[];
  11283. /**
  11284. * Gets or sets the unique id of the particle system
  11285. */
  11286. uniqueId: number;
  11287. /**
  11288. * The id of the Particle system.
  11289. */
  11290. id: string;
  11291. /**
  11292. * The friendly name of the Particle system.
  11293. */
  11294. name: string;
  11295. /**
  11296. * The rendering group used by the Particle system to chose when to render.
  11297. */
  11298. renderingGroupId: number;
  11299. /**
  11300. * The emitter represents the Mesh or position we are attaching the particle system to.
  11301. */
  11302. emitter: Nullable<AbstractMesh | Vector3>;
  11303. /**
  11304. * The maximum number of particles to emit per frame
  11305. */
  11306. emitRate: number;
  11307. /**
  11308. * If you want to launch only a few particles at once, that can be done, as well.
  11309. */
  11310. manualEmitCount: number;
  11311. /**
  11312. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11313. */
  11314. updateSpeed: number;
  11315. /**
  11316. * The amount of time the particle system is running (depends of the overall update speed).
  11317. */
  11318. targetStopDuration: number;
  11319. /**
  11320. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11321. */
  11322. disposeOnStop: boolean;
  11323. /**
  11324. * Minimum power of emitting particles.
  11325. */
  11326. minEmitPower: number;
  11327. /**
  11328. * Maximum power of emitting particles.
  11329. */
  11330. maxEmitPower: number;
  11331. /**
  11332. * Minimum life time of emitting particles.
  11333. */
  11334. minLifeTime: number;
  11335. /**
  11336. * Maximum life time of emitting particles.
  11337. */
  11338. maxLifeTime: number;
  11339. /**
  11340. * Minimum Size of emitting particles.
  11341. */
  11342. minSize: number;
  11343. /**
  11344. * Maximum Size of emitting particles.
  11345. */
  11346. maxSize: number;
  11347. /**
  11348. * Minimum scale of emitting particles on X axis.
  11349. */
  11350. minScaleX: number;
  11351. /**
  11352. * Maximum scale of emitting particles on X axis.
  11353. */
  11354. maxScaleX: number;
  11355. /**
  11356. * Minimum scale of emitting particles on Y axis.
  11357. */
  11358. minScaleY: number;
  11359. /**
  11360. * Maximum scale of emitting particles on Y axis.
  11361. */
  11362. maxScaleY: number;
  11363. /**
  11364. * Gets or sets the minimal initial rotation in radians.
  11365. */
  11366. minInitialRotation: number;
  11367. /**
  11368. * Gets or sets the maximal initial rotation in radians.
  11369. */
  11370. maxInitialRotation: number;
  11371. /**
  11372. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11373. */
  11374. minAngularSpeed: number;
  11375. /**
  11376. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11377. */
  11378. maxAngularSpeed: number;
  11379. /**
  11380. * The texture used to render each particle. (this can be a spritesheet)
  11381. */
  11382. particleTexture: Nullable<Texture>;
  11383. /**
  11384. * The layer mask we are rendering the particles through.
  11385. */
  11386. layerMask: number;
  11387. /**
  11388. * This can help using your own shader to render the particle system.
  11389. * The according effect will be created
  11390. */
  11391. customShader: any;
  11392. /**
  11393. * By default particle system starts as soon as they are created. This prevents the
  11394. * automatic start to happen and let you decide when to start emitting particles.
  11395. */
  11396. preventAutoStart: boolean;
  11397. private _noiseTexture;
  11398. /**
  11399. * Gets or sets a texture used to add random noise to particle positions
  11400. */
  11401. get noiseTexture(): Nullable<ProceduralTexture>;
  11402. set noiseTexture(value: Nullable<ProceduralTexture>);
  11403. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11404. noiseStrength: Vector3;
  11405. /**
  11406. * Callback triggered when the particle animation is ending.
  11407. */
  11408. onAnimationEnd: Nullable<() => void>;
  11409. /**
  11410. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11411. */
  11412. blendMode: number;
  11413. /**
  11414. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11415. * to override the particles.
  11416. */
  11417. forceDepthWrite: boolean;
  11418. /** 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 */
  11419. preWarmCycles: number;
  11420. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11421. preWarmStepOffset: number;
  11422. /**
  11423. * 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)
  11424. */
  11425. spriteCellChangeSpeed: number;
  11426. /**
  11427. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11428. */
  11429. startSpriteCellID: number;
  11430. /**
  11431. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11432. */
  11433. endSpriteCellID: number;
  11434. /**
  11435. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11436. */
  11437. spriteCellWidth: number;
  11438. /**
  11439. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11440. */
  11441. spriteCellHeight: number;
  11442. /**
  11443. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11444. */
  11445. spriteRandomStartCell: boolean;
  11446. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11447. translationPivot: Vector2;
  11448. /** @hidden */
  11449. protected _isAnimationSheetEnabled: boolean;
  11450. /**
  11451. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11452. */
  11453. beginAnimationOnStart: boolean;
  11454. /**
  11455. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11456. */
  11457. beginAnimationFrom: number;
  11458. /**
  11459. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11460. */
  11461. beginAnimationTo: number;
  11462. /**
  11463. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11464. */
  11465. beginAnimationLoop: boolean;
  11466. /**
  11467. * Gets or sets a world offset applied to all particles
  11468. */
  11469. worldOffset: Vector3;
  11470. /**
  11471. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11472. */
  11473. get isAnimationSheetEnabled(): boolean;
  11474. set isAnimationSheetEnabled(value: boolean);
  11475. /**
  11476. * Get hosting scene
  11477. * @returns the scene
  11478. */
  11479. getScene(): Scene;
  11480. /**
  11481. * You can use gravity if you want to give an orientation to your particles.
  11482. */
  11483. gravity: Vector3;
  11484. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11485. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11486. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11487. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11488. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11489. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11490. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11491. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11492. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11493. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11494. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11495. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11496. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11497. /**
  11498. * Defines the delay in milliseconds before starting the system (0 by default)
  11499. */
  11500. startDelay: number;
  11501. /**
  11502. * Gets the current list of drag gradients.
  11503. * You must use addDragGradient and removeDragGradient to udpate this list
  11504. * @returns the list of drag gradients
  11505. */
  11506. getDragGradients(): Nullable<Array<FactorGradient>>;
  11507. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11508. limitVelocityDamping: number;
  11509. /**
  11510. * Gets the current list of limit velocity gradients.
  11511. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11512. * @returns the list of limit velocity gradients
  11513. */
  11514. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11515. /**
  11516. * Gets the current list of color gradients.
  11517. * You must use addColorGradient and removeColorGradient to udpate this list
  11518. * @returns the list of color gradients
  11519. */
  11520. getColorGradients(): Nullable<Array<ColorGradient>>;
  11521. /**
  11522. * Gets the current list of size gradients.
  11523. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11524. * @returns the list of size gradients
  11525. */
  11526. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11527. /**
  11528. * Gets the current list of color remap gradients.
  11529. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11530. * @returns the list of color remap gradients
  11531. */
  11532. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11533. /**
  11534. * Gets the current list of alpha remap gradients.
  11535. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11536. * @returns the list of alpha remap gradients
  11537. */
  11538. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11539. /**
  11540. * Gets the current list of life time gradients.
  11541. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11542. * @returns the list of life time gradients
  11543. */
  11544. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11545. /**
  11546. * Gets the current list of angular speed gradients.
  11547. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11548. * @returns the list of angular speed gradients
  11549. */
  11550. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11551. /**
  11552. * Gets the current list of velocity gradients.
  11553. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11554. * @returns the list of velocity gradients
  11555. */
  11556. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11557. /**
  11558. * Gets the current list of start size gradients.
  11559. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11560. * @returns the list of start size gradients
  11561. */
  11562. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11563. /**
  11564. * Gets the current list of emit rate gradients.
  11565. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11566. * @returns the list of emit rate gradients
  11567. */
  11568. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11569. /**
  11570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11571. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11572. */
  11573. get direction1(): Vector3;
  11574. set direction1(value: Vector3);
  11575. /**
  11576. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11577. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11578. */
  11579. get direction2(): Vector3;
  11580. set direction2(value: Vector3);
  11581. /**
  11582. * 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.
  11583. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11584. */
  11585. get minEmitBox(): Vector3;
  11586. set minEmitBox(value: Vector3);
  11587. /**
  11588. * 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.
  11589. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11590. */
  11591. get maxEmitBox(): Vector3;
  11592. set maxEmitBox(value: Vector3);
  11593. /**
  11594. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11595. */
  11596. color1: Color4;
  11597. /**
  11598. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11599. */
  11600. color2: Color4;
  11601. /**
  11602. * Color the particle will have at the end of its lifetime
  11603. */
  11604. colorDead: Color4;
  11605. /**
  11606. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11607. */
  11608. textureMask: Color4;
  11609. /**
  11610. * The particle emitter type defines the emitter used by the particle system.
  11611. * It can be for example box, sphere, or cone...
  11612. */
  11613. particleEmitterType: IParticleEmitterType;
  11614. /** @hidden */
  11615. _isSubEmitter: boolean;
  11616. /**
  11617. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11618. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11619. */
  11620. billboardMode: number;
  11621. protected _isBillboardBased: boolean;
  11622. /**
  11623. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11624. */
  11625. get isBillboardBased(): boolean;
  11626. set isBillboardBased(value: boolean);
  11627. /**
  11628. * The scene the particle system belongs to.
  11629. */
  11630. protected _scene: Scene;
  11631. /**
  11632. * Local cache of defines for image processing.
  11633. */
  11634. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11635. /**
  11636. * Default configuration related to image processing available in the standard Material.
  11637. */
  11638. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11639. /**
  11640. * Gets the image processing configuration used either in this material.
  11641. */
  11642. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11643. /**
  11644. * Sets the Default image processing configuration used either in the this material.
  11645. *
  11646. * If sets to null, the scene one is in use.
  11647. */
  11648. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11649. /**
  11650. * Attaches a new image processing configuration to the Standard Material.
  11651. * @param configuration
  11652. */
  11653. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11654. /** @hidden */
  11655. protected _reset(): void;
  11656. /** @hidden */
  11657. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11658. /**
  11659. * Instantiates a particle system.
  11660. * 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.
  11661. * @param name The name of the particle system
  11662. */
  11663. constructor(name: string);
  11664. /**
  11665. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11668. * @returns the emitter
  11669. */
  11670. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11671. /**
  11672. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11673. * @param radius The radius of the hemisphere to emit from
  11674. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11675. * @returns the emitter
  11676. */
  11677. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11678. /**
  11679. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11680. * @param radius The radius of the sphere to emit from
  11681. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11682. * @returns the emitter
  11683. */
  11684. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11685. /**
  11686. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11687. * @param radius The radius of the sphere to emit from
  11688. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11689. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11690. * @returns the emitter
  11691. */
  11692. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11693. /**
  11694. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11695. * @param radius The radius of the emission cylinder
  11696. * @param height The height of the emission cylinder
  11697. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11698. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11699. * @returns the emitter
  11700. */
  11701. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11702. /**
  11703. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11704. * @param radius The radius of the cylinder to emit from
  11705. * @param height The height of the emission cylinder
  11706. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11709. * @returns the emitter
  11710. */
  11711. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11712. /**
  11713. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11714. * @param radius The radius of the cone to emit from
  11715. * @param angle The base angle of the cone
  11716. * @returns the emitter
  11717. */
  11718. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11719. /**
  11720. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11721. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11722. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11723. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11724. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11725. * @returns the emitter
  11726. */
  11727. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11728. }
  11729. }
  11730. declare module "babylonjs/Particles/subEmitter" {
  11731. import { Scene } from "babylonjs/scene";
  11732. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11733. /**
  11734. * Type of sub emitter
  11735. */
  11736. export enum SubEmitterType {
  11737. /**
  11738. * Attached to the particle over it's lifetime
  11739. */
  11740. ATTACHED = 0,
  11741. /**
  11742. * Created when the particle dies
  11743. */
  11744. END = 1
  11745. }
  11746. /**
  11747. * Sub emitter class used to emit particles from an existing particle
  11748. */
  11749. export class SubEmitter {
  11750. /**
  11751. * the particle system to be used by the sub emitter
  11752. */
  11753. particleSystem: ParticleSystem;
  11754. /**
  11755. * Type of the submitter (Default: END)
  11756. */
  11757. type: SubEmitterType;
  11758. /**
  11759. * 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)
  11760. * Note: This only is supported when using an emitter of type Mesh
  11761. */
  11762. inheritDirection: boolean;
  11763. /**
  11764. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11765. */
  11766. inheritedVelocityAmount: number;
  11767. /**
  11768. * Creates a sub emitter
  11769. * @param particleSystem the particle system to be used by the sub emitter
  11770. */
  11771. constructor(
  11772. /**
  11773. * the particle system to be used by the sub emitter
  11774. */
  11775. particleSystem: ParticleSystem);
  11776. /**
  11777. * Clones the sub emitter
  11778. * @returns the cloned sub emitter
  11779. */
  11780. clone(): SubEmitter;
  11781. /**
  11782. * Serialize current object to a JSON object
  11783. * @returns the serialized object
  11784. */
  11785. serialize(): any;
  11786. /** @hidden */
  11787. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11788. /**
  11789. * Creates a new SubEmitter from a serialized JSON version
  11790. * @param serializationObject defines the JSON object to read from
  11791. * @param scene defines the hosting scene
  11792. * @param rootUrl defines the rootUrl for data loading
  11793. * @returns a new SubEmitter
  11794. */
  11795. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11796. /** Release associated resources */
  11797. dispose(): void;
  11798. }
  11799. }
  11800. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11801. /** @hidden */
  11802. export var imageProcessingDeclaration: {
  11803. name: string;
  11804. shader: string;
  11805. };
  11806. }
  11807. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11808. /** @hidden */
  11809. export var imageProcessingFunctions: {
  11810. name: string;
  11811. shader: string;
  11812. };
  11813. }
  11814. declare module "babylonjs/Shaders/particles.fragment" {
  11815. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11816. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11817. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11818. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11819. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11820. /** @hidden */
  11821. export var particlesPixelShader: {
  11822. name: string;
  11823. shader: string;
  11824. };
  11825. }
  11826. declare module "babylonjs/Shaders/particles.vertex" {
  11827. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11828. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11829. /** @hidden */
  11830. export var particlesVertexShader: {
  11831. name: string;
  11832. shader: string;
  11833. };
  11834. }
  11835. declare module "babylonjs/Particles/particleSystem" {
  11836. import { Nullable } from "babylonjs/types";
  11837. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11838. import { Observable } from "babylonjs/Misc/observable";
  11839. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11840. import { Effect } from "babylonjs/Materials/effect";
  11841. import { Scene, IDisposable } from "babylonjs/scene";
  11842. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11843. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11844. import { Particle } from "babylonjs/Particles/particle";
  11845. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11846. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11847. import "babylonjs/Shaders/particles.fragment";
  11848. import "babylonjs/Shaders/particles.vertex";
  11849. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11850. /**
  11851. * This represents a particle system in Babylon.
  11852. * 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.
  11853. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11854. * @example https://doc.babylonjs.com/babylon101/particles
  11855. */
  11856. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11857. /**
  11858. * Billboard mode will only apply to Y axis
  11859. */
  11860. static readonly BILLBOARDMODE_Y: number;
  11861. /**
  11862. * Billboard mode will apply to all axes
  11863. */
  11864. static readonly BILLBOARDMODE_ALL: number;
  11865. /**
  11866. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11867. */
  11868. static readonly BILLBOARDMODE_STRETCHED: number;
  11869. /**
  11870. * This function can be defined to provide custom update for active particles.
  11871. * This function will be called instead of regular update (age, position, color, etc.).
  11872. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11873. */
  11874. updateFunction: (particles: Particle[]) => void;
  11875. private _emitterWorldMatrix;
  11876. /**
  11877. * This function can be defined to specify initial direction for every new particle.
  11878. * It by default use the emitterType defined function
  11879. */
  11880. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11881. /**
  11882. * This function can be defined to specify initial position for every new particle.
  11883. * It by default use the emitterType defined function
  11884. */
  11885. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11886. /**
  11887. * @hidden
  11888. */
  11889. _inheritedVelocityOffset: Vector3;
  11890. /**
  11891. * An event triggered when the system is disposed
  11892. */
  11893. onDisposeObservable: Observable<ParticleSystem>;
  11894. private _onDisposeObserver;
  11895. /**
  11896. * Sets a callback that will be triggered when the system is disposed
  11897. */
  11898. set onDispose(callback: () => void);
  11899. private _particles;
  11900. private _epsilon;
  11901. private _capacity;
  11902. private _stockParticles;
  11903. private _newPartsExcess;
  11904. private _vertexData;
  11905. private _vertexBuffer;
  11906. private _vertexBuffers;
  11907. private _spriteBuffer;
  11908. private _indexBuffer;
  11909. private _effect;
  11910. private _customEffect;
  11911. private _cachedDefines;
  11912. private _scaledColorStep;
  11913. private _colorDiff;
  11914. private _scaledDirection;
  11915. private _scaledGravity;
  11916. private _currentRenderId;
  11917. private _alive;
  11918. private _useInstancing;
  11919. private _started;
  11920. private _stopped;
  11921. private _actualFrame;
  11922. private _scaledUpdateSpeed;
  11923. private _vertexBufferSize;
  11924. /** @hidden */
  11925. _currentEmitRateGradient: Nullable<FactorGradient>;
  11926. /** @hidden */
  11927. _currentEmitRate1: number;
  11928. /** @hidden */
  11929. _currentEmitRate2: number;
  11930. /** @hidden */
  11931. _currentStartSizeGradient: Nullable<FactorGradient>;
  11932. /** @hidden */
  11933. _currentStartSize1: number;
  11934. /** @hidden */
  11935. _currentStartSize2: number;
  11936. private readonly _rawTextureWidth;
  11937. private _rampGradientsTexture;
  11938. private _useRampGradients;
  11939. /** Gets or sets a boolean indicating that ramp gradients must be used
  11940. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11941. */
  11942. get useRampGradients(): boolean;
  11943. set useRampGradients(value: boolean);
  11944. /**
  11945. * 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.
  11946. * 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: [])
  11947. */
  11948. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11949. private _subEmitters;
  11950. /**
  11951. * @hidden
  11952. * If the particle systems emitter should be disposed when the particle system is disposed
  11953. */
  11954. _disposeEmitterOnDispose: boolean;
  11955. /**
  11956. * The current active Sub-systems, this property is used by the root particle system only.
  11957. */
  11958. activeSubSystems: Array<ParticleSystem>;
  11959. /**
  11960. * Specifies if the particles are updated in emitter local space or world space
  11961. */
  11962. isLocal: boolean;
  11963. private _rootParticleSystem;
  11964. /**
  11965. * Gets the current list of active particles
  11966. */
  11967. get particles(): Particle[];
  11968. /**
  11969. * Gets the number of particles active at the same time.
  11970. * @returns The number of active particles.
  11971. */
  11972. getActiveCount(): number;
  11973. /**
  11974. * Returns the string "ParticleSystem"
  11975. * @returns a string containing the class name
  11976. */
  11977. getClassName(): string;
  11978. /**
  11979. * Gets a boolean indicating that the system is stopping
  11980. * @returns true if the system is currently stopping
  11981. */
  11982. isStopping(): boolean;
  11983. /**
  11984. * Instantiates a particle system.
  11985. * 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.
  11986. * @param name The name of the particle system
  11987. * @param capacity The max number of particles alive at the same time
  11988. * @param scene The scene the particle system belongs to
  11989. * @param customEffect a custom effect used to change the way particles are rendered by default
  11990. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11991. * @param epsilon Offset used to render the particles
  11992. */
  11993. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11994. private _addFactorGradient;
  11995. private _removeFactorGradient;
  11996. /**
  11997. * Adds a new life time gradient
  11998. * @param gradient defines the gradient to use (between 0 and 1)
  11999. * @param factor defines the life time factor to affect to the specified gradient
  12000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12001. * @returns the current particle system
  12002. */
  12003. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12004. /**
  12005. * Remove a specific life time gradient
  12006. * @param gradient defines the gradient to remove
  12007. * @returns the current particle system
  12008. */
  12009. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12010. /**
  12011. * Adds a new size gradient
  12012. * @param gradient defines the gradient to use (between 0 and 1)
  12013. * @param factor defines the size factor to affect to the specified gradient
  12014. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12015. * @returns the current particle system
  12016. */
  12017. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12018. /**
  12019. * Remove a specific size gradient
  12020. * @param gradient defines the gradient to remove
  12021. * @returns the current particle system
  12022. */
  12023. removeSizeGradient(gradient: number): IParticleSystem;
  12024. /**
  12025. * Adds a new color remap gradient
  12026. * @param gradient defines the gradient to use (between 0 and 1)
  12027. * @param min defines the color remap minimal range
  12028. * @param max defines the color remap maximal range
  12029. * @returns the current particle system
  12030. */
  12031. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12032. /**
  12033. * Remove a specific color remap gradient
  12034. * @param gradient defines the gradient to remove
  12035. * @returns the current particle system
  12036. */
  12037. removeColorRemapGradient(gradient: number): IParticleSystem;
  12038. /**
  12039. * Adds a new alpha remap gradient
  12040. * @param gradient defines the gradient to use (between 0 and 1)
  12041. * @param min defines the alpha remap minimal range
  12042. * @param max defines the alpha remap maximal range
  12043. * @returns the current particle system
  12044. */
  12045. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12046. /**
  12047. * Remove a specific alpha remap gradient
  12048. * @param gradient defines the gradient to remove
  12049. * @returns the current particle system
  12050. */
  12051. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12052. /**
  12053. * Adds a new angular speed gradient
  12054. * @param gradient defines the gradient to use (between 0 and 1)
  12055. * @param factor defines the angular speed to affect to the specified gradient
  12056. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12057. * @returns the current particle system
  12058. */
  12059. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12060. /**
  12061. * Remove a specific angular speed gradient
  12062. * @param gradient defines the gradient to remove
  12063. * @returns the current particle system
  12064. */
  12065. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12066. /**
  12067. * Adds a new velocity gradient
  12068. * @param gradient defines the gradient to use (between 0 and 1)
  12069. * @param factor defines the velocity to affect to the specified gradient
  12070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12071. * @returns the current particle system
  12072. */
  12073. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12074. /**
  12075. * Remove a specific velocity gradient
  12076. * @param gradient defines the gradient to remove
  12077. * @returns the current particle system
  12078. */
  12079. removeVelocityGradient(gradient: number): IParticleSystem;
  12080. /**
  12081. * Adds a new limit velocity gradient
  12082. * @param gradient defines the gradient to use (between 0 and 1)
  12083. * @param factor defines the limit velocity value to affect to the specified gradient
  12084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12085. * @returns the current particle system
  12086. */
  12087. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12088. /**
  12089. * Remove a specific limit velocity gradient
  12090. * @param gradient defines the gradient to remove
  12091. * @returns the current particle system
  12092. */
  12093. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12094. /**
  12095. * Adds a new drag gradient
  12096. * @param gradient defines the gradient to use (between 0 and 1)
  12097. * @param factor defines the drag value to affect to the specified gradient
  12098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12099. * @returns the current particle system
  12100. */
  12101. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12102. /**
  12103. * Remove a specific drag gradient
  12104. * @param gradient defines the gradient to remove
  12105. * @returns the current particle system
  12106. */
  12107. removeDragGradient(gradient: number): IParticleSystem;
  12108. /**
  12109. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12110. * @param gradient defines the gradient to use (between 0 and 1)
  12111. * @param factor defines the emit rate value to affect to the specified gradient
  12112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12113. * @returns the current particle system
  12114. */
  12115. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12116. /**
  12117. * Remove a specific emit rate gradient
  12118. * @param gradient defines the gradient to remove
  12119. * @returns the current particle system
  12120. */
  12121. removeEmitRateGradient(gradient: number): IParticleSystem;
  12122. /**
  12123. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12124. * @param gradient defines the gradient to use (between 0 and 1)
  12125. * @param factor defines the start size value to affect to the specified gradient
  12126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12127. * @returns the current particle system
  12128. */
  12129. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12130. /**
  12131. * Remove a specific start size gradient
  12132. * @param gradient defines the gradient to remove
  12133. * @returns the current particle system
  12134. */
  12135. removeStartSizeGradient(gradient: number): IParticleSystem;
  12136. private _createRampGradientTexture;
  12137. /**
  12138. * Gets the current list of ramp gradients.
  12139. * You must use addRampGradient and removeRampGradient to udpate this list
  12140. * @returns the list of ramp gradients
  12141. */
  12142. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12143. /**
  12144. * Adds a new ramp gradient used to remap particle colors
  12145. * @param gradient defines the gradient to use (between 0 and 1)
  12146. * @param color defines the color to affect to the specified gradient
  12147. * @returns the current particle system
  12148. */
  12149. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12150. /**
  12151. * Remove a specific ramp gradient
  12152. * @param gradient defines the gradient to remove
  12153. * @returns the current particle system
  12154. */
  12155. removeRampGradient(gradient: number): ParticleSystem;
  12156. /**
  12157. * Adds a new color gradient
  12158. * @param gradient defines the gradient to use (between 0 and 1)
  12159. * @param color1 defines the color to affect to the specified gradient
  12160. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12161. * @returns this particle system
  12162. */
  12163. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12164. /**
  12165. * Remove a specific color gradient
  12166. * @param gradient defines the gradient to remove
  12167. * @returns this particle system
  12168. */
  12169. removeColorGradient(gradient: number): IParticleSystem;
  12170. private _fetchR;
  12171. protected _reset(): void;
  12172. private _resetEffect;
  12173. private _createVertexBuffers;
  12174. private _createIndexBuffer;
  12175. /**
  12176. * Gets the maximum number of particles active at the same time.
  12177. * @returns The max number of active particles.
  12178. */
  12179. getCapacity(): number;
  12180. /**
  12181. * Gets whether there are still active particles in the system.
  12182. * @returns True if it is alive, otherwise false.
  12183. */
  12184. isAlive(): boolean;
  12185. /**
  12186. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12187. * @returns True if it has been started, otherwise false.
  12188. */
  12189. isStarted(): boolean;
  12190. private _prepareSubEmitterInternalArray;
  12191. /**
  12192. * Starts the particle system and begins to emit
  12193. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12194. */
  12195. start(delay?: number): void;
  12196. /**
  12197. * Stops the particle system.
  12198. * @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.
  12199. */
  12200. stop(stopSubEmitters?: boolean): void;
  12201. /**
  12202. * Remove all active particles
  12203. */
  12204. reset(): void;
  12205. /**
  12206. * @hidden (for internal use only)
  12207. */
  12208. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12209. /**
  12210. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12211. * Its lifetime will start back at 0.
  12212. */
  12213. recycleParticle: (particle: Particle) => void;
  12214. private _stopSubEmitters;
  12215. private _createParticle;
  12216. private _removeFromRoot;
  12217. private _emitFromParticle;
  12218. private _update;
  12219. /** @hidden */
  12220. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12221. /** @hidden */
  12222. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12223. /** @hidden */
  12224. private _getEffect;
  12225. /**
  12226. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12227. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12228. */
  12229. animate(preWarmOnly?: boolean): void;
  12230. private _appendParticleVertices;
  12231. /**
  12232. * Rebuilds the particle system.
  12233. */
  12234. rebuild(): void;
  12235. /**
  12236. * Is this system ready to be used/rendered
  12237. * @return true if the system is ready
  12238. */
  12239. isReady(): boolean;
  12240. private _render;
  12241. /**
  12242. * Renders the particle system in its current state.
  12243. * @returns the current number of particles
  12244. */
  12245. render(): number;
  12246. /**
  12247. * Disposes the particle system and free the associated resources
  12248. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12249. */
  12250. dispose(disposeTexture?: boolean): void;
  12251. /**
  12252. * Clones the particle system.
  12253. * @param name The name of the cloned object
  12254. * @param newEmitter The new emitter to use
  12255. * @returns the cloned particle system
  12256. */
  12257. clone(name: string, newEmitter: any): ParticleSystem;
  12258. /**
  12259. * Serializes the particle system to a JSON object.
  12260. * @returns the JSON object
  12261. */
  12262. serialize(): any;
  12263. /** @hidden */
  12264. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12265. /** @hidden */
  12266. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12267. /**
  12268. * Parses a JSON object to create a particle system.
  12269. * @param parsedParticleSystem The JSON object to parse
  12270. * @param scene The scene to create the particle system in
  12271. * @param rootUrl The root url to use to load external dependencies like texture
  12272. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12273. * @returns the Parsed particle system
  12274. */
  12275. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12276. }
  12277. }
  12278. declare module "babylonjs/Particles/particle" {
  12279. import { Nullable } from "babylonjs/types";
  12280. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12281. import { Color4 } from "babylonjs/Maths/math.color";
  12282. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12283. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12284. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12285. /**
  12286. * A particle represents one of the element emitted by a particle system.
  12287. * This is mainly define by its coordinates, direction, velocity and age.
  12288. */
  12289. export class Particle {
  12290. /**
  12291. * The particle system the particle belongs to.
  12292. */
  12293. particleSystem: ParticleSystem;
  12294. private static _Count;
  12295. /**
  12296. * Unique ID of the particle
  12297. */
  12298. id: number;
  12299. /**
  12300. * The world position of the particle in the scene.
  12301. */
  12302. position: Vector3;
  12303. /**
  12304. * The world direction of the particle in the scene.
  12305. */
  12306. direction: Vector3;
  12307. /**
  12308. * The color of the particle.
  12309. */
  12310. color: Color4;
  12311. /**
  12312. * The color change of the particle per step.
  12313. */
  12314. colorStep: Color4;
  12315. /**
  12316. * Defines how long will the life of the particle be.
  12317. */
  12318. lifeTime: number;
  12319. /**
  12320. * The current age of the particle.
  12321. */
  12322. age: number;
  12323. /**
  12324. * The current size of the particle.
  12325. */
  12326. size: number;
  12327. /**
  12328. * The current scale of the particle.
  12329. */
  12330. scale: Vector2;
  12331. /**
  12332. * The current angle of the particle.
  12333. */
  12334. angle: number;
  12335. /**
  12336. * Defines how fast is the angle changing.
  12337. */
  12338. angularSpeed: number;
  12339. /**
  12340. * Defines the cell index used by the particle to be rendered from a sprite.
  12341. */
  12342. cellIndex: number;
  12343. /**
  12344. * The information required to support color remapping
  12345. */
  12346. remapData: Vector4;
  12347. /** @hidden */
  12348. _randomCellOffset?: number;
  12349. /** @hidden */
  12350. _initialDirection: Nullable<Vector3>;
  12351. /** @hidden */
  12352. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12353. /** @hidden */
  12354. _initialStartSpriteCellID: number;
  12355. /** @hidden */
  12356. _initialEndSpriteCellID: number;
  12357. /** @hidden */
  12358. _currentColorGradient: Nullable<ColorGradient>;
  12359. /** @hidden */
  12360. _currentColor1: Color4;
  12361. /** @hidden */
  12362. _currentColor2: Color4;
  12363. /** @hidden */
  12364. _currentSizeGradient: Nullable<FactorGradient>;
  12365. /** @hidden */
  12366. _currentSize1: number;
  12367. /** @hidden */
  12368. _currentSize2: number;
  12369. /** @hidden */
  12370. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12371. /** @hidden */
  12372. _currentAngularSpeed1: number;
  12373. /** @hidden */
  12374. _currentAngularSpeed2: number;
  12375. /** @hidden */
  12376. _currentVelocityGradient: Nullable<FactorGradient>;
  12377. /** @hidden */
  12378. _currentVelocity1: number;
  12379. /** @hidden */
  12380. _currentVelocity2: number;
  12381. /** @hidden */
  12382. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12383. /** @hidden */
  12384. _currentLimitVelocity1: number;
  12385. /** @hidden */
  12386. _currentLimitVelocity2: number;
  12387. /** @hidden */
  12388. _currentDragGradient: Nullable<FactorGradient>;
  12389. /** @hidden */
  12390. _currentDrag1: number;
  12391. /** @hidden */
  12392. _currentDrag2: number;
  12393. /** @hidden */
  12394. _randomNoiseCoordinates1: Vector3;
  12395. /** @hidden */
  12396. _randomNoiseCoordinates2: Vector3;
  12397. /** @hidden */
  12398. _localPosition?: Vector3;
  12399. /**
  12400. * Creates a new instance Particle
  12401. * @param particleSystem the particle system the particle belongs to
  12402. */
  12403. constructor(
  12404. /**
  12405. * The particle system the particle belongs to.
  12406. */
  12407. particleSystem: ParticleSystem);
  12408. private updateCellInfoFromSystem;
  12409. /**
  12410. * Defines how the sprite cell index is updated for the particle
  12411. */
  12412. updateCellIndex(): void;
  12413. /** @hidden */
  12414. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12415. /** @hidden */
  12416. _inheritParticleInfoToSubEmitters(): void;
  12417. /** @hidden */
  12418. _reset(): void;
  12419. /**
  12420. * Copy the properties of particle to another one.
  12421. * @param other the particle to copy the information to.
  12422. */
  12423. copyTo(other: Particle): void;
  12424. }
  12425. }
  12426. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12427. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12428. import { Effect } from "babylonjs/Materials/effect";
  12429. import { Particle } from "babylonjs/Particles/particle";
  12430. import { Scene } from "babylonjs/scene";
  12431. /**
  12432. * Particle emitter represents a volume emitting particles.
  12433. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12434. */
  12435. export interface IParticleEmitterType {
  12436. /**
  12437. * Called by the particle System when the direction is computed for the created particle.
  12438. * @param worldMatrix is the world matrix of the particle system
  12439. * @param directionToUpdate is the direction vector to update with the result
  12440. * @param particle is the particle we are computed the direction for
  12441. * @param isLocal defines if the direction should be set in local space
  12442. */
  12443. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12444. /**
  12445. * Called by the particle System when the position is computed for the created particle.
  12446. * @param worldMatrix is the world matrix of the particle system
  12447. * @param positionToUpdate is the position vector to update with the result
  12448. * @param particle is the particle we are computed the position for
  12449. * @param isLocal defines if the position should be set in local space
  12450. */
  12451. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12452. /**
  12453. * Clones the current emitter and returns a copy of it
  12454. * @returns the new emitter
  12455. */
  12456. clone(): IParticleEmitterType;
  12457. /**
  12458. * Called by the GPUParticleSystem to setup the update shader
  12459. * @param effect defines the update shader
  12460. */
  12461. applyToShader(effect: Effect): void;
  12462. /**
  12463. * Returns a string to use to update the GPU particles update shader
  12464. * @returns the effect defines string
  12465. */
  12466. getEffectDefines(): string;
  12467. /**
  12468. * Returns a string representing the class name
  12469. * @returns a string containing the class name
  12470. */
  12471. getClassName(): string;
  12472. /**
  12473. * Serializes the particle system to a JSON object.
  12474. * @returns the JSON object
  12475. */
  12476. serialize(): any;
  12477. /**
  12478. * Parse properties from a JSON object
  12479. * @param serializationObject defines the JSON object
  12480. * @param scene defines the hosting scene
  12481. */
  12482. parse(serializationObject: any, scene: Scene): void;
  12483. }
  12484. }
  12485. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12486. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12487. import { Effect } from "babylonjs/Materials/effect";
  12488. import { Particle } from "babylonjs/Particles/particle";
  12489. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12490. /**
  12491. * Particle emitter emitting particles from the inside of a box.
  12492. * It emits the particles randomly between 2 given directions.
  12493. */
  12494. export class BoxParticleEmitter implements IParticleEmitterType {
  12495. /**
  12496. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12497. */
  12498. direction1: Vector3;
  12499. /**
  12500. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12501. */
  12502. direction2: Vector3;
  12503. /**
  12504. * 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.
  12505. */
  12506. minEmitBox: Vector3;
  12507. /**
  12508. * 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.
  12509. */
  12510. maxEmitBox: Vector3;
  12511. /**
  12512. * Creates a new instance BoxParticleEmitter
  12513. */
  12514. constructor();
  12515. /**
  12516. * Called by the particle System when the direction is computed for the created particle.
  12517. * @param worldMatrix is the world matrix of the particle system
  12518. * @param directionToUpdate is the direction vector to update with the result
  12519. * @param particle is the particle we are computed the direction for
  12520. * @param isLocal defines if the direction should be set in local space
  12521. */
  12522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12523. /**
  12524. * Called by the particle System when the position is computed for the created particle.
  12525. * @param worldMatrix is the world matrix of the particle system
  12526. * @param positionToUpdate is the position vector to update with the result
  12527. * @param particle is the particle we are computed the position for
  12528. * @param isLocal defines if the position should be set in local space
  12529. */
  12530. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12531. /**
  12532. * Clones the current emitter and returns a copy of it
  12533. * @returns the new emitter
  12534. */
  12535. clone(): BoxParticleEmitter;
  12536. /**
  12537. * Called by the GPUParticleSystem to setup the update shader
  12538. * @param effect defines the update shader
  12539. */
  12540. applyToShader(effect: Effect): void;
  12541. /**
  12542. * Returns a string to use to update the GPU particles update shader
  12543. * @returns a string containng the defines string
  12544. */
  12545. getEffectDefines(): string;
  12546. /**
  12547. * Returns the string "BoxParticleEmitter"
  12548. * @returns a string containing the class name
  12549. */
  12550. getClassName(): string;
  12551. /**
  12552. * Serializes the particle system to a JSON object.
  12553. * @returns the JSON object
  12554. */
  12555. serialize(): any;
  12556. /**
  12557. * Parse properties from a JSON object
  12558. * @param serializationObject defines the JSON object
  12559. */
  12560. parse(serializationObject: any): void;
  12561. }
  12562. }
  12563. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12564. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12565. import { Effect } from "babylonjs/Materials/effect";
  12566. import { Particle } from "babylonjs/Particles/particle";
  12567. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12568. /**
  12569. * Particle emitter emitting particles from the inside of a cone.
  12570. * It emits the particles alongside the cone volume from the base to the particle.
  12571. * The emission direction might be randomized.
  12572. */
  12573. export class ConeParticleEmitter implements IParticleEmitterType {
  12574. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12575. directionRandomizer: number;
  12576. private _radius;
  12577. private _angle;
  12578. private _height;
  12579. /**
  12580. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12581. */
  12582. radiusRange: number;
  12583. /**
  12584. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12585. */
  12586. heightRange: number;
  12587. /**
  12588. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12589. */
  12590. emitFromSpawnPointOnly: boolean;
  12591. /**
  12592. * Gets or sets the radius of the emission cone
  12593. */
  12594. get radius(): number;
  12595. set radius(value: number);
  12596. /**
  12597. * Gets or sets the angle of the emission cone
  12598. */
  12599. get angle(): number;
  12600. set angle(value: number);
  12601. private _buildHeight;
  12602. /**
  12603. * Creates a new instance ConeParticleEmitter
  12604. * @param radius the radius of the emission cone (1 by default)
  12605. * @param angle the cone base angle (PI by default)
  12606. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12607. */
  12608. constructor(radius?: number, angle?: number,
  12609. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12610. directionRandomizer?: number);
  12611. /**
  12612. * Called by the particle System when the direction is computed for the created particle.
  12613. * @param worldMatrix is the world matrix of the particle system
  12614. * @param directionToUpdate is the direction vector to update with the result
  12615. * @param particle is the particle we are computed the direction for
  12616. * @param isLocal defines if the direction should be set in local space
  12617. */
  12618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12619. /**
  12620. * Called by the particle System when the position is computed for the created particle.
  12621. * @param worldMatrix is the world matrix of the particle system
  12622. * @param positionToUpdate is the position vector to update with the result
  12623. * @param particle is the particle we are computed the position for
  12624. * @param isLocal defines if the position should be set in local space
  12625. */
  12626. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12627. /**
  12628. * Clones the current emitter and returns a copy of it
  12629. * @returns the new emitter
  12630. */
  12631. clone(): ConeParticleEmitter;
  12632. /**
  12633. * Called by the GPUParticleSystem to setup the update shader
  12634. * @param effect defines the update shader
  12635. */
  12636. applyToShader(effect: Effect): void;
  12637. /**
  12638. * Returns a string to use to update the GPU particles update shader
  12639. * @returns a string containng the defines string
  12640. */
  12641. getEffectDefines(): string;
  12642. /**
  12643. * Returns the string "ConeParticleEmitter"
  12644. * @returns a string containing the class name
  12645. */
  12646. getClassName(): string;
  12647. /**
  12648. * Serializes the particle system to a JSON object.
  12649. * @returns the JSON object
  12650. */
  12651. serialize(): any;
  12652. /**
  12653. * Parse properties from a JSON object
  12654. * @param serializationObject defines the JSON object
  12655. */
  12656. parse(serializationObject: any): void;
  12657. }
  12658. }
  12659. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12660. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12661. import { Effect } from "babylonjs/Materials/effect";
  12662. import { Particle } from "babylonjs/Particles/particle";
  12663. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12664. /**
  12665. * Particle emitter emitting particles from the inside of a cylinder.
  12666. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12667. */
  12668. export class CylinderParticleEmitter implements IParticleEmitterType {
  12669. /**
  12670. * The radius of the emission cylinder.
  12671. */
  12672. radius: number;
  12673. /**
  12674. * The height of the emission cylinder.
  12675. */
  12676. height: number;
  12677. /**
  12678. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12679. */
  12680. radiusRange: number;
  12681. /**
  12682. * How much to randomize the particle direction [0-1].
  12683. */
  12684. directionRandomizer: number;
  12685. /**
  12686. * Creates a new instance CylinderParticleEmitter
  12687. * @param radius the radius of the emission cylinder (1 by default)
  12688. * @param height the height of the emission cylinder (1 by default)
  12689. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12690. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12691. */
  12692. constructor(
  12693. /**
  12694. * The radius of the emission cylinder.
  12695. */
  12696. radius?: number,
  12697. /**
  12698. * The height of the emission cylinder.
  12699. */
  12700. height?: number,
  12701. /**
  12702. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12703. */
  12704. radiusRange?: number,
  12705. /**
  12706. * How much to randomize the particle direction [0-1].
  12707. */
  12708. directionRandomizer?: number);
  12709. /**
  12710. * Called by the particle System when the direction is computed for the created particle.
  12711. * @param worldMatrix is the world matrix of the particle system
  12712. * @param directionToUpdate is the direction vector to update with the result
  12713. * @param particle is the particle we are computed the direction for
  12714. * @param isLocal defines if the direction should be set in local space
  12715. */
  12716. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12717. /**
  12718. * Called by the particle System when the position is computed for the created particle.
  12719. * @param worldMatrix is the world matrix of the particle system
  12720. * @param positionToUpdate is the position vector to update with the result
  12721. * @param particle is the particle we are computed the position for
  12722. * @param isLocal defines if the position should be set in local space
  12723. */
  12724. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12725. /**
  12726. * Clones the current emitter and returns a copy of it
  12727. * @returns the new emitter
  12728. */
  12729. clone(): CylinderParticleEmitter;
  12730. /**
  12731. * Called by the GPUParticleSystem to setup the update shader
  12732. * @param effect defines the update shader
  12733. */
  12734. applyToShader(effect: Effect): void;
  12735. /**
  12736. * Returns a string to use to update the GPU particles update shader
  12737. * @returns a string containng the defines string
  12738. */
  12739. getEffectDefines(): string;
  12740. /**
  12741. * Returns the string "CylinderParticleEmitter"
  12742. * @returns a string containing the class name
  12743. */
  12744. getClassName(): string;
  12745. /**
  12746. * Serializes the particle system to a JSON object.
  12747. * @returns the JSON object
  12748. */
  12749. serialize(): any;
  12750. /**
  12751. * Parse properties from a JSON object
  12752. * @param serializationObject defines the JSON object
  12753. */
  12754. parse(serializationObject: any): void;
  12755. }
  12756. /**
  12757. * Particle emitter emitting particles from the inside of a cylinder.
  12758. * It emits the particles randomly between two vectors.
  12759. */
  12760. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12761. /**
  12762. * The min limit of the emission direction.
  12763. */
  12764. direction1: Vector3;
  12765. /**
  12766. * The max limit of the emission direction.
  12767. */
  12768. direction2: Vector3;
  12769. /**
  12770. * Creates a new instance CylinderDirectedParticleEmitter
  12771. * @param radius the radius of the emission cylinder (1 by default)
  12772. * @param height the height of the emission cylinder (1 by default)
  12773. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12774. * @param direction1 the min limit of the emission direction (up vector by default)
  12775. * @param direction2 the max limit of the emission direction (up vector by default)
  12776. */
  12777. constructor(radius?: number, height?: number, radiusRange?: number,
  12778. /**
  12779. * The min limit of the emission direction.
  12780. */
  12781. direction1?: Vector3,
  12782. /**
  12783. * The max limit of the emission direction.
  12784. */
  12785. direction2?: Vector3);
  12786. /**
  12787. * Called by the particle System when the direction is computed for the created particle.
  12788. * @param worldMatrix is the world matrix of the particle system
  12789. * @param directionToUpdate is the direction vector to update with the result
  12790. * @param particle is the particle we are computed the direction for
  12791. */
  12792. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12793. /**
  12794. * Clones the current emitter and returns a copy of it
  12795. * @returns the new emitter
  12796. */
  12797. clone(): CylinderDirectedParticleEmitter;
  12798. /**
  12799. * Called by the GPUParticleSystem to setup the update shader
  12800. * @param effect defines the update shader
  12801. */
  12802. applyToShader(effect: Effect): void;
  12803. /**
  12804. * Returns a string to use to update the GPU particles update shader
  12805. * @returns a string containng the defines string
  12806. */
  12807. getEffectDefines(): string;
  12808. /**
  12809. * Returns the string "CylinderDirectedParticleEmitter"
  12810. * @returns a string containing the class name
  12811. */
  12812. getClassName(): string;
  12813. /**
  12814. * Serializes the particle system to a JSON object.
  12815. * @returns the JSON object
  12816. */
  12817. serialize(): any;
  12818. /**
  12819. * Parse properties from a JSON object
  12820. * @param serializationObject defines the JSON object
  12821. */
  12822. parse(serializationObject: any): void;
  12823. }
  12824. }
  12825. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12826. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12827. import { Effect } from "babylonjs/Materials/effect";
  12828. import { Particle } from "babylonjs/Particles/particle";
  12829. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12830. /**
  12831. * Particle emitter emitting particles from the inside of a hemisphere.
  12832. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12833. */
  12834. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12835. /**
  12836. * The radius of the emission hemisphere.
  12837. */
  12838. radius: number;
  12839. /**
  12840. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12841. */
  12842. radiusRange: number;
  12843. /**
  12844. * How much to randomize the particle direction [0-1].
  12845. */
  12846. directionRandomizer: number;
  12847. /**
  12848. * Creates a new instance HemisphericParticleEmitter
  12849. * @param radius the radius of the emission hemisphere (1 by default)
  12850. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12851. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12852. */
  12853. constructor(
  12854. /**
  12855. * The radius of the emission hemisphere.
  12856. */
  12857. radius?: number,
  12858. /**
  12859. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12860. */
  12861. radiusRange?: number,
  12862. /**
  12863. * How much to randomize the particle direction [0-1].
  12864. */
  12865. directionRandomizer?: number);
  12866. /**
  12867. * Called by the particle System when the direction is computed for the created particle.
  12868. * @param worldMatrix is the world matrix of the particle system
  12869. * @param directionToUpdate is the direction vector to update with the result
  12870. * @param particle is the particle we are computed the direction for
  12871. * @param isLocal defines if the direction should be set in local space
  12872. */
  12873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12874. /**
  12875. * Called by the particle System when the position is computed for the created particle.
  12876. * @param worldMatrix is the world matrix of the particle system
  12877. * @param positionToUpdate is the position vector to update with the result
  12878. * @param particle is the particle we are computed the position for
  12879. * @param isLocal defines if the position should be set in local space
  12880. */
  12881. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12882. /**
  12883. * Clones the current emitter and returns a copy of it
  12884. * @returns the new emitter
  12885. */
  12886. clone(): HemisphericParticleEmitter;
  12887. /**
  12888. * Called by the GPUParticleSystem to setup the update shader
  12889. * @param effect defines the update shader
  12890. */
  12891. applyToShader(effect: Effect): void;
  12892. /**
  12893. * Returns a string to use to update the GPU particles update shader
  12894. * @returns a string containng the defines string
  12895. */
  12896. getEffectDefines(): string;
  12897. /**
  12898. * Returns the string "HemisphericParticleEmitter"
  12899. * @returns a string containing the class name
  12900. */
  12901. getClassName(): string;
  12902. /**
  12903. * Serializes the particle system to a JSON object.
  12904. * @returns the JSON object
  12905. */
  12906. serialize(): any;
  12907. /**
  12908. * Parse properties from a JSON object
  12909. * @param serializationObject defines the JSON object
  12910. */
  12911. parse(serializationObject: any): void;
  12912. }
  12913. }
  12914. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12915. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12916. import { Effect } from "babylonjs/Materials/effect";
  12917. import { Particle } from "babylonjs/Particles/particle";
  12918. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12919. /**
  12920. * Particle emitter emitting particles from a point.
  12921. * It emits the particles randomly between 2 given directions.
  12922. */
  12923. export class PointParticleEmitter implements IParticleEmitterType {
  12924. /**
  12925. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12926. */
  12927. direction1: Vector3;
  12928. /**
  12929. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12930. */
  12931. direction2: Vector3;
  12932. /**
  12933. * Creates a new instance PointParticleEmitter
  12934. */
  12935. constructor();
  12936. /**
  12937. * Called by the particle System when the direction is computed for the created particle.
  12938. * @param worldMatrix is the world matrix of the particle system
  12939. * @param directionToUpdate is the direction vector to update with the result
  12940. * @param particle is the particle we are computed the direction for
  12941. * @param isLocal defines if the direction should be set in local space
  12942. */
  12943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12944. /**
  12945. * Called by the particle System when the position is computed for the created particle.
  12946. * @param worldMatrix is the world matrix of the particle system
  12947. * @param positionToUpdate is the position vector to update with the result
  12948. * @param particle is the particle we are computed the position for
  12949. * @param isLocal defines if the position should be set in local space
  12950. */
  12951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12952. /**
  12953. * Clones the current emitter and returns a copy of it
  12954. * @returns the new emitter
  12955. */
  12956. clone(): PointParticleEmitter;
  12957. /**
  12958. * Called by the GPUParticleSystem to setup the update shader
  12959. * @param effect defines the update shader
  12960. */
  12961. applyToShader(effect: Effect): void;
  12962. /**
  12963. * Returns a string to use to update the GPU particles update shader
  12964. * @returns a string containng the defines string
  12965. */
  12966. getEffectDefines(): string;
  12967. /**
  12968. * Returns the string "PointParticleEmitter"
  12969. * @returns a string containing the class name
  12970. */
  12971. getClassName(): string;
  12972. /**
  12973. * Serializes the particle system to a JSON object.
  12974. * @returns the JSON object
  12975. */
  12976. serialize(): any;
  12977. /**
  12978. * Parse properties from a JSON object
  12979. * @param serializationObject defines the JSON object
  12980. */
  12981. parse(serializationObject: any): void;
  12982. }
  12983. }
  12984. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12985. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12986. import { Effect } from "babylonjs/Materials/effect";
  12987. import { Particle } from "babylonjs/Particles/particle";
  12988. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12989. /**
  12990. * Particle emitter emitting particles from the inside of a sphere.
  12991. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12992. */
  12993. export class SphereParticleEmitter implements IParticleEmitterType {
  12994. /**
  12995. * The radius of the emission sphere.
  12996. */
  12997. radius: number;
  12998. /**
  12999. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13000. */
  13001. radiusRange: number;
  13002. /**
  13003. * How much to randomize the particle direction [0-1].
  13004. */
  13005. directionRandomizer: number;
  13006. /**
  13007. * Creates a new instance SphereParticleEmitter
  13008. * @param radius the radius of the emission sphere (1 by default)
  13009. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13010. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13011. */
  13012. constructor(
  13013. /**
  13014. * The radius of the emission sphere.
  13015. */
  13016. radius?: number,
  13017. /**
  13018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13019. */
  13020. radiusRange?: number,
  13021. /**
  13022. * How much to randomize the particle direction [0-1].
  13023. */
  13024. directionRandomizer?: number);
  13025. /**
  13026. * Called by the particle System when the direction is computed for the created particle.
  13027. * @param worldMatrix is the world matrix of the particle system
  13028. * @param directionToUpdate is the direction vector to update with the result
  13029. * @param particle is the particle we are computed the direction for
  13030. * @param isLocal defines if the direction should be set in local space
  13031. */
  13032. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13033. /**
  13034. * Called by the particle System when the position is computed for the created particle.
  13035. * @param worldMatrix is the world matrix of the particle system
  13036. * @param positionToUpdate is the position vector to update with the result
  13037. * @param particle is the particle we are computed the position for
  13038. * @param isLocal defines if the position should be set in local space
  13039. */
  13040. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13041. /**
  13042. * Clones the current emitter and returns a copy of it
  13043. * @returns the new emitter
  13044. */
  13045. clone(): SphereParticleEmitter;
  13046. /**
  13047. * Called by the GPUParticleSystem to setup the update shader
  13048. * @param effect defines the update shader
  13049. */
  13050. applyToShader(effect: Effect): void;
  13051. /**
  13052. * Returns a string to use to update the GPU particles update shader
  13053. * @returns a string containng the defines string
  13054. */
  13055. getEffectDefines(): string;
  13056. /**
  13057. * Returns the string "SphereParticleEmitter"
  13058. * @returns a string containing the class name
  13059. */
  13060. getClassName(): string;
  13061. /**
  13062. * Serializes the particle system to a JSON object.
  13063. * @returns the JSON object
  13064. */
  13065. serialize(): any;
  13066. /**
  13067. * Parse properties from a JSON object
  13068. * @param serializationObject defines the JSON object
  13069. */
  13070. parse(serializationObject: any): void;
  13071. }
  13072. /**
  13073. * Particle emitter emitting particles from the inside of a sphere.
  13074. * It emits the particles randomly between two vectors.
  13075. */
  13076. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13077. /**
  13078. * The min limit of the emission direction.
  13079. */
  13080. direction1: Vector3;
  13081. /**
  13082. * The max limit of the emission direction.
  13083. */
  13084. direction2: Vector3;
  13085. /**
  13086. * Creates a new instance SphereDirectedParticleEmitter
  13087. * @param radius the radius of the emission sphere (1 by default)
  13088. * @param direction1 the min limit of the emission direction (up vector by default)
  13089. * @param direction2 the max limit of the emission direction (up vector by default)
  13090. */
  13091. constructor(radius?: number,
  13092. /**
  13093. * The min limit of the emission direction.
  13094. */
  13095. direction1?: Vector3,
  13096. /**
  13097. * The max limit of the emission direction.
  13098. */
  13099. direction2?: Vector3);
  13100. /**
  13101. * Called by the particle System when the direction is computed for the created particle.
  13102. * @param worldMatrix is the world matrix of the particle system
  13103. * @param directionToUpdate is the direction vector to update with the result
  13104. * @param particle is the particle we are computed the direction for
  13105. */
  13106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13107. /**
  13108. * Clones the current emitter and returns a copy of it
  13109. * @returns the new emitter
  13110. */
  13111. clone(): SphereDirectedParticleEmitter;
  13112. /**
  13113. * Called by the GPUParticleSystem to setup the update shader
  13114. * @param effect defines the update shader
  13115. */
  13116. applyToShader(effect: Effect): void;
  13117. /**
  13118. * Returns a string to use to update the GPU particles update shader
  13119. * @returns a string containng the defines string
  13120. */
  13121. getEffectDefines(): string;
  13122. /**
  13123. * Returns the string "SphereDirectedParticleEmitter"
  13124. * @returns a string containing the class name
  13125. */
  13126. getClassName(): string;
  13127. /**
  13128. * Serializes the particle system to a JSON object.
  13129. * @returns the JSON object
  13130. */
  13131. serialize(): any;
  13132. /**
  13133. * Parse properties from a JSON object
  13134. * @param serializationObject defines the JSON object
  13135. */
  13136. parse(serializationObject: any): void;
  13137. }
  13138. }
  13139. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13140. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13141. import { Effect } from "babylonjs/Materials/effect";
  13142. import { Particle } from "babylonjs/Particles/particle";
  13143. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13144. import { Nullable } from "babylonjs/types";
  13145. /**
  13146. * Particle emitter emitting particles from a custom list of positions.
  13147. */
  13148. export class CustomParticleEmitter implements IParticleEmitterType {
  13149. /**
  13150. * Gets or sets the position generator that will create the inital position of each particle.
  13151. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13152. */
  13153. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13154. /**
  13155. * Gets or sets the destination generator that will create the final destination of each particle.
  13156. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13157. */
  13158. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13159. /**
  13160. * Creates a new instance CustomParticleEmitter
  13161. */
  13162. constructor();
  13163. /**
  13164. * Called by the particle System when the direction is computed for the created particle.
  13165. * @param worldMatrix is the world matrix of the particle system
  13166. * @param directionToUpdate is the direction vector to update with the result
  13167. * @param particle is the particle we are computed the direction for
  13168. * @param isLocal defines if the direction should be set in local space
  13169. */
  13170. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13171. /**
  13172. * Called by the particle System when the position is computed for the created particle.
  13173. * @param worldMatrix is the world matrix of the particle system
  13174. * @param positionToUpdate is the position vector to update with the result
  13175. * @param particle is the particle we are computed the position for
  13176. * @param isLocal defines if the position should be set in local space
  13177. */
  13178. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13179. /**
  13180. * Clones the current emitter and returns a copy of it
  13181. * @returns the new emitter
  13182. */
  13183. clone(): CustomParticleEmitter;
  13184. /**
  13185. * Called by the GPUParticleSystem to setup the update shader
  13186. * @param effect defines the update shader
  13187. */
  13188. applyToShader(effect: Effect): void;
  13189. /**
  13190. * Returns a string to use to update the GPU particles update shader
  13191. * @returns a string containng the defines string
  13192. */
  13193. getEffectDefines(): string;
  13194. /**
  13195. * Returns the string "PointParticleEmitter"
  13196. * @returns a string containing the class name
  13197. */
  13198. getClassName(): string;
  13199. /**
  13200. * Serializes the particle system to a JSON object.
  13201. * @returns the JSON object
  13202. */
  13203. serialize(): any;
  13204. /**
  13205. * Parse properties from a JSON object
  13206. * @param serializationObject defines the JSON object
  13207. */
  13208. parse(serializationObject: any): void;
  13209. }
  13210. }
  13211. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13212. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13213. import { Effect } from "babylonjs/Materials/effect";
  13214. import { Particle } from "babylonjs/Particles/particle";
  13215. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13216. import { Nullable } from "babylonjs/types";
  13217. import { Scene } from "babylonjs/scene";
  13218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13219. /**
  13220. * Particle emitter emitting particles from the inside of a box.
  13221. * It emits the particles randomly between 2 given directions.
  13222. */
  13223. export class MeshParticleEmitter implements IParticleEmitterType {
  13224. private _indices;
  13225. private _positions;
  13226. private _normals;
  13227. private _storedNormal;
  13228. private _mesh;
  13229. /**
  13230. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13231. */
  13232. direction1: Vector3;
  13233. /**
  13234. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13235. */
  13236. direction2: Vector3;
  13237. /**
  13238. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13239. */
  13240. useMeshNormalsForDirection: boolean;
  13241. /** Defines the mesh to use as source */
  13242. get mesh(): Nullable<AbstractMesh>;
  13243. set mesh(value: Nullable<AbstractMesh>);
  13244. /**
  13245. * Creates a new instance MeshParticleEmitter
  13246. * @param mesh defines the mesh to use as source
  13247. */
  13248. constructor(mesh?: Nullable<AbstractMesh>);
  13249. /**
  13250. * Called by the particle System when the direction is computed for the created particle.
  13251. * @param worldMatrix is the world matrix of the particle system
  13252. * @param directionToUpdate is the direction vector to update with the result
  13253. * @param particle is the particle we are computed the direction for
  13254. * @param isLocal defines if the direction should be set in local space
  13255. */
  13256. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13257. /**
  13258. * Called by the particle System when the position is computed for the created particle.
  13259. * @param worldMatrix is the world matrix of the particle system
  13260. * @param positionToUpdate is the position vector to update with the result
  13261. * @param particle is the particle we are computed the position for
  13262. * @param isLocal defines if the position should be set in local space
  13263. */
  13264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13265. /**
  13266. * Clones the current emitter and returns a copy of it
  13267. * @returns the new emitter
  13268. */
  13269. clone(): MeshParticleEmitter;
  13270. /**
  13271. * Called by the GPUParticleSystem to setup the update shader
  13272. * @param effect defines the update shader
  13273. */
  13274. applyToShader(effect: Effect): void;
  13275. /**
  13276. * Returns a string to use to update the GPU particles update shader
  13277. * @returns a string containng the defines string
  13278. */
  13279. getEffectDefines(): string;
  13280. /**
  13281. * Returns the string "BoxParticleEmitter"
  13282. * @returns a string containing the class name
  13283. */
  13284. getClassName(): string;
  13285. /**
  13286. * Serializes the particle system to a JSON object.
  13287. * @returns the JSON object
  13288. */
  13289. serialize(): any;
  13290. /**
  13291. * Parse properties from a JSON object
  13292. * @param serializationObject defines the JSON object
  13293. * @param scene defines the hosting scene
  13294. */
  13295. parse(serializationObject: any, scene: Scene): void;
  13296. }
  13297. }
  13298. declare module "babylonjs/Particles/EmitterTypes/index" {
  13299. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13300. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13301. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13302. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13303. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13304. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13305. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13306. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13307. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13308. }
  13309. declare module "babylonjs/Particles/IParticleSystem" {
  13310. import { Nullable } from "babylonjs/types";
  13311. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13312. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13315. import { Texture } from "babylonjs/Materials/Textures/texture";
  13316. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13317. import { Scene } from "babylonjs/scene";
  13318. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13319. import { Animation } from "babylonjs/Animations/animation";
  13320. /**
  13321. * Interface representing a particle system in Babylon.js.
  13322. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13323. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13324. */
  13325. export interface IParticleSystem {
  13326. /**
  13327. * List of animations used by the particle system.
  13328. */
  13329. animations: Animation[];
  13330. /**
  13331. * The id of the Particle system.
  13332. */
  13333. id: string;
  13334. /**
  13335. * The name of the Particle system.
  13336. */
  13337. name: string;
  13338. /**
  13339. * The emitter represents the Mesh or position we are attaching the particle system to.
  13340. */
  13341. emitter: Nullable<AbstractMesh | Vector3>;
  13342. /**
  13343. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13344. */
  13345. isBillboardBased: boolean;
  13346. /**
  13347. * The rendering group used by the Particle system to chose when to render.
  13348. */
  13349. renderingGroupId: number;
  13350. /**
  13351. * The layer mask we are rendering the particles through.
  13352. */
  13353. layerMask: number;
  13354. /**
  13355. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13356. */
  13357. updateSpeed: number;
  13358. /**
  13359. * The amount of time the particle system is running (depends of the overall update speed).
  13360. */
  13361. targetStopDuration: number;
  13362. /**
  13363. * The texture used to render each particle. (this can be a spritesheet)
  13364. */
  13365. particleTexture: Nullable<Texture>;
  13366. /**
  13367. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13368. */
  13369. blendMode: number;
  13370. /**
  13371. * Minimum life time of emitting particles.
  13372. */
  13373. minLifeTime: number;
  13374. /**
  13375. * Maximum life time of emitting particles.
  13376. */
  13377. maxLifeTime: number;
  13378. /**
  13379. * Minimum Size of emitting particles.
  13380. */
  13381. minSize: number;
  13382. /**
  13383. * Maximum Size of emitting particles.
  13384. */
  13385. maxSize: number;
  13386. /**
  13387. * Minimum scale of emitting particles on X axis.
  13388. */
  13389. minScaleX: number;
  13390. /**
  13391. * Maximum scale of emitting particles on X axis.
  13392. */
  13393. maxScaleX: number;
  13394. /**
  13395. * Minimum scale of emitting particles on Y axis.
  13396. */
  13397. minScaleY: number;
  13398. /**
  13399. * Maximum scale of emitting particles on Y axis.
  13400. */
  13401. maxScaleY: number;
  13402. /**
  13403. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13404. */
  13405. color1: Color4;
  13406. /**
  13407. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13408. */
  13409. color2: Color4;
  13410. /**
  13411. * Color the particle will have at the end of its lifetime.
  13412. */
  13413. colorDead: Color4;
  13414. /**
  13415. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13416. */
  13417. emitRate: number;
  13418. /**
  13419. * You can use gravity if you want to give an orientation to your particles.
  13420. */
  13421. gravity: Vector3;
  13422. /**
  13423. * Minimum power of emitting particles.
  13424. */
  13425. minEmitPower: number;
  13426. /**
  13427. * Maximum power of emitting particles.
  13428. */
  13429. maxEmitPower: number;
  13430. /**
  13431. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13432. */
  13433. minAngularSpeed: number;
  13434. /**
  13435. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13436. */
  13437. maxAngularSpeed: number;
  13438. /**
  13439. * Gets or sets the minimal initial rotation in radians.
  13440. */
  13441. minInitialRotation: number;
  13442. /**
  13443. * Gets or sets the maximal initial rotation in radians.
  13444. */
  13445. maxInitialRotation: number;
  13446. /**
  13447. * The particle emitter type defines the emitter used by the particle system.
  13448. * It can be for example box, sphere, or cone...
  13449. */
  13450. particleEmitterType: Nullable<IParticleEmitterType>;
  13451. /**
  13452. * Defines the delay in milliseconds before starting the system (0 by default)
  13453. */
  13454. startDelay: number;
  13455. /**
  13456. * 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
  13457. */
  13458. preWarmCycles: number;
  13459. /**
  13460. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13461. */
  13462. preWarmStepOffset: number;
  13463. /**
  13464. * 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)
  13465. */
  13466. spriteCellChangeSpeed: number;
  13467. /**
  13468. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13469. */
  13470. startSpriteCellID: number;
  13471. /**
  13472. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13473. */
  13474. endSpriteCellID: number;
  13475. /**
  13476. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13477. */
  13478. spriteCellWidth: number;
  13479. /**
  13480. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13481. */
  13482. spriteCellHeight: number;
  13483. /**
  13484. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13485. */
  13486. spriteRandomStartCell: boolean;
  13487. /**
  13488. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13489. */
  13490. isAnimationSheetEnabled: boolean;
  13491. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13492. translationPivot: Vector2;
  13493. /**
  13494. * Gets or sets a texture used to add random noise to particle positions
  13495. */
  13496. noiseTexture: Nullable<BaseTexture>;
  13497. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13498. noiseStrength: Vector3;
  13499. /**
  13500. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13501. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13502. */
  13503. billboardMode: number;
  13504. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13505. limitVelocityDamping: number;
  13506. /**
  13507. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13508. */
  13509. beginAnimationOnStart: boolean;
  13510. /**
  13511. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13512. */
  13513. beginAnimationFrom: number;
  13514. /**
  13515. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13516. */
  13517. beginAnimationTo: number;
  13518. /**
  13519. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13520. */
  13521. beginAnimationLoop: boolean;
  13522. /**
  13523. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13524. */
  13525. disposeOnStop: boolean;
  13526. /**
  13527. * Specifies if the particles are updated in emitter local space or world space
  13528. */
  13529. isLocal: boolean;
  13530. /**
  13531. * Gets the maximum number of particles active at the same time.
  13532. * @returns The max number of active particles.
  13533. */
  13534. getCapacity(): number;
  13535. /**
  13536. * Gets the number of particles active at the same time.
  13537. * @returns The number of active particles.
  13538. */
  13539. getActiveCount(): number;
  13540. /**
  13541. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13542. * @returns True if it has been started, otherwise false.
  13543. */
  13544. isStarted(): boolean;
  13545. /**
  13546. * Animates the particle system for this frame.
  13547. */
  13548. animate(): void;
  13549. /**
  13550. * Renders the particle system in its current state.
  13551. * @returns the current number of particles
  13552. */
  13553. render(): number;
  13554. /**
  13555. * Dispose the particle system and frees its associated resources.
  13556. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13557. */
  13558. dispose(disposeTexture?: boolean): void;
  13559. /**
  13560. * Clones the particle system.
  13561. * @param name The name of the cloned object
  13562. * @param newEmitter The new emitter to use
  13563. * @returns the cloned particle system
  13564. */
  13565. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13566. /**
  13567. * Serializes the particle system to a JSON object.
  13568. * @returns the JSON object
  13569. */
  13570. serialize(): any;
  13571. /**
  13572. * Rebuild the particle system
  13573. */
  13574. rebuild(): void;
  13575. /**
  13576. * Starts the particle system and begins to emit
  13577. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13578. */
  13579. start(delay?: number): void;
  13580. /**
  13581. * Stops the particle system.
  13582. */
  13583. stop(): void;
  13584. /**
  13585. * Remove all active particles
  13586. */
  13587. reset(): void;
  13588. /**
  13589. * Gets a boolean indicating that the system is stopping
  13590. * @returns true if the system is currently stopping
  13591. */
  13592. isStopping(): boolean;
  13593. /**
  13594. * Is this system ready to be used/rendered
  13595. * @return true if the system is ready
  13596. */
  13597. isReady(): boolean;
  13598. /**
  13599. * Returns the string "ParticleSystem"
  13600. * @returns a string containing the class name
  13601. */
  13602. getClassName(): string;
  13603. /**
  13604. * Adds a new color gradient
  13605. * @param gradient defines the gradient to use (between 0 and 1)
  13606. * @param color1 defines the color to affect to the specified gradient
  13607. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13608. * @returns the current particle system
  13609. */
  13610. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13611. /**
  13612. * Remove a specific color gradient
  13613. * @param gradient defines the gradient to remove
  13614. * @returns the current particle system
  13615. */
  13616. removeColorGradient(gradient: number): IParticleSystem;
  13617. /**
  13618. * Adds a new size gradient
  13619. * @param gradient defines the gradient to use (between 0 and 1)
  13620. * @param factor defines the size factor to affect to the specified gradient
  13621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13622. * @returns the current particle system
  13623. */
  13624. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13625. /**
  13626. * Remove a specific size gradient
  13627. * @param gradient defines the gradient to remove
  13628. * @returns the current particle system
  13629. */
  13630. removeSizeGradient(gradient: number): IParticleSystem;
  13631. /**
  13632. * Gets the current list of color gradients.
  13633. * You must use addColorGradient and removeColorGradient to udpate this list
  13634. * @returns the list of color gradients
  13635. */
  13636. getColorGradients(): Nullable<Array<ColorGradient>>;
  13637. /**
  13638. * Gets the current list of size gradients.
  13639. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13640. * @returns the list of size gradients
  13641. */
  13642. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13643. /**
  13644. * Gets the current list of angular speed gradients.
  13645. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13646. * @returns the list of angular speed gradients
  13647. */
  13648. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13649. /**
  13650. * Adds a new angular speed gradient
  13651. * @param gradient defines the gradient to use (between 0 and 1)
  13652. * @param factor defines the angular speed to affect to the specified gradient
  13653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13654. * @returns the current particle system
  13655. */
  13656. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13657. /**
  13658. * Remove a specific angular speed gradient
  13659. * @param gradient defines the gradient to remove
  13660. * @returns the current particle system
  13661. */
  13662. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13663. /**
  13664. * Gets the current list of velocity gradients.
  13665. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13666. * @returns the list of velocity gradients
  13667. */
  13668. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13669. /**
  13670. * Adds a new velocity gradient
  13671. * @param gradient defines the gradient to use (between 0 and 1)
  13672. * @param factor defines the velocity to affect to the specified gradient
  13673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13674. * @returns the current particle system
  13675. */
  13676. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13677. /**
  13678. * Remove a specific velocity gradient
  13679. * @param gradient defines the gradient to remove
  13680. * @returns the current particle system
  13681. */
  13682. removeVelocityGradient(gradient: number): IParticleSystem;
  13683. /**
  13684. * Gets the current list of limit velocity gradients.
  13685. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13686. * @returns the list of limit velocity gradients
  13687. */
  13688. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13689. /**
  13690. * Adds a new limit velocity gradient
  13691. * @param gradient defines the gradient to use (between 0 and 1)
  13692. * @param factor defines the limit velocity to affect to the specified gradient
  13693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13694. * @returns the current particle system
  13695. */
  13696. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13697. /**
  13698. * Remove a specific limit velocity gradient
  13699. * @param gradient defines the gradient to remove
  13700. * @returns the current particle system
  13701. */
  13702. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13703. /**
  13704. * Adds a new drag gradient
  13705. * @param gradient defines the gradient to use (between 0 and 1)
  13706. * @param factor defines the drag to affect to the specified gradient
  13707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13708. * @returns the current particle system
  13709. */
  13710. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13711. /**
  13712. * Remove a specific drag gradient
  13713. * @param gradient defines the gradient to remove
  13714. * @returns the current particle system
  13715. */
  13716. removeDragGradient(gradient: number): IParticleSystem;
  13717. /**
  13718. * Gets the current list of drag gradients.
  13719. * You must use addDragGradient and removeDragGradient to udpate this list
  13720. * @returns the list of drag gradients
  13721. */
  13722. getDragGradients(): Nullable<Array<FactorGradient>>;
  13723. /**
  13724. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13725. * @param gradient defines the gradient to use (between 0 and 1)
  13726. * @param factor defines the emit rate to affect to the specified gradient
  13727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13728. * @returns the current particle system
  13729. */
  13730. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13731. /**
  13732. * Remove a specific emit rate gradient
  13733. * @param gradient defines the gradient to remove
  13734. * @returns the current particle system
  13735. */
  13736. removeEmitRateGradient(gradient: number): IParticleSystem;
  13737. /**
  13738. * Gets the current list of emit rate gradients.
  13739. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13740. * @returns the list of emit rate gradients
  13741. */
  13742. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13743. /**
  13744. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13745. * @param gradient defines the gradient to use (between 0 and 1)
  13746. * @param factor defines the start size to affect to the specified gradient
  13747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13748. * @returns the current particle system
  13749. */
  13750. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13751. /**
  13752. * Remove a specific start size gradient
  13753. * @param gradient defines the gradient to remove
  13754. * @returns the current particle system
  13755. */
  13756. removeStartSizeGradient(gradient: number): IParticleSystem;
  13757. /**
  13758. * Gets the current list of start size gradients.
  13759. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13760. * @returns the list of start size gradients
  13761. */
  13762. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13763. /**
  13764. * Adds a new life time gradient
  13765. * @param gradient defines the gradient to use (between 0 and 1)
  13766. * @param factor defines the life time factor to affect to the specified gradient
  13767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13768. * @returns the current particle system
  13769. */
  13770. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13771. /**
  13772. * Remove a specific life time gradient
  13773. * @param gradient defines the gradient to remove
  13774. * @returns the current particle system
  13775. */
  13776. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13777. /**
  13778. * Gets the current list of life time gradients.
  13779. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13780. * @returns the list of life time gradients
  13781. */
  13782. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13783. /**
  13784. * Gets the current list of color gradients.
  13785. * You must use addColorGradient and removeColorGradient to udpate this list
  13786. * @returns the list of color gradients
  13787. */
  13788. getColorGradients(): Nullable<Array<ColorGradient>>;
  13789. /**
  13790. * Adds a new ramp gradient used to remap particle colors
  13791. * @param gradient defines the gradient to use (between 0 and 1)
  13792. * @param color defines the color to affect to the specified gradient
  13793. * @returns the current particle system
  13794. */
  13795. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13796. /**
  13797. * Gets the current list of ramp gradients.
  13798. * You must use addRampGradient and removeRampGradient to udpate this list
  13799. * @returns the list of ramp gradients
  13800. */
  13801. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13802. /** Gets or sets a boolean indicating that ramp gradients must be used
  13803. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13804. */
  13805. useRampGradients: boolean;
  13806. /**
  13807. * Adds a new color remap gradient
  13808. * @param gradient defines the gradient to use (between 0 and 1)
  13809. * @param min defines the color remap minimal range
  13810. * @param max defines the color remap maximal range
  13811. * @returns the current particle system
  13812. */
  13813. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13814. /**
  13815. * Gets the current list of color remap gradients.
  13816. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13817. * @returns the list of color remap gradients
  13818. */
  13819. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13820. /**
  13821. * Adds a new alpha remap gradient
  13822. * @param gradient defines the gradient to use (between 0 and 1)
  13823. * @param min defines the alpha remap minimal range
  13824. * @param max defines the alpha remap maximal range
  13825. * @returns the current particle system
  13826. */
  13827. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13828. /**
  13829. * Gets the current list of alpha remap gradients.
  13830. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13831. * @returns the list of alpha remap gradients
  13832. */
  13833. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13834. /**
  13835. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13838. * @returns the emitter
  13839. */
  13840. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13841. /**
  13842. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13843. * @param radius The radius of the hemisphere to emit from
  13844. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13845. * @returns the emitter
  13846. */
  13847. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13848. /**
  13849. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13850. * @param radius The radius of the sphere to emit from
  13851. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13852. * @returns the emitter
  13853. */
  13854. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13855. /**
  13856. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13857. * @param radius The radius of the sphere to emit from
  13858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13860. * @returns the emitter
  13861. */
  13862. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13863. /**
  13864. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13865. * @param radius The radius of the emission cylinder
  13866. * @param height The height of the emission cylinder
  13867. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13868. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13869. * @returns the emitter
  13870. */
  13871. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13872. /**
  13873. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13874. * @param radius The radius of the cylinder to emit from
  13875. * @param height The height of the emission cylinder
  13876. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13879. * @returns the emitter
  13880. */
  13881. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13882. /**
  13883. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13884. * @param radius The radius of the cone to emit from
  13885. * @param angle The base angle of the cone
  13886. * @returns the emitter
  13887. */
  13888. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13889. /**
  13890. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13891. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13892. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13893. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13894. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13895. * @returns the emitter
  13896. */
  13897. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13898. /**
  13899. * Get hosting scene
  13900. * @returns the scene
  13901. */
  13902. getScene(): Scene;
  13903. }
  13904. }
  13905. declare module "babylonjs/Meshes/transformNode" {
  13906. import { DeepImmutable } from "babylonjs/types";
  13907. import { Observable } from "babylonjs/Misc/observable";
  13908. import { Nullable } from "babylonjs/types";
  13909. import { Camera } from "babylonjs/Cameras/camera";
  13910. import { Scene } from "babylonjs/scene";
  13911. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13912. import { Node } from "babylonjs/node";
  13913. import { Bone } from "babylonjs/Bones/bone";
  13914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13915. import { Space } from "babylonjs/Maths/math.axis";
  13916. /**
  13917. * 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.
  13918. * @see https://doc.babylonjs.com/how_to/transformnode
  13919. */
  13920. export class TransformNode extends Node {
  13921. /**
  13922. * Object will not rotate to face the camera
  13923. */
  13924. static BILLBOARDMODE_NONE: number;
  13925. /**
  13926. * Object will rotate to face the camera but only on the x axis
  13927. */
  13928. static BILLBOARDMODE_X: number;
  13929. /**
  13930. * Object will rotate to face the camera but only on the y axis
  13931. */
  13932. static BILLBOARDMODE_Y: number;
  13933. /**
  13934. * Object will rotate to face the camera but only on the z axis
  13935. */
  13936. static BILLBOARDMODE_Z: number;
  13937. /**
  13938. * Object will rotate to face the camera
  13939. */
  13940. static BILLBOARDMODE_ALL: number;
  13941. /**
  13942. * Object will rotate to face the camera's position instead of orientation
  13943. */
  13944. static BILLBOARDMODE_USE_POSITION: number;
  13945. private _forward;
  13946. private _forwardInverted;
  13947. private _up;
  13948. private _right;
  13949. private _rightInverted;
  13950. private _position;
  13951. private _rotation;
  13952. private _rotationQuaternion;
  13953. protected _scaling: Vector3;
  13954. protected _isDirty: boolean;
  13955. private _transformToBoneReferal;
  13956. private _isAbsoluteSynced;
  13957. private _billboardMode;
  13958. /**
  13959. * Gets or sets the billboard mode. Default is 0.
  13960. *
  13961. * | Value | Type | Description |
  13962. * | --- | --- | --- |
  13963. * | 0 | BILLBOARDMODE_NONE | |
  13964. * | 1 | BILLBOARDMODE_X | |
  13965. * | 2 | BILLBOARDMODE_Y | |
  13966. * | 4 | BILLBOARDMODE_Z | |
  13967. * | 7 | BILLBOARDMODE_ALL | |
  13968. *
  13969. */
  13970. get billboardMode(): number;
  13971. set billboardMode(value: number);
  13972. private _preserveParentRotationForBillboard;
  13973. /**
  13974. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13975. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13976. */
  13977. get preserveParentRotationForBillboard(): boolean;
  13978. set preserveParentRotationForBillboard(value: boolean);
  13979. /**
  13980. * 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
  13981. */
  13982. scalingDeterminant: number;
  13983. private _infiniteDistance;
  13984. /**
  13985. * Gets or sets the distance of the object to max, often used by skybox
  13986. */
  13987. get infiniteDistance(): boolean;
  13988. set infiniteDistance(value: boolean);
  13989. /**
  13990. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13991. * By default the system will update normals to compensate
  13992. */
  13993. ignoreNonUniformScaling: boolean;
  13994. /**
  13995. * 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
  13996. */
  13997. reIntegrateRotationIntoRotationQuaternion: boolean;
  13998. /** @hidden */
  13999. _poseMatrix: Nullable<Matrix>;
  14000. /** @hidden */
  14001. _localMatrix: Matrix;
  14002. private _usePivotMatrix;
  14003. private _absolutePosition;
  14004. private _absoluteScaling;
  14005. private _absoluteRotationQuaternion;
  14006. private _pivotMatrix;
  14007. private _pivotMatrixInverse;
  14008. protected _postMultiplyPivotMatrix: boolean;
  14009. protected _isWorldMatrixFrozen: boolean;
  14010. /** @hidden */
  14011. _indexInSceneTransformNodesArray: number;
  14012. /**
  14013. * An event triggered after the world matrix is updated
  14014. */
  14015. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14016. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14017. /**
  14018. * Gets a string identifying the name of the class
  14019. * @returns "TransformNode" string
  14020. */
  14021. getClassName(): string;
  14022. /**
  14023. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14024. */
  14025. get position(): Vector3;
  14026. set position(newPosition: Vector3);
  14027. /**
  14028. * 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)).
  14029. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14030. */
  14031. get rotation(): Vector3;
  14032. set rotation(newRotation: Vector3);
  14033. /**
  14034. * 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)).
  14035. */
  14036. get scaling(): Vector3;
  14037. set scaling(newScaling: Vector3);
  14038. /**
  14039. * 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).
  14040. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14041. */
  14042. get rotationQuaternion(): Nullable<Quaternion>;
  14043. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14044. /**
  14045. * The forward direction of that transform in world space.
  14046. */
  14047. get forward(): Vector3;
  14048. /**
  14049. * The up direction of that transform in world space.
  14050. */
  14051. get up(): Vector3;
  14052. /**
  14053. * The right direction of that transform in world space.
  14054. */
  14055. get right(): Vector3;
  14056. /**
  14057. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14058. * @param matrix the matrix to copy the pose from
  14059. * @returns this TransformNode.
  14060. */
  14061. updatePoseMatrix(matrix: Matrix): TransformNode;
  14062. /**
  14063. * Returns the mesh Pose matrix.
  14064. * @returns the pose matrix
  14065. */
  14066. getPoseMatrix(): Matrix;
  14067. /** @hidden */
  14068. _isSynchronized(): boolean;
  14069. /** @hidden */
  14070. _initCache(): void;
  14071. /**
  14072. * Flag the transform node as dirty (Forcing it to update everything)
  14073. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14074. * @returns this transform node
  14075. */
  14076. markAsDirty(property: string): TransformNode;
  14077. /**
  14078. * Returns the current mesh absolute position.
  14079. * Returns a Vector3.
  14080. */
  14081. get absolutePosition(): Vector3;
  14082. /**
  14083. * Returns the current mesh absolute scaling.
  14084. * Returns a Vector3.
  14085. */
  14086. get absoluteScaling(): Vector3;
  14087. /**
  14088. * Returns the current mesh absolute rotation.
  14089. * Returns a Quaternion.
  14090. */
  14091. get absoluteRotationQuaternion(): Quaternion;
  14092. /**
  14093. * Sets a new matrix to apply before all other transformation
  14094. * @param matrix defines the transform matrix
  14095. * @returns the current TransformNode
  14096. */
  14097. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14098. /**
  14099. * Sets a new pivot matrix to the current node
  14100. * @param matrix defines the new pivot matrix to use
  14101. * @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
  14102. * @returns the current TransformNode
  14103. */
  14104. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14105. /**
  14106. * Returns the mesh pivot matrix.
  14107. * Default : Identity.
  14108. * @returns the matrix
  14109. */
  14110. getPivotMatrix(): Matrix;
  14111. /**
  14112. * Instantiate (when possible) or clone that node with its hierarchy
  14113. * @param newParent defines the new parent to use for the instance (or clone)
  14114. * @param options defines options to configure how copy is done
  14115. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14116. * @returns an instance (or a clone) of the current node with its hiearchy
  14117. */
  14118. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14119. doNotInstantiate: boolean;
  14120. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14121. /**
  14122. * Prevents the World matrix to be computed any longer
  14123. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14124. * @returns the TransformNode.
  14125. */
  14126. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14127. /**
  14128. * Allows back the World matrix computation.
  14129. * @returns the TransformNode.
  14130. */
  14131. unfreezeWorldMatrix(): this;
  14132. /**
  14133. * True if the World matrix has been frozen.
  14134. */
  14135. get isWorldMatrixFrozen(): boolean;
  14136. /**
  14137. * Retuns the mesh absolute position in the World.
  14138. * @returns a Vector3.
  14139. */
  14140. getAbsolutePosition(): Vector3;
  14141. /**
  14142. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14143. * @param absolutePosition the absolute position to set
  14144. * @returns the TransformNode.
  14145. */
  14146. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14147. /**
  14148. * Sets the mesh position in its local space.
  14149. * @param vector3 the position to set in localspace
  14150. * @returns the TransformNode.
  14151. */
  14152. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14153. /**
  14154. * Returns the mesh position in the local space from the current World matrix values.
  14155. * @returns a new Vector3.
  14156. */
  14157. getPositionExpressedInLocalSpace(): Vector3;
  14158. /**
  14159. * Translates the mesh along the passed Vector3 in its local space.
  14160. * @param vector3 the distance to translate in localspace
  14161. * @returns the TransformNode.
  14162. */
  14163. locallyTranslate(vector3: Vector3): TransformNode;
  14164. private static _lookAtVectorCache;
  14165. /**
  14166. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14167. * @param targetPoint the position (must be in same space as current mesh) to look at
  14168. * @param yawCor optional yaw (y-axis) correction in radians
  14169. * @param pitchCor optional pitch (x-axis) correction in radians
  14170. * @param rollCor optional roll (z-axis) correction in radians
  14171. * @param space the choosen space of the target
  14172. * @returns the TransformNode.
  14173. */
  14174. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14175. /**
  14176. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14177. * This Vector3 is expressed in the World space.
  14178. * @param localAxis axis to rotate
  14179. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14180. */
  14181. getDirection(localAxis: Vector3): Vector3;
  14182. /**
  14183. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14184. * localAxis is expressed in the mesh local space.
  14185. * result is computed in the Wordl space from the mesh World matrix.
  14186. * @param localAxis axis to rotate
  14187. * @param result the resulting transformnode
  14188. * @returns this TransformNode.
  14189. */
  14190. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14191. /**
  14192. * Sets this transform node rotation to the given local axis.
  14193. * @param localAxis the axis in local space
  14194. * @param yawCor optional yaw (y-axis) correction in radians
  14195. * @param pitchCor optional pitch (x-axis) correction in radians
  14196. * @param rollCor optional roll (z-axis) correction in radians
  14197. * @returns this TransformNode
  14198. */
  14199. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14200. /**
  14201. * Sets a new pivot point to the current node
  14202. * @param point defines the new pivot point to use
  14203. * @param space defines if the point is in world or local space (local by default)
  14204. * @returns the current TransformNode
  14205. */
  14206. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14207. /**
  14208. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14209. * @returns the pivot point
  14210. */
  14211. getPivotPoint(): Vector3;
  14212. /**
  14213. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14214. * @param result the vector3 to store the result
  14215. * @returns this TransformNode.
  14216. */
  14217. getPivotPointToRef(result: Vector3): TransformNode;
  14218. /**
  14219. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14220. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14221. */
  14222. getAbsolutePivotPoint(): Vector3;
  14223. /**
  14224. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14225. * @param result vector3 to store the result
  14226. * @returns this TransformNode.
  14227. */
  14228. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14229. /**
  14230. * Defines the passed node as the parent of the current node.
  14231. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14232. * @see https://doc.babylonjs.com/how_to/parenting
  14233. * @param node the node ot set as the parent
  14234. * @returns this TransformNode.
  14235. */
  14236. setParent(node: Nullable<Node>): TransformNode;
  14237. private _nonUniformScaling;
  14238. /**
  14239. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14240. */
  14241. get nonUniformScaling(): boolean;
  14242. /** @hidden */
  14243. _updateNonUniformScalingState(value: boolean): boolean;
  14244. /**
  14245. * Attach the current TransformNode to another TransformNode associated with a bone
  14246. * @param bone Bone affecting the TransformNode
  14247. * @param affectedTransformNode TransformNode associated with the bone
  14248. * @returns this object
  14249. */
  14250. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14251. /**
  14252. * Detach the transform node if its associated with a bone
  14253. * @returns this object
  14254. */
  14255. detachFromBone(): TransformNode;
  14256. private static _rotationAxisCache;
  14257. /**
  14258. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14259. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14260. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14261. * The passed axis is also normalized.
  14262. * @param axis the axis to rotate around
  14263. * @param amount the amount to rotate in radians
  14264. * @param space Space to rotate in (Default: local)
  14265. * @returns the TransformNode.
  14266. */
  14267. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14268. /**
  14269. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14270. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14271. * The passed axis is also normalized. .
  14272. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14273. * @param point the point to rotate around
  14274. * @param axis the axis to rotate around
  14275. * @param amount the amount to rotate in radians
  14276. * @returns the TransformNode
  14277. */
  14278. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14279. /**
  14280. * Translates the mesh along the axis vector for the passed distance in the given space.
  14281. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14282. * @param axis the axis to translate in
  14283. * @param distance the distance to translate
  14284. * @param space Space to rotate in (Default: local)
  14285. * @returns the TransformNode.
  14286. */
  14287. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14288. /**
  14289. * Adds a rotation step to the mesh current rotation.
  14290. * x, y, z are Euler angles expressed in radians.
  14291. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14292. * This means this rotation is made in the mesh local space only.
  14293. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14294. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14295. * ```javascript
  14296. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14297. * ```
  14298. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14299. * 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.
  14300. * @param x Rotation to add
  14301. * @param y Rotation to add
  14302. * @param z Rotation to add
  14303. * @returns the TransformNode.
  14304. */
  14305. addRotation(x: number, y: number, z: number): TransformNode;
  14306. /**
  14307. * @hidden
  14308. */
  14309. protected _getEffectiveParent(): Nullable<Node>;
  14310. /**
  14311. * Computes the world matrix of the node
  14312. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14313. * @returns the world matrix
  14314. */
  14315. computeWorldMatrix(force?: boolean): Matrix;
  14316. /**
  14317. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14318. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14319. */
  14320. resetLocalMatrix(independentOfChildren?: boolean): void;
  14321. protected _afterComputeWorldMatrix(): void;
  14322. /**
  14323. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14324. * @param func callback function to add
  14325. *
  14326. * @returns the TransformNode.
  14327. */
  14328. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14329. /**
  14330. * Removes a registered callback function.
  14331. * @param func callback function to remove
  14332. * @returns the TransformNode.
  14333. */
  14334. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14335. /**
  14336. * Gets the position of the current mesh in camera space
  14337. * @param camera defines the camera to use
  14338. * @returns a position
  14339. */
  14340. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14341. /**
  14342. * Returns the distance from the mesh to the active camera
  14343. * @param camera defines the camera to use
  14344. * @returns the distance
  14345. */
  14346. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14347. /**
  14348. * Clone the current transform node
  14349. * @param name Name of the new clone
  14350. * @param newParent New parent for the clone
  14351. * @param doNotCloneChildren Do not clone children hierarchy
  14352. * @returns the new transform node
  14353. */
  14354. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14355. /**
  14356. * Serializes the objects information.
  14357. * @param currentSerializationObject defines the object to serialize in
  14358. * @returns the serialized object
  14359. */
  14360. serialize(currentSerializationObject?: any): any;
  14361. /**
  14362. * Returns a new TransformNode object parsed from the source provided.
  14363. * @param parsedTransformNode is the source.
  14364. * @param scene the scne the object belongs to
  14365. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14366. * @returns a new TransformNode object parsed from the source provided.
  14367. */
  14368. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14369. /**
  14370. * Get all child-transformNodes of this node
  14371. * @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
  14372. * @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
  14373. * @returns an array of TransformNode
  14374. */
  14375. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14376. /**
  14377. * Releases resources associated with this transform node.
  14378. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14379. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14380. */
  14381. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14382. /**
  14383. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14384. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14385. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14386. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14387. * @returns the current mesh
  14388. */
  14389. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14390. private _syncAbsoluteScalingAndRotation;
  14391. }
  14392. }
  14393. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14394. /**
  14395. * Class used to override all child animations of a given target
  14396. */
  14397. export class AnimationPropertiesOverride {
  14398. /**
  14399. * Gets or sets a value indicating if animation blending must be used
  14400. */
  14401. enableBlending: boolean;
  14402. /**
  14403. * Gets or sets the blending speed to use when enableBlending is true
  14404. */
  14405. blendingSpeed: number;
  14406. /**
  14407. * Gets or sets the default loop mode to use
  14408. */
  14409. loopMode: number;
  14410. }
  14411. }
  14412. declare module "babylonjs/Bones/bone" {
  14413. import { Skeleton } from "babylonjs/Bones/skeleton";
  14414. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14415. import { Nullable } from "babylonjs/types";
  14416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14417. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14418. import { Node } from "babylonjs/node";
  14419. import { Space } from "babylonjs/Maths/math.axis";
  14420. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14421. /**
  14422. * Class used to store bone information
  14423. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14424. */
  14425. export class Bone extends Node {
  14426. /**
  14427. * defines the bone name
  14428. */
  14429. name: string;
  14430. private static _tmpVecs;
  14431. private static _tmpQuat;
  14432. private static _tmpMats;
  14433. /**
  14434. * Gets the list of child bones
  14435. */
  14436. children: Bone[];
  14437. /** Gets the animations associated with this bone */
  14438. animations: import("babylonjs/Animations/animation").Animation[];
  14439. /**
  14440. * Gets or sets bone length
  14441. */
  14442. length: number;
  14443. /**
  14444. * @hidden Internal only
  14445. * Set this value to map this bone to a different index in the transform matrices
  14446. * Set this value to -1 to exclude the bone from the transform matrices
  14447. */
  14448. _index: Nullable<number>;
  14449. private _skeleton;
  14450. private _localMatrix;
  14451. private _restPose;
  14452. private _baseMatrix;
  14453. private _absoluteTransform;
  14454. private _invertedAbsoluteTransform;
  14455. private _parent;
  14456. private _scalingDeterminant;
  14457. private _worldTransform;
  14458. private _localScaling;
  14459. private _localRotation;
  14460. private _localPosition;
  14461. private _needToDecompose;
  14462. private _needToCompose;
  14463. /** @hidden */
  14464. _linkedTransformNode: Nullable<TransformNode>;
  14465. /** @hidden */
  14466. _waitingTransformNodeId: Nullable<string>;
  14467. /** @hidden */
  14468. get _matrix(): Matrix;
  14469. /** @hidden */
  14470. set _matrix(value: Matrix);
  14471. /**
  14472. * Create a new bone
  14473. * @param name defines the bone name
  14474. * @param skeleton defines the parent skeleton
  14475. * @param parentBone defines the parent (can be null if the bone is the root)
  14476. * @param localMatrix defines the local matrix
  14477. * @param restPose defines the rest pose matrix
  14478. * @param baseMatrix defines the base matrix
  14479. * @param index defines index of the bone in the hiearchy
  14480. */
  14481. constructor(
  14482. /**
  14483. * defines the bone name
  14484. */
  14485. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14486. /**
  14487. * Gets the current object class name.
  14488. * @return the class name
  14489. */
  14490. getClassName(): string;
  14491. /**
  14492. * Gets the parent skeleton
  14493. * @returns a skeleton
  14494. */
  14495. getSkeleton(): Skeleton;
  14496. /**
  14497. * Gets parent bone
  14498. * @returns a bone or null if the bone is the root of the bone hierarchy
  14499. */
  14500. getParent(): Nullable<Bone>;
  14501. /**
  14502. * Returns an array containing the root bones
  14503. * @returns an array containing the root bones
  14504. */
  14505. getChildren(): Array<Bone>;
  14506. /**
  14507. * Gets the node index in matrix array generated for rendering
  14508. * @returns the node index
  14509. */
  14510. getIndex(): number;
  14511. /**
  14512. * Sets the parent bone
  14513. * @param parent defines the parent (can be null if the bone is the root)
  14514. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14515. */
  14516. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14517. /**
  14518. * Gets the local matrix
  14519. * @returns a matrix
  14520. */
  14521. getLocalMatrix(): Matrix;
  14522. /**
  14523. * Gets the base matrix (initial matrix which remains unchanged)
  14524. * @returns a matrix
  14525. */
  14526. getBaseMatrix(): Matrix;
  14527. /**
  14528. * Gets the rest pose matrix
  14529. * @returns a matrix
  14530. */
  14531. getRestPose(): Matrix;
  14532. /**
  14533. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14534. */
  14535. getWorldMatrix(): Matrix;
  14536. /**
  14537. * Sets the local matrix to rest pose matrix
  14538. */
  14539. returnToRest(): void;
  14540. /**
  14541. * Gets the inverse of the absolute transform matrix.
  14542. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14543. * @returns a matrix
  14544. */
  14545. getInvertedAbsoluteTransform(): Matrix;
  14546. /**
  14547. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14548. * @returns a matrix
  14549. */
  14550. getAbsoluteTransform(): Matrix;
  14551. /**
  14552. * Links with the given transform node.
  14553. * The local matrix of this bone is copied from the transform node every frame.
  14554. * @param transformNode defines the transform node to link to
  14555. */
  14556. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14557. /**
  14558. * Gets the node used to drive the bone's transformation
  14559. * @returns a transform node or null
  14560. */
  14561. getTransformNode(): Nullable<TransformNode>;
  14562. /** Gets or sets current position (in local space) */
  14563. get position(): Vector3;
  14564. set position(newPosition: Vector3);
  14565. /** Gets or sets current rotation (in local space) */
  14566. get rotation(): Vector3;
  14567. set rotation(newRotation: Vector3);
  14568. /** Gets or sets current rotation quaternion (in local space) */
  14569. get rotationQuaternion(): Quaternion;
  14570. set rotationQuaternion(newRotation: Quaternion);
  14571. /** Gets or sets current scaling (in local space) */
  14572. get scaling(): Vector3;
  14573. set scaling(newScaling: Vector3);
  14574. /**
  14575. * Gets the animation properties override
  14576. */
  14577. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14578. private _decompose;
  14579. private _compose;
  14580. /**
  14581. * Update the base and local matrices
  14582. * @param matrix defines the new base or local matrix
  14583. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14584. * @param updateLocalMatrix defines if the local matrix should be updated
  14585. */
  14586. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14587. /** @hidden */
  14588. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14589. /**
  14590. * Flag the bone as dirty (Forcing it to update everything)
  14591. */
  14592. markAsDirty(): void;
  14593. /** @hidden */
  14594. _markAsDirtyAndCompose(): void;
  14595. private _markAsDirtyAndDecompose;
  14596. /**
  14597. * Translate the bone in local or world space
  14598. * @param vec The amount to translate the bone
  14599. * @param space The space that the translation is in
  14600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14601. */
  14602. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14603. /**
  14604. * Set the postion of the bone in local or world space
  14605. * @param position The position to set the bone
  14606. * @param space The space that the position is in
  14607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14608. */
  14609. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14610. /**
  14611. * Set the absolute position of the bone (world space)
  14612. * @param position The position to set the bone
  14613. * @param mesh The mesh that this bone is attached to
  14614. */
  14615. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14616. /**
  14617. * Scale the bone on the x, y and z axes (in local space)
  14618. * @param x The amount to scale the bone on the x axis
  14619. * @param y The amount to scale the bone on the y axis
  14620. * @param z The amount to scale the bone on the z axis
  14621. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14622. */
  14623. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14624. /**
  14625. * Set the bone scaling in local space
  14626. * @param scale defines the scaling vector
  14627. */
  14628. setScale(scale: Vector3): void;
  14629. /**
  14630. * Gets the current scaling in local space
  14631. * @returns the current scaling vector
  14632. */
  14633. getScale(): Vector3;
  14634. /**
  14635. * Gets the current scaling in local space and stores it in a target vector
  14636. * @param result defines the target vector
  14637. */
  14638. getScaleToRef(result: Vector3): void;
  14639. /**
  14640. * Set the yaw, pitch, and roll of the bone in local or world space
  14641. * @param yaw The rotation of the bone on the y axis
  14642. * @param pitch The rotation of the bone on the x axis
  14643. * @param roll The rotation of the bone on the z axis
  14644. * @param space The space that the axes of rotation are in
  14645. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14646. */
  14647. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14648. /**
  14649. * Add a rotation to the bone on an axis in local or world space
  14650. * @param axis The axis to rotate the bone on
  14651. * @param amount The amount to rotate the bone
  14652. * @param space The space that the axis is in
  14653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14654. */
  14655. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14656. /**
  14657. * Set the rotation of the bone to a particular axis angle in local or world space
  14658. * @param axis The axis to rotate the bone on
  14659. * @param angle The angle that the bone should be rotated to
  14660. * @param space The space that the axis is in
  14661. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14662. */
  14663. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14664. /**
  14665. * Set the euler rotation of the bone in local of world space
  14666. * @param rotation The euler rotation that the bone should be set to
  14667. * @param space The space that the rotation is in
  14668. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14669. */
  14670. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14671. /**
  14672. * Set the quaternion rotation of the bone in local of world space
  14673. * @param quat The quaternion rotation that the bone should be set to
  14674. * @param space The space that the rotation is in
  14675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14676. */
  14677. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14678. /**
  14679. * Set the rotation matrix of the bone in local of world space
  14680. * @param rotMat The rotation matrix that the bone should be set to
  14681. * @param space The space that the rotation is in
  14682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14683. */
  14684. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14685. private _rotateWithMatrix;
  14686. private _getNegativeRotationToRef;
  14687. /**
  14688. * Get the position of the bone in local or world space
  14689. * @param space The space that the returned position is in
  14690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14691. * @returns The position of the bone
  14692. */
  14693. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14694. /**
  14695. * Copy the position of the bone to a vector3 in local or world space
  14696. * @param space The space that the returned position is in
  14697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14698. * @param result The vector3 to copy the position to
  14699. */
  14700. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14701. /**
  14702. * Get the absolute position of the bone (world space)
  14703. * @param mesh The mesh that this bone is attached to
  14704. * @returns The absolute position of the bone
  14705. */
  14706. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14707. /**
  14708. * Copy the absolute position of the bone (world space) to the result param
  14709. * @param mesh The mesh that this bone is attached to
  14710. * @param result The vector3 to copy the absolute position to
  14711. */
  14712. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14713. /**
  14714. * Compute the absolute transforms of this bone and its children
  14715. */
  14716. computeAbsoluteTransforms(): void;
  14717. /**
  14718. * Get the world direction from an axis that is in the local space of the bone
  14719. * @param localAxis The local direction that is used to compute the world direction
  14720. * @param mesh The mesh that this bone is attached to
  14721. * @returns The world direction
  14722. */
  14723. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14724. /**
  14725. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14726. * @param localAxis The local direction that is used to compute the world direction
  14727. * @param mesh The mesh that this bone is attached to
  14728. * @param result The vector3 that the world direction will be copied to
  14729. */
  14730. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14731. /**
  14732. * Get the euler rotation of the bone in local or world space
  14733. * @param space The space that the rotation should be in
  14734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14735. * @returns The euler rotation
  14736. */
  14737. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14738. /**
  14739. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14740. * @param space The space that the rotation should be in
  14741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14742. * @param result The vector3 that the rotation should be copied to
  14743. */
  14744. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14745. /**
  14746. * Get the quaternion rotation of the bone in either local or world space
  14747. * @param space The space that the rotation should be in
  14748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14749. * @returns The quaternion rotation
  14750. */
  14751. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14752. /**
  14753. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14754. * @param space The space that the rotation should be in
  14755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14756. * @param result The quaternion that the rotation should be copied to
  14757. */
  14758. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14759. /**
  14760. * Get the rotation matrix of the bone in local or world space
  14761. * @param space The space that the rotation should be in
  14762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14763. * @returns The rotation matrix
  14764. */
  14765. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14766. /**
  14767. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14768. * @param space The space that the rotation should be in
  14769. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14770. * @param result The quaternion that the rotation should be copied to
  14771. */
  14772. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14773. /**
  14774. * Get the world position of a point that is in the local space of the bone
  14775. * @param position The local position
  14776. * @param mesh The mesh that this bone is attached to
  14777. * @returns The world position
  14778. */
  14779. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14780. /**
  14781. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14782. * @param position The local position
  14783. * @param mesh The mesh that this bone is attached to
  14784. * @param result The vector3 that the world position should be copied to
  14785. */
  14786. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14787. /**
  14788. * Get the local position of a point that is in world space
  14789. * @param position The world position
  14790. * @param mesh The mesh that this bone is attached to
  14791. * @returns The local position
  14792. */
  14793. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14794. /**
  14795. * Get the local position of a point that is in world space and copy it to the result param
  14796. * @param position The world position
  14797. * @param mesh The mesh that this bone is attached to
  14798. * @param result The vector3 that the local position should be copied to
  14799. */
  14800. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14801. }
  14802. }
  14803. declare module "babylonjs/Animations/runtimeAnimation" {
  14804. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14805. import { Animatable } from "babylonjs/Animations/animatable";
  14806. import { Scene } from "babylonjs/scene";
  14807. /**
  14808. * Defines a runtime animation
  14809. */
  14810. export class RuntimeAnimation {
  14811. private _events;
  14812. /**
  14813. * The current frame of the runtime animation
  14814. */
  14815. private _currentFrame;
  14816. /**
  14817. * The animation used by the runtime animation
  14818. */
  14819. private _animation;
  14820. /**
  14821. * The target of the runtime animation
  14822. */
  14823. private _target;
  14824. /**
  14825. * The initiating animatable
  14826. */
  14827. private _host;
  14828. /**
  14829. * The original value of the runtime animation
  14830. */
  14831. private _originalValue;
  14832. /**
  14833. * The original blend value of the runtime animation
  14834. */
  14835. private _originalBlendValue;
  14836. /**
  14837. * The offsets cache of the runtime animation
  14838. */
  14839. private _offsetsCache;
  14840. /**
  14841. * The high limits cache of the runtime animation
  14842. */
  14843. private _highLimitsCache;
  14844. /**
  14845. * Specifies if the runtime animation has been stopped
  14846. */
  14847. private _stopped;
  14848. /**
  14849. * The blending factor of the runtime animation
  14850. */
  14851. private _blendingFactor;
  14852. /**
  14853. * The BabylonJS scene
  14854. */
  14855. private _scene;
  14856. /**
  14857. * The current value of the runtime animation
  14858. */
  14859. private _currentValue;
  14860. /** @hidden */
  14861. _animationState: _IAnimationState;
  14862. /**
  14863. * The active target of the runtime animation
  14864. */
  14865. private _activeTargets;
  14866. private _currentActiveTarget;
  14867. private _directTarget;
  14868. /**
  14869. * The target path of the runtime animation
  14870. */
  14871. private _targetPath;
  14872. /**
  14873. * The weight of the runtime animation
  14874. */
  14875. private _weight;
  14876. /**
  14877. * The ratio offset of the runtime animation
  14878. */
  14879. private _ratioOffset;
  14880. /**
  14881. * The previous delay of the runtime animation
  14882. */
  14883. private _previousDelay;
  14884. /**
  14885. * The previous ratio of the runtime animation
  14886. */
  14887. private _previousRatio;
  14888. private _enableBlending;
  14889. private _keys;
  14890. private _minFrame;
  14891. private _maxFrame;
  14892. private _minValue;
  14893. private _maxValue;
  14894. private _targetIsArray;
  14895. /**
  14896. * Gets the current frame of the runtime animation
  14897. */
  14898. get currentFrame(): number;
  14899. /**
  14900. * Gets the weight of the runtime animation
  14901. */
  14902. get weight(): number;
  14903. /**
  14904. * Gets the current value of the runtime animation
  14905. */
  14906. get currentValue(): any;
  14907. /**
  14908. * Gets the target path of the runtime animation
  14909. */
  14910. get targetPath(): string;
  14911. /**
  14912. * Gets the actual target of the runtime animation
  14913. */
  14914. get target(): any;
  14915. /**
  14916. * Gets the additive state of the runtime animation
  14917. */
  14918. get isAdditive(): boolean;
  14919. /** @hidden */
  14920. _onLoop: () => void;
  14921. /**
  14922. * Create a new RuntimeAnimation object
  14923. * @param target defines the target of the animation
  14924. * @param animation defines the source animation object
  14925. * @param scene defines the hosting scene
  14926. * @param host defines the initiating Animatable
  14927. */
  14928. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14929. private _preparePath;
  14930. /**
  14931. * Gets the animation from the runtime animation
  14932. */
  14933. get animation(): Animation;
  14934. /**
  14935. * Resets the runtime animation to the beginning
  14936. * @param restoreOriginal defines whether to restore the target property to the original value
  14937. */
  14938. reset(restoreOriginal?: boolean): void;
  14939. /**
  14940. * Specifies if the runtime animation is stopped
  14941. * @returns Boolean specifying if the runtime animation is stopped
  14942. */
  14943. isStopped(): boolean;
  14944. /**
  14945. * Disposes of the runtime animation
  14946. */
  14947. dispose(): void;
  14948. /**
  14949. * Apply the interpolated value to the target
  14950. * @param currentValue defines the value computed by the animation
  14951. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14952. */
  14953. setValue(currentValue: any, weight: number): void;
  14954. private _getOriginalValues;
  14955. private _setValue;
  14956. /**
  14957. * Gets the loop pmode of the runtime animation
  14958. * @returns Loop Mode
  14959. */
  14960. private _getCorrectLoopMode;
  14961. /**
  14962. * Move the current animation to a given frame
  14963. * @param frame defines the frame to move to
  14964. */
  14965. goToFrame(frame: number): void;
  14966. /**
  14967. * @hidden Internal use only
  14968. */
  14969. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14970. /**
  14971. * Execute the current animation
  14972. * @param delay defines the delay to add to the current frame
  14973. * @param from defines the lower bound of the animation range
  14974. * @param to defines the upper bound of the animation range
  14975. * @param loop defines if the current animation must loop
  14976. * @param speedRatio defines the current speed ratio
  14977. * @param weight defines the weight of the animation (default is -1 so no weight)
  14978. * @param onLoop optional callback called when animation loops
  14979. * @returns a boolean indicating if the animation is running
  14980. */
  14981. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14982. }
  14983. }
  14984. declare module "babylonjs/Animations/animatable" {
  14985. import { Animation } from "babylonjs/Animations/animation";
  14986. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14987. import { Nullable } from "babylonjs/types";
  14988. import { Observable } from "babylonjs/Misc/observable";
  14989. import { Scene } from "babylonjs/scene";
  14990. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14991. import { Node } from "babylonjs/node";
  14992. /**
  14993. * Class used to store an actual running animation
  14994. */
  14995. export class Animatable {
  14996. /** defines the target object */
  14997. target: any;
  14998. /** defines the starting frame number (default is 0) */
  14999. fromFrame: number;
  15000. /** defines the ending frame number (default is 100) */
  15001. toFrame: number;
  15002. /** defines if the animation must loop (default is false) */
  15003. loopAnimation: boolean;
  15004. /** defines a callback to call when animation ends if it is not looping */
  15005. onAnimationEnd?: (() => void) | null | undefined;
  15006. /** defines a callback to call when animation loops */
  15007. onAnimationLoop?: (() => void) | null | undefined;
  15008. /** defines whether the animation should be evaluated additively */
  15009. isAdditive: boolean;
  15010. private _localDelayOffset;
  15011. private _pausedDelay;
  15012. private _runtimeAnimations;
  15013. private _paused;
  15014. private _scene;
  15015. private _speedRatio;
  15016. private _weight;
  15017. private _syncRoot;
  15018. /**
  15019. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15020. * This will only apply for non looping animation (default is true)
  15021. */
  15022. disposeOnEnd: boolean;
  15023. /**
  15024. * Gets a boolean indicating if the animation has started
  15025. */
  15026. animationStarted: boolean;
  15027. /**
  15028. * Observer raised when the animation ends
  15029. */
  15030. onAnimationEndObservable: Observable<Animatable>;
  15031. /**
  15032. * Observer raised when the animation loops
  15033. */
  15034. onAnimationLoopObservable: Observable<Animatable>;
  15035. /**
  15036. * Gets the root Animatable used to synchronize and normalize animations
  15037. */
  15038. get syncRoot(): Nullable<Animatable>;
  15039. /**
  15040. * Gets the current frame of the first RuntimeAnimation
  15041. * Used to synchronize Animatables
  15042. */
  15043. get masterFrame(): number;
  15044. /**
  15045. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15046. */
  15047. get weight(): number;
  15048. set weight(value: number);
  15049. /**
  15050. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15051. */
  15052. get speedRatio(): number;
  15053. set speedRatio(value: number);
  15054. /**
  15055. * Creates a new Animatable
  15056. * @param scene defines the hosting scene
  15057. * @param target defines the target object
  15058. * @param fromFrame defines the starting frame number (default is 0)
  15059. * @param toFrame defines the ending frame number (default is 100)
  15060. * @param loopAnimation defines if the animation must loop (default is false)
  15061. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15062. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15063. * @param animations defines a group of animation to add to the new Animatable
  15064. * @param onAnimationLoop defines a callback to call when animation loops
  15065. * @param isAdditive defines whether the animation should be evaluated additively
  15066. */
  15067. constructor(scene: Scene,
  15068. /** defines the target object */
  15069. target: any,
  15070. /** defines the starting frame number (default is 0) */
  15071. fromFrame?: number,
  15072. /** defines the ending frame number (default is 100) */
  15073. toFrame?: number,
  15074. /** defines if the animation must loop (default is false) */
  15075. loopAnimation?: boolean, speedRatio?: number,
  15076. /** defines a callback to call when animation ends if it is not looping */
  15077. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15078. /** defines a callback to call when animation loops */
  15079. onAnimationLoop?: (() => void) | null | undefined,
  15080. /** defines whether the animation should be evaluated additively */
  15081. isAdditive?: boolean);
  15082. /**
  15083. * Synchronize and normalize current Animatable with a source Animatable
  15084. * This is useful when using animation weights and when animations are not of the same length
  15085. * @param root defines the root Animatable to synchronize with
  15086. * @returns the current Animatable
  15087. */
  15088. syncWith(root: Animatable): Animatable;
  15089. /**
  15090. * Gets the list of runtime animations
  15091. * @returns an array of RuntimeAnimation
  15092. */
  15093. getAnimations(): RuntimeAnimation[];
  15094. /**
  15095. * Adds more animations to the current animatable
  15096. * @param target defines the target of the animations
  15097. * @param animations defines the new animations to add
  15098. */
  15099. appendAnimations(target: any, animations: Animation[]): void;
  15100. /**
  15101. * Gets the source animation for a specific property
  15102. * @param property defines the propertyu to look for
  15103. * @returns null or the source animation for the given property
  15104. */
  15105. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15106. /**
  15107. * Gets the runtime animation for a specific property
  15108. * @param property defines the propertyu to look for
  15109. * @returns null or the runtime animation for the given property
  15110. */
  15111. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15112. /**
  15113. * Resets the animatable to its original state
  15114. */
  15115. reset(): void;
  15116. /**
  15117. * Allows the animatable to blend with current running animations
  15118. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15119. * @param blendingSpeed defines the blending speed to use
  15120. */
  15121. enableBlending(blendingSpeed: number): void;
  15122. /**
  15123. * Disable animation blending
  15124. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15125. */
  15126. disableBlending(): void;
  15127. /**
  15128. * Jump directly to a given frame
  15129. * @param frame defines the frame to jump to
  15130. */
  15131. goToFrame(frame: number): void;
  15132. /**
  15133. * Pause the animation
  15134. */
  15135. pause(): void;
  15136. /**
  15137. * Restart the animation
  15138. */
  15139. restart(): void;
  15140. private _raiseOnAnimationEnd;
  15141. /**
  15142. * Stop and delete the current animation
  15143. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15144. * @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)
  15145. */
  15146. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15147. /**
  15148. * Wait asynchronously for the animation to end
  15149. * @returns a promise which will be fullfilled when the animation ends
  15150. */
  15151. waitAsync(): Promise<Animatable>;
  15152. /** @hidden */
  15153. _animate(delay: number): boolean;
  15154. }
  15155. module "babylonjs/scene" {
  15156. interface Scene {
  15157. /** @hidden */
  15158. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15159. /** @hidden */
  15160. _processLateAnimationBindingsForMatrices(holder: {
  15161. totalWeight: number;
  15162. totalAdditiveWeight: number;
  15163. animations: RuntimeAnimation[];
  15164. additiveAnimations: RuntimeAnimation[];
  15165. originalValue: Matrix;
  15166. }): any;
  15167. /** @hidden */
  15168. _processLateAnimationBindingsForQuaternions(holder: {
  15169. totalWeight: number;
  15170. totalAdditiveWeight: number;
  15171. animations: RuntimeAnimation[];
  15172. additiveAnimations: RuntimeAnimation[];
  15173. originalValue: Quaternion;
  15174. }, refQuaternion: Quaternion): Quaternion;
  15175. /** @hidden */
  15176. _processLateAnimationBindings(): void;
  15177. /**
  15178. * Will start the animation sequence of a given target
  15179. * @param target defines the target
  15180. * @param from defines from which frame should animation start
  15181. * @param to defines until which frame should animation run.
  15182. * @param weight defines the weight to apply to the animation (1.0 by default)
  15183. * @param loop defines if the animation loops
  15184. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15185. * @param onAnimationEnd defines the function to be executed when the animation ends
  15186. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15187. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15188. * @param onAnimationLoop defines the callback to call when an animation loops
  15189. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15190. * @returns the animatable object created for this animation
  15191. */
  15192. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15193. /**
  15194. * Will start the animation sequence of a given target
  15195. * @param target defines the target
  15196. * @param from defines from which frame should animation start
  15197. * @param to defines until which frame should animation run.
  15198. * @param loop defines if the animation loops
  15199. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15200. * @param onAnimationEnd defines the function to be executed when the animation ends
  15201. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15202. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15203. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15204. * @param onAnimationLoop defines the callback to call when an animation loops
  15205. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15206. * @returns the animatable object created for this animation
  15207. */
  15208. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15209. /**
  15210. * Will start the animation sequence of a given target and its hierarchy
  15211. * @param target defines the target
  15212. * @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.
  15213. * @param from defines from which frame should animation start
  15214. * @param to defines until which frame should animation run.
  15215. * @param loop defines if the animation loops
  15216. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15217. * @param onAnimationEnd defines the function to be executed when the animation ends
  15218. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15219. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15220. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15221. * @param onAnimationLoop defines the callback to call when an animation loops
  15222. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15223. * @returns the list of created animatables
  15224. */
  15225. 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, isAdditive?: boolean): Animatable[];
  15226. /**
  15227. * Begin a new animation on a given node
  15228. * @param target defines the target where the animation will take place
  15229. * @param animations defines the list of animations to start
  15230. * @param from defines the initial value
  15231. * @param to defines the final value
  15232. * @param loop defines if you want animation to loop (off by default)
  15233. * @param speedRatio defines the speed ratio to apply to all animations
  15234. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15235. * @param onAnimationLoop defines the callback to call when an animation loops
  15236. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15237. * @returns the list of created animatables
  15238. */
  15239. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15240. /**
  15241. * Begin a new animation on a given node and its hierarchy
  15242. * @param target defines the root node where the animation will take place
  15243. * @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.
  15244. * @param animations defines the list of animations to start
  15245. * @param from defines the initial value
  15246. * @param to defines the final value
  15247. * @param loop defines if you want animation to loop (off by default)
  15248. * @param speedRatio defines the speed ratio to apply to all animations
  15249. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15250. * @param onAnimationLoop defines the callback to call when an animation loops
  15251. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15252. * @returns the list of animatables created for all nodes
  15253. */
  15254. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15255. /**
  15256. * Gets the animatable associated with a specific target
  15257. * @param target defines the target of the animatable
  15258. * @returns the required animatable if found
  15259. */
  15260. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15261. /**
  15262. * Gets all animatables associated with a given target
  15263. * @param target defines the target to look animatables for
  15264. * @returns an array of Animatables
  15265. */
  15266. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15267. /**
  15268. * Stops and removes all animations that have been applied to the scene
  15269. */
  15270. stopAllAnimations(): void;
  15271. /**
  15272. * Gets the current delta time used by animation engine
  15273. */
  15274. deltaTime: number;
  15275. }
  15276. }
  15277. module "babylonjs/Bones/bone" {
  15278. interface Bone {
  15279. /**
  15280. * Copy an animation range from another bone
  15281. * @param source defines the source bone
  15282. * @param rangeName defines the range name to copy
  15283. * @param frameOffset defines the frame offset
  15284. * @param rescaleAsRequired defines if rescaling must be applied if required
  15285. * @param skelDimensionsRatio defines the scaling ratio
  15286. * @returns true if operation was successful
  15287. */
  15288. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15289. }
  15290. }
  15291. }
  15292. declare module "babylonjs/Bones/skeleton" {
  15293. import { Bone } from "babylonjs/Bones/bone";
  15294. import { Observable } from "babylonjs/Misc/observable";
  15295. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15296. import { Scene } from "babylonjs/scene";
  15297. import { Nullable } from "babylonjs/types";
  15298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15299. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15300. import { Animatable } from "babylonjs/Animations/animatable";
  15301. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15302. import { Animation } from "babylonjs/Animations/animation";
  15303. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15304. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15305. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15306. /**
  15307. * Class used to handle skinning animations
  15308. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15309. */
  15310. export class Skeleton implements IAnimatable {
  15311. /** defines the skeleton name */
  15312. name: string;
  15313. /** defines the skeleton Id */
  15314. id: string;
  15315. /**
  15316. * Defines the list of child bones
  15317. */
  15318. bones: Bone[];
  15319. /**
  15320. * Defines an estimate of the dimension of the skeleton at rest
  15321. */
  15322. dimensionsAtRest: Vector3;
  15323. /**
  15324. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15325. */
  15326. needInitialSkinMatrix: boolean;
  15327. /**
  15328. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15329. */
  15330. overrideMesh: Nullable<AbstractMesh>;
  15331. /**
  15332. * Gets the list of animations attached to this skeleton
  15333. */
  15334. animations: Array<Animation>;
  15335. private _scene;
  15336. private _isDirty;
  15337. private _transformMatrices;
  15338. private _transformMatrixTexture;
  15339. private _meshesWithPoseMatrix;
  15340. private _animatables;
  15341. private _identity;
  15342. private _synchronizedWithMesh;
  15343. private _ranges;
  15344. private _lastAbsoluteTransformsUpdateId;
  15345. private _canUseTextureForBones;
  15346. private _uniqueId;
  15347. /** @hidden */
  15348. _numBonesWithLinkedTransformNode: number;
  15349. /** @hidden */
  15350. _hasWaitingData: Nullable<boolean>;
  15351. /**
  15352. * Specifies if the skeleton should be serialized
  15353. */
  15354. doNotSerialize: boolean;
  15355. private _useTextureToStoreBoneMatrices;
  15356. /**
  15357. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15358. * Please note that this option is not available if the hardware does not support it
  15359. */
  15360. get useTextureToStoreBoneMatrices(): boolean;
  15361. set useTextureToStoreBoneMatrices(value: boolean);
  15362. private _animationPropertiesOverride;
  15363. /**
  15364. * Gets or sets the animation properties override
  15365. */
  15366. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15367. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15368. /**
  15369. * List of inspectable custom properties (used by the Inspector)
  15370. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15371. */
  15372. inspectableCustomProperties: IInspectable[];
  15373. /**
  15374. * An observable triggered before computing the skeleton's matrices
  15375. */
  15376. onBeforeComputeObservable: Observable<Skeleton>;
  15377. /**
  15378. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15379. */
  15380. get isUsingTextureForMatrices(): boolean;
  15381. /**
  15382. * Gets the unique ID of this skeleton
  15383. */
  15384. get uniqueId(): number;
  15385. /**
  15386. * Creates a new skeleton
  15387. * @param name defines the skeleton name
  15388. * @param id defines the skeleton Id
  15389. * @param scene defines the hosting scene
  15390. */
  15391. constructor(
  15392. /** defines the skeleton name */
  15393. name: string,
  15394. /** defines the skeleton Id */
  15395. id: string, scene: Scene);
  15396. /**
  15397. * Gets the current object class name.
  15398. * @return the class name
  15399. */
  15400. getClassName(): string;
  15401. /**
  15402. * Returns an array containing the root bones
  15403. * @returns an array containing the root bones
  15404. */
  15405. getChildren(): Array<Bone>;
  15406. /**
  15407. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15408. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15409. * @returns a Float32Array containing matrices data
  15410. */
  15411. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15412. /**
  15413. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15414. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15415. * @returns a raw texture containing the data
  15416. */
  15417. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15418. /**
  15419. * Gets the current hosting scene
  15420. * @returns a scene object
  15421. */
  15422. getScene(): Scene;
  15423. /**
  15424. * Gets a string representing the current skeleton data
  15425. * @param fullDetails defines a boolean indicating if we want a verbose version
  15426. * @returns a string representing the current skeleton data
  15427. */
  15428. toString(fullDetails?: boolean): string;
  15429. /**
  15430. * Get bone's index searching by name
  15431. * @param name defines bone's name to search for
  15432. * @return the indice of the bone. Returns -1 if not found
  15433. */
  15434. getBoneIndexByName(name: string): number;
  15435. /**
  15436. * Creater a new animation range
  15437. * @param name defines the name of the range
  15438. * @param from defines the start key
  15439. * @param to defines the end key
  15440. */
  15441. createAnimationRange(name: string, from: number, to: number): void;
  15442. /**
  15443. * Delete a specific animation range
  15444. * @param name defines the name of the range
  15445. * @param deleteFrames defines if frames must be removed as well
  15446. */
  15447. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15448. /**
  15449. * Gets a specific animation range
  15450. * @param name defines the name of the range to look for
  15451. * @returns the requested animation range or null if not found
  15452. */
  15453. getAnimationRange(name: string): Nullable<AnimationRange>;
  15454. /**
  15455. * Gets the list of all animation ranges defined on this skeleton
  15456. * @returns an array
  15457. */
  15458. getAnimationRanges(): Nullable<AnimationRange>[];
  15459. /**
  15460. * Copy animation range from a source skeleton.
  15461. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15462. * @param source defines the source skeleton
  15463. * @param name defines the name of the range to copy
  15464. * @param rescaleAsRequired defines if rescaling must be applied if required
  15465. * @returns true if operation was successful
  15466. */
  15467. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15468. /**
  15469. * Forces the skeleton to go to rest pose
  15470. */
  15471. returnToRest(): void;
  15472. private _getHighestAnimationFrame;
  15473. /**
  15474. * Begin a specific animation range
  15475. * @param name defines the name of the range to start
  15476. * @param loop defines if looping must be turned on (false by default)
  15477. * @param speedRatio defines the speed ratio to apply (1 by default)
  15478. * @param onAnimationEnd defines a callback which will be called when animation will end
  15479. * @returns a new animatable
  15480. */
  15481. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15482. /**
  15483. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15484. * @param skeleton defines the Skeleton containing the animation range to convert
  15485. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15486. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15487. * @returns the original skeleton
  15488. */
  15489. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15490. /** @hidden */
  15491. _markAsDirty(): void;
  15492. /** @hidden */
  15493. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15494. /** @hidden */
  15495. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15496. private _computeTransformMatrices;
  15497. /**
  15498. * Build all resources required to render a skeleton
  15499. */
  15500. prepare(): void;
  15501. /**
  15502. * Gets the list of animatables currently running for this skeleton
  15503. * @returns an array of animatables
  15504. */
  15505. getAnimatables(): IAnimatable[];
  15506. /**
  15507. * Clone the current skeleton
  15508. * @param name defines the name of the new skeleton
  15509. * @param id defines the id of the new skeleton
  15510. * @returns the new skeleton
  15511. */
  15512. clone(name: string, id?: string): Skeleton;
  15513. /**
  15514. * Enable animation blending for this skeleton
  15515. * @param blendingSpeed defines the blending speed to apply
  15516. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15517. */
  15518. enableBlending(blendingSpeed?: number): void;
  15519. /**
  15520. * Releases all resources associated with the current skeleton
  15521. */
  15522. dispose(): void;
  15523. /**
  15524. * Serialize the skeleton in a JSON object
  15525. * @returns a JSON object
  15526. */
  15527. serialize(): any;
  15528. /**
  15529. * Creates a new skeleton from serialized data
  15530. * @param parsedSkeleton defines the serialized data
  15531. * @param scene defines the hosting scene
  15532. * @returns a new skeleton
  15533. */
  15534. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15535. /**
  15536. * Compute all node absolute transforms
  15537. * @param forceUpdate defines if computation must be done even if cache is up to date
  15538. */
  15539. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15540. /**
  15541. * Gets the root pose matrix
  15542. * @returns a matrix
  15543. */
  15544. getPoseMatrix(): Nullable<Matrix>;
  15545. /**
  15546. * Sorts bones per internal index
  15547. */
  15548. sortBones(): void;
  15549. private _sortBones;
  15550. }
  15551. }
  15552. declare module "babylonjs/Meshes/instancedMesh" {
  15553. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15554. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15555. import { Camera } from "babylonjs/Cameras/camera";
  15556. import { Node } from "babylonjs/node";
  15557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15558. import { Mesh } from "babylonjs/Meshes/mesh";
  15559. import { Material } from "babylonjs/Materials/material";
  15560. import { Skeleton } from "babylonjs/Bones/skeleton";
  15561. import { Light } from "babylonjs/Lights/light";
  15562. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15563. /**
  15564. * Creates an instance based on a source mesh.
  15565. */
  15566. export class InstancedMesh extends AbstractMesh {
  15567. private _sourceMesh;
  15568. private _currentLOD;
  15569. /** @hidden */
  15570. _indexInSourceMeshInstanceArray: number;
  15571. constructor(name: string, source: Mesh);
  15572. /**
  15573. * Returns the string "InstancedMesh".
  15574. */
  15575. getClassName(): string;
  15576. /** Gets the list of lights affecting that mesh */
  15577. get lightSources(): Light[];
  15578. _resyncLightSources(): void;
  15579. _resyncLightSource(light: Light): void;
  15580. _removeLightSource(light: Light, dispose: boolean): void;
  15581. /**
  15582. * If the source mesh receives shadows
  15583. */
  15584. get receiveShadows(): boolean;
  15585. /**
  15586. * The material of the source mesh
  15587. */
  15588. get material(): Nullable<Material>;
  15589. /**
  15590. * Visibility of the source mesh
  15591. */
  15592. get visibility(): number;
  15593. /**
  15594. * Skeleton of the source mesh
  15595. */
  15596. get skeleton(): Nullable<Skeleton>;
  15597. /**
  15598. * Rendering ground id of the source mesh
  15599. */
  15600. get renderingGroupId(): number;
  15601. set renderingGroupId(value: number);
  15602. /**
  15603. * Returns the total number of vertices (integer).
  15604. */
  15605. getTotalVertices(): number;
  15606. /**
  15607. * Returns a positive integer : the total number of indices in this mesh geometry.
  15608. * @returns the numner of indices or zero if the mesh has no geometry.
  15609. */
  15610. getTotalIndices(): number;
  15611. /**
  15612. * The source mesh of the instance
  15613. */
  15614. get sourceMesh(): Mesh;
  15615. /**
  15616. * Is this node ready to be used/rendered
  15617. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15618. * @return {boolean} is it ready
  15619. */
  15620. isReady(completeCheck?: boolean): boolean;
  15621. /**
  15622. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15623. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15624. * @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.
  15625. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15626. */
  15627. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15628. /**
  15629. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15630. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15631. * The `data` are either a numeric array either a Float32Array.
  15632. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15633. * 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).
  15634. * Note that a new underlying VertexBuffer object is created each call.
  15635. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15636. *
  15637. * Possible `kind` values :
  15638. * - VertexBuffer.PositionKind
  15639. * - VertexBuffer.UVKind
  15640. * - VertexBuffer.UV2Kind
  15641. * - VertexBuffer.UV3Kind
  15642. * - VertexBuffer.UV4Kind
  15643. * - VertexBuffer.UV5Kind
  15644. * - VertexBuffer.UV6Kind
  15645. * - VertexBuffer.ColorKind
  15646. * - VertexBuffer.MatricesIndicesKind
  15647. * - VertexBuffer.MatricesIndicesExtraKind
  15648. * - VertexBuffer.MatricesWeightsKind
  15649. * - VertexBuffer.MatricesWeightsExtraKind
  15650. *
  15651. * Returns the Mesh.
  15652. */
  15653. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15654. /**
  15655. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15656. * If the mesh has no geometry, it is simply returned as it is.
  15657. * The `data` are either a numeric array either a Float32Array.
  15658. * No new underlying VertexBuffer object is created.
  15659. * 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.
  15660. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15661. *
  15662. * Possible `kind` values :
  15663. * - VertexBuffer.PositionKind
  15664. * - VertexBuffer.UVKind
  15665. * - VertexBuffer.UV2Kind
  15666. * - VertexBuffer.UV3Kind
  15667. * - VertexBuffer.UV4Kind
  15668. * - VertexBuffer.UV5Kind
  15669. * - VertexBuffer.UV6Kind
  15670. * - VertexBuffer.ColorKind
  15671. * - VertexBuffer.MatricesIndicesKind
  15672. * - VertexBuffer.MatricesIndicesExtraKind
  15673. * - VertexBuffer.MatricesWeightsKind
  15674. * - VertexBuffer.MatricesWeightsExtraKind
  15675. *
  15676. * Returns the Mesh.
  15677. */
  15678. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15679. /**
  15680. * Sets the mesh indices.
  15681. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15682. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15683. * This method creates a new index buffer each call.
  15684. * Returns the Mesh.
  15685. */
  15686. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15687. /**
  15688. * Boolean : True if the mesh owns the requested kind of data.
  15689. */
  15690. isVerticesDataPresent(kind: string): boolean;
  15691. /**
  15692. * Returns an array of indices (IndicesArray).
  15693. */
  15694. getIndices(): Nullable<IndicesArray>;
  15695. get _positions(): Nullable<Vector3[]>;
  15696. /**
  15697. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15698. * This means the mesh underlying bounding box and sphere are recomputed.
  15699. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15700. * @returns the current mesh
  15701. */
  15702. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15703. /** @hidden */
  15704. _preActivate(): InstancedMesh;
  15705. /** @hidden */
  15706. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15707. /** @hidden */
  15708. _postActivate(): void;
  15709. getWorldMatrix(): Matrix;
  15710. get isAnInstance(): boolean;
  15711. /**
  15712. * Returns the current associated LOD AbstractMesh.
  15713. */
  15714. getLOD(camera: Camera): AbstractMesh;
  15715. /** @hidden */
  15716. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15717. /** @hidden */
  15718. _syncSubMeshes(): InstancedMesh;
  15719. /** @hidden */
  15720. _generatePointsArray(): boolean;
  15721. /**
  15722. * Creates a new InstancedMesh from the current mesh.
  15723. * - name (string) : the cloned mesh name
  15724. * - newParent (optional Node) : the optional Node to parent the clone to.
  15725. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15726. *
  15727. * Returns the clone.
  15728. */
  15729. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15730. /**
  15731. * Disposes the InstancedMesh.
  15732. * Returns nothing.
  15733. */
  15734. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15735. }
  15736. module "babylonjs/Meshes/mesh" {
  15737. interface Mesh {
  15738. /**
  15739. * Register a custom buffer that will be instanced
  15740. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15741. * @param kind defines the buffer kind
  15742. * @param stride defines the stride in floats
  15743. */
  15744. registerInstancedBuffer(kind: string, stride: number): void;
  15745. /** @hidden */
  15746. _userInstancedBuffersStorage: {
  15747. data: {
  15748. [key: string]: Float32Array;
  15749. };
  15750. sizes: {
  15751. [key: string]: number;
  15752. };
  15753. vertexBuffers: {
  15754. [key: string]: Nullable<VertexBuffer>;
  15755. };
  15756. strides: {
  15757. [key: string]: number;
  15758. };
  15759. };
  15760. }
  15761. }
  15762. module "babylonjs/Meshes/abstractMesh" {
  15763. interface AbstractMesh {
  15764. /**
  15765. * Object used to store instanced buffers defined by user
  15766. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15767. */
  15768. instancedBuffers: {
  15769. [key: string]: any;
  15770. };
  15771. }
  15772. }
  15773. }
  15774. declare module "babylonjs/Materials/shaderMaterial" {
  15775. import { Scene } from "babylonjs/scene";
  15776. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15778. import { Mesh } from "babylonjs/Meshes/mesh";
  15779. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15780. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15781. import { Material } from "babylonjs/Materials/material";
  15782. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15783. /**
  15784. * Defines the options associated with the creation of a shader material.
  15785. */
  15786. export interface IShaderMaterialOptions {
  15787. /**
  15788. * Does the material work in alpha blend mode
  15789. */
  15790. needAlphaBlending: boolean;
  15791. /**
  15792. * Does the material work in alpha test mode
  15793. */
  15794. needAlphaTesting: boolean;
  15795. /**
  15796. * The list of attribute names used in the shader
  15797. */
  15798. attributes: string[];
  15799. /**
  15800. * The list of unifrom names used in the shader
  15801. */
  15802. uniforms: string[];
  15803. /**
  15804. * The list of UBO names used in the shader
  15805. */
  15806. uniformBuffers: string[];
  15807. /**
  15808. * The list of sampler names used in the shader
  15809. */
  15810. samplers: string[];
  15811. /**
  15812. * The list of defines used in the shader
  15813. */
  15814. defines: string[];
  15815. }
  15816. /**
  15817. * 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.
  15818. *
  15819. * This returned material effects how the mesh will look based on the code in the shaders.
  15820. *
  15821. * @see http://doc.babylonjs.com/how_to/shader_material
  15822. */
  15823. export class ShaderMaterial extends Material {
  15824. private _shaderPath;
  15825. private _options;
  15826. private _textures;
  15827. private _textureArrays;
  15828. private _floats;
  15829. private _ints;
  15830. private _floatsArrays;
  15831. private _colors3;
  15832. private _colors3Arrays;
  15833. private _colors4;
  15834. private _colors4Arrays;
  15835. private _vectors2;
  15836. private _vectors3;
  15837. private _vectors4;
  15838. private _matrices;
  15839. private _matrixArrays;
  15840. private _matrices3x3;
  15841. private _matrices2x2;
  15842. private _vectors2Arrays;
  15843. private _vectors3Arrays;
  15844. private _vectors4Arrays;
  15845. private _cachedWorldViewMatrix;
  15846. private _cachedWorldViewProjectionMatrix;
  15847. private _renderId;
  15848. private _multiview;
  15849. /**
  15850. * Instantiate a new shader material.
  15851. * 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.
  15852. * This returned material effects how the mesh will look based on the code in the shaders.
  15853. * @see http://doc.babylonjs.com/how_to/shader_material
  15854. * @param name Define the name of the material in the scene
  15855. * @param scene Define the scene the material belongs to
  15856. * @param shaderPath Defines the route to the shader code in one of three ways:
  15857. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15858. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15859. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15860. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15861. * @param options Define the options used to create the shader
  15862. */
  15863. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15864. /**
  15865. * Gets the shader path used to define the shader code
  15866. * It can be modified to trigger a new compilation
  15867. */
  15868. get shaderPath(): any;
  15869. /**
  15870. * Sets the shader path used to define the shader code
  15871. * It can be modified to trigger a new compilation
  15872. */
  15873. set shaderPath(shaderPath: any);
  15874. /**
  15875. * Gets the options used to compile the shader.
  15876. * They can be modified to trigger a new compilation
  15877. */
  15878. get options(): IShaderMaterialOptions;
  15879. /**
  15880. * Gets the current class name of the material e.g. "ShaderMaterial"
  15881. * Mainly use in serialization.
  15882. * @returns the class name
  15883. */
  15884. getClassName(): string;
  15885. /**
  15886. * Specifies if the material will require alpha blending
  15887. * @returns a boolean specifying if alpha blending is needed
  15888. */
  15889. needAlphaBlending(): boolean;
  15890. /**
  15891. * Specifies if this material should be rendered in alpha test mode
  15892. * @returns a boolean specifying if an alpha test is needed.
  15893. */
  15894. needAlphaTesting(): boolean;
  15895. private _checkUniform;
  15896. /**
  15897. * Set a texture in the shader.
  15898. * @param name Define the name of the uniform samplers as defined in the shader
  15899. * @param texture Define the texture to bind to this sampler
  15900. * @return the material itself allowing "fluent" like uniform updates
  15901. */
  15902. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15903. /**
  15904. * Set a texture array in the shader.
  15905. * @param name Define the name of the uniform sampler array as defined in the shader
  15906. * @param textures Define the list of textures to bind to this sampler
  15907. * @return the material itself allowing "fluent" like uniform updates
  15908. */
  15909. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15910. /**
  15911. * Set a float in the shader.
  15912. * @param name Define the name of the uniform as defined in the shader
  15913. * @param value Define the value to give to the uniform
  15914. * @return the material itself allowing "fluent" like uniform updates
  15915. */
  15916. setFloat(name: string, value: number): ShaderMaterial;
  15917. /**
  15918. * Set a int in the shader.
  15919. * @param name Define the name of the uniform as defined in the shader
  15920. * @param value Define the value to give to the uniform
  15921. * @return the material itself allowing "fluent" like uniform updates
  15922. */
  15923. setInt(name: string, value: number): ShaderMaterial;
  15924. /**
  15925. * Set an array of floats in the shader.
  15926. * @param name Define the name of the uniform as defined in the shader
  15927. * @param value Define the value to give to the uniform
  15928. * @return the material itself allowing "fluent" like uniform updates
  15929. */
  15930. setFloats(name: string, value: number[]): ShaderMaterial;
  15931. /**
  15932. * Set a vec3 in the shader from a Color3.
  15933. * @param name Define the name of the uniform as defined in the shader
  15934. * @param value Define the value to give to the uniform
  15935. * @return the material itself allowing "fluent" like uniform updates
  15936. */
  15937. setColor3(name: string, value: Color3): ShaderMaterial;
  15938. /**
  15939. * Set a vec3 array in the shader from a Color3 array.
  15940. * @param name Define the name of the uniform as defined in the shader
  15941. * @param value Define the value to give to the uniform
  15942. * @return the material itself allowing "fluent" like uniform updates
  15943. */
  15944. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15945. /**
  15946. * Set a vec4 in the shader from a Color4.
  15947. * @param name Define the name of the uniform as defined in the shader
  15948. * @param value Define the value to give to the uniform
  15949. * @return the material itself allowing "fluent" like uniform updates
  15950. */
  15951. setColor4(name: string, value: Color4): ShaderMaterial;
  15952. /**
  15953. * Set a vec4 array in the shader from a Color4 array.
  15954. * @param name Define the name of the uniform as defined in the shader
  15955. * @param value Define the value to give to the uniform
  15956. * @return the material itself allowing "fluent" like uniform updates
  15957. */
  15958. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15959. /**
  15960. * Set a vec2 in the shader from a Vector2.
  15961. * @param name Define the name of the uniform as defined in the shader
  15962. * @param value Define the value to give to the uniform
  15963. * @return the material itself allowing "fluent" like uniform updates
  15964. */
  15965. setVector2(name: string, value: Vector2): ShaderMaterial;
  15966. /**
  15967. * Set a vec3 in the shader from a Vector3.
  15968. * @param name Define the name of the uniform as defined in the shader
  15969. * @param value Define the value to give to the uniform
  15970. * @return the material itself allowing "fluent" like uniform updates
  15971. */
  15972. setVector3(name: string, value: Vector3): ShaderMaterial;
  15973. /**
  15974. * Set a vec4 in the shader from a Vector4.
  15975. * @param name Define the name of the uniform as defined in the shader
  15976. * @param value Define the value to give to the uniform
  15977. * @return the material itself allowing "fluent" like uniform updates
  15978. */
  15979. setVector4(name: string, value: Vector4): ShaderMaterial;
  15980. /**
  15981. * Set a mat4 in the shader from a Matrix.
  15982. * @param name Define the name of the uniform as defined in the shader
  15983. * @param value Define the value to give to the uniform
  15984. * @return the material itself allowing "fluent" like uniform updates
  15985. */
  15986. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15987. /**
  15988. * Set a float32Array in the shader from a matrix array.
  15989. * @param name Define the name of the uniform as defined in the shader
  15990. * @param value Define the value to give to the uniform
  15991. * @return the material itself allowing "fluent" like uniform updates
  15992. */
  15993. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15994. /**
  15995. * Set a mat3 in the shader from a Float32Array.
  15996. * @param name Define the name of the uniform as defined in the shader
  15997. * @param value Define the value to give to the uniform
  15998. * @return the material itself allowing "fluent" like uniform updates
  15999. */
  16000. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16001. /**
  16002. * Set a mat2 in the shader from a Float32Array.
  16003. * @param name Define the name of the uniform as defined in the shader
  16004. * @param value Define the value to give to the uniform
  16005. * @return the material itself allowing "fluent" like uniform updates
  16006. */
  16007. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16008. /**
  16009. * Set a vec2 array in the shader from a number array.
  16010. * @param name Define the name of the uniform as defined in the shader
  16011. * @param value Define the value to give to the uniform
  16012. * @return the material itself allowing "fluent" like uniform updates
  16013. */
  16014. setArray2(name: string, value: number[]): ShaderMaterial;
  16015. /**
  16016. * Set a vec3 array in the shader from a number array.
  16017. * @param name Define the name of the uniform as defined in the shader
  16018. * @param value Define the value to give to the uniform
  16019. * @return the material itself allowing "fluent" like uniform updates
  16020. */
  16021. setArray3(name: string, value: number[]): ShaderMaterial;
  16022. /**
  16023. * Set a vec4 array in the shader from a number array.
  16024. * @param name Define the name of the uniform as defined in the shader
  16025. * @param value Define the value to give to the uniform
  16026. * @return the material itself allowing "fluent" like uniform updates
  16027. */
  16028. setArray4(name: string, value: number[]): ShaderMaterial;
  16029. private _checkCache;
  16030. /**
  16031. * Specifies that the submesh is ready to be used
  16032. * @param mesh defines the mesh to check
  16033. * @param subMesh defines which submesh to check
  16034. * @param useInstances specifies that instances should be used
  16035. * @returns a boolean indicating that the submesh is ready or not
  16036. */
  16037. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16038. /**
  16039. * Checks if the material is ready to render the requested mesh
  16040. * @param mesh Define the mesh to render
  16041. * @param useInstances Define whether or not the material is used with instances
  16042. * @returns true if ready, otherwise false
  16043. */
  16044. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16045. /**
  16046. * Binds the world matrix to the material
  16047. * @param world defines the world transformation matrix
  16048. */
  16049. bindOnlyWorldMatrix(world: Matrix): void;
  16050. /**
  16051. * Binds the material to the mesh
  16052. * @param world defines the world transformation matrix
  16053. * @param mesh defines the mesh to bind the material to
  16054. */
  16055. bind(world: Matrix, mesh?: Mesh): void;
  16056. /**
  16057. * Gets the active textures from the material
  16058. * @returns an array of textures
  16059. */
  16060. getActiveTextures(): BaseTexture[];
  16061. /**
  16062. * Specifies if the material uses a texture
  16063. * @param texture defines the texture to check against the material
  16064. * @returns a boolean specifying if the material uses the texture
  16065. */
  16066. hasTexture(texture: BaseTexture): boolean;
  16067. /**
  16068. * Makes a duplicate of the material, and gives it a new name
  16069. * @param name defines the new name for the duplicated material
  16070. * @returns the cloned material
  16071. */
  16072. clone(name: string): ShaderMaterial;
  16073. /**
  16074. * Disposes the material
  16075. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16076. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16077. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16078. */
  16079. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16080. /**
  16081. * Serializes this material in a JSON representation
  16082. * @returns the serialized material object
  16083. */
  16084. serialize(): any;
  16085. /**
  16086. * Creates a shader material from parsed shader material data
  16087. * @param source defines the JSON represnetation of the material
  16088. * @param scene defines the hosting scene
  16089. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16090. * @returns a new material
  16091. */
  16092. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16093. }
  16094. }
  16095. declare module "babylonjs/Shaders/color.fragment" {
  16096. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16097. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16098. /** @hidden */
  16099. export var colorPixelShader: {
  16100. name: string;
  16101. shader: string;
  16102. };
  16103. }
  16104. declare module "babylonjs/Shaders/color.vertex" {
  16105. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16106. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16107. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16108. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16109. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16110. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16111. /** @hidden */
  16112. export var colorVertexShader: {
  16113. name: string;
  16114. shader: string;
  16115. };
  16116. }
  16117. declare module "babylonjs/Meshes/linesMesh" {
  16118. import { Nullable } from "babylonjs/types";
  16119. import { Scene } from "babylonjs/scene";
  16120. import { Color3 } from "babylonjs/Maths/math.color";
  16121. import { Node } from "babylonjs/node";
  16122. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16123. import { Mesh } from "babylonjs/Meshes/mesh";
  16124. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16125. import { Effect } from "babylonjs/Materials/effect";
  16126. import { Material } from "babylonjs/Materials/material";
  16127. import "babylonjs/Shaders/color.fragment";
  16128. import "babylonjs/Shaders/color.vertex";
  16129. /**
  16130. * Line mesh
  16131. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16132. */
  16133. export class LinesMesh extends Mesh {
  16134. /**
  16135. * If vertex color should be applied to the mesh
  16136. */
  16137. readonly useVertexColor?: boolean | undefined;
  16138. /**
  16139. * If vertex alpha should be applied to the mesh
  16140. */
  16141. readonly useVertexAlpha?: boolean | undefined;
  16142. /**
  16143. * Color of the line (Default: White)
  16144. */
  16145. color: Color3;
  16146. /**
  16147. * Alpha of the line (Default: 1)
  16148. */
  16149. alpha: number;
  16150. /**
  16151. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16152. * This margin is expressed in world space coordinates, so its value may vary.
  16153. * Default value is 0.1
  16154. */
  16155. intersectionThreshold: number;
  16156. private _colorShader;
  16157. private color4;
  16158. /**
  16159. * Creates a new LinesMesh
  16160. * @param name defines the name
  16161. * @param scene defines the hosting scene
  16162. * @param parent defines the parent mesh if any
  16163. * @param source defines the optional source LinesMesh used to clone data from
  16164. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16165. * When false, achieved by calling a clone(), also passing False.
  16166. * This will make creation of children, recursive.
  16167. * @param useVertexColor defines if this LinesMesh supports vertex color
  16168. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16169. */
  16170. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16171. /**
  16172. * If vertex color should be applied to the mesh
  16173. */
  16174. useVertexColor?: boolean | undefined,
  16175. /**
  16176. * If vertex alpha should be applied to the mesh
  16177. */
  16178. useVertexAlpha?: boolean | undefined);
  16179. private _addClipPlaneDefine;
  16180. private _removeClipPlaneDefine;
  16181. isReady(): boolean;
  16182. /**
  16183. * Returns the string "LineMesh"
  16184. */
  16185. getClassName(): string;
  16186. /**
  16187. * @hidden
  16188. */
  16189. get material(): Material;
  16190. /**
  16191. * @hidden
  16192. */
  16193. set material(value: Material);
  16194. /**
  16195. * @hidden
  16196. */
  16197. get checkCollisions(): boolean;
  16198. /** @hidden */
  16199. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16200. /** @hidden */
  16201. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16202. /**
  16203. * Disposes of the line mesh
  16204. * @param doNotRecurse If children should be disposed
  16205. */
  16206. dispose(doNotRecurse?: boolean): void;
  16207. /**
  16208. * Returns a new LineMesh object cloned from the current one.
  16209. */
  16210. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16211. /**
  16212. * Creates a new InstancedLinesMesh object from the mesh model.
  16213. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16214. * @param name defines the name of the new instance
  16215. * @returns a new InstancedLinesMesh
  16216. */
  16217. createInstance(name: string): InstancedLinesMesh;
  16218. }
  16219. /**
  16220. * Creates an instance based on a source LinesMesh
  16221. */
  16222. export class InstancedLinesMesh extends InstancedMesh {
  16223. /**
  16224. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16225. * This margin is expressed in world space coordinates, so its value may vary.
  16226. * Initilized with the intersectionThreshold value of the source LinesMesh
  16227. */
  16228. intersectionThreshold: number;
  16229. constructor(name: string, source: LinesMesh);
  16230. /**
  16231. * Returns the string "InstancedLinesMesh".
  16232. */
  16233. getClassName(): string;
  16234. }
  16235. }
  16236. declare module "babylonjs/Shaders/line.fragment" {
  16237. /** @hidden */
  16238. export var linePixelShader: {
  16239. name: string;
  16240. shader: string;
  16241. };
  16242. }
  16243. declare module "babylonjs/Shaders/line.vertex" {
  16244. /** @hidden */
  16245. export var lineVertexShader: {
  16246. name: string;
  16247. shader: string;
  16248. };
  16249. }
  16250. declare module "babylonjs/Rendering/edgesRenderer" {
  16251. import { Nullable } from "babylonjs/types";
  16252. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16254. import { Vector3 } from "babylonjs/Maths/math.vector";
  16255. import { IDisposable } from "babylonjs/scene";
  16256. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16257. import "babylonjs/Shaders/line.fragment";
  16258. import "babylonjs/Shaders/line.vertex";
  16259. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16260. module "babylonjs/Meshes/abstractMesh" {
  16261. interface AbstractMesh {
  16262. /**
  16263. * Gets the edgesRenderer associated with the mesh
  16264. */
  16265. edgesRenderer: Nullable<EdgesRenderer>;
  16266. }
  16267. }
  16268. module "babylonjs/Meshes/linesMesh" {
  16269. interface LinesMesh {
  16270. /**
  16271. * Enables the edge rendering mode on the mesh.
  16272. * This mode makes the mesh edges visible
  16273. * @param epsilon defines the maximal distance between two angles to detect a face
  16274. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16275. * @returns the currentAbstractMesh
  16276. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16277. */
  16278. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16279. }
  16280. }
  16281. module "babylonjs/Meshes/linesMesh" {
  16282. interface InstancedLinesMesh {
  16283. /**
  16284. * Enables the edge rendering mode on the mesh.
  16285. * This mode makes the mesh edges visible
  16286. * @param epsilon defines the maximal distance between two angles to detect a face
  16287. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16288. * @returns the current InstancedLinesMesh
  16289. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16290. */
  16291. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16292. }
  16293. }
  16294. /**
  16295. * Defines the minimum contract an Edges renderer should follow.
  16296. */
  16297. export interface IEdgesRenderer extends IDisposable {
  16298. /**
  16299. * Gets or sets a boolean indicating if the edgesRenderer is active
  16300. */
  16301. isEnabled: boolean;
  16302. /**
  16303. * Renders the edges of the attached mesh,
  16304. */
  16305. render(): void;
  16306. /**
  16307. * Checks wether or not the edges renderer is ready to render.
  16308. * @return true if ready, otherwise false.
  16309. */
  16310. isReady(): boolean;
  16311. }
  16312. /**
  16313. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16314. */
  16315. export class EdgesRenderer implements IEdgesRenderer {
  16316. /**
  16317. * Define the size of the edges with an orthographic camera
  16318. */
  16319. edgesWidthScalerForOrthographic: number;
  16320. /**
  16321. * Define the size of the edges with a perspective camera
  16322. */
  16323. edgesWidthScalerForPerspective: number;
  16324. protected _source: AbstractMesh;
  16325. protected _linesPositions: number[];
  16326. protected _linesNormals: number[];
  16327. protected _linesIndices: number[];
  16328. protected _epsilon: number;
  16329. protected _indicesCount: number;
  16330. protected _lineShader: ShaderMaterial;
  16331. protected _ib: DataBuffer;
  16332. protected _buffers: {
  16333. [key: string]: Nullable<VertexBuffer>;
  16334. };
  16335. protected _checkVerticesInsteadOfIndices: boolean;
  16336. private _meshRebuildObserver;
  16337. private _meshDisposeObserver;
  16338. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16339. isEnabled: boolean;
  16340. /**
  16341. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16342. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16343. * @param source Mesh used to create edges
  16344. * @param epsilon sum of angles in adjacency to check for edge
  16345. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16346. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16347. */
  16348. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16349. protected _prepareRessources(): void;
  16350. /** @hidden */
  16351. _rebuild(): void;
  16352. /**
  16353. * Releases the required resources for the edges renderer
  16354. */
  16355. dispose(): void;
  16356. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16357. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16358. /**
  16359. * Checks if the pair of p0 and p1 is en edge
  16360. * @param faceIndex
  16361. * @param edge
  16362. * @param faceNormals
  16363. * @param p0
  16364. * @param p1
  16365. * @private
  16366. */
  16367. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16368. /**
  16369. * push line into the position, normal and index buffer
  16370. * @protected
  16371. */
  16372. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16373. /**
  16374. * Generates lines edges from adjacencjes
  16375. * @private
  16376. */
  16377. _generateEdgesLines(): void;
  16378. /**
  16379. * Checks wether or not the edges renderer is ready to render.
  16380. * @return true if ready, otherwise false.
  16381. */
  16382. isReady(): boolean;
  16383. /**
  16384. * Renders the edges of the attached mesh,
  16385. */
  16386. render(): void;
  16387. }
  16388. /**
  16389. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16390. */
  16391. export class LineEdgesRenderer extends EdgesRenderer {
  16392. /**
  16393. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16394. * @param source LineMesh used to generate edges
  16395. * @param epsilon not important (specified angle for edge detection)
  16396. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16397. */
  16398. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16399. /**
  16400. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16401. */
  16402. _generateEdgesLines(): void;
  16403. }
  16404. }
  16405. declare module "babylonjs/Rendering/renderingGroup" {
  16406. import { SmartArray } from "babylonjs/Misc/smartArray";
  16407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16409. import { Nullable } from "babylonjs/types";
  16410. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16411. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16412. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16413. import { Material } from "babylonjs/Materials/material";
  16414. import { Scene } from "babylonjs/scene";
  16415. /**
  16416. * This represents the object necessary to create a rendering group.
  16417. * This is exclusively used and created by the rendering manager.
  16418. * To modify the behavior, you use the available helpers in your scene or meshes.
  16419. * @hidden
  16420. */
  16421. export class RenderingGroup {
  16422. index: number;
  16423. private static _zeroVector;
  16424. private _scene;
  16425. private _opaqueSubMeshes;
  16426. private _transparentSubMeshes;
  16427. private _alphaTestSubMeshes;
  16428. private _depthOnlySubMeshes;
  16429. private _particleSystems;
  16430. private _spriteManagers;
  16431. private _opaqueSortCompareFn;
  16432. private _alphaTestSortCompareFn;
  16433. private _transparentSortCompareFn;
  16434. private _renderOpaque;
  16435. private _renderAlphaTest;
  16436. private _renderTransparent;
  16437. /** @hidden */
  16438. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16439. onBeforeTransparentRendering: () => void;
  16440. /**
  16441. * Set the opaque sort comparison function.
  16442. * If null the sub meshes will be render in the order they were created
  16443. */
  16444. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16445. /**
  16446. * Set the alpha test sort comparison function.
  16447. * If null the sub meshes will be render in the order they were created
  16448. */
  16449. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16450. /**
  16451. * Set the transparent sort comparison function.
  16452. * If null the sub meshes will be render in the order they were created
  16453. */
  16454. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16455. /**
  16456. * Creates a new rendering group.
  16457. * @param index The rendering group index
  16458. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16459. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16460. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16461. */
  16462. 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>);
  16463. /**
  16464. * Render all the sub meshes contained in the group.
  16465. * @param customRenderFunction Used to override the default render behaviour of the group.
  16466. * @returns true if rendered some submeshes.
  16467. */
  16468. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16469. /**
  16470. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16471. * @param subMeshes The submeshes to render
  16472. */
  16473. private renderOpaqueSorted;
  16474. /**
  16475. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16476. * @param subMeshes The submeshes to render
  16477. */
  16478. private renderAlphaTestSorted;
  16479. /**
  16480. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16481. * @param subMeshes The submeshes to render
  16482. */
  16483. private renderTransparentSorted;
  16484. /**
  16485. * Renders the submeshes in a specified order.
  16486. * @param subMeshes The submeshes to sort before render
  16487. * @param sortCompareFn The comparison function use to sort
  16488. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16489. * @param transparent Specifies to activate blending if true
  16490. */
  16491. private static renderSorted;
  16492. /**
  16493. * Renders the submeshes in the order they were dispatched (no sort applied).
  16494. * @param subMeshes The submeshes to render
  16495. */
  16496. private static renderUnsorted;
  16497. /**
  16498. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16499. * are rendered back to front if in the same alpha index.
  16500. *
  16501. * @param a The first submesh
  16502. * @param b The second submesh
  16503. * @returns The result of the comparison
  16504. */
  16505. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16506. /**
  16507. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16508. * are rendered back to front.
  16509. *
  16510. * @param a The first submesh
  16511. * @param b The second submesh
  16512. * @returns The result of the comparison
  16513. */
  16514. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16515. /**
  16516. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16517. * are rendered front to back (prevent overdraw).
  16518. *
  16519. * @param a The first submesh
  16520. * @param b The second submesh
  16521. * @returns The result of the comparison
  16522. */
  16523. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16524. /**
  16525. * Resets the different lists of submeshes to prepare a new frame.
  16526. */
  16527. prepare(): void;
  16528. dispose(): void;
  16529. /**
  16530. * Inserts the submesh in its correct queue depending on its material.
  16531. * @param subMesh The submesh to dispatch
  16532. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16533. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16534. */
  16535. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16536. dispatchSprites(spriteManager: ISpriteManager): void;
  16537. dispatchParticles(particleSystem: IParticleSystem): void;
  16538. private _renderParticles;
  16539. private _renderSprites;
  16540. }
  16541. }
  16542. declare module "babylonjs/Rendering/renderingManager" {
  16543. import { Nullable } from "babylonjs/types";
  16544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16545. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16546. import { SmartArray } from "babylonjs/Misc/smartArray";
  16547. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16548. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16549. import { Material } from "babylonjs/Materials/material";
  16550. import { Scene } from "babylonjs/scene";
  16551. import { Camera } from "babylonjs/Cameras/camera";
  16552. /**
  16553. * Interface describing the different options available in the rendering manager
  16554. * regarding Auto Clear between groups.
  16555. */
  16556. export interface IRenderingManagerAutoClearSetup {
  16557. /**
  16558. * Defines whether or not autoclear is enable.
  16559. */
  16560. autoClear: boolean;
  16561. /**
  16562. * Defines whether or not to autoclear the depth buffer.
  16563. */
  16564. depth: boolean;
  16565. /**
  16566. * Defines whether or not to autoclear the stencil buffer.
  16567. */
  16568. stencil: boolean;
  16569. }
  16570. /**
  16571. * This class is used by the onRenderingGroupObservable
  16572. */
  16573. export class RenderingGroupInfo {
  16574. /**
  16575. * The Scene that being rendered
  16576. */
  16577. scene: Scene;
  16578. /**
  16579. * The camera currently used for the rendering pass
  16580. */
  16581. camera: Nullable<Camera>;
  16582. /**
  16583. * The ID of the renderingGroup being processed
  16584. */
  16585. renderingGroupId: number;
  16586. }
  16587. /**
  16588. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16589. * It is enable to manage the different groups as well as the different necessary sort functions.
  16590. * This should not be used directly aside of the few static configurations
  16591. */
  16592. export class RenderingManager {
  16593. /**
  16594. * The max id used for rendering groups (not included)
  16595. */
  16596. static MAX_RENDERINGGROUPS: number;
  16597. /**
  16598. * The min id used for rendering groups (included)
  16599. */
  16600. static MIN_RENDERINGGROUPS: number;
  16601. /**
  16602. * Used to globally prevent autoclearing scenes.
  16603. */
  16604. static AUTOCLEAR: boolean;
  16605. /**
  16606. * @hidden
  16607. */
  16608. _useSceneAutoClearSetup: boolean;
  16609. private _scene;
  16610. private _renderingGroups;
  16611. private _depthStencilBufferAlreadyCleaned;
  16612. private _autoClearDepthStencil;
  16613. private _customOpaqueSortCompareFn;
  16614. private _customAlphaTestSortCompareFn;
  16615. private _customTransparentSortCompareFn;
  16616. private _renderingGroupInfo;
  16617. /**
  16618. * Instantiates a new rendering group for a particular scene
  16619. * @param scene Defines the scene the groups belongs to
  16620. */
  16621. constructor(scene: Scene);
  16622. private _clearDepthStencilBuffer;
  16623. /**
  16624. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16625. * @hidden
  16626. */
  16627. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16628. /**
  16629. * Resets the different information of the group to prepare a new frame
  16630. * @hidden
  16631. */
  16632. reset(): void;
  16633. /**
  16634. * Dispose and release the group and its associated resources.
  16635. * @hidden
  16636. */
  16637. dispose(): void;
  16638. /**
  16639. * Clear the info related to rendering groups preventing retention points during dispose.
  16640. */
  16641. freeRenderingGroups(): void;
  16642. private _prepareRenderingGroup;
  16643. /**
  16644. * Add a sprite manager to the rendering manager in order to render it this frame.
  16645. * @param spriteManager Define the sprite manager to render
  16646. */
  16647. dispatchSprites(spriteManager: ISpriteManager): void;
  16648. /**
  16649. * Add a particle system to the rendering manager in order to render it this frame.
  16650. * @param particleSystem Define the particle system to render
  16651. */
  16652. dispatchParticles(particleSystem: IParticleSystem): void;
  16653. /**
  16654. * Add a submesh to the manager in order to render it this frame
  16655. * @param subMesh The submesh to dispatch
  16656. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16657. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16658. */
  16659. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16660. /**
  16661. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16662. * This allowed control for front to back rendering or reversly depending of the special needs.
  16663. *
  16664. * @param renderingGroupId The rendering group id corresponding to its index
  16665. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16666. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16667. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16668. */
  16669. 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;
  16670. /**
  16671. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16672. *
  16673. * @param renderingGroupId The rendering group id corresponding to its index
  16674. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16675. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16676. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16677. */
  16678. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16679. /**
  16680. * Gets the current auto clear configuration for one rendering group of the rendering
  16681. * manager.
  16682. * @param index the rendering group index to get the information for
  16683. * @returns The auto clear setup for the requested rendering group
  16684. */
  16685. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16686. }
  16687. }
  16688. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16689. import { SmartArray } from "babylonjs/Misc/smartArray";
  16690. import { Nullable } from "babylonjs/types";
  16691. import { Scene } from "babylonjs/scene";
  16692. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16693. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16695. import { Mesh } from "babylonjs/Meshes/mesh";
  16696. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16697. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16698. import { Effect } from "babylonjs/Materials/effect";
  16699. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16700. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16701. import "babylonjs/Shaders/shadowMap.fragment";
  16702. import "babylonjs/Shaders/shadowMap.vertex";
  16703. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16704. import { Observable } from "babylonjs/Misc/observable";
  16705. /**
  16706. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16707. */
  16708. export interface ICustomShaderOptions {
  16709. /**
  16710. * Gets or sets the custom shader name to use
  16711. */
  16712. shaderName: string;
  16713. /**
  16714. * The list of attribute names used in the shader
  16715. */
  16716. attributes?: string[];
  16717. /**
  16718. * The list of unifrom names used in the shader
  16719. */
  16720. uniforms?: string[];
  16721. /**
  16722. * The list of sampler names used in the shader
  16723. */
  16724. samplers?: string[];
  16725. /**
  16726. * The list of defines used in the shader
  16727. */
  16728. defines?: string[];
  16729. }
  16730. /**
  16731. * Interface to implement to create a shadow generator compatible with BJS.
  16732. */
  16733. export interface IShadowGenerator {
  16734. /**
  16735. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16736. * @returns The render target texture if present otherwise, null
  16737. */
  16738. getShadowMap(): Nullable<RenderTargetTexture>;
  16739. /**
  16740. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16741. * @param subMesh The submesh we want to render in the shadow map
  16742. * @param useInstances Defines wether will draw in the map using instances
  16743. * @returns true if ready otherwise, false
  16744. */
  16745. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16746. /**
  16747. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16748. * @param defines Defines of the material we want to update
  16749. * @param lightIndex Index of the light in the enabled light list of the material
  16750. */
  16751. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16752. /**
  16753. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16754. * defined in the generator but impacting the effect).
  16755. * It implies the unifroms available on the materials are the standard BJS ones.
  16756. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16757. * @param effect The effect we are binfing the information for
  16758. */
  16759. bindShadowLight(lightIndex: string, effect: Effect): void;
  16760. /**
  16761. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16762. * (eq to shadow prjection matrix * light transform matrix)
  16763. * @returns The transform matrix used to create the shadow map
  16764. */
  16765. getTransformMatrix(): Matrix;
  16766. /**
  16767. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16768. * Cube and 2D textures for instance.
  16769. */
  16770. recreateShadowMap(): void;
  16771. /**
  16772. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16773. * @param onCompiled Callback triggered at the and of the effects compilation
  16774. * @param options Sets of optional options forcing the compilation with different modes
  16775. */
  16776. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16777. useInstances: boolean;
  16778. }>): void;
  16779. /**
  16780. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16781. * @param options Sets of optional options forcing the compilation with different modes
  16782. * @returns A promise that resolves when the compilation completes
  16783. */
  16784. forceCompilationAsync(options?: Partial<{
  16785. useInstances: boolean;
  16786. }>): Promise<void>;
  16787. /**
  16788. * Serializes the shadow generator setup to a json object.
  16789. * @returns The serialized JSON object
  16790. */
  16791. serialize(): any;
  16792. /**
  16793. * Disposes the Shadow map and related Textures and effects.
  16794. */
  16795. dispose(): void;
  16796. }
  16797. /**
  16798. * Default implementation IShadowGenerator.
  16799. * This is the main object responsible of generating shadows in the framework.
  16800. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16801. */
  16802. export class ShadowGenerator implements IShadowGenerator {
  16803. /**
  16804. * Name of the shadow generator class
  16805. */
  16806. static CLASSNAME: string;
  16807. /**
  16808. * Shadow generator mode None: no filtering applied.
  16809. */
  16810. static readonly FILTER_NONE: number;
  16811. /**
  16812. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16813. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16814. */
  16815. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16816. /**
  16817. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16818. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16819. */
  16820. static readonly FILTER_POISSONSAMPLING: number;
  16821. /**
  16822. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16823. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16824. */
  16825. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16826. /**
  16827. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16828. * edge artifacts on steep falloff.
  16829. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16830. */
  16831. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16832. /**
  16833. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16834. * edge artifacts on steep falloff.
  16835. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16836. */
  16837. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16838. /**
  16839. * Shadow generator mode PCF: Percentage Closer Filtering
  16840. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16841. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16842. */
  16843. static readonly FILTER_PCF: number;
  16844. /**
  16845. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16846. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16847. * Contact Hardening
  16848. */
  16849. static readonly FILTER_PCSS: number;
  16850. /**
  16851. * Reserved for PCF and PCSS
  16852. * Highest Quality.
  16853. *
  16854. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16855. *
  16856. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16857. */
  16858. static readonly QUALITY_HIGH: number;
  16859. /**
  16860. * Reserved for PCF and PCSS
  16861. * Good tradeoff for quality/perf cross devices
  16862. *
  16863. * Execute PCF on a 3*3 kernel.
  16864. *
  16865. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16866. */
  16867. static readonly QUALITY_MEDIUM: number;
  16868. /**
  16869. * Reserved for PCF and PCSS
  16870. * The lowest quality but the fastest.
  16871. *
  16872. * Execute PCF on a 1*1 kernel.
  16873. *
  16874. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16875. */
  16876. static readonly QUALITY_LOW: number;
  16877. /** Gets or sets the custom shader name to use */
  16878. customShaderOptions: ICustomShaderOptions;
  16879. /**
  16880. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16881. */
  16882. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16883. /**
  16884. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16885. */
  16886. onAfterShadowMapRenderObservable: Observable<Effect>;
  16887. /**
  16888. * Observable triggered before a mesh is rendered in the shadow map.
  16889. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16890. */
  16891. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16892. /**
  16893. * Observable triggered after a mesh is rendered in the shadow map.
  16894. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16895. */
  16896. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16897. protected _bias: number;
  16898. /**
  16899. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16900. */
  16901. get bias(): number;
  16902. /**
  16903. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16904. */
  16905. set bias(bias: number);
  16906. protected _normalBias: number;
  16907. /**
  16908. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16909. */
  16910. get normalBias(): number;
  16911. /**
  16912. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16913. */
  16914. set normalBias(normalBias: number);
  16915. protected _blurBoxOffset: number;
  16916. /**
  16917. * Gets the blur box offset: offset applied during the blur pass.
  16918. * Only useful if useKernelBlur = false
  16919. */
  16920. get blurBoxOffset(): number;
  16921. /**
  16922. * Sets the blur box offset: offset applied during the blur pass.
  16923. * Only useful if useKernelBlur = false
  16924. */
  16925. set blurBoxOffset(value: number);
  16926. protected _blurScale: number;
  16927. /**
  16928. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16929. * 2 means half of the size.
  16930. */
  16931. get blurScale(): number;
  16932. /**
  16933. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16934. * 2 means half of the size.
  16935. */
  16936. set blurScale(value: number);
  16937. protected _blurKernel: number;
  16938. /**
  16939. * Gets the blur kernel: kernel size of the blur pass.
  16940. * Only useful if useKernelBlur = true
  16941. */
  16942. get blurKernel(): number;
  16943. /**
  16944. * Sets the blur kernel: kernel size of the blur pass.
  16945. * Only useful if useKernelBlur = true
  16946. */
  16947. set blurKernel(value: number);
  16948. protected _useKernelBlur: boolean;
  16949. /**
  16950. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16951. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16952. */
  16953. get useKernelBlur(): boolean;
  16954. /**
  16955. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16956. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16957. */
  16958. set useKernelBlur(value: boolean);
  16959. protected _depthScale: number;
  16960. /**
  16961. * Gets the depth scale used in ESM mode.
  16962. */
  16963. get depthScale(): number;
  16964. /**
  16965. * Sets the depth scale used in ESM mode.
  16966. * This can override the scale stored on the light.
  16967. */
  16968. set depthScale(value: number);
  16969. protected _validateFilter(filter: number): number;
  16970. protected _filter: number;
  16971. /**
  16972. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16973. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16974. */
  16975. get filter(): number;
  16976. /**
  16977. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16978. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16979. */
  16980. set filter(value: number);
  16981. /**
  16982. * Gets if the current filter is set to Poisson Sampling.
  16983. */
  16984. get usePoissonSampling(): boolean;
  16985. /**
  16986. * Sets the current filter to Poisson Sampling.
  16987. */
  16988. set usePoissonSampling(value: boolean);
  16989. /**
  16990. * Gets if the current filter is set to ESM.
  16991. */
  16992. get useExponentialShadowMap(): boolean;
  16993. /**
  16994. * Sets the current filter is to ESM.
  16995. */
  16996. set useExponentialShadowMap(value: boolean);
  16997. /**
  16998. * Gets if the current filter is set to filtered ESM.
  16999. */
  17000. get useBlurExponentialShadowMap(): boolean;
  17001. /**
  17002. * Gets if the current filter is set to filtered ESM.
  17003. */
  17004. set useBlurExponentialShadowMap(value: boolean);
  17005. /**
  17006. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17007. * exponential to prevent steep falloff artifacts).
  17008. */
  17009. get useCloseExponentialShadowMap(): boolean;
  17010. /**
  17011. * Sets the current filter to "close ESM" (using the inverse of the
  17012. * exponential to prevent steep falloff artifacts).
  17013. */
  17014. set useCloseExponentialShadowMap(value: boolean);
  17015. /**
  17016. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17017. * exponential to prevent steep falloff artifacts).
  17018. */
  17019. get useBlurCloseExponentialShadowMap(): boolean;
  17020. /**
  17021. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17022. * exponential to prevent steep falloff artifacts).
  17023. */
  17024. set useBlurCloseExponentialShadowMap(value: boolean);
  17025. /**
  17026. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17027. */
  17028. get usePercentageCloserFiltering(): boolean;
  17029. /**
  17030. * Sets the current filter to "PCF" (percentage closer filtering).
  17031. */
  17032. set usePercentageCloserFiltering(value: boolean);
  17033. protected _filteringQuality: number;
  17034. /**
  17035. * Gets the PCF or PCSS Quality.
  17036. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17037. */
  17038. get filteringQuality(): number;
  17039. /**
  17040. * Sets the PCF or PCSS Quality.
  17041. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17042. */
  17043. set filteringQuality(filteringQuality: number);
  17044. /**
  17045. * Gets if the current filter is set to "PCSS" (contact hardening).
  17046. */
  17047. get useContactHardeningShadow(): boolean;
  17048. /**
  17049. * Sets the current filter to "PCSS" (contact hardening).
  17050. */
  17051. set useContactHardeningShadow(value: boolean);
  17052. protected _contactHardeningLightSizeUVRatio: number;
  17053. /**
  17054. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17055. * Using a ratio helps keeping shape stability independently of the map size.
  17056. *
  17057. * It does not account for the light projection as it was having too much
  17058. * instability during the light setup or during light position changes.
  17059. *
  17060. * Only valid if useContactHardeningShadow is true.
  17061. */
  17062. get contactHardeningLightSizeUVRatio(): number;
  17063. /**
  17064. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17065. * Using a ratio helps keeping shape stability independently of the map size.
  17066. *
  17067. * It does not account for the light projection as it was having too much
  17068. * instability during the light setup or during light position changes.
  17069. *
  17070. * Only valid if useContactHardeningShadow is true.
  17071. */
  17072. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17073. protected _darkness: number;
  17074. /** Gets or sets the actual darkness of a shadow */
  17075. get darkness(): number;
  17076. set darkness(value: number);
  17077. /**
  17078. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17079. * 0 means strongest and 1 would means no shadow.
  17080. * @returns the darkness.
  17081. */
  17082. getDarkness(): number;
  17083. /**
  17084. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17085. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17086. * @returns the shadow generator allowing fluent coding.
  17087. */
  17088. setDarkness(darkness: number): ShadowGenerator;
  17089. protected _transparencyShadow: boolean;
  17090. /** Gets or sets the ability to have transparent shadow */
  17091. get transparencyShadow(): boolean;
  17092. set transparencyShadow(value: boolean);
  17093. /**
  17094. * Sets the ability to have transparent shadow (boolean).
  17095. * @param transparent True if transparent else False
  17096. * @returns the shadow generator allowing fluent coding
  17097. */
  17098. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17099. protected _shadowMap: Nullable<RenderTargetTexture>;
  17100. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17101. /**
  17102. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17103. * @returns The render target texture if present otherwise, null
  17104. */
  17105. getShadowMap(): Nullable<RenderTargetTexture>;
  17106. /**
  17107. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17108. * @returns The render target texture if the shadow map is present otherwise, null
  17109. */
  17110. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17111. /**
  17112. * Gets the class name of that object
  17113. * @returns "ShadowGenerator"
  17114. */
  17115. getClassName(): string;
  17116. /**
  17117. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17118. * @param mesh Mesh to add
  17119. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17120. * @returns the Shadow Generator itself
  17121. */
  17122. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17123. /**
  17124. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17125. * @param mesh Mesh to remove
  17126. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17127. * @returns the Shadow Generator itself
  17128. */
  17129. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17130. /**
  17131. * Controls the extent to which the shadows fade out at the edge of the frustum
  17132. */
  17133. frustumEdgeFalloff: number;
  17134. protected _light: IShadowLight;
  17135. /**
  17136. * Returns the associated light object.
  17137. * @returns the light generating the shadow
  17138. */
  17139. getLight(): IShadowLight;
  17140. /**
  17141. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17142. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17143. * It might on the other hand introduce peter panning.
  17144. */
  17145. forceBackFacesOnly: boolean;
  17146. protected _scene: Scene;
  17147. protected _lightDirection: Vector3;
  17148. protected _effect: Effect;
  17149. protected _viewMatrix: Matrix;
  17150. protected _projectionMatrix: Matrix;
  17151. protected _transformMatrix: Matrix;
  17152. protected _cachedPosition: Vector3;
  17153. protected _cachedDirection: Vector3;
  17154. protected _cachedDefines: string;
  17155. protected _currentRenderID: number;
  17156. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17157. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17158. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17159. protected _blurPostProcesses: PostProcess[];
  17160. protected _mapSize: number;
  17161. protected _currentFaceIndex: number;
  17162. protected _currentFaceIndexCache: number;
  17163. protected _textureType: number;
  17164. protected _defaultTextureMatrix: Matrix;
  17165. protected _storedUniqueId: Nullable<number>;
  17166. /** @hidden */
  17167. static _SceneComponentInitialization: (scene: Scene) => void;
  17168. /**
  17169. * Creates a ShadowGenerator object.
  17170. * A ShadowGenerator is the required tool to use the shadows.
  17171. * Each light casting shadows needs to use its own ShadowGenerator.
  17172. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17173. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17174. * @param light The light object generating the shadows.
  17175. * @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.
  17176. */
  17177. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17178. protected _initializeGenerator(): void;
  17179. protected _createTargetRenderTexture(): void;
  17180. protected _initializeShadowMap(): void;
  17181. protected _initializeBlurRTTAndPostProcesses(): void;
  17182. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17183. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17184. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17185. protected _applyFilterValues(): void;
  17186. /**
  17187. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17188. * @param onCompiled Callback triggered at the and of the effects compilation
  17189. * @param options Sets of optional options forcing the compilation with different modes
  17190. */
  17191. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17192. useInstances: boolean;
  17193. }>): void;
  17194. /**
  17195. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17196. * @param options Sets of optional options forcing the compilation with different modes
  17197. * @returns A promise that resolves when the compilation completes
  17198. */
  17199. forceCompilationAsync(options?: Partial<{
  17200. useInstances: boolean;
  17201. }>): Promise<void>;
  17202. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17203. /**
  17204. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17205. * @param subMesh The submesh we want to render in the shadow map
  17206. * @param useInstances Defines wether will draw in the map using instances
  17207. * @returns true if ready otherwise, false
  17208. */
  17209. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17210. /**
  17211. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17212. * @param defines Defines of the material we want to update
  17213. * @param lightIndex Index of the light in the enabled light list of the material
  17214. */
  17215. prepareDefines(defines: any, lightIndex: number): void;
  17216. /**
  17217. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17218. * defined in the generator but impacting the effect).
  17219. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17220. * @param effect The effect we are binfing the information for
  17221. */
  17222. bindShadowLight(lightIndex: string, effect: Effect): void;
  17223. /**
  17224. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17225. * (eq to shadow prjection matrix * light transform matrix)
  17226. * @returns The transform matrix used to create the shadow map
  17227. */
  17228. getTransformMatrix(): Matrix;
  17229. /**
  17230. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17231. * Cube and 2D textures for instance.
  17232. */
  17233. recreateShadowMap(): void;
  17234. protected _disposeBlurPostProcesses(): void;
  17235. protected _disposeRTTandPostProcesses(): void;
  17236. /**
  17237. * Disposes the ShadowGenerator.
  17238. * Returns nothing.
  17239. */
  17240. dispose(): void;
  17241. /**
  17242. * Serializes the shadow generator setup to a json object.
  17243. * @returns The serialized JSON object
  17244. */
  17245. serialize(): any;
  17246. /**
  17247. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17248. * @param parsedShadowGenerator The JSON object to parse
  17249. * @param scene The scene to create the shadow map for
  17250. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17251. * @returns The parsed shadow generator
  17252. */
  17253. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17254. }
  17255. }
  17256. declare module "babylonjs/Lights/light" {
  17257. import { Nullable } from "babylonjs/types";
  17258. import { Scene } from "babylonjs/scene";
  17259. import { Vector3 } from "babylonjs/Maths/math.vector";
  17260. import { Color3 } from "babylonjs/Maths/math.color";
  17261. import { Node } from "babylonjs/node";
  17262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17263. import { Effect } from "babylonjs/Materials/effect";
  17264. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17265. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17266. /**
  17267. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17268. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17269. * 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.
  17270. */
  17271. export abstract class Light extends Node {
  17272. /**
  17273. * Falloff Default: light is falling off following the material specification:
  17274. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17275. */
  17276. static readonly FALLOFF_DEFAULT: number;
  17277. /**
  17278. * Falloff Physical: light is falling off following the inverse squared distance law.
  17279. */
  17280. static readonly FALLOFF_PHYSICAL: number;
  17281. /**
  17282. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17283. * to enhance interoperability with other engines.
  17284. */
  17285. static readonly FALLOFF_GLTF: number;
  17286. /**
  17287. * Falloff Standard: light is falling off like in the standard material
  17288. * to enhance interoperability with other materials.
  17289. */
  17290. static readonly FALLOFF_STANDARD: number;
  17291. /**
  17292. * If every light affecting the material is in this lightmapMode,
  17293. * material.lightmapTexture adds or multiplies
  17294. * (depends on material.useLightmapAsShadowmap)
  17295. * after every other light calculations.
  17296. */
  17297. static readonly LIGHTMAP_DEFAULT: number;
  17298. /**
  17299. * material.lightmapTexture as only diffuse lighting from this light
  17300. * adds only specular lighting from this light
  17301. * adds dynamic shadows
  17302. */
  17303. static readonly LIGHTMAP_SPECULAR: number;
  17304. /**
  17305. * material.lightmapTexture as only lighting
  17306. * no light calculation from this light
  17307. * only adds dynamic shadows from this light
  17308. */
  17309. static readonly LIGHTMAP_SHADOWSONLY: number;
  17310. /**
  17311. * Each light type uses the default quantity according to its type:
  17312. * point/spot lights use luminous intensity
  17313. * directional lights use illuminance
  17314. */
  17315. static readonly INTENSITYMODE_AUTOMATIC: number;
  17316. /**
  17317. * lumen (lm)
  17318. */
  17319. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17320. /**
  17321. * candela (lm/sr)
  17322. */
  17323. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17324. /**
  17325. * lux (lm/m^2)
  17326. */
  17327. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17328. /**
  17329. * nit (cd/m^2)
  17330. */
  17331. static readonly INTENSITYMODE_LUMINANCE: number;
  17332. /**
  17333. * Light type const id of the point light.
  17334. */
  17335. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17336. /**
  17337. * Light type const id of the directional light.
  17338. */
  17339. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17340. /**
  17341. * Light type const id of the spot light.
  17342. */
  17343. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17344. /**
  17345. * Light type const id of the hemispheric light.
  17346. */
  17347. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17348. /**
  17349. * Diffuse gives the basic color to an object.
  17350. */
  17351. diffuse: Color3;
  17352. /**
  17353. * Specular produces a highlight color on an object.
  17354. * Note: This is note affecting PBR materials.
  17355. */
  17356. specular: Color3;
  17357. /**
  17358. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17359. * falling off base on range or angle.
  17360. * This can be set to any values in Light.FALLOFF_x.
  17361. *
  17362. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17363. * other types of materials.
  17364. */
  17365. falloffType: number;
  17366. /**
  17367. * Strength of the light.
  17368. * Note: By default it is define in the framework own unit.
  17369. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17370. */
  17371. intensity: number;
  17372. private _range;
  17373. protected _inverseSquaredRange: number;
  17374. /**
  17375. * Defines how far from the source the light is impacting in scene units.
  17376. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17377. */
  17378. get range(): number;
  17379. /**
  17380. * Defines how far from the source the light is impacting in scene units.
  17381. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17382. */
  17383. set range(value: number);
  17384. /**
  17385. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17386. * of light.
  17387. */
  17388. private _photometricScale;
  17389. private _intensityMode;
  17390. /**
  17391. * Gets the photometric scale used to interpret the intensity.
  17392. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17393. */
  17394. get intensityMode(): number;
  17395. /**
  17396. * Sets the photometric scale used to interpret the intensity.
  17397. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17398. */
  17399. set intensityMode(value: number);
  17400. private _radius;
  17401. /**
  17402. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17403. */
  17404. get radius(): number;
  17405. /**
  17406. * sets the light radius used by PBR Materials to simulate soft area lights.
  17407. */
  17408. set radius(value: number);
  17409. private _renderPriority;
  17410. /**
  17411. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17412. * exceeding the number allowed of the materials.
  17413. */
  17414. renderPriority: number;
  17415. private _shadowEnabled;
  17416. /**
  17417. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17418. * the current shadow generator.
  17419. */
  17420. get shadowEnabled(): boolean;
  17421. /**
  17422. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17423. * the current shadow generator.
  17424. */
  17425. set shadowEnabled(value: boolean);
  17426. private _includedOnlyMeshes;
  17427. /**
  17428. * Gets the only meshes impacted by this light.
  17429. */
  17430. get includedOnlyMeshes(): AbstractMesh[];
  17431. /**
  17432. * Sets the only meshes impacted by this light.
  17433. */
  17434. set includedOnlyMeshes(value: AbstractMesh[]);
  17435. private _excludedMeshes;
  17436. /**
  17437. * Gets the meshes not impacted by this light.
  17438. */
  17439. get excludedMeshes(): AbstractMesh[];
  17440. /**
  17441. * Sets the meshes not impacted by this light.
  17442. */
  17443. set excludedMeshes(value: AbstractMesh[]);
  17444. private _excludeWithLayerMask;
  17445. /**
  17446. * Gets the layer id use to find what meshes are not impacted by the light.
  17447. * Inactive if 0
  17448. */
  17449. get excludeWithLayerMask(): number;
  17450. /**
  17451. * Sets the layer id use to find what meshes are not impacted by the light.
  17452. * Inactive if 0
  17453. */
  17454. set excludeWithLayerMask(value: number);
  17455. private _includeOnlyWithLayerMask;
  17456. /**
  17457. * Gets the layer id use to find what meshes are impacted by the light.
  17458. * Inactive if 0
  17459. */
  17460. get includeOnlyWithLayerMask(): number;
  17461. /**
  17462. * Sets the layer id use to find what meshes are impacted by the light.
  17463. * Inactive if 0
  17464. */
  17465. set includeOnlyWithLayerMask(value: number);
  17466. private _lightmapMode;
  17467. /**
  17468. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17469. */
  17470. get lightmapMode(): number;
  17471. /**
  17472. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17473. */
  17474. set lightmapMode(value: number);
  17475. /**
  17476. * Shadow generator associted to the light.
  17477. * @hidden Internal use only.
  17478. */
  17479. _shadowGenerator: Nullable<IShadowGenerator>;
  17480. /**
  17481. * @hidden Internal use only.
  17482. */
  17483. _excludedMeshesIds: string[];
  17484. /**
  17485. * @hidden Internal use only.
  17486. */
  17487. _includedOnlyMeshesIds: string[];
  17488. /**
  17489. * The current light unifom buffer.
  17490. * @hidden Internal use only.
  17491. */
  17492. _uniformBuffer: UniformBuffer;
  17493. /** @hidden */
  17494. _renderId: number;
  17495. /**
  17496. * Creates a Light object in the scene.
  17497. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17498. * @param name The firendly name of the light
  17499. * @param scene The scene the light belongs too
  17500. */
  17501. constructor(name: string, scene: Scene);
  17502. protected abstract _buildUniformLayout(): void;
  17503. /**
  17504. * Sets the passed Effect "effect" with the Light information.
  17505. * @param effect The effect to update
  17506. * @param lightIndex The index of the light in the effect to update
  17507. * @returns The light
  17508. */
  17509. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17510. /**
  17511. * Sets the passed Effect "effect" with the Light textures.
  17512. * @param effect The effect to update
  17513. * @param lightIndex The index of the light in the effect to update
  17514. * @returns The light
  17515. */
  17516. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17517. /**
  17518. * Binds the lights information from the scene to the effect for the given mesh.
  17519. * @param lightIndex Light index
  17520. * @param scene The scene where the light belongs to
  17521. * @param effect The effect we are binding the data to
  17522. * @param useSpecular Defines if specular is supported
  17523. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17524. */
  17525. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17526. /**
  17527. * Sets the passed Effect "effect" with the Light information.
  17528. * @param effect The effect to update
  17529. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17530. * @returns The light
  17531. */
  17532. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17533. /**
  17534. * Returns the string "Light".
  17535. * @returns the class name
  17536. */
  17537. getClassName(): string;
  17538. /** @hidden */
  17539. readonly _isLight: boolean;
  17540. /**
  17541. * Converts the light information to a readable string for debug purpose.
  17542. * @param fullDetails Supports for multiple levels of logging within scene loading
  17543. * @returns the human readable light info
  17544. */
  17545. toString(fullDetails?: boolean): string;
  17546. /** @hidden */
  17547. protected _syncParentEnabledState(): void;
  17548. /**
  17549. * Set the enabled state of this node.
  17550. * @param value - the new enabled state
  17551. */
  17552. setEnabled(value: boolean): void;
  17553. /**
  17554. * Returns the Light associated shadow generator if any.
  17555. * @return the associated shadow generator.
  17556. */
  17557. getShadowGenerator(): Nullable<IShadowGenerator>;
  17558. /**
  17559. * Returns a Vector3, the absolute light position in the World.
  17560. * @returns the world space position of the light
  17561. */
  17562. getAbsolutePosition(): Vector3;
  17563. /**
  17564. * Specifies if the light will affect the passed mesh.
  17565. * @param mesh The mesh to test against the light
  17566. * @return true the mesh is affected otherwise, false.
  17567. */
  17568. canAffectMesh(mesh: AbstractMesh): boolean;
  17569. /**
  17570. * Sort function to order lights for rendering.
  17571. * @param a First Light object to compare to second.
  17572. * @param b Second Light object to compare first.
  17573. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17574. */
  17575. static CompareLightsPriority(a: Light, b: Light): number;
  17576. /**
  17577. * Releases resources associated with this node.
  17578. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17579. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17580. */
  17581. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17582. /**
  17583. * Returns the light type ID (integer).
  17584. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17585. */
  17586. getTypeID(): number;
  17587. /**
  17588. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17589. * @returns the scaled intensity in intensity mode unit
  17590. */
  17591. getScaledIntensity(): number;
  17592. /**
  17593. * Returns a new Light object, named "name", from the current one.
  17594. * @param name The name of the cloned light
  17595. * @returns the new created light
  17596. */
  17597. clone(name: string): Nullable<Light>;
  17598. /**
  17599. * Serializes the current light into a Serialization object.
  17600. * @returns the serialized object.
  17601. */
  17602. serialize(): any;
  17603. /**
  17604. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17605. * This new light is named "name" and added to the passed scene.
  17606. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17607. * @param name The friendly name of the light
  17608. * @param scene The scene the new light will belong to
  17609. * @returns the constructor function
  17610. */
  17611. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17612. /**
  17613. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17614. * @param parsedLight The JSON representation of the light
  17615. * @param scene The scene to create the parsed light in
  17616. * @returns the created light after parsing
  17617. */
  17618. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17619. private _hookArrayForExcluded;
  17620. private _hookArrayForIncludedOnly;
  17621. private _resyncMeshes;
  17622. /**
  17623. * Forces the meshes to update their light related information in their rendering used effects
  17624. * @hidden Internal Use Only
  17625. */
  17626. _markMeshesAsLightDirty(): void;
  17627. /**
  17628. * Recomputes the cached photometric scale if needed.
  17629. */
  17630. private _computePhotometricScale;
  17631. /**
  17632. * Returns the Photometric Scale according to the light type and intensity mode.
  17633. */
  17634. private _getPhotometricScale;
  17635. /**
  17636. * Reorder the light in the scene according to their defined priority.
  17637. * @hidden Internal Use Only
  17638. */
  17639. _reorderLightsInScene(): void;
  17640. /**
  17641. * Prepares the list of defines specific to the light type.
  17642. * @param defines the list of defines
  17643. * @param lightIndex defines the index of the light for the effect
  17644. */
  17645. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17646. }
  17647. }
  17648. declare module "babylonjs/Actions/action" {
  17649. import { Observable } from "babylonjs/Misc/observable";
  17650. import { Condition } from "babylonjs/Actions/condition";
  17651. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17652. import { ActionManager } from "babylonjs/Actions/actionManager";
  17653. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17654. /**
  17655. * Interface used to define Action
  17656. */
  17657. export interface IAction {
  17658. /**
  17659. * Trigger for the action
  17660. */
  17661. trigger: number;
  17662. /** Options of the trigger */
  17663. triggerOptions: any;
  17664. /**
  17665. * Gets the trigger parameters
  17666. * @returns the trigger parameters
  17667. */
  17668. getTriggerParameter(): any;
  17669. /**
  17670. * Internal only - executes current action event
  17671. * @hidden
  17672. */
  17673. _executeCurrent(evt?: ActionEvent): void;
  17674. /**
  17675. * Serialize placeholder for child classes
  17676. * @param parent of child
  17677. * @returns the serialized object
  17678. */
  17679. serialize(parent: any): any;
  17680. /**
  17681. * Internal only
  17682. * @hidden
  17683. */
  17684. _prepare(): void;
  17685. /**
  17686. * Internal only - manager for action
  17687. * @hidden
  17688. */
  17689. _actionManager: AbstractActionManager;
  17690. /**
  17691. * Adds action to chain of actions, may be a DoNothingAction
  17692. * @param action defines the next action to execute
  17693. * @returns The action passed in
  17694. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17695. */
  17696. then(action: IAction): IAction;
  17697. }
  17698. /**
  17699. * The action to be carried out following a trigger
  17700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17701. */
  17702. export class Action implements IAction {
  17703. /** the trigger, with or without parameters, for the action */
  17704. triggerOptions: any;
  17705. /**
  17706. * Trigger for the action
  17707. */
  17708. trigger: number;
  17709. /**
  17710. * Internal only - manager for action
  17711. * @hidden
  17712. */
  17713. _actionManager: ActionManager;
  17714. private _nextActiveAction;
  17715. private _child;
  17716. private _condition?;
  17717. private _triggerParameter;
  17718. /**
  17719. * An event triggered prior to action being executed.
  17720. */
  17721. onBeforeExecuteObservable: Observable<Action>;
  17722. /**
  17723. * Creates a new Action
  17724. * @param triggerOptions the trigger, with or without parameters, for the action
  17725. * @param condition an optional determinant of action
  17726. */
  17727. constructor(
  17728. /** the trigger, with or without parameters, for the action */
  17729. triggerOptions: any, condition?: Condition);
  17730. /**
  17731. * Internal only
  17732. * @hidden
  17733. */
  17734. _prepare(): void;
  17735. /**
  17736. * Gets the trigger parameters
  17737. * @returns the trigger parameters
  17738. */
  17739. getTriggerParameter(): any;
  17740. /**
  17741. * Internal only - executes current action event
  17742. * @hidden
  17743. */
  17744. _executeCurrent(evt?: ActionEvent): void;
  17745. /**
  17746. * Execute placeholder for child classes
  17747. * @param evt optional action event
  17748. */
  17749. execute(evt?: ActionEvent): void;
  17750. /**
  17751. * Skips to next active action
  17752. */
  17753. skipToNextActiveAction(): void;
  17754. /**
  17755. * Adds action to chain of actions, may be a DoNothingAction
  17756. * @param action defines the next action to execute
  17757. * @returns The action passed in
  17758. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17759. */
  17760. then(action: Action): Action;
  17761. /**
  17762. * Internal only
  17763. * @hidden
  17764. */
  17765. _getProperty(propertyPath: string): string;
  17766. /**
  17767. * Internal only
  17768. * @hidden
  17769. */
  17770. _getEffectiveTarget(target: any, propertyPath: string): any;
  17771. /**
  17772. * Serialize placeholder for child classes
  17773. * @param parent of child
  17774. * @returns the serialized object
  17775. */
  17776. serialize(parent: any): any;
  17777. /**
  17778. * Internal only called by serialize
  17779. * @hidden
  17780. */
  17781. protected _serialize(serializedAction: any, parent?: any): any;
  17782. /**
  17783. * Internal only
  17784. * @hidden
  17785. */
  17786. static _SerializeValueAsString: (value: any) => string;
  17787. /**
  17788. * Internal only
  17789. * @hidden
  17790. */
  17791. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17792. name: string;
  17793. targetType: string;
  17794. value: string;
  17795. };
  17796. }
  17797. }
  17798. declare module "babylonjs/Actions/condition" {
  17799. import { ActionManager } from "babylonjs/Actions/actionManager";
  17800. /**
  17801. * A Condition applied to an Action
  17802. */
  17803. export class Condition {
  17804. /**
  17805. * Internal only - manager for action
  17806. * @hidden
  17807. */
  17808. _actionManager: ActionManager;
  17809. /**
  17810. * Internal only
  17811. * @hidden
  17812. */
  17813. _evaluationId: number;
  17814. /**
  17815. * Internal only
  17816. * @hidden
  17817. */
  17818. _currentResult: boolean;
  17819. /**
  17820. * Creates a new Condition
  17821. * @param actionManager the manager of the action the condition is applied to
  17822. */
  17823. constructor(actionManager: ActionManager);
  17824. /**
  17825. * Check if the current condition is valid
  17826. * @returns a boolean
  17827. */
  17828. isValid(): boolean;
  17829. /**
  17830. * Internal only
  17831. * @hidden
  17832. */
  17833. _getProperty(propertyPath: string): string;
  17834. /**
  17835. * Internal only
  17836. * @hidden
  17837. */
  17838. _getEffectiveTarget(target: any, propertyPath: string): any;
  17839. /**
  17840. * Serialize placeholder for child classes
  17841. * @returns the serialized object
  17842. */
  17843. serialize(): any;
  17844. /**
  17845. * Internal only
  17846. * @hidden
  17847. */
  17848. protected _serialize(serializedCondition: any): any;
  17849. }
  17850. /**
  17851. * Defines specific conditional operators as extensions of Condition
  17852. */
  17853. export class ValueCondition extends Condition {
  17854. /** path to specify the property of the target the conditional operator uses */
  17855. propertyPath: string;
  17856. /** the value compared by the conditional operator against the current value of the property */
  17857. value: any;
  17858. /** the conditional operator, default ValueCondition.IsEqual */
  17859. operator: number;
  17860. /**
  17861. * Internal only
  17862. * @hidden
  17863. */
  17864. private static _IsEqual;
  17865. /**
  17866. * Internal only
  17867. * @hidden
  17868. */
  17869. private static _IsDifferent;
  17870. /**
  17871. * Internal only
  17872. * @hidden
  17873. */
  17874. private static _IsGreater;
  17875. /**
  17876. * Internal only
  17877. * @hidden
  17878. */
  17879. private static _IsLesser;
  17880. /**
  17881. * returns the number for IsEqual
  17882. */
  17883. static get IsEqual(): number;
  17884. /**
  17885. * Returns the number for IsDifferent
  17886. */
  17887. static get IsDifferent(): number;
  17888. /**
  17889. * Returns the number for IsGreater
  17890. */
  17891. static get IsGreater(): number;
  17892. /**
  17893. * Returns the number for IsLesser
  17894. */
  17895. static get IsLesser(): number;
  17896. /**
  17897. * Internal only The action manager for the condition
  17898. * @hidden
  17899. */
  17900. _actionManager: ActionManager;
  17901. /**
  17902. * Internal only
  17903. * @hidden
  17904. */
  17905. private _target;
  17906. /**
  17907. * Internal only
  17908. * @hidden
  17909. */
  17910. private _effectiveTarget;
  17911. /**
  17912. * Internal only
  17913. * @hidden
  17914. */
  17915. private _property;
  17916. /**
  17917. * Creates a new ValueCondition
  17918. * @param actionManager manager for the action the condition applies to
  17919. * @param target for the action
  17920. * @param propertyPath path to specify the property of the target the conditional operator uses
  17921. * @param value the value compared by the conditional operator against the current value of the property
  17922. * @param operator the conditional operator, default ValueCondition.IsEqual
  17923. */
  17924. constructor(actionManager: ActionManager, target: any,
  17925. /** path to specify the property of the target the conditional operator uses */
  17926. propertyPath: string,
  17927. /** the value compared by the conditional operator against the current value of the property */
  17928. value: any,
  17929. /** the conditional operator, default ValueCondition.IsEqual */
  17930. operator?: number);
  17931. /**
  17932. * Compares the given value with the property value for the specified conditional operator
  17933. * @returns the result of the comparison
  17934. */
  17935. isValid(): boolean;
  17936. /**
  17937. * Serialize the ValueCondition into a JSON compatible object
  17938. * @returns serialization object
  17939. */
  17940. serialize(): any;
  17941. /**
  17942. * Gets the name of the conditional operator for the ValueCondition
  17943. * @param operator the conditional operator
  17944. * @returns the name
  17945. */
  17946. static GetOperatorName(operator: number): string;
  17947. }
  17948. /**
  17949. * Defines a predicate condition as an extension of Condition
  17950. */
  17951. export class PredicateCondition extends Condition {
  17952. /** defines the predicate function used to validate the condition */
  17953. predicate: () => boolean;
  17954. /**
  17955. * Internal only - manager for action
  17956. * @hidden
  17957. */
  17958. _actionManager: ActionManager;
  17959. /**
  17960. * Creates a new PredicateCondition
  17961. * @param actionManager manager for the action the condition applies to
  17962. * @param predicate defines the predicate function used to validate the condition
  17963. */
  17964. constructor(actionManager: ActionManager,
  17965. /** defines the predicate function used to validate the condition */
  17966. predicate: () => boolean);
  17967. /**
  17968. * @returns the validity of the predicate condition
  17969. */
  17970. isValid(): boolean;
  17971. }
  17972. /**
  17973. * Defines a state condition as an extension of Condition
  17974. */
  17975. export class StateCondition extends Condition {
  17976. /** Value to compare with target state */
  17977. value: string;
  17978. /**
  17979. * Internal only - manager for action
  17980. * @hidden
  17981. */
  17982. _actionManager: ActionManager;
  17983. /**
  17984. * Internal only
  17985. * @hidden
  17986. */
  17987. private _target;
  17988. /**
  17989. * Creates a new StateCondition
  17990. * @param actionManager manager for the action the condition applies to
  17991. * @param target of the condition
  17992. * @param value to compare with target state
  17993. */
  17994. constructor(actionManager: ActionManager, target: any,
  17995. /** Value to compare with target state */
  17996. value: string);
  17997. /**
  17998. * Gets a boolean indicating if the current condition is met
  17999. * @returns the validity of the state
  18000. */
  18001. isValid(): boolean;
  18002. /**
  18003. * Serialize the StateCondition into a JSON compatible object
  18004. * @returns serialization object
  18005. */
  18006. serialize(): any;
  18007. }
  18008. }
  18009. declare module "babylonjs/Actions/directActions" {
  18010. import { Action } from "babylonjs/Actions/action";
  18011. import { Condition } from "babylonjs/Actions/condition";
  18012. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18013. /**
  18014. * This defines an action responsible to toggle a boolean once triggered.
  18015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18016. */
  18017. export class SwitchBooleanAction extends Action {
  18018. /**
  18019. * The path to the boolean property in the target object
  18020. */
  18021. propertyPath: string;
  18022. private _target;
  18023. private _effectiveTarget;
  18024. private _property;
  18025. /**
  18026. * Instantiate the action
  18027. * @param triggerOptions defines the trigger options
  18028. * @param target defines the object containing the boolean
  18029. * @param propertyPath defines the path to the boolean property in the target object
  18030. * @param condition defines the trigger related conditions
  18031. */
  18032. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18033. /** @hidden */
  18034. _prepare(): void;
  18035. /**
  18036. * Execute the action toggle the boolean value.
  18037. */
  18038. execute(): void;
  18039. /**
  18040. * Serializes the actions and its related information.
  18041. * @param parent defines the object to serialize in
  18042. * @returns the serialized object
  18043. */
  18044. serialize(parent: any): any;
  18045. }
  18046. /**
  18047. * This defines an action responsible to set a the state field of the target
  18048. * to a desired value once triggered.
  18049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18050. */
  18051. export class SetStateAction extends Action {
  18052. /**
  18053. * The value to store in the state field.
  18054. */
  18055. value: string;
  18056. private _target;
  18057. /**
  18058. * Instantiate the action
  18059. * @param triggerOptions defines the trigger options
  18060. * @param target defines the object containing the state property
  18061. * @param value defines the value to store in the state field
  18062. * @param condition defines the trigger related conditions
  18063. */
  18064. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18065. /**
  18066. * Execute the action and store the value on the target state property.
  18067. */
  18068. execute(): void;
  18069. /**
  18070. * Serializes the actions and its related information.
  18071. * @param parent defines the object to serialize in
  18072. * @returns the serialized object
  18073. */
  18074. serialize(parent: any): any;
  18075. }
  18076. /**
  18077. * This defines an action responsible to set a property of the target
  18078. * to a desired value once triggered.
  18079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18080. */
  18081. export class SetValueAction extends Action {
  18082. /**
  18083. * The path of the property to set in the target.
  18084. */
  18085. propertyPath: string;
  18086. /**
  18087. * The value to set in the property
  18088. */
  18089. value: any;
  18090. private _target;
  18091. private _effectiveTarget;
  18092. private _property;
  18093. /**
  18094. * Instantiate the action
  18095. * @param triggerOptions defines the trigger options
  18096. * @param target defines the object containing the property
  18097. * @param propertyPath defines the path of the property to set in the target
  18098. * @param value defines the value to set in the property
  18099. * @param condition defines the trigger related conditions
  18100. */
  18101. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18102. /** @hidden */
  18103. _prepare(): void;
  18104. /**
  18105. * Execute the action and set the targetted property to the desired value.
  18106. */
  18107. execute(): void;
  18108. /**
  18109. * Serializes the actions and its related information.
  18110. * @param parent defines the object to serialize in
  18111. * @returns the serialized object
  18112. */
  18113. serialize(parent: any): any;
  18114. }
  18115. /**
  18116. * This defines an action responsible to increment the target value
  18117. * to a desired value once triggered.
  18118. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18119. */
  18120. export class IncrementValueAction extends Action {
  18121. /**
  18122. * The path of the property to increment in the target.
  18123. */
  18124. propertyPath: string;
  18125. /**
  18126. * The value we should increment the property by.
  18127. */
  18128. value: any;
  18129. private _target;
  18130. private _effectiveTarget;
  18131. private _property;
  18132. /**
  18133. * Instantiate the action
  18134. * @param triggerOptions defines the trigger options
  18135. * @param target defines the object containing the property
  18136. * @param propertyPath defines the path of the property to increment in the target
  18137. * @param value defines the value value we should increment the property by
  18138. * @param condition defines the trigger related conditions
  18139. */
  18140. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18141. /** @hidden */
  18142. _prepare(): void;
  18143. /**
  18144. * Execute the action and increment the target of the value amount.
  18145. */
  18146. execute(): void;
  18147. /**
  18148. * Serializes the actions and its related information.
  18149. * @param parent defines the object to serialize in
  18150. * @returns the serialized object
  18151. */
  18152. serialize(parent: any): any;
  18153. }
  18154. /**
  18155. * This defines an action responsible to start an animation once triggered.
  18156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18157. */
  18158. export class PlayAnimationAction extends Action {
  18159. /**
  18160. * Where the animation should start (animation frame)
  18161. */
  18162. from: number;
  18163. /**
  18164. * Where the animation should stop (animation frame)
  18165. */
  18166. to: number;
  18167. /**
  18168. * Define if the animation should loop or stop after the first play.
  18169. */
  18170. loop?: boolean;
  18171. private _target;
  18172. /**
  18173. * Instantiate the action
  18174. * @param triggerOptions defines the trigger options
  18175. * @param target defines the target animation or animation name
  18176. * @param from defines from where the animation should start (animation frame)
  18177. * @param end defines where the animation should stop (animation frame)
  18178. * @param loop defines if the animation should loop or stop after the first play
  18179. * @param condition defines the trigger related conditions
  18180. */
  18181. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18182. /** @hidden */
  18183. _prepare(): void;
  18184. /**
  18185. * Execute the action and play the animation.
  18186. */
  18187. execute(): void;
  18188. /**
  18189. * Serializes the actions and its related information.
  18190. * @param parent defines the object to serialize in
  18191. * @returns the serialized object
  18192. */
  18193. serialize(parent: any): any;
  18194. }
  18195. /**
  18196. * This defines an action responsible to stop an animation once triggered.
  18197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18198. */
  18199. export class StopAnimationAction extends Action {
  18200. private _target;
  18201. /**
  18202. * Instantiate the action
  18203. * @param triggerOptions defines the trigger options
  18204. * @param target defines the target animation or animation name
  18205. * @param condition defines the trigger related conditions
  18206. */
  18207. constructor(triggerOptions: any, target: any, condition?: Condition);
  18208. /** @hidden */
  18209. _prepare(): void;
  18210. /**
  18211. * Execute the action and stop the animation.
  18212. */
  18213. execute(): void;
  18214. /**
  18215. * Serializes the actions and its related information.
  18216. * @param parent defines the object to serialize in
  18217. * @returns the serialized object
  18218. */
  18219. serialize(parent: any): any;
  18220. }
  18221. /**
  18222. * This defines an action responsible that does nothing once triggered.
  18223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18224. */
  18225. export class DoNothingAction extends Action {
  18226. /**
  18227. * Instantiate the action
  18228. * @param triggerOptions defines the trigger options
  18229. * @param condition defines the trigger related conditions
  18230. */
  18231. constructor(triggerOptions?: any, condition?: Condition);
  18232. /**
  18233. * Execute the action and do nothing.
  18234. */
  18235. execute(): void;
  18236. /**
  18237. * Serializes the actions and its related information.
  18238. * @param parent defines the object to serialize in
  18239. * @returns the serialized object
  18240. */
  18241. serialize(parent: any): any;
  18242. }
  18243. /**
  18244. * This defines an action responsible to trigger several actions once triggered.
  18245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18246. */
  18247. export class CombineAction extends Action {
  18248. /**
  18249. * The list of aggregated animations to run.
  18250. */
  18251. children: Action[];
  18252. /**
  18253. * Instantiate the action
  18254. * @param triggerOptions defines the trigger options
  18255. * @param children defines the list of aggregated animations to run
  18256. * @param condition defines the trigger related conditions
  18257. */
  18258. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18259. /** @hidden */
  18260. _prepare(): void;
  18261. /**
  18262. * Execute the action and executes all the aggregated actions.
  18263. */
  18264. execute(evt: ActionEvent): void;
  18265. /**
  18266. * Serializes the actions and its related information.
  18267. * @param parent defines the object to serialize in
  18268. * @returns the serialized object
  18269. */
  18270. serialize(parent: any): any;
  18271. }
  18272. /**
  18273. * This defines an action responsible to run code (external event) once triggered.
  18274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18275. */
  18276. export class ExecuteCodeAction extends Action {
  18277. /**
  18278. * The callback function to run.
  18279. */
  18280. func: (evt: ActionEvent) => void;
  18281. /**
  18282. * Instantiate the action
  18283. * @param triggerOptions defines the trigger options
  18284. * @param func defines the callback function to run
  18285. * @param condition defines the trigger related conditions
  18286. */
  18287. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18288. /**
  18289. * Execute the action and run the attached code.
  18290. */
  18291. execute(evt: ActionEvent): void;
  18292. }
  18293. /**
  18294. * This defines an action responsible to set the parent property of the target once triggered.
  18295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18296. */
  18297. export class SetParentAction extends Action {
  18298. private _parent;
  18299. private _target;
  18300. /**
  18301. * Instantiate the action
  18302. * @param triggerOptions defines the trigger options
  18303. * @param target defines the target containing the parent property
  18304. * @param parent defines from where the animation should start (animation frame)
  18305. * @param condition defines the trigger related conditions
  18306. */
  18307. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18308. /** @hidden */
  18309. _prepare(): void;
  18310. /**
  18311. * Execute the action and set the parent property.
  18312. */
  18313. execute(): void;
  18314. /**
  18315. * Serializes the actions and its related information.
  18316. * @param parent defines the object to serialize in
  18317. * @returns the serialized object
  18318. */
  18319. serialize(parent: any): any;
  18320. }
  18321. }
  18322. declare module "babylonjs/Actions/actionManager" {
  18323. import { Nullable } from "babylonjs/types";
  18324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18325. import { Scene } from "babylonjs/scene";
  18326. import { IAction } from "babylonjs/Actions/action";
  18327. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18328. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18329. /**
  18330. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18331. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18333. */
  18334. export class ActionManager extends AbstractActionManager {
  18335. /**
  18336. * Nothing
  18337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18338. */
  18339. static readonly NothingTrigger: number;
  18340. /**
  18341. * On pick
  18342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18343. */
  18344. static readonly OnPickTrigger: number;
  18345. /**
  18346. * On left pick
  18347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18348. */
  18349. static readonly OnLeftPickTrigger: number;
  18350. /**
  18351. * On right pick
  18352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18353. */
  18354. static readonly OnRightPickTrigger: number;
  18355. /**
  18356. * On center pick
  18357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18358. */
  18359. static readonly OnCenterPickTrigger: number;
  18360. /**
  18361. * On pick down
  18362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18363. */
  18364. static readonly OnPickDownTrigger: number;
  18365. /**
  18366. * On double pick
  18367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18368. */
  18369. static readonly OnDoublePickTrigger: number;
  18370. /**
  18371. * On pick up
  18372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18373. */
  18374. static readonly OnPickUpTrigger: number;
  18375. /**
  18376. * On pick out.
  18377. * This trigger will only be raised if you also declared a OnPickDown
  18378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18379. */
  18380. static readonly OnPickOutTrigger: number;
  18381. /**
  18382. * On long press
  18383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18384. */
  18385. static readonly OnLongPressTrigger: number;
  18386. /**
  18387. * On pointer over
  18388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18389. */
  18390. static readonly OnPointerOverTrigger: number;
  18391. /**
  18392. * On pointer out
  18393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18394. */
  18395. static readonly OnPointerOutTrigger: number;
  18396. /**
  18397. * On every frame
  18398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18399. */
  18400. static readonly OnEveryFrameTrigger: number;
  18401. /**
  18402. * On intersection enter
  18403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18404. */
  18405. static readonly OnIntersectionEnterTrigger: number;
  18406. /**
  18407. * On intersection exit
  18408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18409. */
  18410. static readonly OnIntersectionExitTrigger: number;
  18411. /**
  18412. * On key down
  18413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18414. */
  18415. static readonly OnKeyDownTrigger: number;
  18416. /**
  18417. * On key up
  18418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18419. */
  18420. static readonly OnKeyUpTrigger: number;
  18421. private _scene;
  18422. /**
  18423. * Creates a new action manager
  18424. * @param scene defines the hosting scene
  18425. */
  18426. constructor(scene: Scene);
  18427. /**
  18428. * Releases all associated resources
  18429. */
  18430. dispose(): void;
  18431. /**
  18432. * Gets hosting scene
  18433. * @returns the hosting scene
  18434. */
  18435. getScene(): Scene;
  18436. /**
  18437. * Does this action manager handles actions of any of the given triggers
  18438. * @param triggers defines the triggers to be tested
  18439. * @return a boolean indicating whether one (or more) of the triggers is handled
  18440. */
  18441. hasSpecificTriggers(triggers: number[]): boolean;
  18442. /**
  18443. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18444. * speed.
  18445. * @param triggerA defines the trigger to be tested
  18446. * @param triggerB defines the trigger to be tested
  18447. * @return a boolean indicating whether one (or more) of the triggers is handled
  18448. */
  18449. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18450. /**
  18451. * Does this action manager handles actions of a given trigger
  18452. * @param trigger defines the trigger to be tested
  18453. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18454. * @return whether the trigger is handled
  18455. */
  18456. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18457. /**
  18458. * Does this action manager has pointer triggers
  18459. */
  18460. get hasPointerTriggers(): boolean;
  18461. /**
  18462. * Does this action manager has pick triggers
  18463. */
  18464. get hasPickTriggers(): boolean;
  18465. /**
  18466. * Registers an action to this action manager
  18467. * @param action defines the action to be registered
  18468. * @return the action amended (prepared) after registration
  18469. */
  18470. registerAction(action: IAction): Nullable<IAction>;
  18471. /**
  18472. * Unregisters an action to this action manager
  18473. * @param action defines the action to be unregistered
  18474. * @return a boolean indicating whether the action has been unregistered
  18475. */
  18476. unregisterAction(action: IAction): Boolean;
  18477. /**
  18478. * Process a specific trigger
  18479. * @param trigger defines the trigger to process
  18480. * @param evt defines the event details to be processed
  18481. */
  18482. processTrigger(trigger: number, evt?: IActionEvent): void;
  18483. /** @hidden */
  18484. _getEffectiveTarget(target: any, propertyPath: string): any;
  18485. /** @hidden */
  18486. _getProperty(propertyPath: string): string;
  18487. /**
  18488. * Serialize this manager to a JSON object
  18489. * @param name defines the property name to store this manager
  18490. * @returns a JSON representation of this manager
  18491. */
  18492. serialize(name: string): any;
  18493. /**
  18494. * Creates a new ActionManager from a JSON data
  18495. * @param parsedActions defines the JSON data to read from
  18496. * @param object defines the hosting mesh
  18497. * @param scene defines the hosting scene
  18498. */
  18499. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18500. /**
  18501. * Get a trigger name by index
  18502. * @param trigger defines the trigger index
  18503. * @returns a trigger name
  18504. */
  18505. static GetTriggerName(trigger: number): string;
  18506. }
  18507. }
  18508. declare module "babylonjs/Sprites/sprite" {
  18509. import { Vector3 } from "babylonjs/Maths/math.vector";
  18510. import { Nullable } from "babylonjs/types";
  18511. import { ActionManager } from "babylonjs/Actions/actionManager";
  18512. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18513. import { Color4 } from "babylonjs/Maths/math.color";
  18514. /**
  18515. * Class used to represent a sprite
  18516. * @see http://doc.babylonjs.com/babylon101/sprites
  18517. */
  18518. export class Sprite {
  18519. /** defines the name */
  18520. name: string;
  18521. /** Gets or sets the current world position */
  18522. position: Vector3;
  18523. /** Gets or sets the main color */
  18524. color: Color4;
  18525. /** Gets or sets the width */
  18526. width: number;
  18527. /** Gets or sets the height */
  18528. height: number;
  18529. /** Gets or sets rotation angle */
  18530. angle: number;
  18531. /** Gets or sets the cell index in the sprite sheet */
  18532. cellIndex: number;
  18533. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18534. cellRef: string;
  18535. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18536. invertU: number;
  18537. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18538. invertV: number;
  18539. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18540. disposeWhenFinishedAnimating: boolean;
  18541. /** Gets the list of attached animations */
  18542. animations: Animation[];
  18543. /** Gets or sets a boolean indicating if the sprite can be picked */
  18544. isPickable: boolean;
  18545. /**
  18546. * Gets or sets the associated action manager
  18547. */
  18548. actionManager: Nullable<ActionManager>;
  18549. private _animationStarted;
  18550. private _loopAnimation;
  18551. private _fromIndex;
  18552. private _toIndex;
  18553. private _delay;
  18554. private _direction;
  18555. private _manager;
  18556. private _time;
  18557. private _onAnimationEnd;
  18558. /**
  18559. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18560. */
  18561. isVisible: boolean;
  18562. /**
  18563. * Gets or sets the sprite size
  18564. */
  18565. get size(): number;
  18566. set size(value: number);
  18567. /**
  18568. * Creates a new Sprite
  18569. * @param name defines the name
  18570. * @param manager defines the manager
  18571. */
  18572. constructor(
  18573. /** defines the name */
  18574. name: string, manager: ISpriteManager);
  18575. /**
  18576. * Starts an animation
  18577. * @param from defines the initial key
  18578. * @param to defines the end key
  18579. * @param loop defines if the animation must loop
  18580. * @param delay defines the start delay (in ms)
  18581. * @param onAnimationEnd defines a callback to call when animation ends
  18582. */
  18583. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18584. /** Stops current animation (if any) */
  18585. stopAnimation(): void;
  18586. /** @hidden */
  18587. _animate(deltaTime: number): void;
  18588. /** Release associated resources */
  18589. dispose(): void;
  18590. }
  18591. }
  18592. declare module "babylonjs/Collisions/pickingInfo" {
  18593. import { Nullable } from "babylonjs/types";
  18594. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18596. import { Sprite } from "babylonjs/Sprites/sprite";
  18597. import { Ray } from "babylonjs/Culling/ray";
  18598. /**
  18599. * Information about the result of picking within a scene
  18600. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18601. */
  18602. export class PickingInfo {
  18603. /** @hidden */
  18604. _pickingUnavailable: boolean;
  18605. /**
  18606. * If the pick collided with an object
  18607. */
  18608. hit: boolean;
  18609. /**
  18610. * Distance away where the pick collided
  18611. */
  18612. distance: number;
  18613. /**
  18614. * The location of pick collision
  18615. */
  18616. pickedPoint: Nullable<Vector3>;
  18617. /**
  18618. * The mesh corresponding the the pick collision
  18619. */
  18620. pickedMesh: Nullable<AbstractMesh>;
  18621. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18622. bu: number;
  18623. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18624. bv: number;
  18625. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18626. faceId: number;
  18627. /** Id of the the submesh that was picked */
  18628. subMeshId: number;
  18629. /** If a sprite was picked, this will be the sprite the pick collided with */
  18630. pickedSprite: Nullable<Sprite>;
  18631. /**
  18632. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18633. */
  18634. originMesh: Nullable<AbstractMesh>;
  18635. /**
  18636. * The ray that was used to perform the picking.
  18637. */
  18638. ray: Nullable<Ray>;
  18639. /**
  18640. * Gets the normal correspodning to the face the pick collided with
  18641. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18642. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18643. * @returns The normal correspodning to the face the pick collided with
  18644. */
  18645. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18646. /**
  18647. * Gets the texture coordinates of where the pick occured
  18648. * @returns the vector containing the coordnates of the texture
  18649. */
  18650. getTextureCoordinates(): Nullable<Vector2>;
  18651. }
  18652. }
  18653. declare module "babylonjs/Events/pointerEvents" {
  18654. import { Nullable } from "babylonjs/types";
  18655. import { Vector2 } from "babylonjs/Maths/math.vector";
  18656. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18657. import { Ray } from "babylonjs/Culling/ray";
  18658. /**
  18659. * Gather the list of pointer event types as constants.
  18660. */
  18661. export class PointerEventTypes {
  18662. /**
  18663. * 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.
  18664. */
  18665. static readonly POINTERDOWN: number;
  18666. /**
  18667. * The pointerup event is fired when a pointer is no longer active.
  18668. */
  18669. static readonly POINTERUP: number;
  18670. /**
  18671. * The pointermove event is fired when a pointer changes coordinates.
  18672. */
  18673. static readonly POINTERMOVE: number;
  18674. /**
  18675. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18676. */
  18677. static readonly POINTERWHEEL: number;
  18678. /**
  18679. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18680. */
  18681. static readonly POINTERPICK: number;
  18682. /**
  18683. * The pointertap event is fired when a the object has been touched and released without drag.
  18684. */
  18685. static readonly POINTERTAP: number;
  18686. /**
  18687. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18688. */
  18689. static readonly POINTERDOUBLETAP: number;
  18690. }
  18691. /**
  18692. * Base class of pointer info types.
  18693. */
  18694. export class PointerInfoBase {
  18695. /**
  18696. * Defines the type of event (PointerEventTypes)
  18697. */
  18698. type: number;
  18699. /**
  18700. * Defines the related dom event
  18701. */
  18702. event: PointerEvent | MouseWheelEvent;
  18703. /**
  18704. * Instantiates the base class of pointers info.
  18705. * @param type Defines the type of event (PointerEventTypes)
  18706. * @param event Defines the related dom event
  18707. */
  18708. constructor(
  18709. /**
  18710. * Defines the type of event (PointerEventTypes)
  18711. */
  18712. type: number,
  18713. /**
  18714. * Defines the related dom event
  18715. */
  18716. event: PointerEvent | MouseWheelEvent);
  18717. }
  18718. /**
  18719. * This class is used to store pointer related info for the onPrePointerObservable event.
  18720. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18721. */
  18722. export class PointerInfoPre extends PointerInfoBase {
  18723. /**
  18724. * Ray from a pointer if availible (eg. 6dof controller)
  18725. */
  18726. ray: Nullable<Ray>;
  18727. /**
  18728. * Defines the local position of the pointer on the canvas.
  18729. */
  18730. localPosition: Vector2;
  18731. /**
  18732. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18733. */
  18734. skipOnPointerObservable: boolean;
  18735. /**
  18736. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18737. * @param type Defines the type of event (PointerEventTypes)
  18738. * @param event Defines the related dom event
  18739. * @param localX Defines the local x coordinates of the pointer when the event occured
  18740. * @param localY Defines the local y coordinates of the pointer when the event occured
  18741. */
  18742. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18743. }
  18744. /**
  18745. * This type contains all the data related to a pointer event in Babylon.js.
  18746. * 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.
  18747. */
  18748. export class PointerInfo extends PointerInfoBase {
  18749. /**
  18750. * Defines the picking info associated to the info (if any)\
  18751. */
  18752. pickInfo: Nullable<PickingInfo>;
  18753. /**
  18754. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18755. * @param type Defines the type of event (PointerEventTypes)
  18756. * @param event Defines the related dom event
  18757. * @param pickInfo Defines the picking info associated to the info (if any)\
  18758. */
  18759. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18760. /**
  18761. * Defines the picking info associated to the info (if any)\
  18762. */
  18763. pickInfo: Nullable<PickingInfo>);
  18764. }
  18765. /**
  18766. * Data relating to a touch event on the screen.
  18767. */
  18768. export interface PointerTouch {
  18769. /**
  18770. * X coordinate of touch.
  18771. */
  18772. x: number;
  18773. /**
  18774. * Y coordinate of touch.
  18775. */
  18776. y: number;
  18777. /**
  18778. * Id of touch. Unique for each finger.
  18779. */
  18780. pointerId: number;
  18781. /**
  18782. * Event type passed from DOM.
  18783. */
  18784. type: any;
  18785. }
  18786. }
  18787. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18788. import { Observable } from "babylonjs/Misc/observable";
  18789. import { Nullable } from "babylonjs/types";
  18790. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18791. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18792. /**
  18793. * Manage the mouse inputs to control the movement of a free camera.
  18794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18795. */
  18796. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18797. /**
  18798. * Define if touch is enabled in the mouse input
  18799. */
  18800. touchEnabled: boolean;
  18801. /**
  18802. * Defines the camera the input is attached to.
  18803. */
  18804. camera: FreeCamera;
  18805. /**
  18806. * Defines the buttons associated with the input to handle camera move.
  18807. */
  18808. buttons: number[];
  18809. /**
  18810. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18811. */
  18812. angularSensibility: number;
  18813. private _pointerInput;
  18814. private _onMouseMove;
  18815. private _observer;
  18816. private previousPosition;
  18817. /**
  18818. * Observable for when a pointer move event occurs containing the move offset
  18819. */
  18820. onPointerMovedObservable: Observable<{
  18821. offsetX: number;
  18822. offsetY: number;
  18823. }>;
  18824. /**
  18825. * @hidden
  18826. * If the camera should be rotated automatically based on pointer movement
  18827. */
  18828. _allowCameraRotation: boolean;
  18829. /**
  18830. * Manage the mouse inputs to control the movement of a free camera.
  18831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18832. * @param touchEnabled Defines if touch is enabled or not
  18833. */
  18834. constructor(
  18835. /**
  18836. * Define if touch is enabled in the mouse input
  18837. */
  18838. touchEnabled?: boolean);
  18839. /**
  18840. * Attach the input controls to a specific dom element to get the input from.
  18841. * @param element Defines the element the controls should be listened from
  18842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18843. */
  18844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18845. /**
  18846. * Called on JS contextmenu event.
  18847. * Override this method to provide functionality.
  18848. */
  18849. protected onContextMenu(evt: PointerEvent): void;
  18850. /**
  18851. * Detach the current controls from the specified dom element.
  18852. * @param element Defines the element to stop listening the inputs from
  18853. */
  18854. detachControl(element: Nullable<HTMLElement>): void;
  18855. /**
  18856. * Gets the class name of the current intput.
  18857. * @returns the class name
  18858. */
  18859. getClassName(): string;
  18860. /**
  18861. * Get the friendly name associated with the input class.
  18862. * @returns the input friendly name
  18863. */
  18864. getSimpleName(): string;
  18865. }
  18866. }
  18867. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18868. import { Nullable } from "babylonjs/types";
  18869. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18870. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18871. /**
  18872. * Manage the touch inputs to control the movement of a free camera.
  18873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18874. */
  18875. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18876. /**
  18877. * Defines the camera the input is attached to.
  18878. */
  18879. camera: FreeCamera;
  18880. /**
  18881. * Defines the touch sensibility for rotation.
  18882. * The higher the faster.
  18883. */
  18884. touchAngularSensibility: number;
  18885. /**
  18886. * Defines the touch sensibility for move.
  18887. * The higher the faster.
  18888. */
  18889. touchMoveSensibility: number;
  18890. private _offsetX;
  18891. private _offsetY;
  18892. private _pointerPressed;
  18893. private _pointerInput;
  18894. private _observer;
  18895. private _onLostFocus;
  18896. /**
  18897. * Attach the input controls to a specific dom element to get the input from.
  18898. * @param element Defines the element the controls should be listened from
  18899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18900. */
  18901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18902. /**
  18903. * Detach the current controls from the specified dom element.
  18904. * @param element Defines the element to stop listening the inputs from
  18905. */
  18906. detachControl(element: Nullable<HTMLElement>): void;
  18907. /**
  18908. * Update the current camera state depending on the inputs that have been used this frame.
  18909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18910. */
  18911. checkInputs(): void;
  18912. /**
  18913. * Gets the class name of the current intput.
  18914. * @returns the class name
  18915. */
  18916. getClassName(): string;
  18917. /**
  18918. * Get the friendly name associated with the input class.
  18919. * @returns the input friendly name
  18920. */
  18921. getSimpleName(): string;
  18922. }
  18923. }
  18924. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18925. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18926. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18927. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18928. import { Nullable } from "babylonjs/types";
  18929. /**
  18930. * Default Inputs manager for the FreeCamera.
  18931. * It groups all the default supported inputs for ease of use.
  18932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18933. */
  18934. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18935. /**
  18936. * @hidden
  18937. */
  18938. _mouseInput: Nullable<FreeCameraMouseInput>;
  18939. /**
  18940. * Instantiates a new FreeCameraInputsManager.
  18941. * @param camera Defines the camera the inputs belong to
  18942. */
  18943. constructor(camera: FreeCamera);
  18944. /**
  18945. * Add keyboard input support to the input manager.
  18946. * @returns the current input manager
  18947. */
  18948. addKeyboard(): FreeCameraInputsManager;
  18949. /**
  18950. * Add mouse input support to the input manager.
  18951. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18952. * @returns the current input manager
  18953. */
  18954. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18955. /**
  18956. * Removes the mouse input support from the manager
  18957. * @returns the current input manager
  18958. */
  18959. removeMouse(): FreeCameraInputsManager;
  18960. /**
  18961. * Add touch input support to the input manager.
  18962. * @returns the current input manager
  18963. */
  18964. addTouch(): FreeCameraInputsManager;
  18965. /**
  18966. * Remove all attached input methods from a camera
  18967. */
  18968. clear(): void;
  18969. }
  18970. }
  18971. declare module "babylonjs/Cameras/freeCamera" {
  18972. import { Vector3 } from "babylonjs/Maths/math.vector";
  18973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18974. import { Scene } from "babylonjs/scene";
  18975. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18976. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18977. /**
  18978. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18979. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18981. */
  18982. export class FreeCamera extends TargetCamera {
  18983. /**
  18984. * Define the collision ellipsoid of the camera.
  18985. * This is helpful to simulate a camera body like the player body around the camera
  18986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18987. */
  18988. ellipsoid: Vector3;
  18989. /**
  18990. * Define an offset for the position of the ellipsoid around the camera.
  18991. * This can be helpful to determine the center of the body near the gravity center of the body
  18992. * instead of its head.
  18993. */
  18994. ellipsoidOffset: Vector3;
  18995. /**
  18996. * Enable or disable collisions of the camera with the rest of the scene objects.
  18997. */
  18998. checkCollisions: boolean;
  18999. /**
  19000. * Enable or disable gravity on the camera.
  19001. */
  19002. applyGravity: boolean;
  19003. /**
  19004. * Define the input manager associated to the camera.
  19005. */
  19006. inputs: FreeCameraInputsManager;
  19007. /**
  19008. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19009. * Higher values reduce sensitivity.
  19010. */
  19011. get angularSensibility(): number;
  19012. /**
  19013. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19014. * Higher values reduce sensitivity.
  19015. */
  19016. set angularSensibility(value: number);
  19017. /**
  19018. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19019. */
  19020. get keysUp(): number[];
  19021. set keysUp(value: number[]);
  19022. /**
  19023. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19024. */
  19025. get keysUpward(): number[];
  19026. set keysUpward(value: number[]);
  19027. /**
  19028. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19029. */
  19030. get keysDown(): number[];
  19031. set keysDown(value: number[]);
  19032. /**
  19033. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19034. */
  19035. get keysDownward(): number[];
  19036. set keysDownward(value: number[]);
  19037. /**
  19038. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19039. */
  19040. get keysLeft(): number[];
  19041. set keysLeft(value: number[]);
  19042. /**
  19043. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19044. */
  19045. get keysRight(): number[];
  19046. set keysRight(value: number[]);
  19047. /**
  19048. * Event raised when the camera collide with a mesh in the scene.
  19049. */
  19050. onCollide: (collidedMesh: AbstractMesh) => void;
  19051. private _collider;
  19052. private _needMoveForGravity;
  19053. private _oldPosition;
  19054. private _diffPosition;
  19055. private _newPosition;
  19056. /** @hidden */
  19057. _localDirection: Vector3;
  19058. /** @hidden */
  19059. _transformedDirection: Vector3;
  19060. /**
  19061. * Instantiates a Free Camera.
  19062. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19063. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19064. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19065. * @param name Define the name of the camera in the scene
  19066. * @param position Define the start position of the camera in the scene
  19067. * @param scene Define the scene the camera belongs to
  19068. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19069. */
  19070. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19071. /**
  19072. * Attached controls to the current camera.
  19073. * @param element Defines the element the controls should be listened from
  19074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19075. */
  19076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19077. /**
  19078. * Detach the current controls from the camera.
  19079. * The camera will stop reacting to inputs.
  19080. * @param element Defines the element to stop listening the inputs from
  19081. */
  19082. detachControl(element: HTMLElement): void;
  19083. private _collisionMask;
  19084. /**
  19085. * Define a collision mask to limit the list of object the camera can collide with
  19086. */
  19087. get collisionMask(): number;
  19088. set collisionMask(mask: number);
  19089. /** @hidden */
  19090. _collideWithWorld(displacement: Vector3): void;
  19091. private _onCollisionPositionChange;
  19092. /** @hidden */
  19093. _checkInputs(): void;
  19094. /** @hidden */
  19095. _decideIfNeedsToMove(): boolean;
  19096. /** @hidden */
  19097. _updatePosition(): void;
  19098. /**
  19099. * Destroy the camera and release the current resources hold by it.
  19100. */
  19101. dispose(): void;
  19102. /**
  19103. * Gets the current object class name.
  19104. * @return the class name
  19105. */
  19106. getClassName(): string;
  19107. }
  19108. }
  19109. declare module "babylonjs/Gamepads/gamepad" {
  19110. import { Observable } from "babylonjs/Misc/observable";
  19111. /**
  19112. * Represents a gamepad control stick position
  19113. */
  19114. export class StickValues {
  19115. /**
  19116. * The x component of the control stick
  19117. */
  19118. x: number;
  19119. /**
  19120. * The y component of the control stick
  19121. */
  19122. y: number;
  19123. /**
  19124. * Initializes the gamepad x and y control stick values
  19125. * @param x The x component of the gamepad control stick value
  19126. * @param y The y component of the gamepad control stick value
  19127. */
  19128. constructor(
  19129. /**
  19130. * The x component of the control stick
  19131. */
  19132. x: number,
  19133. /**
  19134. * The y component of the control stick
  19135. */
  19136. y: number);
  19137. }
  19138. /**
  19139. * An interface which manages callbacks for gamepad button changes
  19140. */
  19141. export interface GamepadButtonChanges {
  19142. /**
  19143. * Called when a gamepad has been changed
  19144. */
  19145. changed: boolean;
  19146. /**
  19147. * Called when a gamepad press event has been triggered
  19148. */
  19149. pressChanged: boolean;
  19150. /**
  19151. * Called when a touch event has been triggered
  19152. */
  19153. touchChanged: boolean;
  19154. /**
  19155. * Called when a value has changed
  19156. */
  19157. valueChanged: boolean;
  19158. }
  19159. /**
  19160. * Represents a gamepad
  19161. */
  19162. export class Gamepad {
  19163. /**
  19164. * The id of the gamepad
  19165. */
  19166. id: string;
  19167. /**
  19168. * The index of the gamepad
  19169. */
  19170. index: number;
  19171. /**
  19172. * The browser gamepad
  19173. */
  19174. browserGamepad: any;
  19175. /**
  19176. * Specifies what type of gamepad this represents
  19177. */
  19178. type: number;
  19179. private _leftStick;
  19180. private _rightStick;
  19181. /** @hidden */
  19182. _isConnected: boolean;
  19183. private _leftStickAxisX;
  19184. private _leftStickAxisY;
  19185. private _rightStickAxisX;
  19186. private _rightStickAxisY;
  19187. /**
  19188. * Triggered when the left control stick has been changed
  19189. */
  19190. private _onleftstickchanged;
  19191. /**
  19192. * Triggered when the right control stick has been changed
  19193. */
  19194. private _onrightstickchanged;
  19195. /**
  19196. * Represents a gamepad controller
  19197. */
  19198. static GAMEPAD: number;
  19199. /**
  19200. * Represents a generic controller
  19201. */
  19202. static GENERIC: number;
  19203. /**
  19204. * Represents an XBox controller
  19205. */
  19206. static XBOX: number;
  19207. /**
  19208. * Represents a pose-enabled controller
  19209. */
  19210. static POSE_ENABLED: number;
  19211. /**
  19212. * Represents an Dual Shock controller
  19213. */
  19214. static DUALSHOCK: number;
  19215. /**
  19216. * Specifies whether the left control stick should be Y-inverted
  19217. */
  19218. protected _invertLeftStickY: boolean;
  19219. /**
  19220. * Specifies if the gamepad has been connected
  19221. */
  19222. get isConnected(): boolean;
  19223. /**
  19224. * Initializes the gamepad
  19225. * @param id The id of the gamepad
  19226. * @param index The index of the gamepad
  19227. * @param browserGamepad The browser gamepad
  19228. * @param leftStickX The x component of the left joystick
  19229. * @param leftStickY The y component of the left joystick
  19230. * @param rightStickX The x component of the right joystick
  19231. * @param rightStickY The y component of the right joystick
  19232. */
  19233. constructor(
  19234. /**
  19235. * The id of the gamepad
  19236. */
  19237. id: string,
  19238. /**
  19239. * The index of the gamepad
  19240. */
  19241. index: number,
  19242. /**
  19243. * The browser gamepad
  19244. */
  19245. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19246. /**
  19247. * Callback triggered when the left joystick has changed
  19248. * @param callback
  19249. */
  19250. onleftstickchanged(callback: (values: StickValues) => void): void;
  19251. /**
  19252. * Callback triggered when the right joystick has changed
  19253. * @param callback
  19254. */
  19255. onrightstickchanged(callback: (values: StickValues) => void): void;
  19256. /**
  19257. * Gets the left joystick
  19258. */
  19259. get leftStick(): StickValues;
  19260. /**
  19261. * Sets the left joystick values
  19262. */
  19263. set leftStick(newValues: StickValues);
  19264. /**
  19265. * Gets the right joystick
  19266. */
  19267. get rightStick(): StickValues;
  19268. /**
  19269. * Sets the right joystick value
  19270. */
  19271. set rightStick(newValues: StickValues);
  19272. /**
  19273. * Updates the gamepad joystick positions
  19274. */
  19275. update(): void;
  19276. /**
  19277. * Disposes the gamepad
  19278. */
  19279. dispose(): void;
  19280. }
  19281. /**
  19282. * Represents a generic gamepad
  19283. */
  19284. export class GenericPad extends Gamepad {
  19285. private _buttons;
  19286. private _onbuttondown;
  19287. private _onbuttonup;
  19288. /**
  19289. * Observable triggered when a button has been pressed
  19290. */
  19291. onButtonDownObservable: Observable<number>;
  19292. /**
  19293. * Observable triggered when a button has been released
  19294. */
  19295. onButtonUpObservable: Observable<number>;
  19296. /**
  19297. * Callback triggered when a button has been pressed
  19298. * @param callback Called when a button has been pressed
  19299. */
  19300. onbuttondown(callback: (buttonPressed: number) => void): void;
  19301. /**
  19302. * Callback triggered when a button has been released
  19303. * @param callback Called when a button has been released
  19304. */
  19305. onbuttonup(callback: (buttonReleased: number) => void): void;
  19306. /**
  19307. * Initializes the generic gamepad
  19308. * @param id The id of the generic gamepad
  19309. * @param index The index of the generic gamepad
  19310. * @param browserGamepad The browser gamepad
  19311. */
  19312. constructor(id: string, index: number, browserGamepad: any);
  19313. private _setButtonValue;
  19314. /**
  19315. * Updates the generic gamepad
  19316. */
  19317. update(): void;
  19318. /**
  19319. * Disposes the generic gamepad
  19320. */
  19321. dispose(): void;
  19322. }
  19323. }
  19324. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19325. import { Observable } from "babylonjs/Misc/observable";
  19326. import { Nullable } from "babylonjs/types";
  19327. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19328. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19330. import { Ray } from "babylonjs/Culling/ray";
  19331. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19332. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19333. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19334. /**
  19335. * Defines the types of pose enabled controllers that are supported
  19336. */
  19337. export enum PoseEnabledControllerType {
  19338. /**
  19339. * HTC Vive
  19340. */
  19341. VIVE = 0,
  19342. /**
  19343. * Oculus Rift
  19344. */
  19345. OCULUS = 1,
  19346. /**
  19347. * Windows mixed reality
  19348. */
  19349. WINDOWS = 2,
  19350. /**
  19351. * Samsung gear VR
  19352. */
  19353. GEAR_VR = 3,
  19354. /**
  19355. * Google Daydream
  19356. */
  19357. DAYDREAM = 4,
  19358. /**
  19359. * Generic
  19360. */
  19361. GENERIC = 5
  19362. }
  19363. /**
  19364. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19365. */
  19366. export interface MutableGamepadButton {
  19367. /**
  19368. * Value of the button/trigger
  19369. */
  19370. value: number;
  19371. /**
  19372. * If the button/trigger is currently touched
  19373. */
  19374. touched: boolean;
  19375. /**
  19376. * If the button/trigger is currently pressed
  19377. */
  19378. pressed: boolean;
  19379. }
  19380. /**
  19381. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19382. * @hidden
  19383. */
  19384. export interface ExtendedGamepadButton extends GamepadButton {
  19385. /**
  19386. * If the button/trigger is currently pressed
  19387. */
  19388. readonly pressed: boolean;
  19389. /**
  19390. * If the button/trigger is currently touched
  19391. */
  19392. readonly touched: boolean;
  19393. /**
  19394. * Value of the button/trigger
  19395. */
  19396. readonly value: number;
  19397. }
  19398. /** @hidden */
  19399. export interface _GamePadFactory {
  19400. /**
  19401. * Returns whether or not the current gamepad can be created for this type of controller.
  19402. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19403. * @returns true if it can be created, otherwise false
  19404. */
  19405. canCreate(gamepadInfo: any): boolean;
  19406. /**
  19407. * Creates a new instance of the Gamepad.
  19408. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19409. * @returns the new gamepad instance
  19410. */
  19411. create(gamepadInfo: any): Gamepad;
  19412. }
  19413. /**
  19414. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19415. */
  19416. export class PoseEnabledControllerHelper {
  19417. /** @hidden */
  19418. static _ControllerFactories: _GamePadFactory[];
  19419. /** @hidden */
  19420. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19421. /**
  19422. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19423. * @param vrGamepad the gamepad to initialized
  19424. * @returns a vr controller of the type the gamepad identified as
  19425. */
  19426. static InitiateController(vrGamepad: any): Gamepad;
  19427. }
  19428. /**
  19429. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19430. */
  19431. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19432. /**
  19433. * If the controller is used in a webXR session
  19434. */
  19435. isXR: boolean;
  19436. private _deviceRoomPosition;
  19437. private _deviceRoomRotationQuaternion;
  19438. /**
  19439. * The device position in babylon space
  19440. */
  19441. devicePosition: Vector3;
  19442. /**
  19443. * The device rotation in babylon space
  19444. */
  19445. deviceRotationQuaternion: Quaternion;
  19446. /**
  19447. * The scale factor of the device in babylon space
  19448. */
  19449. deviceScaleFactor: number;
  19450. /**
  19451. * (Likely devicePosition should be used instead) The device position in its room space
  19452. */
  19453. position: Vector3;
  19454. /**
  19455. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19456. */
  19457. rotationQuaternion: Quaternion;
  19458. /**
  19459. * The type of controller (Eg. Windows mixed reality)
  19460. */
  19461. controllerType: PoseEnabledControllerType;
  19462. protected _calculatedPosition: Vector3;
  19463. private _calculatedRotation;
  19464. /**
  19465. * The raw pose from the device
  19466. */
  19467. rawPose: DevicePose;
  19468. private _trackPosition;
  19469. private _maxRotationDistFromHeadset;
  19470. private _draggedRoomRotation;
  19471. /**
  19472. * @hidden
  19473. */
  19474. _disableTrackPosition(fixedPosition: Vector3): void;
  19475. /**
  19476. * Internal, the mesh attached to the controller
  19477. * @hidden
  19478. */
  19479. _mesh: Nullable<AbstractMesh>;
  19480. private _poseControlledCamera;
  19481. private _leftHandSystemQuaternion;
  19482. /**
  19483. * Internal, matrix used to convert room space to babylon space
  19484. * @hidden
  19485. */
  19486. _deviceToWorld: Matrix;
  19487. /**
  19488. * Node to be used when casting a ray from the controller
  19489. * @hidden
  19490. */
  19491. _pointingPoseNode: Nullable<TransformNode>;
  19492. /**
  19493. * Name of the child mesh that can be used to cast a ray from the controller
  19494. */
  19495. static readonly POINTING_POSE: string;
  19496. /**
  19497. * Creates a new PoseEnabledController from a gamepad
  19498. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19499. */
  19500. constructor(browserGamepad: any);
  19501. private _workingMatrix;
  19502. /**
  19503. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19504. */
  19505. update(): void;
  19506. /**
  19507. * Updates only the pose device and mesh without doing any button event checking
  19508. */
  19509. protected _updatePoseAndMesh(): void;
  19510. /**
  19511. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19512. * @param poseData raw pose fromthe device
  19513. */
  19514. updateFromDevice(poseData: DevicePose): void;
  19515. /**
  19516. * @hidden
  19517. */
  19518. _meshAttachedObservable: Observable<AbstractMesh>;
  19519. /**
  19520. * Attaches a mesh to the controller
  19521. * @param mesh the mesh to be attached
  19522. */
  19523. attachToMesh(mesh: AbstractMesh): void;
  19524. /**
  19525. * Attaches the controllers mesh to a camera
  19526. * @param camera the camera the mesh should be attached to
  19527. */
  19528. attachToPoseControlledCamera(camera: TargetCamera): void;
  19529. /**
  19530. * Disposes of the controller
  19531. */
  19532. dispose(): void;
  19533. /**
  19534. * The mesh that is attached to the controller
  19535. */
  19536. get mesh(): Nullable<AbstractMesh>;
  19537. /**
  19538. * Gets the ray of the controller in the direction the controller is pointing
  19539. * @param length the length the resulting ray should be
  19540. * @returns a ray in the direction the controller is pointing
  19541. */
  19542. getForwardRay(length?: number): Ray;
  19543. }
  19544. }
  19545. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19546. import { Observable } from "babylonjs/Misc/observable";
  19547. import { Scene } from "babylonjs/scene";
  19548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19549. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19550. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19551. import { Nullable } from "babylonjs/types";
  19552. /**
  19553. * Defines the WebVRController object that represents controllers tracked in 3D space
  19554. */
  19555. export abstract class WebVRController extends PoseEnabledController {
  19556. /**
  19557. * Internal, the default controller model for the controller
  19558. */
  19559. protected _defaultModel: Nullable<AbstractMesh>;
  19560. /**
  19561. * Fired when the trigger state has changed
  19562. */
  19563. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19564. /**
  19565. * Fired when the main button state has changed
  19566. */
  19567. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19568. /**
  19569. * Fired when the secondary button state has changed
  19570. */
  19571. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19572. /**
  19573. * Fired when the pad state has changed
  19574. */
  19575. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19576. /**
  19577. * Fired when controllers stick values have changed
  19578. */
  19579. onPadValuesChangedObservable: Observable<StickValues>;
  19580. /**
  19581. * Array of button availible on the controller
  19582. */
  19583. protected _buttons: Array<MutableGamepadButton>;
  19584. private _onButtonStateChange;
  19585. /**
  19586. * Fired when a controller button's state has changed
  19587. * @param callback the callback containing the button that was modified
  19588. */
  19589. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19590. /**
  19591. * X and Y axis corresponding to the controllers joystick
  19592. */
  19593. pad: StickValues;
  19594. /**
  19595. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19596. */
  19597. hand: string;
  19598. /**
  19599. * The default controller model for the controller
  19600. */
  19601. get defaultModel(): Nullable<AbstractMesh>;
  19602. /**
  19603. * Creates a new WebVRController from a gamepad
  19604. * @param vrGamepad the gamepad that the WebVRController should be created from
  19605. */
  19606. constructor(vrGamepad: any);
  19607. /**
  19608. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19609. */
  19610. update(): void;
  19611. /**
  19612. * Function to be called when a button is modified
  19613. */
  19614. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19615. /**
  19616. * Loads a mesh and attaches it to the controller
  19617. * @param scene the scene the mesh should be added to
  19618. * @param meshLoaded callback for when the mesh has been loaded
  19619. */
  19620. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19621. private _setButtonValue;
  19622. private _changes;
  19623. private _checkChanges;
  19624. /**
  19625. * Disposes of th webVRCOntroller
  19626. */
  19627. dispose(): void;
  19628. }
  19629. }
  19630. declare module "babylonjs/Lights/hemisphericLight" {
  19631. import { Nullable } from "babylonjs/types";
  19632. import { Scene } from "babylonjs/scene";
  19633. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19634. import { Color3 } from "babylonjs/Maths/math.color";
  19635. import { Effect } from "babylonjs/Materials/effect";
  19636. import { Light } from "babylonjs/Lights/light";
  19637. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19638. /**
  19639. * The HemisphericLight simulates the ambient environment light,
  19640. * so the passed direction is the light reflection direction, not the incoming direction.
  19641. */
  19642. export class HemisphericLight extends Light {
  19643. /**
  19644. * The groundColor is the light in the opposite direction to the one specified during creation.
  19645. * 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.
  19646. */
  19647. groundColor: Color3;
  19648. /**
  19649. * The light reflection direction, not the incoming direction.
  19650. */
  19651. direction: Vector3;
  19652. /**
  19653. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19654. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19655. * The HemisphericLight can't cast shadows.
  19656. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19657. * @param name The friendly name of the light
  19658. * @param direction The direction of the light reflection
  19659. * @param scene The scene the light belongs to
  19660. */
  19661. constructor(name: string, direction: Vector3, scene: Scene);
  19662. protected _buildUniformLayout(): void;
  19663. /**
  19664. * Returns the string "HemisphericLight".
  19665. * @return The class name
  19666. */
  19667. getClassName(): string;
  19668. /**
  19669. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19670. * Returns the updated direction.
  19671. * @param target The target the direction should point to
  19672. * @return The computed direction
  19673. */
  19674. setDirectionToTarget(target: Vector3): Vector3;
  19675. /**
  19676. * Returns the shadow generator associated to the light.
  19677. * @returns Always null for hemispheric lights because it does not support shadows.
  19678. */
  19679. getShadowGenerator(): Nullable<IShadowGenerator>;
  19680. /**
  19681. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19682. * @param effect The effect to update
  19683. * @param lightIndex The index of the light in the effect to update
  19684. * @returns The hemispheric light
  19685. */
  19686. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19687. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19688. /**
  19689. * Computes the world matrix of the node
  19690. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19691. * @param useWasUpdatedFlag defines a reserved property
  19692. * @returns the world matrix
  19693. */
  19694. computeWorldMatrix(): Matrix;
  19695. /**
  19696. * Returns the integer 3.
  19697. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19698. */
  19699. getTypeID(): number;
  19700. /**
  19701. * Prepares the list of defines specific to the light type.
  19702. * @param defines the list of defines
  19703. * @param lightIndex defines the index of the light for the effect
  19704. */
  19705. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19706. }
  19707. }
  19708. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19709. /** @hidden */
  19710. export var vrMultiviewToSingleviewPixelShader: {
  19711. name: string;
  19712. shader: string;
  19713. };
  19714. }
  19715. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19716. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19717. import { Scene } from "babylonjs/scene";
  19718. /**
  19719. * Renders to multiple views with a single draw call
  19720. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19721. */
  19722. export class MultiviewRenderTarget extends RenderTargetTexture {
  19723. /**
  19724. * Creates a multiview render target
  19725. * @param scene scene used with the render target
  19726. * @param size the size of the render target (used for each view)
  19727. */
  19728. constructor(scene: Scene, size?: number | {
  19729. width: number;
  19730. height: number;
  19731. } | {
  19732. ratio: number;
  19733. });
  19734. /**
  19735. * @hidden
  19736. * @param faceIndex the face index, if its a cube texture
  19737. */
  19738. _bindFrameBuffer(faceIndex?: number): void;
  19739. /**
  19740. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19741. * @returns the view count
  19742. */
  19743. getViewCount(): number;
  19744. }
  19745. }
  19746. declare module "babylonjs/Maths/math.frustum" {
  19747. import { Matrix } from "babylonjs/Maths/math.vector";
  19748. import { DeepImmutable } from "babylonjs/types";
  19749. import { Plane } from "babylonjs/Maths/math.plane";
  19750. /**
  19751. * Represents a camera frustum
  19752. */
  19753. export class Frustum {
  19754. /**
  19755. * Gets the planes representing the frustum
  19756. * @param transform matrix to be applied to the returned planes
  19757. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19758. */
  19759. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19760. /**
  19761. * Gets the near frustum plane transformed by the transform matrix
  19762. * @param transform transformation matrix to be applied to the resulting frustum plane
  19763. * @param frustumPlane the resuling frustum plane
  19764. */
  19765. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19766. /**
  19767. * Gets the far frustum plane transformed by the transform matrix
  19768. * @param transform transformation matrix to be applied to the resulting frustum plane
  19769. * @param frustumPlane the resuling frustum plane
  19770. */
  19771. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19772. /**
  19773. * Gets the left frustum plane transformed by the transform matrix
  19774. * @param transform transformation matrix to be applied to the resulting frustum plane
  19775. * @param frustumPlane the resuling frustum plane
  19776. */
  19777. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19778. /**
  19779. * Gets the right frustum plane transformed by the transform matrix
  19780. * @param transform transformation matrix to be applied to the resulting frustum plane
  19781. * @param frustumPlane the resuling frustum plane
  19782. */
  19783. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19784. /**
  19785. * Gets the top frustum plane transformed by the transform matrix
  19786. * @param transform transformation matrix to be applied to the resulting frustum plane
  19787. * @param frustumPlane the resuling frustum plane
  19788. */
  19789. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19790. /**
  19791. * Gets the bottom frustum plane transformed by the transform matrix
  19792. * @param transform transformation matrix to be applied to the resulting frustum plane
  19793. * @param frustumPlane the resuling frustum plane
  19794. */
  19795. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19796. /**
  19797. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19798. * @param transform transformation matrix to be applied to the resulting frustum planes
  19799. * @param frustumPlanes the resuling frustum planes
  19800. */
  19801. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19802. }
  19803. }
  19804. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19805. import { Camera } from "babylonjs/Cameras/camera";
  19806. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19807. import { Nullable } from "babylonjs/types";
  19808. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19809. import { Matrix } from "babylonjs/Maths/math.vector";
  19810. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19811. module "babylonjs/Engines/engine" {
  19812. interface Engine {
  19813. /**
  19814. * Creates a new multiview render target
  19815. * @param width defines the width of the texture
  19816. * @param height defines the height of the texture
  19817. * @returns the created multiview texture
  19818. */
  19819. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19820. /**
  19821. * Binds a multiview framebuffer to be drawn to
  19822. * @param multiviewTexture texture to bind
  19823. */
  19824. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19825. }
  19826. }
  19827. module "babylonjs/Cameras/camera" {
  19828. interface Camera {
  19829. /**
  19830. * @hidden
  19831. * 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)
  19832. */
  19833. _useMultiviewToSingleView: boolean;
  19834. /**
  19835. * @hidden
  19836. * 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)
  19837. */
  19838. _multiviewTexture: Nullable<RenderTargetTexture>;
  19839. /**
  19840. * @hidden
  19841. * ensures the multiview texture of the camera exists and has the specified width/height
  19842. * @param width height to set on the multiview texture
  19843. * @param height width to set on the multiview texture
  19844. */
  19845. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19846. }
  19847. }
  19848. module "babylonjs/scene" {
  19849. interface Scene {
  19850. /** @hidden */
  19851. _transformMatrixR: Matrix;
  19852. /** @hidden */
  19853. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19854. /** @hidden */
  19855. _createMultiviewUbo(): void;
  19856. /** @hidden */
  19857. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19858. /** @hidden */
  19859. _renderMultiviewToSingleView(camera: Camera): void;
  19860. }
  19861. }
  19862. }
  19863. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19864. import { Camera } from "babylonjs/Cameras/camera";
  19865. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19866. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19867. import "babylonjs/Engines/Extensions/engine.multiview";
  19868. /**
  19869. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19870. * This will not be used for webXR as it supports displaying texture arrays directly
  19871. */
  19872. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19873. /**
  19874. * Initializes a VRMultiviewToSingleview
  19875. * @param name name of the post process
  19876. * @param camera camera to be applied to
  19877. * @param scaleFactor scaling factor to the size of the output texture
  19878. */
  19879. constructor(name: string, camera: Camera, scaleFactor: number);
  19880. }
  19881. }
  19882. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19883. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19884. import { Nullable } from "babylonjs/types";
  19885. import { Size } from "babylonjs/Maths/math.size";
  19886. import { Observable } from "babylonjs/Misc/observable";
  19887. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19888. /**
  19889. * Interface used to define additional presentation attributes
  19890. */
  19891. export interface IVRPresentationAttributes {
  19892. /**
  19893. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19894. */
  19895. highRefreshRate: boolean;
  19896. /**
  19897. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19898. */
  19899. foveationLevel: number;
  19900. }
  19901. module "babylonjs/Engines/engine" {
  19902. interface Engine {
  19903. /** @hidden */
  19904. _vrDisplay: any;
  19905. /** @hidden */
  19906. _vrSupported: boolean;
  19907. /** @hidden */
  19908. _oldSize: Size;
  19909. /** @hidden */
  19910. _oldHardwareScaleFactor: number;
  19911. /** @hidden */
  19912. _vrExclusivePointerMode: boolean;
  19913. /** @hidden */
  19914. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19915. /** @hidden */
  19916. _onVRDisplayPointerRestricted: () => void;
  19917. /** @hidden */
  19918. _onVRDisplayPointerUnrestricted: () => void;
  19919. /** @hidden */
  19920. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19921. /** @hidden */
  19922. _onVrDisplayDisconnect: Nullable<() => void>;
  19923. /** @hidden */
  19924. _onVrDisplayPresentChange: Nullable<() => void>;
  19925. /**
  19926. * Observable signaled when VR display mode changes
  19927. */
  19928. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19929. /**
  19930. * Observable signaled when VR request present is complete
  19931. */
  19932. onVRRequestPresentComplete: Observable<boolean>;
  19933. /**
  19934. * Observable signaled when VR request present starts
  19935. */
  19936. onVRRequestPresentStart: Observable<Engine>;
  19937. /**
  19938. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19939. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19940. */
  19941. isInVRExclusivePointerMode: boolean;
  19942. /**
  19943. * Gets a boolean indicating if a webVR device was detected
  19944. * @returns true if a webVR device was detected
  19945. */
  19946. isVRDevicePresent(): boolean;
  19947. /**
  19948. * Gets the current webVR device
  19949. * @returns the current webVR device (or null)
  19950. */
  19951. getVRDevice(): any;
  19952. /**
  19953. * Initializes a webVR display and starts listening to display change events
  19954. * The onVRDisplayChangedObservable will be notified upon these changes
  19955. * @returns A promise containing a VRDisplay and if vr is supported
  19956. */
  19957. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19958. /** @hidden */
  19959. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19960. /**
  19961. * Gets or sets the presentation attributes used to configure VR rendering
  19962. */
  19963. vrPresentationAttributes?: IVRPresentationAttributes;
  19964. /**
  19965. * Call this function to switch to webVR mode
  19966. * Will do nothing if webVR is not supported or if there is no webVR device
  19967. * @param options the webvr options provided to the camera. mainly used for multiview
  19968. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19969. */
  19970. enableVR(options: WebVROptions): void;
  19971. /** @hidden */
  19972. _onVRFullScreenTriggered(): void;
  19973. }
  19974. }
  19975. }
  19976. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19977. import { Nullable } from "babylonjs/types";
  19978. import { Observable } from "babylonjs/Misc/observable";
  19979. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19980. import { Scene } from "babylonjs/scene";
  19981. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19982. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19983. import { Node } from "babylonjs/node";
  19984. import { Ray } from "babylonjs/Culling/ray";
  19985. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19986. import "babylonjs/Engines/Extensions/engine.webVR";
  19987. /**
  19988. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19989. * IMPORTANT!! The data is right-hand data.
  19990. * @export
  19991. * @interface DevicePose
  19992. */
  19993. export interface DevicePose {
  19994. /**
  19995. * The position of the device, values in array are [x,y,z].
  19996. */
  19997. readonly position: Nullable<Float32Array>;
  19998. /**
  19999. * The linearVelocity of the device, values in array are [x,y,z].
  20000. */
  20001. readonly linearVelocity: Nullable<Float32Array>;
  20002. /**
  20003. * The linearAcceleration of the device, values in array are [x,y,z].
  20004. */
  20005. readonly linearAcceleration: Nullable<Float32Array>;
  20006. /**
  20007. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20008. */
  20009. readonly orientation: Nullable<Float32Array>;
  20010. /**
  20011. * The angularVelocity of the device, values in array are [x,y,z].
  20012. */
  20013. readonly angularVelocity: Nullable<Float32Array>;
  20014. /**
  20015. * The angularAcceleration of the device, values in array are [x,y,z].
  20016. */
  20017. readonly angularAcceleration: Nullable<Float32Array>;
  20018. }
  20019. /**
  20020. * Interface representing a pose controlled object in Babylon.
  20021. * A pose controlled object has both regular pose values as well as pose values
  20022. * from an external device such as a VR head mounted display
  20023. */
  20024. export interface PoseControlled {
  20025. /**
  20026. * The position of the object in babylon space.
  20027. */
  20028. position: Vector3;
  20029. /**
  20030. * The rotation quaternion of the object in babylon space.
  20031. */
  20032. rotationQuaternion: Quaternion;
  20033. /**
  20034. * The position of the device in babylon space.
  20035. */
  20036. devicePosition?: Vector3;
  20037. /**
  20038. * The rotation quaternion of the device in babylon space.
  20039. */
  20040. deviceRotationQuaternion: Quaternion;
  20041. /**
  20042. * The raw pose coming from the device.
  20043. */
  20044. rawPose: Nullable<DevicePose>;
  20045. /**
  20046. * The scale of the device to be used when translating from device space to babylon space.
  20047. */
  20048. deviceScaleFactor: number;
  20049. /**
  20050. * Updates the poseControlled values based on the input device pose.
  20051. * @param poseData the pose data to update the object with
  20052. */
  20053. updateFromDevice(poseData: DevicePose): void;
  20054. }
  20055. /**
  20056. * Set of options to customize the webVRCamera
  20057. */
  20058. export interface WebVROptions {
  20059. /**
  20060. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20061. */
  20062. trackPosition?: boolean;
  20063. /**
  20064. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20065. */
  20066. positionScale?: number;
  20067. /**
  20068. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20069. */
  20070. displayName?: string;
  20071. /**
  20072. * Should the native controller meshes be initialized. (default: true)
  20073. */
  20074. controllerMeshes?: boolean;
  20075. /**
  20076. * Creating a default HemiLight only on controllers. (default: true)
  20077. */
  20078. defaultLightingOnControllers?: boolean;
  20079. /**
  20080. * If you don't want to use the default VR button of the helper. (default: false)
  20081. */
  20082. useCustomVRButton?: boolean;
  20083. /**
  20084. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20085. */
  20086. customVRButton?: HTMLButtonElement;
  20087. /**
  20088. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20089. */
  20090. rayLength?: number;
  20091. /**
  20092. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20093. */
  20094. defaultHeight?: number;
  20095. /**
  20096. * If multiview should be used if availible (default: false)
  20097. */
  20098. useMultiview?: boolean;
  20099. }
  20100. /**
  20101. * This represents a WebVR camera.
  20102. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20103. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20104. */
  20105. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20106. private webVROptions;
  20107. /**
  20108. * @hidden
  20109. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20110. */
  20111. _vrDevice: any;
  20112. /**
  20113. * The rawPose of the vrDevice.
  20114. */
  20115. rawPose: Nullable<DevicePose>;
  20116. private _onVREnabled;
  20117. private _specsVersion;
  20118. private _attached;
  20119. private _frameData;
  20120. protected _descendants: Array<Node>;
  20121. private _deviceRoomPosition;
  20122. /** @hidden */
  20123. _deviceRoomRotationQuaternion: Quaternion;
  20124. private _standingMatrix;
  20125. /**
  20126. * Represents device position in babylon space.
  20127. */
  20128. devicePosition: Vector3;
  20129. /**
  20130. * Represents device rotation in babylon space.
  20131. */
  20132. deviceRotationQuaternion: Quaternion;
  20133. /**
  20134. * The scale of the device to be used when translating from device space to babylon space.
  20135. */
  20136. deviceScaleFactor: number;
  20137. private _deviceToWorld;
  20138. private _worldToDevice;
  20139. /**
  20140. * References to the webVR controllers for the vrDevice.
  20141. */
  20142. controllers: Array<WebVRController>;
  20143. /**
  20144. * Emits an event when a controller is attached.
  20145. */
  20146. onControllersAttachedObservable: Observable<WebVRController[]>;
  20147. /**
  20148. * Emits an event when a controller's mesh has been loaded;
  20149. */
  20150. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20151. /**
  20152. * Emits an event when the HMD's pose has been updated.
  20153. */
  20154. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20155. private _poseSet;
  20156. /**
  20157. * If the rig cameras be used as parent instead of this camera.
  20158. */
  20159. rigParenting: boolean;
  20160. private _lightOnControllers;
  20161. private _defaultHeight?;
  20162. /**
  20163. * Instantiates a WebVRFreeCamera.
  20164. * @param name The name of the WebVRFreeCamera
  20165. * @param position The starting anchor position for the camera
  20166. * @param scene The scene the camera belongs to
  20167. * @param webVROptions a set of customizable options for the webVRCamera
  20168. */
  20169. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20170. /**
  20171. * Gets the device distance from the ground in meters.
  20172. * @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.
  20173. */
  20174. deviceDistanceToRoomGround(): number;
  20175. /**
  20176. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20177. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20178. */
  20179. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20180. /**
  20181. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20182. * @returns A promise with a boolean set to if the standing matrix is supported.
  20183. */
  20184. useStandingMatrixAsync(): Promise<boolean>;
  20185. /**
  20186. * Disposes the camera
  20187. */
  20188. dispose(): void;
  20189. /**
  20190. * Gets a vrController by name.
  20191. * @param name The name of the controller to retreive
  20192. * @returns the controller matching the name specified or null if not found
  20193. */
  20194. getControllerByName(name: string): Nullable<WebVRController>;
  20195. private _leftController;
  20196. /**
  20197. * The controller corresponding to the users left hand.
  20198. */
  20199. get leftController(): Nullable<WebVRController>;
  20200. private _rightController;
  20201. /**
  20202. * The controller corresponding to the users right hand.
  20203. */
  20204. get rightController(): Nullable<WebVRController>;
  20205. /**
  20206. * Casts a ray forward from the vrCamera's gaze.
  20207. * @param length Length of the ray (default: 100)
  20208. * @returns the ray corresponding to the gaze
  20209. */
  20210. getForwardRay(length?: number): Ray;
  20211. /**
  20212. * @hidden
  20213. * Updates the camera based on device's frame data
  20214. */
  20215. _checkInputs(): void;
  20216. /**
  20217. * Updates the poseControlled values based on the input device pose.
  20218. * @param poseData Pose coming from the device
  20219. */
  20220. updateFromDevice(poseData: DevicePose): void;
  20221. private _htmlElementAttached;
  20222. private _detachIfAttached;
  20223. /**
  20224. * WebVR's attach control will start broadcasting frames to the device.
  20225. * Note that in certain browsers (chrome for example) this function must be called
  20226. * within a user-interaction callback. Example:
  20227. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20228. *
  20229. * @param element html element to attach the vrDevice to
  20230. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20231. */
  20232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20233. /**
  20234. * Detaches the camera from the html element and disables VR
  20235. *
  20236. * @param element html element to detach from
  20237. */
  20238. detachControl(element: HTMLElement): void;
  20239. /**
  20240. * @returns the name of this class
  20241. */
  20242. getClassName(): string;
  20243. /**
  20244. * Calls resetPose on the vrDisplay
  20245. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20246. */
  20247. resetToCurrentRotation(): void;
  20248. /**
  20249. * @hidden
  20250. * Updates the rig cameras (left and right eye)
  20251. */
  20252. _updateRigCameras(): void;
  20253. private _workingVector;
  20254. private _oneVector;
  20255. private _workingMatrix;
  20256. private updateCacheCalled;
  20257. private _correctPositionIfNotTrackPosition;
  20258. /**
  20259. * @hidden
  20260. * Updates the cached values of the camera
  20261. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20262. */
  20263. _updateCache(ignoreParentClass?: boolean): void;
  20264. /**
  20265. * @hidden
  20266. * Get current device position in babylon world
  20267. */
  20268. _computeDevicePosition(): void;
  20269. /**
  20270. * Updates the current device position and rotation in the babylon world
  20271. */
  20272. update(): void;
  20273. /**
  20274. * @hidden
  20275. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20276. * @returns an identity matrix
  20277. */
  20278. _getViewMatrix(): Matrix;
  20279. private _tmpMatrix;
  20280. /**
  20281. * This function is called by the two RIG cameras.
  20282. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20283. * @hidden
  20284. */
  20285. _getWebVRViewMatrix(): Matrix;
  20286. /** @hidden */
  20287. _getWebVRProjectionMatrix(): Matrix;
  20288. private _onGamepadConnectedObserver;
  20289. private _onGamepadDisconnectedObserver;
  20290. private _updateCacheWhenTrackingDisabledObserver;
  20291. /**
  20292. * Initializes the controllers and their meshes
  20293. */
  20294. initControllers(): void;
  20295. }
  20296. }
  20297. declare module "babylonjs/PostProcesses/postProcess" {
  20298. import { Nullable } from "babylonjs/types";
  20299. import { SmartArray } from "babylonjs/Misc/smartArray";
  20300. import { Observable } from "babylonjs/Misc/observable";
  20301. import { Vector2 } from "babylonjs/Maths/math.vector";
  20302. import { Camera } from "babylonjs/Cameras/camera";
  20303. import { Effect } from "babylonjs/Materials/effect";
  20304. import "babylonjs/Shaders/postprocess.vertex";
  20305. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20306. import { Engine } from "babylonjs/Engines/engine";
  20307. import { Color4 } from "babylonjs/Maths/math.color";
  20308. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20310. /**
  20311. * Size options for a post process
  20312. */
  20313. export type PostProcessOptions = {
  20314. width: number;
  20315. height: number;
  20316. };
  20317. /**
  20318. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20319. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20320. */
  20321. export class PostProcess {
  20322. /** Name of the PostProcess. */
  20323. name: string;
  20324. /**
  20325. * Gets or sets the unique id of the post process
  20326. */
  20327. uniqueId: number;
  20328. /**
  20329. * Width of the texture to apply the post process on
  20330. */
  20331. width: number;
  20332. /**
  20333. * Height of the texture to apply the post process on
  20334. */
  20335. height: number;
  20336. /**
  20337. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20338. * @hidden
  20339. */
  20340. _outputTexture: Nullable<InternalTexture>;
  20341. /**
  20342. * Sampling mode used by the shader
  20343. * See https://doc.babylonjs.com/classes/3.1/texture
  20344. */
  20345. renderTargetSamplingMode: number;
  20346. /**
  20347. * Clear color to use when screen clearing
  20348. */
  20349. clearColor: Color4;
  20350. /**
  20351. * If the buffer needs to be cleared before applying the post process. (default: true)
  20352. * Should be set to false if shader will overwrite all previous pixels.
  20353. */
  20354. autoClear: boolean;
  20355. /**
  20356. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20357. */
  20358. alphaMode: number;
  20359. /**
  20360. * Sets the setAlphaBlendConstants of the babylon engine
  20361. */
  20362. alphaConstants: Color4;
  20363. /**
  20364. * Animations to be used for the post processing
  20365. */
  20366. animations: import("babylonjs/Animations/animation").Animation[];
  20367. /**
  20368. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20369. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20370. */
  20371. enablePixelPerfectMode: boolean;
  20372. /**
  20373. * Force the postprocess to be applied without taking in account viewport
  20374. */
  20375. forceFullscreenViewport: boolean;
  20376. /**
  20377. * List of inspectable custom properties (used by the Inspector)
  20378. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20379. */
  20380. inspectableCustomProperties: IInspectable[];
  20381. /**
  20382. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20383. *
  20384. * | Value | Type | Description |
  20385. * | ----- | ----------------------------------- | ----------- |
  20386. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20387. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20388. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20389. *
  20390. */
  20391. scaleMode: number;
  20392. /**
  20393. * Force textures to be a power of two (default: false)
  20394. */
  20395. alwaysForcePOT: boolean;
  20396. private _samples;
  20397. /**
  20398. * Number of sample textures (default: 1)
  20399. */
  20400. get samples(): number;
  20401. set samples(n: number);
  20402. /**
  20403. * Modify the scale of the post process to be the same as the viewport (default: false)
  20404. */
  20405. adaptScaleToCurrentViewport: boolean;
  20406. private _camera;
  20407. private _scene;
  20408. private _engine;
  20409. private _options;
  20410. private _reusable;
  20411. private _textureType;
  20412. private _textureFormat;
  20413. /**
  20414. * Smart array of input and output textures for the post process.
  20415. * @hidden
  20416. */
  20417. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20418. /**
  20419. * The index in _textures that corresponds to the output texture.
  20420. * @hidden
  20421. */
  20422. _currentRenderTextureInd: number;
  20423. private _effect;
  20424. private _samplers;
  20425. private _fragmentUrl;
  20426. private _vertexUrl;
  20427. private _parameters;
  20428. private _scaleRatio;
  20429. protected _indexParameters: any;
  20430. private _shareOutputWithPostProcess;
  20431. private _texelSize;
  20432. private _forcedOutputTexture;
  20433. /**
  20434. * Returns the fragment url or shader name used in the post process.
  20435. * @returns the fragment url or name in the shader store.
  20436. */
  20437. getEffectName(): string;
  20438. /**
  20439. * An event triggered when the postprocess is activated.
  20440. */
  20441. onActivateObservable: Observable<Camera>;
  20442. private _onActivateObserver;
  20443. /**
  20444. * A function that is added to the onActivateObservable
  20445. */
  20446. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20447. /**
  20448. * An event triggered when the postprocess changes its size.
  20449. */
  20450. onSizeChangedObservable: Observable<PostProcess>;
  20451. private _onSizeChangedObserver;
  20452. /**
  20453. * A function that is added to the onSizeChangedObservable
  20454. */
  20455. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20456. /**
  20457. * An event triggered when the postprocess applies its effect.
  20458. */
  20459. onApplyObservable: Observable<Effect>;
  20460. private _onApplyObserver;
  20461. /**
  20462. * A function that is added to the onApplyObservable
  20463. */
  20464. set onApply(callback: (effect: Effect) => void);
  20465. /**
  20466. * An event triggered before rendering the postprocess
  20467. */
  20468. onBeforeRenderObservable: Observable<Effect>;
  20469. private _onBeforeRenderObserver;
  20470. /**
  20471. * A function that is added to the onBeforeRenderObservable
  20472. */
  20473. set onBeforeRender(callback: (effect: Effect) => void);
  20474. /**
  20475. * An event triggered after rendering the postprocess
  20476. */
  20477. onAfterRenderObservable: Observable<Effect>;
  20478. private _onAfterRenderObserver;
  20479. /**
  20480. * A function that is added to the onAfterRenderObservable
  20481. */
  20482. set onAfterRender(callback: (efect: Effect) => void);
  20483. /**
  20484. * 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
  20485. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20486. */
  20487. get inputTexture(): InternalTexture;
  20488. set inputTexture(value: InternalTexture);
  20489. /**
  20490. * Gets the camera which post process is applied to.
  20491. * @returns The camera the post process is applied to.
  20492. */
  20493. getCamera(): Camera;
  20494. /**
  20495. * Gets the texel size of the postprocess.
  20496. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20497. */
  20498. get texelSize(): Vector2;
  20499. /**
  20500. * Creates a new instance PostProcess
  20501. * @param name The name of the PostProcess.
  20502. * @param fragmentUrl The url of the fragment shader to be used.
  20503. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20504. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20505. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20506. * @param camera The camera to apply the render pass to.
  20507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20508. * @param engine The engine which the post process will be applied. (default: current engine)
  20509. * @param reusable If the post process can be reused on the same frame. (default: false)
  20510. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20511. * @param textureType Type of textures used when performing the post process. (default: 0)
  20512. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20513. * @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
  20514. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20515. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20516. */
  20517. constructor(
  20518. /** Name of the PostProcess. */
  20519. 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);
  20520. /**
  20521. * Gets a string idenfifying the name of the class
  20522. * @returns "PostProcess" string
  20523. */
  20524. getClassName(): string;
  20525. /**
  20526. * Gets the engine which this post process belongs to.
  20527. * @returns The engine the post process was enabled with.
  20528. */
  20529. getEngine(): Engine;
  20530. /**
  20531. * The effect that is created when initializing the post process.
  20532. * @returns The created effect corresponding the the postprocess.
  20533. */
  20534. getEffect(): Effect;
  20535. /**
  20536. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20537. * @param postProcess The post process to share the output with.
  20538. * @returns This post process.
  20539. */
  20540. shareOutputWith(postProcess: PostProcess): PostProcess;
  20541. /**
  20542. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20543. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20544. */
  20545. useOwnOutput(): void;
  20546. /**
  20547. * Updates the effect with the current post process compile time values and recompiles the shader.
  20548. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20549. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20550. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20551. * @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
  20552. * @param onCompiled Called when the shader has been compiled.
  20553. * @param onError Called if there is an error when compiling a shader.
  20554. */
  20555. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20556. /**
  20557. * The post process is reusable if it can be used multiple times within one frame.
  20558. * @returns If the post process is reusable
  20559. */
  20560. isReusable(): boolean;
  20561. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20562. markTextureDirty(): void;
  20563. /**
  20564. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20565. * 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.
  20566. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20567. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20568. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20569. * @returns The target texture that was bound to be written to.
  20570. */
  20571. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20572. /**
  20573. * If the post process is supported.
  20574. */
  20575. get isSupported(): boolean;
  20576. /**
  20577. * The aspect ratio of the output texture.
  20578. */
  20579. get aspectRatio(): number;
  20580. /**
  20581. * Get a value indicating if the post-process is ready to be used
  20582. * @returns true if the post-process is ready (shader is compiled)
  20583. */
  20584. isReady(): boolean;
  20585. /**
  20586. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20587. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20588. */
  20589. apply(): Nullable<Effect>;
  20590. private _disposeTextures;
  20591. /**
  20592. * Disposes the post process.
  20593. * @param camera The camera to dispose the post process on.
  20594. */
  20595. dispose(camera?: Camera): void;
  20596. }
  20597. }
  20598. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20599. /** @hidden */
  20600. export var kernelBlurVaryingDeclaration: {
  20601. name: string;
  20602. shader: string;
  20603. };
  20604. }
  20605. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20606. /** @hidden */
  20607. export var kernelBlurFragment: {
  20608. name: string;
  20609. shader: string;
  20610. };
  20611. }
  20612. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20613. /** @hidden */
  20614. export var kernelBlurFragment2: {
  20615. name: string;
  20616. shader: string;
  20617. };
  20618. }
  20619. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20620. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20621. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20622. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20623. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20624. /** @hidden */
  20625. export var kernelBlurPixelShader: {
  20626. name: string;
  20627. shader: string;
  20628. };
  20629. }
  20630. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20631. /** @hidden */
  20632. export var kernelBlurVertex: {
  20633. name: string;
  20634. shader: string;
  20635. };
  20636. }
  20637. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20638. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20639. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20640. /** @hidden */
  20641. export var kernelBlurVertexShader: {
  20642. name: string;
  20643. shader: string;
  20644. };
  20645. }
  20646. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20647. import { Vector2 } from "babylonjs/Maths/math.vector";
  20648. import { Nullable } from "babylonjs/types";
  20649. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20650. import { Camera } from "babylonjs/Cameras/camera";
  20651. import { Effect } from "babylonjs/Materials/effect";
  20652. import { Engine } from "babylonjs/Engines/engine";
  20653. import "babylonjs/Shaders/kernelBlur.fragment";
  20654. import "babylonjs/Shaders/kernelBlur.vertex";
  20655. /**
  20656. * The Blur Post Process which blurs an image based on a kernel and direction.
  20657. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20658. */
  20659. export class BlurPostProcess extends PostProcess {
  20660. /** The direction in which to blur the image. */
  20661. direction: Vector2;
  20662. private blockCompilation;
  20663. protected _kernel: number;
  20664. protected _idealKernel: number;
  20665. protected _packedFloat: boolean;
  20666. private _staticDefines;
  20667. /**
  20668. * Sets the length in pixels of the blur sample region
  20669. */
  20670. set kernel(v: number);
  20671. /**
  20672. * Gets the length in pixels of the blur sample region
  20673. */
  20674. get kernel(): number;
  20675. /**
  20676. * Sets wether or not the blur needs to unpack/repack floats
  20677. */
  20678. set packedFloat(v: boolean);
  20679. /**
  20680. * Gets wether or not the blur is unpacking/repacking floats
  20681. */
  20682. get packedFloat(): boolean;
  20683. /**
  20684. * Creates a new instance BlurPostProcess
  20685. * @param name The name of the effect.
  20686. * @param direction The direction in which to blur the image.
  20687. * @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.
  20688. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20689. * @param camera The camera to apply the render pass to.
  20690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20691. * @param engine The engine which the post process will be applied. (default: current engine)
  20692. * @param reusable If the post process can be reused on the same frame. (default: false)
  20693. * @param textureType Type of textures used when performing the post process. (default: 0)
  20694. * @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)
  20695. */
  20696. constructor(name: string,
  20697. /** The direction in which to blur the image. */
  20698. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20699. /**
  20700. * Updates the effect with the current post process compile time values and recompiles the shader.
  20701. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20702. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20703. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20704. * @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
  20705. * @param onCompiled Called when the shader has been compiled.
  20706. * @param onError Called if there is an error when compiling a shader.
  20707. */
  20708. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20709. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20710. /**
  20711. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20712. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20713. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20714. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20715. * The gaps between physical kernels are compensated for in the weighting of the samples
  20716. * @param idealKernel Ideal blur kernel.
  20717. * @return Nearest best kernel.
  20718. */
  20719. protected _nearestBestKernel(idealKernel: number): number;
  20720. /**
  20721. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20722. * @param x The point on the Gaussian distribution to sample.
  20723. * @return the value of the Gaussian function at x.
  20724. */
  20725. protected _gaussianWeight(x: number): number;
  20726. /**
  20727. * Generates a string that can be used as a floating point number in GLSL.
  20728. * @param x Value to print.
  20729. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20730. * @return GLSL float string.
  20731. */
  20732. protected _glslFloat(x: number, decimalFigures?: number): string;
  20733. }
  20734. }
  20735. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20736. import { Scene } from "babylonjs/scene";
  20737. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20738. import { Plane } from "babylonjs/Maths/math.plane";
  20739. /**
  20740. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20741. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20742. * You can then easily use it as a reflectionTexture on a flat surface.
  20743. * In case the surface is not a plane, please consider relying on reflection probes.
  20744. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20745. */
  20746. export class MirrorTexture extends RenderTargetTexture {
  20747. private scene;
  20748. /**
  20749. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20750. * 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.
  20751. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20752. */
  20753. mirrorPlane: Plane;
  20754. /**
  20755. * Define the blur ratio used to blur the reflection if needed.
  20756. */
  20757. set blurRatio(value: number);
  20758. get blurRatio(): number;
  20759. /**
  20760. * Define the adaptive blur kernel used to blur the reflection if needed.
  20761. * This will autocompute the closest best match for the `blurKernel`
  20762. */
  20763. set adaptiveBlurKernel(value: number);
  20764. /**
  20765. * Define the blur kernel used to blur the reflection if needed.
  20766. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20767. */
  20768. set blurKernel(value: number);
  20769. /**
  20770. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20772. */
  20773. set blurKernelX(value: number);
  20774. get blurKernelX(): number;
  20775. /**
  20776. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20777. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20778. */
  20779. set blurKernelY(value: number);
  20780. get blurKernelY(): number;
  20781. private _autoComputeBlurKernel;
  20782. protected _onRatioRescale(): void;
  20783. private _updateGammaSpace;
  20784. private _imageProcessingConfigChangeObserver;
  20785. private _transformMatrix;
  20786. private _mirrorMatrix;
  20787. private _savedViewMatrix;
  20788. private _blurX;
  20789. private _blurY;
  20790. private _adaptiveBlurKernel;
  20791. private _blurKernelX;
  20792. private _blurKernelY;
  20793. private _blurRatio;
  20794. /**
  20795. * Instantiates a Mirror Texture.
  20796. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20797. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20798. * You can then easily use it as a reflectionTexture on a flat surface.
  20799. * In case the surface is not a plane, please consider relying on reflection probes.
  20800. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20801. * @param name
  20802. * @param size
  20803. * @param scene
  20804. * @param generateMipMaps
  20805. * @param type
  20806. * @param samplingMode
  20807. * @param generateDepthBuffer
  20808. */
  20809. constructor(name: string, size: number | {
  20810. width: number;
  20811. height: number;
  20812. } | {
  20813. ratio: number;
  20814. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20815. private _preparePostProcesses;
  20816. /**
  20817. * Clone the mirror texture.
  20818. * @returns the cloned texture
  20819. */
  20820. clone(): MirrorTexture;
  20821. /**
  20822. * Serialize the texture to a JSON representation you could use in Parse later on
  20823. * @returns the serialized JSON representation
  20824. */
  20825. serialize(): any;
  20826. /**
  20827. * Dispose the texture and release its associated resources.
  20828. */
  20829. dispose(): void;
  20830. }
  20831. }
  20832. declare module "babylonjs/Materials/Textures/texture" {
  20833. import { Observable } from "babylonjs/Misc/observable";
  20834. import { Nullable } from "babylonjs/types";
  20835. import { Matrix } from "babylonjs/Maths/math.vector";
  20836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20837. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20838. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20839. import { Scene } from "babylonjs/scene";
  20840. /**
  20841. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20842. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20843. */
  20844. export class Texture extends BaseTexture {
  20845. /**
  20846. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20847. */
  20848. static SerializeBuffers: boolean;
  20849. /** @hidden */
  20850. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20851. /** @hidden */
  20852. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20853. /** @hidden */
  20854. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20855. /** nearest is mag = nearest and min = nearest and mip = linear */
  20856. static readonly NEAREST_SAMPLINGMODE: number;
  20857. /** nearest is mag = nearest and min = nearest and mip = linear */
  20858. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20859. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20860. static readonly BILINEAR_SAMPLINGMODE: number;
  20861. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20862. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20863. /** Trilinear is mag = linear and min = linear and mip = linear */
  20864. static readonly TRILINEAR_SAMPLINGMODE: number;
  20865. /** Trilinear is mag = linear and min = linear and mip = linear */
  20866. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20867. /** mag = nearest and min = nearest and mip = nearest */
  20868. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20869. /** mag = nearest and min = linear and mip = nearest */
  20870. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20871. /** mag = nearest and min = linear and mip = linear */
  20872. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20873. /** mag = nearest and min = linear and mip = none */
  20874. static readonly NEAREST_LINEAR: number;
  20875. /** mag = nearest and min = nearest and mip = none */
  20876. static readonly NEAREST_NEAREST: number;
  20877. /** mag = linear and min = nearest and mip = nearest */
  20878. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20879. /** mag = linear and min = nearest and mip = linear */
  20880. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20881. /** mag = linear and min = linear and mip = none */
  20882. static readonly LINEAR_LINEAR: number;
  20883. /** mag = linear and min = nearest and mip = none */
  20884. static readonly LINEAR_NEAREST: number;
  20885. /** Explicit coordinates mode */
  20886. static readonly EXPLICIT_MODE: number;
  20887. /** Spherical coordinates mode */
  20888. static readonly SPHERICAL_MODE: number;
  20889. /** Planar coordinates mode */
  20890. static readonly PLANAR_MODE: number;
  20891. /** Cubic coordinates mode */
  20892. static readonly CUBIC_MODE: number;
  20893. /** Projection coordinates mode */
  20894. static readonly PROJECTION_MODE: number;
  20895. /** Inverse Cubic coordinates mode */
  20896. static readonly SKYBOX_MODE: number;
  20897. /** Inverse Cubic coordinates mode */
  20898. static readonly INVCUBIC_MODE: number;
  20899. /** Equirectangular coordinates mode */
  20900. static readonly EQUIRECTANGULAR_MODE: number;
  20901. /** Equirectangular Fixed coordinates mode */
  20902. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20903. /** Equirectangular Fixed Mirrored coordinates mode */
  20904. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20905. /** Texture is not repeating outside of 0..1 UVs */
  20906. static readonly CLAMP_ADDRESSMODE: number;
  20907. /** Texture is repeating outside of 0..1 UVs */
  20908. static readonly WRAP_ADDRESSMODE: number;
  20909. /** Texture is repeating and mirrored */
  20910. static readonly MIRROR_ADDRESSMODE: number;
  20911. /**
  20912. * 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
  20913. */
  20914. static UseSerializedUrlIfAny: boolean;
  20915. /**
  20916. * Define the url of the texture.
  20917. */
  20918. url: Nullable<string>;
  20919. /**
  20920. * Define an offset on the texture to offset the u coordinates of the UVs
  20921. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20922. */
  20923. uOffset: number;
  20924. /**
  20925. * Define an offset on the texture to offset the v coordinates of the UVs
  20926. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20927. */
  20928. vOffset: number;
  20929. /**
  20930. * Define an offset on the texture to scale the u coordinates of the UVs
  20931. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20932. */
  20933. uScale: number;
  20934. /**
  20935. * Define an offset on the texture to scale the v coordinates of the UVs
  20936. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20937. */
  20938. vScale: number;
  20939. /**
  20940. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20941. * @see http://doc.babylonjs.com/how_to/more_materials
  20942. */
  20943. uAng: number;
  20944. /**
  20945. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20946. * @see http://doc.babylonjs.com/how_to/more_materials
  20947. */
  20948. vAng: number;
  20949. /**
  20950. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20951. * @see http://doc.babylonjs.com/how_to/more_materials
  20952. */
  20953. wAng: number;
  20954. /**
  20955. * Defines the center of rotation (U)
  20956. */
  20957. uRotationCenter: number;
  20958. /**
  20959. * Defines the center of rotation (V)
  20960. */
  20961. vRotationCenter: number;
  20962. /**
  20963. * Defines the center of rotation (W)
  20964. */
  20965. wRotationCenter: number;
  20966. /**
  20967. * Are mip maps generated for this texture or not.
  20968. */
  20969. get noMipmap(): boolean;
  20970. /**
  20971. * List of inspectable custom properties (used by the Inspector)
  20972. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20973. */
  20974. inspectableCustomProperties: Nullable<IInspectable[]>;
  20975. private _noMipmap;
  20976. /** @hidden */
  20977. _invertY: boolean;
  20978. private _rowGenerationMatrix;
  20979. private _cachedTextureMatrix;
  20980. private _projectionModeMatrix;
  20981. private _t0;
  20982. private _t1;
  20983. private _t2;
  20984. private _cachedUOffset;
  20985. private _cachedVOffset;
  20986. private _cachedUScale;
  20987. private _cachedVScale;
  20988. private _cachedUAng;
  20989. private _cachedVAng;
  20990. private _cachedWAng;
  20991. private _cachedProjectionMatrixId;
  20992. private _cachedCoordinatesMode;
  20993. /** @hidden */
  20994. protected _initialSamplingMode: number;
  20995. /** @hidden */
  20996. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20997. private _deleteBuffer;
  20998. protected _format: Nullable<number>;
  20999. private _delayedOnLoad;
  21000. private _delayedOnError;
  21001. private _mimeType?;
  21002. /**
  21003. * Observable triggered once the texture has been loaded.
  21004. */
  21005. onLoadObservable: Observable<Texture>;
  21006. protected _isBlocking: boolean;
  21007. /**
  21008. * Is the texture preventing material to render while loading.
  21009. * If false, a default texture will be used instead of the loading one during the preparation step.
  21010. */
  21011. set isBlocking(value: boolean);
  21012. get isBlocking(): boolean;
  21013. /**
  21014. * Get the current sampling mode associated with the texture.
  21015. */
  21016. get samplingMode(): number;
  21017. /**
  21018. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21019. */
  21020. get invertY(): boolean;
  21021. /**
  21022. * Instantiates a new texture.
  21023. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21024. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21025. * @param url defines the url of the picture to load as a texture
  21026. * @param scene defines the scene or engine the texture will belong to
  21027. * @param noMipmap defines if the texture will require mip maps or not
  21028. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21029. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21030. * @param onLoad defines a callback triggered when the texture has been loaded
  21031. * @param onError defines a callback triggered when an error occurred during the loading session
  21032. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21033. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21034. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21035. * @param mimeType defines an optional mime type information
  21036. */
  21037. 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);
  21038. /**
  21039. * Update the url (and optional buffer) of this texture if url was null during construction.
  21040. * @param url the url of the texture
  21041. * @param buffer the buffer of the texture (defaults to null)
  21042. * @param onLoad callback called when the texture is loaded (defaults to null)
  21043. */
  21044. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21045. /**
  21046. * Finish the loading sequence of a texture flagged as delayed load.
  21047. * @hidden
  21048. */
  21049. delayLoad(): void;
  21050. private _prepareRowForTextureGeneration;
  21051. /**
  21052. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21053. * @returns the transform matrix of the texture.
  21054. */
  21055. getTextureMatrix(uBase?: number): Matrix;
  21056. /**
  21057. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21058. * @returns The reflection texture transform
  21059. */
  21060. getReflectionTextureMatrix(): Matrix;
  21061. /**
  21062. * Clones the texture.
  21063. * @returns the cloned texture
  21064. */
  21065. clone(): Texture;
  21066. /**
  21067. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21068. * @returns The JSON representation of the texture
  21069. */
  21070. serialize(): any;
  21071. /**
  21072. * Get the current class name of the texture useful for serialization or dynamic coding.
  21073. * @returns "Texture"
  21074. */
  21075. getClassName(): string;
  21076. /**
  21077. * Dispose the texture and release its associated resources.
  21078. */
  21079. dispose(): void;
  21080. /**
  21081. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21082. * @param parsedTexture Define the JSON representation of the texture
  21083. * @param scene Define the scene the parsed texture should be instantiated in
  21084. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21085. * @returns The parsed texture if successful
  21086. */
  21087. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21088. /**
  21089. * Creates a texture from its base 64 representation.
  21090. * @param data Define the base64 payload without the data: prefix
  21091. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21092. * @param scene Define the scene the texture should belong to
  21093. * @param noMipmap Forces the texture to not create mip map information if true
  21094. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21095. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21096. * @param onLoad define a callback triggered when the texture has been loaded
  21097. * @param onError define a callback triggered when an error occurred during the loading session
  21098. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21099. * @returns the created texture
  21100. */
  21101. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21102. /**
  21103. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21104. * @param data Define the base64 payload without the data: prefix
  21105. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21106. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21107. * @param scene Define the scene the texture should belong to
  21108. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21109. * @param noMipmap Forces the texture to not create mip map information if true
  21110. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21111. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21112. * @param onLoad define a callback triggered when the texture has been loaded
  21113. * @param onError define a callback triggered when an error occurred during the loading session
  21114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21115. * @returns the created texture
  21116. */
  21117. 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;
  21118. }
  21119. }
  21120. declare module "babylonjs/PostProcesses/postProcessManager" {
  21121. import { Nullable } from "babylonjs/types";
  21122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21124. import { Scene } from "babylonjs/scene";
  21125. /**
  21126. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21127. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21128. */
  21129. export class PostProcessManager {
  21130. private _scene;
  21131. private _indexBuffer;
  21132. private _vertexBuffers;
  21133. /**
  21134. * Creates a new instance PostProcess
  21135. * @param scene The scene that the post process is associated with.
  21136. */
  21137. constructor(scene: Scene);
  21138. private _prepareBuffers;
  21139. private _buildIndexBuffer;
  21140. /**
  21141. * Rebuilds the vertex buffers of the manager.
  21142. * @hidden
  21143. */
  21144. _rebuild(): void;
  21145. /**
  21146. * Prepares a frame to be run through a post process.
  21147. * @param sourceTexture The input texture to the post procesess. (default: null)
  21148. * @param postProcesses An array of post processes to be run. (default: null)
  21149. * @returns True if the post processes were able to be run.
  21150. * @hidden
  21151. */
  21152. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21153. /**
  21154. * Manually render a set of post processes to a texture.
  21155. * @param postProcesses An array of post processes to be run.
  21156. * @param targetTexture The target texture to render to.
  21157. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21158. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21159. * @param lodLevel defines which lod of the texture to render to
  21160. */
  21161. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21162. /**
  21163. * Finalize the result of the output of the postprocesses.
  21164. * @param doNotPresent If true the result will not be displayed to the screen.
  21165. * @param targetTexture The target texture to render to.
  21166. * @param faceIndex The index of the face to bind the target texture to.
  21167. * @param postProcesses The array of post processes to render.
  21168. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21169. * @hidden
  21170. */
  21171. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21172. /**
  21173. * Disposes of the post process manager.
  21174. */
  21175. dispose(): void;
  21176. }
  21177. }
  21178. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21179. import { Observable } from "babylonjs/Misc/observable";
  21180. import { SmartArray } from "babylonjs/Misc/smartArray";
  21181. import { Nullable, Immutable } from "babylonjs/types";
  21182. import { Camera } from "babylonjs/Cameras/camera";
  21183. import { Scene } from "babylonjs/scene";
  21184. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21185. import { Color4 } from "babylonjs/Maths/math.color";
  21186. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21188. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21189. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21190. import { Texture } from "babylonjs/Materials/Textures/texture";
  21191. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21192. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21193. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21194. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21195. import { Engine } from "babylonjs/Engines/engine";
  21196. /**
  21197. * This Helps creating a texture that will be created from a camera in your scene.
  21198. * It is basically a dynamic texture that could be used to create special effects for instance.
  21199. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21200. */
  21201. export class RenderTargetTexture extends Texture {
  21202. isCube: boolean;
  21203. /**
  21204. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21205. */
  21206. static readonly REFRESHRATE_RENDER_ONCE: number;
  21207. /**
  21208. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21209. */
  21210. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21211. /**
  21212. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21213. * the central point of your effect and can save a lot of performances.
  21214. */
  21215. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21216. /**
  21217. * Use this predicate to dynamically define the list of mesh you want to render.
  21218. * If set, the renderList property will be overwritten.
  21219. */
  21220. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21221. private _renderList;
  21222. /**
  21223. * Use this list to define the list of mesh you want to render.
  21224. */
  21225. get renderList(): Nullable<Array<AbstractMesh>>;
  21226. set renderList(value: Nullable<Array<AbstractMesh>>);
  21227. /**
  21228. * Use this function to overload the renderList array at rendering time.
  21229. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21230. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21231. * the cube (if the RTT is a cube, else layerOrFace=0).
  21232. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21233. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21234. * hold dummy elements!
  21235. */
  21236. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21237. private _hookArray;
  21238. /**
  21239. * Define if particles should be rendered in your texture.
  21240. */
  21241. renderParticles: boolean;
  21242. /**
  21243. * Define if sprites should be rendered in your texture.
  21244. */
  21245. renderSprites: boolean;
  21246. /**
  21247. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21248. */
  21249. coordinatesMode: number;
  21250. /**
  21251. * Define the camera used to render the texture.
  21252. */
  21253. activeCamera: Nullable<Camera>;
  21254. /**
  21255. * Override the mesh isReady function with your own one.
  21256. */
  21257. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21258. /**
  21259. * Override the render function of the texture with your own one.
  21260. */
  21261. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21262. /**
  21263. * Define if camera post processes should be use while rendering the texture.
  21264. */
  21265. useCameraPostProcesses: boolean;
  21266. /**
  21267. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21268. */
  21269. ignoreCameraViewport: boolean;
  21270. private _postProcessManager;
  21271. private _postProcesses;
  21272. private _resizeObserver;
  21273. /**
  21274. * An event triggered when the texture is unbind.
  21275. */
  21276. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21277. /**
  21278. * An event triggered when the texture is unbind.
  21279. */
  21280. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21281. private _onAfterUnbindObserver;
  21282. /**
  21283. * Set a after unbind callback in the texture.
  21284. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21285. */
  21286. set onAfterUnbind(callback: () => void);
  21287. /**
  21288. * An event triggered before rendering the texture
  21289. */
  21290. onBeforeRenderObservable: Observable<number>;
  21291. private _onBeforeRenderObserver;
  21292. /**
  21293. * Set a before render callback in the texture.
  21294. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21295. */
  21296. set onBeforeRender(callback: (faceIndex: number) => void);
  21297. /**
  21298. * An event triggered after rendering the texture
  21299. */
  21300. onAfterRenderObservable: Observable<number>;
  21301. private _onAfterRenderObserver;
  21302. /**
  21303. * Set a after render callback in the texture.
  21304. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21305. */
  21306. set onAfterRender(callback: (faceIndex: number) => void);
  21307. /**
  21308. * An event triggered after the texture clear
  21309. */
  21310. onClearObservable: Observable<Engine>;
  21311. private _onClearObserver;
  21312. /**
  21313. * Set a clear callback in the texture.
  21314. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21315. */
  21316. set onClear(callback: (Engine: Engine) => void);
  21317. /**
  21318. * An event triggered when the texture is resized.
  21319. */
  21320. onResizeObservable: Observable<RenderTargetTexture>;
  21321. /**
  21322. * Define the clear color of the Render Target if it should be different from the scene.
  21323. */
  21324. clearColor: Color4;
  21325. protected _size: number | {
  21326. width: number;
  21327. height: number;
  21328. layers?: number;
  21329. };
  21330. protected _initialSizeParameter: number | {
  21331. width: number;
  21332. height: number;
  21333. } | {
  21334. ratio: number;
  21335. };
  21336. protected _sizeRatio: Nullable<number>;
  21337. /** @hidden */
  21338. _generateMipMaps: boolean;
  21339. protected _renderingManager: RenderingManager;
  21340. /** @hidden */
  21341. _waitingRenderList: string[];
  21342. protected _doNotChangeAspectRatio: boolean;
  21343. protected _currentRefreshId: number;
  21344. protected _refreshRate: number;
  21345. protected _textureMatrix: Matrix;
  21346. protected _samples: number;
  21347. protected _renderTargetOptions: RenderTargetCreationOptions;
  21348. /**
  21349. * Gets render target creation options that were used.
  21350. */
  21351. get renderTargetOptions(): RenderTargetCreationOptions;
  21352. protected _engine: Engine;
  21353. protected _onRatioRescale(): void;
  21354. /**
  21355. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21356. * It must define where the camera used to render the texture is set
  21357. */
  21358. boundingBoxPosition: Vector3;
  21359. private _boundingBoxSize;
  21360. /**
  21361. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21362. * When defined, the cubemap will switch to local mode
  21363. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21364. * @example https://www.babylonjs-playground.com/#RNASML
  21365. */
  21366. set boundingBoxSize(value: Vector3);
  21367. get boundingBoxSize(): Vector3;
  21368. /**
  21369. * In case the RTT has been created with a depth texture, get the associated
  21370. * depth texture.
  21371. * Otherwise, return null.
  21372. */
  21373. get depthStencilTexture(): Nullable<InternalTexture>;
  21374. /**
  21375. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21376. * or used a shadow, depth texture...
  21377. * @param name The friendly name of the texture
  21378. * @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)
  21379. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21380. * @param generateMipMaps True if mip maps need to be generated after render.
  21381. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21382. * @param type The type of the buffer in the RTT (int, half float, float...)
  21383. * @param isCube True if a cube texture needs to be created
  21384. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21385. * @param generateDepthBuffer True to generate a depth buffer
  21386. * @param generateStencilBuffer True to generate a stencil buffer
  21387. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21388. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21389. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21390. */
  21391. constructor(name: string, size: number | {
  21392. width: number;
  21393. height: number;
  21394. layers?: number;
  21395. } | {
  21396. ratio: number;
  21397. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21398. /**
  21399. * Creates a depth stencil texture.
  21400. * This is only available in WebGL 2 or with the depth texture extension available.
  21401. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21402. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21403. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21404. */
  21405. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21406. private _processSizeParameter;
  21407. /**
  21408. * Define the number of samples to use in case of MSAA.
  21409. * It defaults to one meaning no MSAA has been enabled.
  21410. */
  21411. get samples(): number;
  21412. set samples(value: number);
  21413. /**
  21414. * Resets the refresh counter of the texture and start bak from scratch.
  21415. * Could be useful to regenerate the texture if it is setup to render only once.
  21416. */
  21417. resetRefreshCounter(): void;
  21418. /**
  21419. * Define the refresh rate of the texture or the rendering frequency.
  21420. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21421. */
  21422. get refreshRate(): number;
  21423. set refreshRate(value: number);
  21424. /**
  21425. * Adds a post process to the render target rendering passes.
  21426. * @param postProcess define the post process to add
  21427. */
  21428. addPostProcess(postProcess: PostProcess): void;
  21429. /**
  21430. * Clear all the post processes attached to the render target
  21431. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21432. */
  21433. clearPostProcesses(dispose?: boolean): void;
  21434. /**
  21435. * Remove one of the post process from the list of attached post processes to the texture
  21436. * @param postProcess define the post process to remove from the list
  21437. */
  21438. removePostProcess(postProcess: PostProcess): void;
  21439. /** @hidden */
  21440. _shouldRender(): boolean;
  21441. /**
  21442. * Gets the actual render size of the texture.
  21443. * @returns the width of the render size
  21444. */
  21445. getRenderSize(): number;
  21446. /**
  21447. * Gets the actual render width of the texture.
  21448. * @returns the width of the render size
  21449. */
  21450. getRenderWidth(): number;
  21451. /**
  21452. * Gets the actual render height of the texture.
  21453. * @returns the height of the render size
  21454. */
  21455. getRenderHeight(): number;
  21456. /**
  21457. * Gets the actual number of layers of the texture.
  21458. * @returns the number of layers
  21459. */
  21460. getRenderLayers(): number;
  21461. /**
  21462. * Get if the texture can be rescaled or not.
  21463. */
  21464. get canRescale(): boolean;
  21465. /**
  21466. * Resize the texture using a ratio.
  21467. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21468. */
  21469. scale(ratio: number): void;
  21470. /**
  21471. * Get the texture reflection matrix used to rotate/transform the reflection.
  21472. * @returns the reflection matrix
  21473. */
  21474. getReflectionTextureMatrix(): Matrix;
  21475. /**
  21476. * Resize the texture to a new desired size.
  21477. * Be carrefull as it will recreate all the data in the new texture.
  21478. * @param size Define the new size. It can be:
  21479. * - a number for squared texture,
  21480. * - an object containing { width: number, height: number }
  21481. * - or an object containing a ratio { ratio: number }
  21482. */
  21483. resize(size: number | {
  21484. width: number;
  21485. height: number;
  21486. } | {
  21487. ratio: number;
  21488. }): void;
  21489. private _defaultRenderListPrepared;
  21490. /**
  21491. * Renders all the objects from the render list into the texture.
  21492. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21493. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21494. */
  21495. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21496. private _bestReflectionRenderTargetDimension;
  21497. private _prepareRenderingManager;
  21498. /**
  21499. * @hidden
  21500. * @param faceIndex face index to bind to if this is a cubetexture
  21501. * @param layer defines the index of the texture to bind in the array
  21502. */
  21503. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21504. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21505. private renderToTarget;
  21506. /**
  21507. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21508. * This allowed control for front to back rendering or reversly depending of the special needs.
  21509. *
  21510. * @param renderingGroupId The rendering group id corresponding to its index
  21511. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21512. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21513. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21514. */
  21515. 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;
  21516. /**
  21517. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21518. *
  21519. * @param renderingGroupId The rendering group id corresponding to its index
  21520. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21521. */
  21522. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21523. /**
  21524. * Clones the texture.
  21525. * @returns the cloned texture
  21526. */
  21527. clone(): RenderTargetTexture;
  21528. /**
  21529. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21530. * @returns The JSON representation of the texture
  21531. */
  21532. serialize(): any;
  21533. /**
  21534. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21535. */
  21536. disposeFramebufferObjects(): void;
  21537. /**
  21538. * Dispose the texture and release its associated resources.
  21539. */
  21540. dispose(): void;
  21541. /** @hidden */
  21542. _rebuild(): void;
  21543. /**
  21544. * Clear the info related to rendering groups preventing retention point in material dispose.
  21545. */
  21546. freeRenderingGroups(): void;
  21547. /**
  21548. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21549. * @returns the view count
  21550. */
  21551. getViewCount(): number;
  21552. }
  21553. }
  21554. declare module "babylonjs/Materials/material" {
  21555. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21556. import { SmartArray } from "babylonjs/Misc/smartArray";
  21557. import { Observable } from "babylonjs/Misc/observable";
  21558. import { Nullable } from "babylonjs/types";
  21559. import { Scene } from "babylonjs/scene";
  21560. import { Matrix } from "babylonjs/Maths/math.vector";
  21561. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21563. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21564. import { Effect } from "babylonjs/Materials/effect";
  21565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21566. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21567. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21568. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21569. import { Mesh } from "babylonjs/Meshes/mesh";
  21570. import { Animation } from "babylonjs/Animations/animation";
  21571. /**
  21572. * Options for compiling materials.
  21573. */
  21574. export interface IMaterialCompilationOptions {
  21575. /**
  21576. * Defines whether clip planes are enabled.
  21577. */
  21578. clipPlane: boolean;
  21579. /**
  21580. * Defines whether instances are enabled.
  21581. */
  21582. useInstances: boolean;
  21583. }
  21584. /**
  21585. * Base class for the main features of a material in Babylon.js
  21586. */
  21587. export class Material implements IAnimatable {
  21588. /**
  21589. * Returns the triangle fill mode
  21590. */
  21591. static readonly TriangleFillMode: number;
  21592. /**
  21593. * Returns the wireframe mode
  21594. */
  21595. static readonly WireFrameFillMode: number;
  21596. /**
  21597. * Returns the point fill mode
  21598. */
  21599. static readonly PointFillMode: number;
  21600. /**
  21601. * Returns the point list draw mode
  21602. */
  21603. static readonly PointListDrawMode: number;
  21604. /**
  21605. * Returns the line list draw mode
  21606. */
  21607. static readonly LineListDrawMode: number;
  21608. /**
  21609. * Returns the line loop draw mode
  21610. */
  21611. static readonly LineLoopDrawMode: number;
  21612. /**
  21613. * Returns the line strip draw mode
  21614. */
  21615. static readonly LineStripDrawMode: number;
  21616. /**
  21617. * Returns the triangle strip draw mode
  21618. */
  21619. static readonly TriangleStripDrawMode: number;
  21620. /**
  21621. * Returns the triangle fan draw mode
  21622. */
  21623. static readonly TriangleFanDrawMode: number;
  21624. /**
  21625. * Stores the clock-wise side orientation
  21626. */
  21627. static readonly ClockWiseSideOrientation: number;
  21628. /**
  21629. * Stores the counter clock-wise side orientation
  21630. */
  21631. static readonly CounterClockWiseSideOrientation: number;
  21632. /**
  21633. * The dirty texture flag value
  21634. */
  21635. static readonly TextureDirtyFlag: number;
  21636. /**
  21637. * The dirty light flag value
  21638. */
  21639. static readonly LightDirtyFlag: number;
  21640. /**
  21641. * The dirty fresnel flag value
  21642. */
  21643. static readonly FresnelDirtyFlag: number;
  21644. /**
  21645. * The dirty attribute flag value
  21646. */
  21647. static readonly AttributesDirtyFlag: number;
  21648. /**
  21649. * The dirty misc flag value
  21650. */
  21651. static readonly MiscDirtyFlag: number;
  21652. /**
  21653. * The all dirty flag value
  21654. */
  21655. static readonly AllDirtyFlag: number;
  21656. /**
  21657. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21658. */
  21659. static readonly MATERIAL_OPAQUE: number;
  21660. /**
  21661. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21662. */
  21663. static readonly MATERIAL_ALPHATEST: number;
  21664. /**
  21665. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21666. */
  21667. static readonly MATERIAL_ALPHABLEND: number;
  21668. /**
  21669. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21670. * They are also discarded below the alpha cutoff threshold to improve performances.
  21671. */
  21672. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21673. /**
  21674. * The ID of the material
  21675. */
  21676. id: string;
  21677. /**
  21678. * Gets or sets the unique id of the material
  21679. */
  21680. uniqueId: number;
  21681. /**
  21682. * The name of the material
  21683. */
  21684. name: string;
  21685. /**
  21686. * Gets or sets user defined metadata
  21687. */
  21688. metadata: any;
  21689. /**
  21690. * For internal use only. Please do not use.
  21691. */
  21692. reservedDataStore: any;
  21693. /**
  21694. * Specifies if the ready state should be checked on each call
  21695. */
  21696. checkReadyOnEveryCall: boolean;
  21697. /**
  21698. * Specifies if the ready state should be checked once
  21699. */
  21700. checkReadyOnlyOnce: boolean;
  21701. /**
  21702. * The state of the material
  21703. */
  21704. state: string;
  21705. /**
  21706. * The alpha value of the material
  21707. */
  21708. protected _alpha: number;
  21709. /**
  21710. * List of inspectable custom properties (used by the Inspector)
  21711. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21712. */
  21713. inspectableCustomProperties: IInspectable[];
  21714. /**
  21715. * Sets the alpha value of the material
  21716. */
  21717. set alpha(value: number);
  21718. /**
  21719. * Gets the alpha value of the material
  21720. */
  21721. get alpha(): number;
  21722. /**
  21723. * Specifies if back face culling is enabled
  21724. */
  21725. protected _backFaceCulling: boolean;
  21726. /**
  21727. * Sets the back-face culling state
  21728. */
  21729. set backFaceCulling(value: boolean);
  21730. /**
  21731. * Gets the back-face culling state
  21732. */
  21733. get backFaceCulling(): boolean;
  21734. /**
  21735. * Stores the value for side orientation
  21736. */
  21737. sideOrientation: number;
  21738. /**
  21739. * Callback triggered when the material is compiled
  21740. */
  21741. onCompiled: Nullable<(effect: Effect) => void>;
  21742. /**
  21743. * Callback triggered when an error occurs
  21744. */
  21745. onError: Nullable<(effect: Effect, errors: string) => void>;
  21746. /**
  21747. * Callback triggered to get the render target textures
  21748. */
  21749. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21750. /**
  21751. * Gets a boolean indicating that current material needs to register RTT
  21752. */
  21753. get hasRenderTargetTextures(): boolean;
  21754. /**
  21755. * Specifies if the material should be serialized
  21756. */
  21757. doNotSerialize: boolean;
  21758. /**
  21759. * @hidden
  21760. */
  21761. _storeEffectOnSubMeshes: boolean;
  21762. /**
  21763. * Stores the animations for the material
  21764. */
  21765. animations: Nullable<Array<Animation>>;
  21766. /**
  21767. * An event triggered when the material is disposed
  21768. */
  21769. onDisposeObservable: Observable<Material>;
  21770. /**
  21771. * An observer which watches for dispose events
  21772. */
  21773. private _onDisposeObserver;
  21774. private _onUnBindObservable;
  21775. /**
  21776. * Called during a dispose event
  21777. */
  21778. set onDispose(callback: () => void);
  21779. private _onBindObservable;
  21780. /**
  21781. * An event triggered when the material is bound
  21782. */
  21783. get onBindObservable(): Observable<AbstractMesh>;
  21784. /**
  21785. * An observer which watches for bind events
  21786. */
  21787. private _onBindObserver;
  21788. /**
  21789. * Called during a bind event
  21790. */
  21791. set onBind(callback: (Mesh: AbstractMesh) => void);
  21792. /**
  21793. * An event triggered when the material is unbound
  21794. */
  21795. get onUnBindObservable(): Observable<Material>;
  21796. /**
  21797. * Stores the value of the alpha mode
  21798. */
  21799. private _alphaMode;
  21800. /**
  21801. * Sets the value of the alpha mode.
  21802. *
  21803. * | Value | Type | Description |
  21804. * | --- | --- | --- |
  21805. * | 0 | ALPHA_DISABLE | |
  21806. * | 1 | ALPHA_ADD | |
  21807. * | 2 | ALPHA_COMBINE | |
  21808. * | 3 | ALPHA_SUBTRACT | |
  21809. * | 4 | ALPHA_MULTIPLY | |
  21810. * | 5 | ALPHA_MAXIMIZED | |
  21811. * | 6 | ALPHA_ONEONE | |
  21812. * | 7 | ALPHA_PREMULTIPLIED | |
  21813. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21814. * | 9 | ALPHA_INTERPOLATE | |
  21815. * | 10 | ALPHA_SCREENMODE | |
  21816. *
  21817. */
  21818. set alphaMode(value: number);
  21819. /**
  21820. * Gets the value of the alpha mode
  21821. */
  21822. get alphaMode(): number;
  21823. /**
  21824. * Stores the state of the need depth pre-pass value
  21825. */
  21826. private _needDepthPrePass;
  21827. /**
  21828. * Sets the need depth pre-pass value
  21829. */
  21830. set needDepthPrePass(value: boolean);
  21831. /**
  21832. * Gets the depth pre-pass value
  21833. */
  21834. get needDepthPrePass(): boolean;
  21835. /**
  21836. * Specifies if depth writing should be disabled
  21837. */
  21838. disableDepthWrite: boolean;
  21839. /**
  21840. * Specifies if depth writing should be forced
  21841. */
  21842. forceDepthWrite: boolean;
  21843. /**
  21844. * Specifies the depth function that should be used. 0 means the default engine function
  21845. */
  21846. depthFunction: number;
  21847. /**
  21848. * Specifies if there should be a separate pass for culling
  21849. */
  21850. separateCullingPass: boolean;
  21851. /**
  21852. * Stores the state specifing if fog should be enabled
  21853. */
  21854. private _fogEnabled;
  21855. /**
  21856. * Sets the state for enabling fog
  21857. */
  21858. set fogEnabled(value: boolean);
  21859. /**
  21860. * Gets the value of the fog enabled state
  21861. */
  21862. get fogEnabled(): boolean;
  21863. /**
  21864. * Stores the size of points
  21865. */
  21866. pointSize: number;
  21867. /**
  21868. * Stores the z offset value
  21869. */
  21870. zOffset: number;
  21871. /**
  21872. * Gets a value specifying if wireframe mode is enabled
  21873. */
  21874. get wireframe(): boolean;
  21875. /**
  21876. * Sets the state of wireframe mode
  21877. */
  21878. set wireframe(value: boolean);
  21879. /**
  21880. * Gets the value specifying if point clouds are enabled
  21881. */
  21882. get pointsCloud(): boolean;
  21883. /**
  21884. * Sets the state of point cloud mode
  21885. */
  21886. set pointsCloud(value: boolean);
  21887. /**
  21888. * Gets the material fill mode
  21889. */
  21890. get fillMode(): number;
  21891. /**
  21892. * Sets the material fill mode
  21893. */
  21894. set fillMode(value: number);
  21895. /**
  21896. * @hidden
  21897. * Stores the effects for the material
  21898. */
  21899. _effect: Nullable<Effect>;
  21900. /**
  21901. * Specifies if uniform buffers should be used
  21902. */
  21903. private _useUBO;
  21904. /**
  21905. * Stores a reference to the scene
  21906. */
  21907. private _scene;
  21908. /**
  21909. * Stores the fill mode state
  21910. */
  21911. private _fillMode;
  21912. /**
  21913. * Specifies if the depth write state should be cached
  21914. */
  21915. private _cachedDepthWriteState;
  21916. /**
  21917. * Specifies if the depth function state should be cached
  21918. */
  21919. private _cachedDepthFunctionState;
  21920. /**
  21921. * Stores the uniform buffer
  21922. */
  21923. protected _uniformBuffer: UniformBuffer;
  21924. /** @hidden */
  21925. _indexInSceneMaterialArray: number;
  21926. /** @hidden */
  21927. meshMap: Nullable<{
  21928. [id: string]: AbstractMesh | undefined;
  21929. }>;
  21930. /**
  21931. * Creates a material instance
  21932. * @param name defines the name of the material
  21933. * @param scene defines the scene to reference
  21934. * @param doNotAdd specifies if the material should be added to the scene
  21935. */
  21936. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21937. /**
  21938. * Returns a string representation of the current material
  21939. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21940. * @returns a string with material information
  21941. */
  21942. toString(fullDetails?: boolean): string;
  21943. /**
  21944. * Gets the class name of the material
  21945. * @returns a string with the class name of the material
  21946. */
  21947. getClassName(): string;
  21948. /**
  21949. * Specifies if updates for the material been locked
  21950. */
  21951. get isFrozen(): boolean;
  21952. /**
  21953. * Locks updates for the material
  21954. */
  21955. freeze(): void;
  21956. /**
  21957. * Unlocks updates for the material
  21958. */
  21959. unfreeze(): void;
  21960. /**
  21961. * Specifies if the material is ready to be used
  21962. * @param mesh defines the mesh to check
  21963. * @param useInstances specifies if instances should be used
  21964. * @returns a boolean indicating if the material is ready to be used
  21965. */
  21966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21967. /**
  21968. * Specifies that the submesh is ready to be used
  21969. * @param mesh defines the mesh to check
  21970. * @param subMesh defines which submesh to check
  21971. * @param useInstances specifies that instances should be used
  21972. * @returns a boolean indicating that the submesh is ready or not
  21973. */
  21974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21975. /**
  21976. * Returns the material effect
  21977. * @returns the effect associated with the material
  21978. */
  21979. getEffect(): Nullable<Effect>;
  21980. /**
  21981. * Returns the current scene
  21982. * @returns a Scene
  21983. */
  21984. getScene(): Scene;
  21985. /**
  21986. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21987. */
  21988. protected _forceAlphaTest: boolean;
  21989. /**
  21990. * The transparency mode of the material.
  21991. */
  21992. protected _transparencyMode: Nullable<number>;
  21993. /**
  21994. * Gets the current transparency mode.
  21995. */
  21996. get transparencyMode(): Nullable<number>;
  21997. /**
  21998. * Sets the transparency mode of the material.
  21999. *
  22000. * | Value | Type | Description |
  22001. * | ----- | ----------------------------------- | ----------- |
  22002. * | 0 | OPAQUE | |
  22003. * | 1 | ALPHATEST | |
  22004. * | 2 | ALPHABLEND | |
  22005. * | 3 | ALPHATESTANDBLEND | |
  22006. *
  22007. */
  22008. set transparencyMode(value: Nullable<number>);
  22009. /**
  22010. * Returns true if alpha blending should be disabled.
  22011. */
  22012. protected get _disableAlphaBlending(): boolean;
  22013. /**
  22014. * Specifies whether or not this material should be rendered in alpha blend mode.
  22015. * @returns a boolean specifying if alpha blending is needed
  22016. */
  22017. needAlphaBlending(): boolean;
  22018. /**
  22019. * Specifies if the mesh will require alpha blending
  22020. * @param mesh defines the mesh to check
  22021. * @returns a boolean specifying if alpha blending is needed for the mesh
  22022. */
  22023. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22024. /**
  22025. * Specifies whether or not this material should be rendered in alpha test mode.
  22026. * @returns a boolean specifying if an alpha test is needed.
  22027. */
  22028. needAlphaTesting(): boolean;
  22029. /**
  22030. * Specifies if material alpha testing should be turned on for the mesh
  22031. * @param mesh defines the mesh to check
  22032. */
  22033. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22034. /**
  22035. * Gets the texture used for the alpha test
  22036. * @returns the texture to use for alpha testing
  22037. */
  22038. getAlphaTestTexture(): Nullable<BaseTexture>;
  22039. /**
  22040. * Marks the material to indicate that it needs to be re-calculated
  22041. */
  22042. markDirty(): void;
  22043. /** @hidden */
  22044. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22045. /**
  22046. * Binds the material to the mesh
  22047. * @param world defines the world transformation matrix
  22048. * @param mesh defines the mesh to bind the material to
  22049. */
  22050. bind(world: Matrix, mesh?: Mesh): void;
  22051. /**
  22052. * Binds the submesh to the material
  22053. * @param world defines the world transformation matrix
  22054. * @param mesh defines the mesh containing the submesh
  22055. * @param subMesh defines the submesh to bind the material to
  22056. */
  22057. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22058. /**
  22059. * Binds the world matrix to the material
  22060. * @param world defines the world transformation matrix
  22061. */
  22062. bindOnlyWorldMatrix(world: Matrix): void;
  22063. /**
  22064. * Binds the scene's uniform buffer to the effect.
  22065. * @param effect defines the effect to bind to the scene uniform buffer
  22066. * @param sceneUbo defines the uniform buffer storing scene data
  22067. */
  22068. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22069. /**
  22070. * Binds the view matrix to the effect
  22071. * @param effect defines the effect to bind the view matrix to
  22072. */
  22073. bindView(effect: Effect): void;
  22074. /**
  22075. * Binds the view projection matrix to the effect
  22076. * @param effect defines the effect to bind the view projection matrix to
  22077. */
  22078. bindViewProjection(effect: Effect): void;
  22079. /**
  22080. * Processes to execute after binding the material to a mesh
  22081. * @param mesh defines the rendered mesh
  22082. */
  22083. protected _afterBind(mesh?: Mesh): void;
  22084. /**
  22085. * Unbinds the material from the mesh
  22086. */
  22087. unbind(): void;
  22088. /**
  22089. * Gets the active textures from the material
  22090. * @returns an array of textures
  22091. */
  22092. getActiveTextures(): BaseTexture[];
  22093. /**
  22094. * Specifies if the material uses a texture
  22095. * @param texture defines the texture to check against the material
  22096. * @returns a boolean specifying if the material uses the texture
  22097. */
  22098. hasTexture(texture: BaseTexture): boolean;
  22099. /**
  22100. * Makes a duplicate of the material, and gives it a new name
  22101. * @param name defines the new name for the duplicated material
  22102. * @returns the cloned material
  22103. */
  22104. clone(name: string): Nullable<Material>;
  22105. /**
  22106. * Gets the meshes bound to the material
  22107. * @returns an array of meshes bound to the material
  22108. */
  22109. getBindedMeshes(): AbstractMesh[];
  22110. /**
  22111. * Force shader compilation
  22112. * @param mesh defines the mesh associated with this material
  22113. * @param onCompiled defines a function to execute once the material is compiled
  22114. * @param options defines the options to configure the compilation
  22115. * @param onError defines a function to execute if the material fails compiling
  22116. */
  22117. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22118. /**
  22119. * Force shader compilation
  22120. * @param mesh defines the mesh that will use this material
  22121. * @param options defines additional options for compiling the shaders
  22122. * @returns a promise that resolves when the compilation completes
  22123. */
  22124. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22125. private static readonly _AllDirtyCallBack;
  22126. private static readonly _ImageProcessingDirtyCallBack;
  22127. private static readonly _TextureDirtyCallBack;
  22128. private static readonly _FresnelDirtyCallBack;
  22129. private static readonly _MiscDirtyCallBack;
  22130. private static readonly _LightsDirtyCallBack;
  22131. private static readonly _AttributeDirtyCallBack;
  22132. private static _FresnelAndMiscDirtyCallBack;
  22133. private static _TextureAndMiscDirtyCallBack;
  22134. private static readonly _DirtyCallbackArray;
  22135. private static readonly _RunDirtyCallBacks;
  22136. /**
  22137. * Marks a define in the material to indicate that it needs to be re-computed
  22138. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22139. */
  22140. markAsDirty(flag: number): void;
  22141. /**
  22142. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22143. * @param func defines a function which checks material defines against the submeshes
  22144. */
  22145. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22146. /**
  22147. * Indicates that we need to re-calculated for all submeshes
  22148. */
  22149. protected _markAllSubMeshesAsAllDirty(): void;
  22150. /**
  22151. * Indicates that image processing needs to be re-calculated for all submeshes
  22152. */
  22153. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22154. /**
  22155. * Indicates that textures need to be re-calculated for all submeshes
  22156. */
  22157. protected _markAllSubMeshesAsTexturesDirty(): void;
  22158. /**
  22159. * Indicates that fresnel needs to be re-calculated for all submeshes
  22160. */
  22161. protected _markAllSubMeshesAsFresnelDirty(): void;
  22162. /**
  22163. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22164. */
  22165. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22166. /**
  22167. * Indicates that lights need to be re-calculated for all submeshes
  22168. */
  22169. protected _markAllSubMeshesAsLightsDirty(): void;
  22170. /**
  22171. * Indicates that attributes need to be re-calculated for all submeshes
  22172. */
  22173. protected _markAllSubMeshesAsAttributesDirty(): void;
  22174. /**
  22175. * Indicates that misc needs to be re-calculated for all submeshes
  22176. */
  22177. protected _markAllSubMeshesAsMiscDirty(): void;
  22178. /**
  22179. * Indicates that textures and misc need to be re-calculated for all submeshes
  22180. */
  22181. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22182. /**
  22183. * Disposes the material
  22184. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22185. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22186. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22187. */
  22188. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22189. /** @hidden */
  22190. private releaseVertexArrayObject;
  22191. /**
  22192. * Serializes this material
  22193. * @returns the serialized material object
  22194. */
  22195. serialize(): any;
  22196. /**
  22197. * Creates a material from parsed material data
  22198. * @param parsedMaterial defines parsed material data
  22199. * @param scene defines the hosting scene
  22200. * @param rootUrl defines the root URL to use to load textures
  22201. * @returns a new material
  22202. */
  22203. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22204. }
  22205. }
  22206. declare module "babylonjs/Materials/multiMaterial" {
  22207. import { Nullable } from "babylonjs/types";
  22208. import { Scene } from "babylonjs/scene";
  22209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22210. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22212. import { Material } from "babylonjs/Materials/material";
  22213. /**
  22214. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22215. * separate meshes. This can be use to improve performances.
  22216. * @see http://doc.babylonjs.com/how_to/multi_materials
  22217. */
  22218. export class MultiMaterial extends Material {
  22219. private _subMaterials;
  22220. /**
  22221. * Gets or Sets the list of Materials used within the multi material.
  22222. * They need to be ordered according to the submeshes order in the associated mesh
  22223. */
  22224. get subMaterials(): Nullable<Material>[];
  22225. set subMaterials(value: Nullable<Material>[]);
  22226. /**
  22227. * Function used to align with Node.getChildren()
  22228. * @returns the list of Materials used within the multi material
  22229. */
  22230. getChildren(): Nullable<Material>[];
  22231. /**
  22232. * Instantiates a new Multi Material
  22233. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22234. * separate meshes. This can be use to improve performances.
  22235. * @see http://doc.babylonjs.com/how_to/multi_materials
  22236. * @param name Define the name in the scene
  22237. * @param scene Define the scene the material belongs to
  22238. */
  22239. constructor(name: string, scene: Scene);
  22240. private _hookArray;
  22241. /**
  22242. * Get one of the submaterial by its index in the submaterials array
  22243. * @param index The index to look the sub material at
  22244. * @returns The Material if the index has been defined
  22245. */
  22246. getSubMaterial(index: number): Nullable<Material>;
  22247. /**
  22248. * Get the list of active textures for the whole sub materials list.
  22249. * @returns All the textures that will be used during the rendering
  22250. */
  22251. getActiveTextures(): BaseTexture[];
  22252. /**
  22253. * Gets the current class name of the material e.g. "MultiMaterial"
  22254. * Mainly use in serialization.
  22255. * @returns the class name
  22256. */
  22257. getClassName(): string;
  22258. /**
  22259. * Checks if the material is ready to render the requested sub mesh
  22260. * @param mesh Define the mesh the submesh belongs to
  22261. * @param subMesh Define the sub mesh to look readyness for
  22262. * @param useInstances Define whether or not the material is used with instances
  22263. * @returns true if ready, otherwise false
  22264. */
  22265. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22266. /**
  22267. * Clones the current material and its related sub materials
  22268. * @param name Define the name of the newly cloned material
  22269. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22270. * @returns the cloned material
  22271. */
  22272. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22273. /**
  22274. * Serializes the materials into a JSON representation.
  22275. * @returns the JSON representation
  22276. */
  22277. serialize(): any;
  22278. /**
  22279. * Dispose the material and release its associated resources
  22280. * @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)
  22281. * @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)
  22282. * @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)
  22283. */
  22284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22285. /**
  22286. * Creates a MultiMaterial from parsed MultiMaterial data.
  22287. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22288. * @param scene defines the hosting scene
  22289. * @returns a new MultiMaterial
  22290. */
  22291. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22292. }
  22293. }
  22294. declare module "babylonjs/Meshes/subMesh" {
  22295. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22296. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22297. import { Engine } from "babylonjs/Engines/engine";
  22298. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22299. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22300. import { Effect } from "babylonjs/Materials/effect";
  22301. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22302. import { Plane } from "babylonjs/Maths/math.plane";
  22303. import { Collider } from "babylonjs/Collisions/collider";
  22304. import { Material } from "babylonjs/Materials/material";
  22305. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22307. import { Mesh } from "babylonjs/Meshes/mesh";
  22308. import { Ray } from "babylonjs/Culling/ray";
  22309. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22310. /**
  22311. * Base class for submeshes
  22312. */
  22313. export class BaseSubMesh {
  22314. /** @hidden */
  22315. _materialDefines: Nullable<MaterialDefines>;
  22316. /** @hidden */
  22317. _materialEffect: Nullable<Effect>;
  22318. /**
  22319. * Gets material defines used by the effect associated to the sub mesh
  22320. */
  22321. get materialDefines(): Nullable<MaterialDefines>;
  22322. /**
  22323. * Sets material defines used by the effect associated to the sub mesh
  22324. */
  22325. set materialDefines(defines: Nullable<MaterialDefines>);
  22326. /**
  22327. * Gets associated effect
  22328. */
  22329. get effect(): Nullable<Effect>;
  22330. /**
  22331. * Sets associated effect (effect used to render this submesh)
  22332. * @param effect defines the effect to associate with
  22333. * @param defines defines the set of defines used to compile this effect
  22334. */
  22335. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22336. }
  22337. /**
  22338. * Defines a subdivision inside a mesh
  22339. */
  22340. export class SubMesh extends BaseSubMesh implements ICullable {
  22341. /** the material index to use */
  22342. materialIndex: number;
  22343. /** vertex index start */
  22344. verticesStart: number;
  22345. /** vertices count */
  22346. verticesCount: number;
  22347. /** index start */
  22348. indexStart: number;
  22349. /** indices count */
  22350. indexCount: number;
  22351. /** @hidden */
  22352. _linesIndexCount: number;
  22353. private _mesh;
  22354. private _renderingMesh;
  22355. private _boundingInfo;
  22356. private _linesIndexBuffer;
  22357. /** @hidden */
  22358. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22359. /** @hidden */
  22360. _trianglePlanes: Plane[];
  22361. /** @hidden */
  22362. _lastColliderTransformMatrix: Nullable<Matrix>;
  22363. /** @hidden */
  22364. _renderId: number;
  22365. /** @hidden */
  22366. _alphaIndex: number;
  22367. /** @hidden */
  22368. _distanceToCamera: number;
  22369. /** @hidden */
  22370. _id: number;
  22371. private _currentMaterial;
  22372. /**
  22373. * Add a new submesh to a mesh
  22374. * @param materialIndex defines the material index to use
  22375. * @param verticesStart defines vertex index start
  22376. * @param verticesCount defines vertices count
  22377. * @param indexStart defines index start
  22378. * @param indexCount defines indices count
  22379. * @param mesh defines the parent mesh
  22380. * @param renderingMesh defines an optional rendering mesh
  22381. * @param createBoundingBox defines if bounding box should be created for this submesh
  22382. * @returns the new submesh
  22383. */
  22384. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22385. /**
  22386. * Creates a new submesh
  22387. * @param materialIndex defines the material index to use
  22388. * @param verticesStart defines vertex index start
  22389. * @param verticesCount defines vertices count
  22390. * @param indexStart defines index start
  22391. * @param indexCount defines indices count
  22392. * @param mesh defines the parent mesh
  22393. * @param renderingMesh defines an optional rendering mesh
  22394. * @param createBoundingBox defines if bounding box should be created for this submesh
  22395. */
  22396. constructor(
  22397. /** the material index to use */
  22398. materialIndex: number,
  22399. /** vertex index start */
  22400. verticesStart: number,
  22401. /** vertices count */
  22402. verticesCount: number,
  22403. /** index start */
  22404. indexStart: number,
  22405. /** indices count */
  22406. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22407. /**
  22408. * Returns true if this submesh covers the entire parent mesh
  22409. * @ignorenaming
  22410. */
  22411. get IsGlobal(): boolean;
  22412. /**
  22413. * Returns the submesh BoudingInfo object
  22414. * @returns current bounding info (or mesh's one if the submesh is global)
  22415. */
  22416. getBoundingInfo(): BoundingInfo;
  22417. /**
  22418. * Sets the submesh BoundingInfo
  22419. * @param boundingInfo defines the new bounding info to use
  22420. * @returns the SubMesh
  22421. */
  22422. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22423. /**
  22424. * Returns the mesh of the current submesh
  22425. * @return the parent mesh
  22426. */
  22427. getMesh(): AbstractMesh;
  22428. /**
  22429. * Returns the rendering mesh of the submesh
  22430. * @returns the rendering mesh (could be different from parent mesh)
  22431. */
  22432. getRenderingMesh(): Mesh;
  22433. /**
  22434. * Returns the submesh material
  22435. * @returns null or the current material
  22436. */
  22437. getMaterial(): Nullable<Material>;
  22438. /**
  22439. * Sets a new updated BoundingInfo object to the submesh
  22440. * @param data defines an optional position array to use to determine the bounding info
  22441. * @returns the SubMesh
  22442. */
  22443. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22444. /** @hidden */
  22445. _checkCollision(collider: Collider): boolean;
  22446. /**
  22447. * Updates the submesh BoundingInfo
  22448. * @param world defines the world matrix to use to update the bounding info
  22449. * @returns the submesh
  22450. */
  22451. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22452. /**
  22453. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22454. * @param frustumPlanes defines the frustum planes
  22455. * @returns true if the submesh is intersecting with the frustum
  22456. */
  22457. isInFrustum(frustumPlanes: Plane[]): boolean;
  22458. /**
  22459. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22460. * @param frustumPlanes defines the frustum planes
  22461. * @returns true if the submesh is inside the frustum
  22462. */
  22463. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22464. /**
  22465. * Renders the submesh
  22466. * @param enableAlphaMode defines if alpha needs to be used
  22467. * @returns the submesh
  22468. */
  22469. render(enableAlphaMode: boolean): SubMesh;
  22470. /**
  22471. * @hidden
  22472. */
  22473. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22474. /**
  22475. * Checks if the submesh intersects with a ray
  22476. * @param ray defines the ray to test
  22477. * @returns true is the passed ray intersects the submesh bounding box
  22478. */
  22479. canIntersects(ray: Ray): boolean;
  22480. /**
  22481. * Intersects current submesh with a ray
  22482. * @param ray defines the ray to test
  22483. * @param positions defines mesh's positions array
  22484. * @param indices defines mesh's indices array
  22485. * @param fastCheck defines if only bounding info should be used
  22486. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22487. * @returns intersection info or null if no intersection
  22488. */
  22489. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22490. /** @hidden */
  22491. private _intersectLines;
  22492. /** @hidden */
  22493. private _intersectUnIndexedLines;
  22494. /** @hidden */
  22495. private _intersectTriangles;
  22496. /** @hidden */
  22497. private _intersectUnIndexedTriangles;
  22498. /** @hidden */
  22499. _rebuild(): void;
  22500. /**
  22501. * Creates a new submesh from the passed mesh
  22502. * @param newMesh defines the new hosting mesh
  22503. * @param newRenderingMesh defines an optional rendering mesh
  22504. * @returns the new submesh
  22505. */
  22506. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22507. /**
  22508. * Release associated resources
  22509. */
  22510. dispose(): void;
  22511. /**
  22512. * Gets the class name
  22513. * @returns the string "SubMesh".
  22514. */
  22515. getClassName(): string;
  22516. /**
  22517. * Creates a new submesh from indices data
  22518. * @param materialIndex the index of the main mesh material
  22519. * @param startIndex the index where to start the copy in the mesh indices array
  22520. * @param indexCount the number of indices to copy then from the startIndex
  22521. * @param mesh the main mesh to create the submesh from
  22522. * @param renderingMesh the optional rendering mesh
  22523. * @returns a new submesh
  22524. */
  22525. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22526. }
  22527. }
  22528. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22529. /**
  22530. * Class used to represent data loading progression
  22531. */
  22532. export class SceneLoaderFlags {
  22533. private static _ForceFullSceneLoadingForIncremental;
  22534. private static _ShowLoadingScreen;
  22535. private static _CleanBoneMatrixWeights;
  22536. private static _loggingLevel;
  22537. /**
  22538. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22539. */
  22540. static get ForceFullSceneLoadingForIncremental(): boolean;
  22541. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22542. /**
  22543. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22544. */
  22545. static get ShowLoadingScreen(): boolean;
  22546. static set ShowLoadingScreen(value: boolean);
  22547. /**
  22548. * Defines the current logging level (while loading the scene)
  22549. * @ignorenaming
  22550. */
  22551. static get loggingLevel(): number;
  22552. static set loggingLevel(value: number);
  22553. /**
  22554. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22555. */
  22556. static get CleanBoneMatrixWeights(): boolean;
  22557. static set CleanBoneMatrixWeights(value: boolean);
  22558. }
  22559. }
  22560. declare module "babylonjs/Meshes/geometry" {
  22561. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22562. import { Scene } from "babylonjs/scene";
  22563. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22564. import { Engine } from "babylonjs/Engines/engine";
  22565. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22566. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22567. import { Effect } from "babylonjs/Materials/effect";
  22568. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22569. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22570. import { Mesh } from "babylonjs/Meshes/mesh";
  22571. /**
  22572. * Class used to store geometry data (vertex buffers + index buffer)
  22573. */
  22574. export class Geometry implements IGetSetVerticesData {
  22575. /**
  22576. * Gets or sets the ID of the geometry
  22577. */
  22578. id: string;
  22579. /**
  22580. * Gets or sets the unique ID of the geometry
  22581. */
  22582. uniqueId: number;
  22583. /**
  22584. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22585. */
  22586. delayLoadState: number;
  22587. /**
  22588. * Gets the file containing the data to load when running in delay load state
  22589. */
  22590. delayLoadingFile: Nullable<string>;
  22591. /**
  22592. * Callback called when the geometry is updated
  22593. */
  22594. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22595. private _scene;
  22596. private _engine;
  22597. private _meshes;
  22598. private _totalVertices;
  22599. /** @hidden */
  22600. _indices: IndicesArray;
  22601. /** @hidden */
  22602. _vertexBuffers: {
  22603. [key: string]: VertexBuffer;
  22604. };
  22605. private _isDisposed;
  22606. private _extend;
  22607. private _boundingBias;
  22608. /** @hidden */
  22609. _delayInfo: Array<string>;
  22610. private _indexBuffer;
  22611. private _indexBufferIsUpdatable;
  22612. /** @hidden */
  22613. _boundingInfo: Nullable<BoundingInfo>;
  22614. /** @hidden */
  22615. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22616. /** @hidden */
  22617. _softwareSkinningFrameId: number;
  22618. private _vertexArrayObjects;
  22619. private _updatable;
  22620. /** @hidden */
  22621. _positions: Nullable<Vector3[]>;
  22622. /**
  22623. * 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
  22624. */
  22625. get boundingBias(): Vector2;
  22626. /**
  22627. * 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
  22628. */
  22629. set boundingBias(value: Vector2);
  22630. /**
  22631. * Static function used to attach a new empty geometry to a mesh
  22632. * @param mesh defines the mesh to attach the geometry to
  22633. * @returns the new Geometry
  22634. */
  22635. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22636. /**
  22637. * Creates a new geometry
  22638. * @param id defines the unique ID
  22639. * @param scene defines the hosting scene
  22640. * @param vertexData defines the VertexData used to get geometry data
  22641. * @param updatable defines if geometry must be updatable (false by default)
  22642. * @param mesh defines the mesh that will be associated with the geometry
  22643. */
  22644. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22645. /**
  22646. * Gets the current extend of the geometry
  22647. */
  22648. get extend(): {
  22649. minimum: Vector3;
  22650. maximum: Vector3;
  22651. };
  22652. /**
  22653. * Gets the hosting scene
  22654. * @returns the hosting Scene
  22655. */
  22656. getScene(): Scene;
  22657. /**
  22658. * Gets the hosting engine
  22659. * @returns the hosting Engine
  22660. */
  22661. getEngine(): Engine;
  22662. /**
  22663. * Defines if the geometry is ready to use
  22664. * @returns true if the geometry is ready to be used
  22665. */
  22666. isReady(): boolean;
  22667. /**
  22668. * Gets a value indicating that the geometry should not be serialized
  22669. */
  22670. get doNotSerialize(): boolean;
  22671. /** @hidden */
  22672. _rebuild(): void;
  22673. /**
  22674. * Affects all geometry data in one call
  22675. * @param vertexData defines the geometry data
  22676. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22677. */
  22678. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22679. /**
  22680. * Set specific vertex data
  22681. * @param kind defines the data kind (Position, normal, etc...)
  22682. * @param data defines the vertex data to use
  22683. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22684. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22685. */
  22686. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22687. /**
  22688. * Removes a specific vertex data
  22689. * @param kind defines the data kind (Position, normal, etc...)
  22690. */
  22691. removeVerticesData(kind: string): void;
  22692. /**
  22693. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22694. * @param buffer defines the vertex buffer to use
  22695. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22696. */
  22697. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22698. /**
  22699. * Update a specific vertex buffer
  22700. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22701. * It will do nothing if the buffer is not updatable
  22702. * @param kind defines the data kind (Position, normal, etc...)
  22703. * @param data defines the data to use
  22704. * @param offset defines the offset in the target buffer where to store the data
  22705. * @param useBytes set to true if the offset is in bytes
  22706. */
  22707. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22708. /**
  22709. * Update a specific vertex buffer
  22710. * This function will create a new buffer if the current one is not updatable
  22711. * @param kind defines the data kind (Position, normal, etc...)
  22712. * @param data defines the data to use
  22713. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22714. */
  22715. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22716. private _updateBoundingInfo;
  22717. /** @hidden */
  22718. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22719. /**
  22720. * Gets total number of vertices
  22721. * @returns the total number of vertices
  22722. */
  22723. getTotalVertices(): number;
  22724. /**
  22725. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22726. * @param kind defines the data kind (Position, normal, etc...)
  22727. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22729. * @returns a float array containing vertex data
  22730. */
  22731. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22732. /**
  22733. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22734. * @param kind defines the data kind (Position, normal, etc...)
  22735. * @returns true if the vertex buffer with the specified kind is updatable
  22736. */
  22737. isVertexBufferUpdatable(kind: string): boolean;
  22738. /**
  22739. * Gets a specific vertex buffer
  22740. * @param kind defines the data kind (Position, normal, etc...)
  22741. * @returns a VertexBuffer
  22742. */
  22743. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22744. /**
  22745. * Returns all vertex buffers
  22746. * @return an object holding all vertex buffers indexed by kind
  22747. */
  22748. getVertexBuffers(): Nullable<{
  22749. [key: string]: VertexBuffer;
  22750. }>;
  22751. /**
  22752. * Gets a boolean indicating if specific vertex buffer is present
  22753. * @param kind defines the data kind (Position, normal, etc...)
  22754. * @returns true if data is present
  22755. */
  22756. isVerticesDataPresent(kind: string): boolean;
  22757. /**
  22758. * Gets a list of all attached data kinds (Position, normal, etc...)
  22759. * @returns a list of string containing all kinds
  22760. */
  22761. getVerticesDataKinds(): string[];
  22762. /**
  22763. * Update index buffer
  22764. * @param indices defines the indices to store in the index buffer
  22765. * @param offset defines the offset in the target buffer where to store the data
  22766. * @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)
  22767. */
  22768. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22769. /**
  22770. * Creates a new index buffer
  22771. * @param indices defines the indices to store in the index buffer
  22772. * @param totalVertices defines the total number of vertices (could be null)
  22773. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22774. */
  22775. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22776. /**
  22777. * Return the total number of indices
  22778. * @returns the total number of indices
  22779. */
  22780. getTotalIndices(): number;
  22781. /**
  22782. * Gets the index buffer array
  22783. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22784. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22785. * @returns the index buffer array
  22786. */
  22787. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22788. /**
  22789. * Gets the index buffer
  22790. * @return the index buffer
  22791. */
  22792. getIndexBuffer(): Nullable<DataBuffer>;
  22793. /** @hidden */
  22794. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22795. /**
  22796. * Release the associated resources for a specific mesh
  22797. * @param mesh defines the source mesh
  22798. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22799. */
  22800. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22801. /**
  22802. * Apply current geometry to a given mesh
  22803. * @param mesh defines the mesh to apply geometry to
  22804. */
  22805. applyToMesh(mesh: Mesh): void;
  22806. private _updateExtend;
  22807. private _applyToMesh;
  22808. private notifyUpdate;
  22809. /**
  22810. * Load the geometry if it was flagged as delay loaded
  22811. * @param scene defines the hosting scene
  22812. * @param onLoaded defines a callback called when the geometry is loaded
  22813. */
  22814. load(scene: Scene, onLoaded?: () => void): void;
  22815. private _queueLoad;
  22816. /**
  22817. * Invert the geometry to move from a right handed system to a left handed one.
  22818. */
  22819. toLeftHanded(): void;
  22820. /** @hidden */
  22821. _resetPointsArrayCache(): void;
  22822. /** @hidden */
  22823. _generatePointsArray(): boolean;
  22824. /**
  22825. * Gets a value indicating if the geometry is disposed
  22826. * @returns true if the geometry was disposed
  22827. */
  22828. isDisposed(): boolean;
  22829. private _disposeVertexArrayObjects;
  22830. /**
  22831. * Free all associated resources
  22832. */
  22833. dispose(): void;
  22834. /**
  22835. * Clone the current geometry into a new geometry
  22836. * @param id defines the unique ID of the new geometry
  22837. * @returns a new geometry object
  22838. */
  22839. copy(id: string): Geometry;
  22840. /**
  22841. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22842. * @return a JSON representation of the current geometry data (without the vertices data)
  22843. */
  22844. serialize(): any;
  22845. private toNumberArray;
  22846. /**
  22847. * Serialize all vertices data into a JSON oject
  22848. * @returns a JSON representation of the current geometry data
  22849. */
  22850. serializeVerticeData(): any;
  22851. /**
  22852. * Extracts a clone of a mesh geometry
  22853. * @param mesh defines the source mesh
  22854. * @param id defines the unique ID of the new geometry object
  22855. * @returns the new geometry object
  22856. */
  22857. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22858. /**
  22859. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22860. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22861. * Be aware Math.random() could cause collisions, but:
  22862. * "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"
  22863. * @returns a string containing a new GUID
  22864. */
  22865. static RandomId(): string;
  22866. /** @hidden */
  22867. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22868. private static _CleanMatricesWeights;
  22869. /**
  22870. * Create a new geometry from persisted data (Using .babylon file format)
  22871. * @param parsedVertexData defines the persisted data
  22872. * @param scene defines the hosting scene
  22873. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22874. * @returns the new geometry object
  22875. */
  22876. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22877. }
  22878. }
  22879. declare module "babylonjs/Meshes/mesh.vertexData" {
  22880. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22881. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22882. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22883. import { Geometry } from "babylonjs/Meshes/geometry";
  22884. import { Mesh } from "babylonjs/Meshes/mesh";
  22885. /**
  22886. * Define an interface for all classes that will get and set the data on vertices
  22887. */
  22888. export interface IGetSetVerticesData {
  22889. /**
  22890. * Gets a boolean indicating if specific vertex data is present
  22891. * @param kind defines the vertex data kind to use
  22892. * @returns true is data kind is present
  22893. */
  22894. isVerticesDataPresent(kind: string): boolean;
  22895. /**
  22896. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22897. * @param kind defines the data kind (Position, normal, etc...)
  22898. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22899. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22900. * @returns a float array containing vertex data
  22901. */
  22902. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22903. /**
  22904. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22905. * @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.
  22906. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22907. * @returns the indices array or an empty array if the mesh has no geometry
  22908. */
  22909. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22910. /**
  22911. * Set specific vertex data
  22912. * @param kind defines the data kind (Position, normal, etc...)
  22913. * @param data defines the vertex data to use
  22914. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22915. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22916. */
  22917. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22918. /**
  22919. * Update a specific associated vertex buffer
  22920. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22921. * - VertexBuffer.PositionKind
  22922. * - VertexBuffer.UVKind
  22923. * - VertexBuffer.UV2Kind
  22924. * - VertexBuffer.UV3Kind
  22925. * - VertexBuffer.UV4Kind
  22926. * - VertexBuffer.UV5Kind
  22927. * - VertexBuffer.UV6Kind
  22928. * - VertexBuffer.ColorKind
  22929. * - VertexBuffer.MatricesIndicesKind
  22930. * - VertexBuffer.MatricesIndicesExtraKind
  22931. * - VertexBuffer.MatricesWeightsKind
  22932. * - VertexBuffer.MatricesWeightsExtraKind
  22933. * @param data defines the data source
  22934. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22935. * @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)
  22936. */
  22937. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22938. /**
  22939. * Creates a new index buffer
  22940. * @param indices defines the indices to store in the index buffer
  22941. * @param totalVertices defines the total number of vertices (could be null)
  22942. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22943. */
  22944. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22945. }
  22946. /**
  22947. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22948. */
  22949. export class VertexData {
  22950. /**
  22951. * Mesh side orientation : usually the external or front surface
  22952. */
  22953. static readonly FRONTSIDE: number;
  22954. /**
  22955. * Mesh side orientation : usually the internal or back surface
  22956. */
  22957. static readonly BACKSIDE: number;
  22958. /**
  22959. * Mesh side orientation : both internal and external or front and back surfaces
  22960. */
  22961. static readonly DOUBLESIDE: number;
  22962. /**
  22963. * Mesh side orientation : by default, `FRONTSIDE`
  22964. */
  22965. static readonly DEFAULTSIDE: number;
  22966. /**
  22967. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22968. */
  22969. positions: Nullable<FloatArray>;
  22970. /**
  22971. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22972. */
  22973. normals: Nullable<FloatArray>;
  22974. /**
  22975. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22976. */
  22977. tangents: Nullable<FloatArray>;
  22978. /**
  22979. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22980. */
  22981. uvs: Nullable<FloatArray>;
  22982. /**
  22983. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22984. */
  22985. uvs2: Nullable<FloatArray>;
  22986. /**
  22987. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22988. */
  22989. uvs3: Nullable<FloatArray>;
  22990. /**
  22991. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22992. */
  22993. uvs4: Nullable<FloatArray>;
  22994. /**
  22995. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22996. */
  22997. uvs5: Nullable<FloatArray>;
  22998. /**
  22999. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23000. */
  23001. uvs6: Nullable<FloatArray>;
  23002. /**
  23003. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23004. */
  23005. colors: Nullable<FloatArray>;
  23006. /**
  23007. * 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).
  23008. */
  23009. matricesIndices: Nullable<FloatArray>;
  23010. /**
  23011. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23012. */
  23013. matricesWeights: Nullable<FloatArray>;
  23014. /**
  23015. * An array extending the number of possible indices
  23016. */
  23017. matricesIndicesExtra: Nullable<FloatArray>;
  23018. /**
  23019. * An array extending the number of possible weights when the number of indices is extended
  23020. */
  23021. matricesWeightsExtra: Nullable<FloatArray>;
  23022. /**
  23023. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23024. */
  23025. indices: Nullable<IndicesArray>;
  23026. /**
  23027. * Uses the passed data array to set the set the values for the specified kind of data
  23028. * @param data a linear array of floating numbers
  23029. * @param kind the type of data that is being set, eg positions, colors etc
  23030. */
  23031. set(data: FloatArray, kind: string): void;
  23032. /**
  23033. * Associates the vertexData to the passed Mesh.
  23034. * Sets it as updatable or not (default `false`)
  23035. * @param mesh the mesh the vertexData is applied to
  23036. * @param updatable when used and having the value true allows new data to update the vertexData
  23037. * @returns the VertexData
  23038. */
  23039. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23040. /**
  23041. * Associates the vertexData to the passed Geometry.
  23042. * Sets it as updatable or not (default `false`)
  23043. * @param geometry the geometry the vertexData is applied to
  23044. * @param updatable when used and having the value true allows new data to update the vertexData
  23045. * @returns VertexData
  23046. */
  23047. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23048. /**
  23049. * Updates the associated mesh
  23050. * @param mesh the mesh to be updated
  23051. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23052. * @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
  23053. * @returns VertexData
  23054. */
  23055. updateMesh(mesh: Mesh): VertexData;
  23056. /**
  23057. * Updates the associated geometry
  23058. * @param geometry the geometry to be updated
  23059. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23060. * @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
  23061. * @returns VertexData.
  23062. */
  23063. updateGeometry(geometry: Geometry): VertexData;
  23064. private _applyTo;
  23065. private _update;
  23066. /**
  23067. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23068. * @param matrix the transforming matrix
  23069. * @returns the VertexData
  23070. */
  23071. transform(matrix: Matrix): VertexData;
  23072. /**
  23073. * Merges the passed VertexData into the current one
  23074. * @param other the VertexData to be merged into the current one
  23075. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23076. * @returns the modified VertexData
  23077. */
  23078. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23079. private _mergeElement;
  23080. private _validate;
  23081. /**
  23082. * Serializes the VertexData
  23083. * @returns a serialized object
  23084. */
  23085. serialize(): any;
  23086. /**
  23087. * Extracts the vertexData from a mesh
  23088. * @param mesh the mesh from which to extract the VertexData
  23089. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23090. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23091. * @returns the object VertexData associated to the passed mesh
  23092. */
  23093. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23094. /**
  23095. * Extracts the vertexData from the geometry
  23096. * @param geometry the geometry from which to extract the VertexData
  23097. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23098. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23099. * @returns the object VertexData associated to the passed mesh
  23100. */
  23101. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23102. private static _ExtractFrom;
  23103. /**
  23104. * Creates the VertexData for a Ribbon
  23105. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23106. * * pathArray array of paths, each of which an array of successive Vector3
  23107. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23108. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23109. * * 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
  23110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23111. * * 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)
  23112. * * 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)
  23113. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23114. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23115. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23116. * @returns the VertexData of the ribbon
  23117. */
  23118. static CreateRibbon(options: {
  23119. pathArray: Vector3[][];
  23120. closeArray?: boolean;
  23121. closePath?: boolean;
  23122. offset?: number;
  23123. sideOrientation?: number;
  23124. frontUVs?: Vector4;
  23125. backUVs?: Vector4;
  23126. invertUV?: boolean;
  23127. uvs?: Vector2[];
  23128. colors?: Color4[];
  23129. }): VertexData;
  23130. /**
  23131. * Creates the VertexData for a box
  23132. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23133. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23134. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23135. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23136. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23137. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23138. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23140. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23141. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23142. * @returns the VertexData of the box
  23143. */
  23144. static CreateBox(options: {
  23145. size?: number;
  23146. width?: number;
  23147. height?: number;
  23148. depth?: number;
  23149. faceUV?: Vector4[];
  23150. faceColors?: Color4[];
  23151. sideOrientation?: number;
  23152. frontUVs?: Vector4;
  23153. backUVs?: Vector4;
  23154. }): VertexData;
  23155. /**
  23156. * Creates the VertexData for a tiled box
  23157. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23158. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23159. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23160. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23162. * @returns the VertexData of the box
  23163. */
  23164. static CreateTiledBox(options: {
  23165. pattern?: number;
  23166. width?: number;
  23167. height?: number;
  23168. depth?: number;
  23169. tileSize?: number;
  23170. tileWidth?: number;
  23171. tileHeight?: number;
  23172. alignHorizontal?: number;
  23173. alignVertical?: number;
  23174. faceUV?: Vector4[];
  23175. faceColors?: Color4[];
  23176. sideOrientation?: number;
  23177. }): VertexData;
  23178. /**
  23179. * Creates the VertexData for a tiled plane
  23180. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23181. * * pattern a limited pattern arrangement depending on the number
  23182. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23183. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23184. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23186. * * 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)
  23187. * * 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)
  23188. * @returns the VertexData of the tiled plane
  23189. */
  23190. static CreateTiledPlane(options: {
  23191. pattern?: number;
  23192. tileSize?: number;
  23193. tileWidth?: number;
  23194. tileHeight?: number;
  23195. size?: number;
  23196. width?: number;
  23197. height?: number;
  23198. alignHorizontal?: number;
  23199. alignVertical?: number;
  23200. sideOrientation?: number;
  23201. frontUVs?: Vector4;
  23202. backUVs?: Vector4;
  23203. }): VertexData;
  23204. /**
  23205. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23206. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23207. * * segments sets the number of horizontal strips optional, default 32
  23208. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23209. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23210. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23211. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23212. * * 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
  23213. * * 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
  23214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23215. * * 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)
  23216. * * 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)
  23217. * @returns the VertexData of the ellipsoid
  23218. */
  23219. static CreateSphere(options: {
  23220. segments?: number;
  23221. diameter?: number;
  23222. diameterX?: number;
  23223. diameterY?: number;
  23224. diameterZ?: number;
  23225. arc?: number;
  23226. slice?: number;
  23227. sideOrientation?: number;
  23228. frontUVs?: Vector4;
  23229. backUVs?: Vector4;
  23230. }): VertexData;
  23231. /**
  23232. * Creates the VertexData for a cylinder, cone or prism
  23233. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23234. * * height sets the height (y direction) of the cylinder, optional, default 2
  23235. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23236. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23237. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23238. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23239. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23240. * * 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
  23241. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23242. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23243. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23244. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23246. * * 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)
  23247. * * 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)
  23248. * @returns the VertexData of the cylinder, cone or prism
  23249. */
  23250. static CreateCylinder(options: {
  23251. height?: number;
  23252. diameterTop?: number;
  23253. diameterBottom?: number;
  23254. diameter?: number;
  23255. tessellation?: number;
  23256. subdivisions?: number;
  23257. arc?: number;
  23258. faceColors?: Color4[];
  23259. faceUV?: Vector4[];
  23260. hasRings?: boolean;
  23261. enclose?: boolean;
  23262. sideOrientation?: number;
  23263. frontUVs?: Vector4;
  23264. backUVs?: Vector4;
  23265. }): VertexData;
  23266. /**
  23267. * Creates the VertexData for a torus
  23268. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23269. * * diameter the diameter of the torus, optional default 1
  23270. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23271. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23273. * * 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)
  23274. * * 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)
  23275. * @returns the VertexData of the torus
  23276. */
  23277. static CreateTorus(options: {
  23278. diameter?: number;
  23279. thickness?: number;
  23280. tessellation?: number;
  23281. sideOrientation?: number;
  23282. frontUVs?: Vector4;
  23283. backUVs?: Vector4;
  23284. }): VertexData;
  23285. /**
  23286. * Creates the VertexData of the LineSystem
  23287. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23288. * - lines an array of lines, each line being an array of successive Vector3
  23289. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23290. * @returns the VertexData of the LineSystem
  23291. */
  23292. static CreateLineSystem(options: {
  23293. lines: Vector3[][];
  23294. colors?: Nullable<Color4[][]>;
  23295. }): VertexData;
  23296. /**
  23297. * Create the VertexData for a DashedLines
  23298. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23299. * - points an array successive Vector3
  23300. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23301. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23302. * - dashNb the intended total number of dashes, optional, default 200
  23303. * @returns the VertexData for the DashedLines
  23304. */
  23305. static CreateDashedLines(options: {
  23306. points: Vector3[];
  23307. dashSize?: number;
  23308. gapSize?: number;
  23309. dashNb?: number;
  23310. }): VertexData;
  23311. /**
  23312. * Creates the VertexData for a Ground
  23313. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23314. * - width the width (x direction) of the ground, optional, default 1
  23315. * - height the height (z direction) of the ground, optional, default 1
  23316. * - subdivisions the number of subdivisions per side, optional, default 1
  23317. * @returns the VertexData of the Ground
  23318. */
  23319. static CreateGround(options: {
  23320. width?: number;
  23321. height?: number;
  23322. subdivisions?: number;
  23323. subdivisionsX?: number;
  23324. subdivisionsY?: number;
  23325. }): VertexData;
  23326. /**
  23327. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23328. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23329. * * xmin the ground minimum X coordinate, optional, default -1
  23330. * * zmin the ground minimum Z coordinate, optional, default -1
  23331. * * xmax the ground maximum X coordinate, optional, default 1
  23332. * * zmax the ground maximum Z coordinate, optional, default 1
  23333. * * 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}
  23334. * * 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}
  23335. * @returns the VertexData of the TiledGround
  23336. */
  23337. static CreateTiledGround(options: {
  23338. xmin: number;
  23339. zmin: number;
  23340. xmax: number;
  23341. zmax: number;
  23342. subdivisions?: {
  23343. w: number;
  23344. h: number;
  23345. };
  23346. precision?: {
  23347. w: number;
  23348. h: number;
  23349. };
  23350. }): VertexData;
  23351. /**
  23352. * Creates the VertexData of the Ground designed from a heightmap
  23353. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23354. * * width the width (x direction) of the ground
  23355. * * height the height (z direction) of the ground
  23356. * * subdivisions the number of subdivisions per side
  23357. * * minHeight the minimum altitude on the ground, optional, default 0
  23358. * * maxHeight the maximum altitude on the ground, optional default 1
  23359. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23360. * * buffer the array holding the image color data
  23361. * * bufferWidth the width of image
  23362. * * bufferHeight the height of image
  23363. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23364. * @returns the VertexData of the Ground designed from a heightmap
  23365. */
  23366. static CreateGroundFromHeightMap(options: {
  23367. width: number;
  23368. height: number;
  23369. subdivisions: number;
  23370. minHeight: number;
  23371. maxHeight: number;
  23372. colorFilter: Color3;
  23373. buffer: Uint8Array;
  23374. bufferWidth: number;
  23375. bufferHeight: number;
  23376. alphaFilter: number;
  23377. }): VertexData;
  23378. /**
  23379. * Creates the VertexData for a Plane
  23380. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23381. * * size sets the width and height of the plane to the value of size, optional default 1
  23382. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23383. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23385. * * 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)
  23386. * * 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)
  23387. * @returns the VertexData of the box
  23388. */
  23389. static CreatePlane(options: {
  23390. size?: number;
  23391. width?: number;
  23392. height?: number;
  23393. sideOrientation?: number;
  23394. frontUVs?: Vector4;
  23395. backUVs?: Vector4;
  23396. }): VertexData;
  23397. /**
  23398. * Creates the VertexData of the Disc or regular Polygon
  23399. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23400. * * radius the radius of the disc, optional default 0.5
  23401. * * tessellation the number of polygon sides, optional, default 64
  23402. * * 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
  23403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23404. * * 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)
  23405. * * 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)
  23406. * @returns the VertexData of the box
  23407. */
  23408. static CreateDisc(options: {
  23409. radius?: number;
  23410. tessellation?: number;
  23411. arc?: number;
  23412. sideOrientation?: number;
  23413. frontUVs?: Vector4;
  23414. backUVs?: Vector4;
  23415. }): VertexData;
  23416. /**
  23417. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23418. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23419. * @param polygon a mesh built from polygonTriangulation.build()
  23420. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23421. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23422. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23423. * @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)
  23424. * @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)
  23425. * @returns the VertexData of the Polygon
  23426. */
  23427. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23428. /**
  23429. * Creates the VertexData of the IcoSphere
  23430. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23431. * * radius the radius of the IcoSphere, optional default 1
  23432. * * radiusX allows stretching in the x direction, optional, default radius
  23433. * * radiusY allows stretching in the y direction, optional, default radius
  23434. * * radiusZ allows stretching in the z direction, optional, default radius
  23435. * * flat when true creates a flat shaded mesh, optional, default true
  23436. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23437. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23438. * * 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)
  23439. * * 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)
  23440. * @returns the VertexData of the IcoSphere
  23441. */
  23442. static CreateIcoSphere(options: {
  23443. radius?: number;
  23444. radiusX?: number;
  23445. radiusY?: number;
  23446. radiusZ?: number;
  23447. flat?: boolean;
  23448. subdivisions?: number;
  23449. sideOrientation?: number;
  23450. frontUVs?: Vector4;
  23451. backUVs?: Vector4;
  23452. }): VertexData;
  23453. /**
  23454. * Creates the VertexData for a Polyhedron
  23455. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23456. * * type provided types are:
  23457. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23458. * * 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)
  23459. * * size the size of the IcoSphere, optional default 1
  23460. * * sizeX allows stretching in the x direction, optional, default size
  23461. * * sizeY allows stretching in the y direction, optional, default size
  23462. * * sizeZ allows stretching in the z direction, optional, default size
  23463. * * 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
  23464. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23465. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23466. * * flat when true creates a flat shaded mesh, optional, default true
  23467. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23469. * * 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)
  23470. * * 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)
  23471. * @returns the VertexData of the Polyhedron
  23472. */
  23473. static CreatePolyhedron(options: {
  23474. type?: number;
  23475. size?: number;
  23476. sizeX?: number;
  23477. sizeY?: number;
  23478. sizeZ?: number;
  23479. custom?: any;
  23480. faceUV?: Vector4[];
  23481. faceColors?: Color4[];
  23482. flat?: boolean;
  23483. sideOrientation?: number;
  23484. frontUVs?: Vector4;
  23485. backUVs?: Vector4;
  23486. }): VertexData;
  23487. /**
  23488. * Creates the VertexData for a TorusKnot
  23489. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23490. * * radius the radius of the torus knot, optional, default 2
  23491. * * tube the thickness of the tube, optional, default 0.5
  23492. * * radialSegments the number of sides on each tube segments, optional, default 32
  23493. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23494. * * p the number of windings around the z axis, optional, default 2
  23495. * * q the number of windings around the x axis, optional, default 3
  23496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23497. * * 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)
  23498. * * 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)
  23499. * @returns the VertexData of the Torus Knot
  23500. */
  23501. static CreateTorusKnot(options: {
  23502. radius?: number;
  23503. tube?: number;
  23504. radialSegments?: number;
  23505. tubularSegments?: number;
  23506. p?: number;
  23507. q?: number;
  23508. sideOrientation?: number;
  23509. frontUVs?: Vector4;
  23510. backUVs?: Vector4;
  23511. }): VertexData;
  23512. /**
  23513. * Compute normals for given positions and indices
  23514. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23515. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23516. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23517. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23518. * * facetNormals : optional array of facet normals (vector3)
  23519. * * facetPositions : optional array of facet positions (vector3)
  23520. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23521. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23522. * * bInfo : optional bounding info, required for facetPartitioning computation
  23523. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23524. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23525. * * useRightHandedSystem: optional boolean to for right handed system computation
  23526. * * depthSort : optional boolean to enable the facet depth sort computation
  23527. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23528. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23529. */
  23530. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23531. facetNormals?: any;
  23532. facetPositions?: any;
  23533. facetPartitioning?: any;
  23534. ratio?: number;
  23535. bInfo?: any;
  23536. bbSize?: Vector3;
  23537. subDiv?: any;
  23538. useRightHandedSystem?: boolean;
  23539. depthSort?: boolean;
  23540. distanceTo?: Vector3;
  23541. depthSortedFacets?: any;
  23542. }): void;
  23543. /** @hidden */
  23544. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23545. /**
  23546. * Applies VertexData created from the imported parameters to the geometry
  23547. * @param parsedVertexData the parsed data from an imported file
  23548. * @param geometry the geometry to apply the VertexData to
  23549. */
  23550. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23551. }
  23552. }
  23553. declare module "babylonjs/Morph/morphTarget" {
  23554. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23555. import { Observable } from "babylonjs/Misc/observable";
  23556. import { Nullable, FloatArray } from "babylonjs/types";
  23557. import { Scene } from "babylonjs/scene";
  23558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23559. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23560. /**
  23561. * Defines a target to use with MorphTargetManager
  23562. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23563. */
  23564. export class MorphTarget implements IAnimatable {
  23565. /** defines the name of the target */
  23566. name: string;
  23567. /**
  23568. * Gets or sets the list of animations
  23569. */
  23570. animations: import("babylonjs/Animations/animation").Animation[];
  23571. private _scene;
  23572. private _positions;
  23573. private _normals;
  23574. private _tangents;
  23575. private _uvs;
  23576. private _influence;
  23577. private _uniqueId;
  23578. /**
  23579. * Observable raised when the influence changes
  23580. */
  23581. onInfluenceChanged: Observable<boolean>;
  23582. /** @hidden */
  23583. _onDataLayoutChanged: Observable<void>;
  23584. /**
  23585. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23586. */
  23587. get influence(): number;
  23588. set influence(influence: number);
  23589. /**
  23590. * Gets or sets the id of the morph Target
  23591. */
  23592. id: string;
  23593. private _animationPropertiesOverride;
  23594. /**
  23595. * Gets or sets the animation properties override
  23596. */
  23597. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23598. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23599. /**
  23600. * Creates a new MorphTarget
  23601. * @param name defines the name of the target
  23602. * @param influence defines the influence to use
  23603. * @param scene defines the scene the morphtarget belongs to
  23604. */
  23605. constructor(
  23606. /** defines the name of the target */
  23607. name: string, influence?: number, scene?: Nullable<Scene>);
  23608. /**
  23609. * Gets the unique ID of this manager
  23610. */
  23611. get uniqueId(): number;
  23612. /**
  23613. * Gets a boolean defining if the target contains position data
  23614. */
  23615. get hasPositions(): boolean;
  23616. /**
  23617. * Gets a boolean defining if the target contains normal data
  23618. */
  23619. get hasNormals(): boolean;
  23620. /**
  23621. * Gets a boolean defining if the target contains tangent data
  23622. */
  23623. get hasTangents(): boolean;
  23624. /**
  23625. * Gets a boolean defining if the target contains texture coordinates data
  23626. */
  23627. get hasUVs(): boolean;
  23628. /**
  23629. * Affects position data to this target
  23630. * @param data defines the position data to use
  23631. */
  23632. setPositions(data: Nullable<FloatArray>): void;
  23633. /**
  23634. * Gets the position data stored in this target
  23635. * @returns a FloatArray containing the position data (or null if not present)
  23636. */
  23637. getPositions(): Nullable<FloatArray>;
  23638. /**
  23639. * Affects normal data to this target
  23640. * @param data defines the normal data to use
  23641. */
  23642. setNormals(data: Nullable<FloatArray>): void;
  23643. /**
  23644. * Gets the normal data stored in this target
  23645. * @returns a FloatArray containing the normal data (or null if not present)
  23646. */
  23647. getNormals(): Nullable<FloatArray>;
  23648. /**
  23649. * Affects tangent data to this target
  23650. * @param data defines the tangent data to use
  23651. */
  23652. setTangents(data: Nullable<FloatArray>): void;
  23653. /**
  23654. * Gets the tangent data stored in this target
  23655. * @returns a FloatArray containing the tangent data (or null if not present)
  23656. */
  23657. getTangents(): Nullable<FloatArray>;
  23658. /**
  23659. * Affects texture coordinates data to this target
  23660. * @param data defines the texture coordinates data to use
  23661. */
  23662. setUVs(data: Nullable<FloatArray>): void;
  23663. /**
  23664. * Gets the texture coordinates data stored in this target
  23665. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23666. */
  23667. getUVs(): Nullable<FloatArray>;
  23668. /**
  23669. * Clone the current target
  23670. * @returns a new MorphTarget
  23671. */
  23672. clone(): MorphTarget;
  23673. /**
  23674. * Serializes the current target into a Serialization object
  23675. * @returns the serialized object
  23676. */
  23677. serialize(): any;
  23678. /**
  23679. * Returns the string "MorphTarget"
  23680. * @returns "MorphTarget"
  23681. */
  23682. getClassName(): string;
  23683. /**
  23684. * Creates a new target from serialized data
  23685. * @param serializationObject defines the serialized data to use
  23686. * @returns a new MorphTarget
  23687. */
  23688. static Parse(serializationObject: any): MorphTarget;
  23689. /**
  23690. * Creates a MorphTarget from mesh data
  23691. * @param mesh defines the source mesh
  23692. * @param name defines the name to use for the new target
  23693. * @param influence defines the influence to attach to the target
  23694. * @returns a new MorphTarget
  23695. */
  23696. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23697. }
  23698. }
  23699. declare module "babylonjs/Morph/morphTargetManager" {
  23700. import { Nullable } from "babylonjs/types";
  23701. import { Scene } from "babylonjs/scene";
  23702. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23703. /**
  23704. * This class is used to deform meshes using morphing between different targets
  23705. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23706. */
  23707. export class MorphTargetManager {
  23708. private _targets;
  23709. private _targetInfluenceChangedObservers;
  23710. private _targetDataLayoutChangedObservers;
  23711. private _activeTargets;
  23712. private _scene;
  23713. private _influences;
  23714. private _supportsNormals;
  23715. private _supportsTangents;
  23716. private _supportsUVs;
  23717. private _vertexCount;
  23718. private _uniqueId;
  23719. private _tempInfluences;
  23720. /**
  23721. * Gets or sets a boolean indicating if normals must be morphed
  23722. */
  23723. enableNormalMorphing: boolean;
  23724. /**
  23725. * Gets or sets a boolean indicating if tangents must be morphed
  23726. */
  23727. enableTangentMorphing: boolean;
  23728. /**
  23729. * Gets or sets a boolean indicating if UV must be morphed
  23730. */
  23731. enableUVMorphing: boolean;
  23732. /**
  23733. * Creates a new MorphTargetManager
  23734. * @param scene defines the current scene
  23735. */
  23736. constructor(scene?: Nullable<Scene>);
  23737. /**
  23738. * Gets the unique ID of this manager
  23739. */
  23740. get uniqueId(): number;
  23741. /**
  23742. * Gets the number of vertices handled by this manager
  23743. */
  23744. get vertexCount(): number;
  23745. /**
  23746. * Gets a boolean indicating if this manager supports morphing of normals
  23747. */
  23748. get supportsNormals(): boolean;
  23749. /**
  23750. * Gets a boolean indicating if this manager supports morphing of tangents
  23751. */
  23752. get supportsTangents(): boolean;
  23753. /**
  23754. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23755. */
  23756. get supportsUVs(): boolean;
  23757. /**
  23758. * Gets the number of targets stored in this manager
  23759. */
  23760. get numTargets(): number;
  23761. /**
  23762. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23763. */
  23764. get numInfluencers(): number;
  23765. /**
  23766. * Gets the list of influences (one per target)
  23767. */
  23768. get influences(): Float32Array;
  23769. /**
  23770. * Gets the active target at specified index. An active target is a target with an influence > 0
  23771. * @param index defines the index to check
  23772. * @returns the requested target
  23773. */
  23774. getActiveTarget(index: number): MorphTarget;
  23775. /**
  23776. * Gets the target at specified index
  23777. * @param index defines the index to check
  23778. * @returns the requested target
  23779. */
  23780. getTarget(index: number): MorphTarget;
  23781. /**
  23782. * Add a new target to this manager
  23783. * @param target defines the target to add
  23784. */
  23785. addTarget(target: MorphTarget): void;
  23786. /**
  23787. * Removes a target from the manager
  23788. * @param target defines the target to remove
  23789. */
  23790. removeTarget(target: MorphTarget): void;
  23791. /**
  23792. * Clone the current manager
  23793. * @returns a new MorphTargetManager
  23794. */
  23795. clone(): MorphTargetManager;
  23796. /**
  23797. * Serializes the current manager into a Serialization object
  23798. * @returns the serialized object
  23799. */
  23800. serialize(): any;
  23801. private _syncActiveTargets;
  23802. /**
  23803. * Syncrhonize the targets with all the meshes using this morph target manager
  23804. */
  23805. synchronize(): void;
  23806. /**
  23807. * Creates a new MorphTargetManager from serialized data
  23808. * @param serializationObject defines the serialized data
  23809. * @param scene defines the hosting scene
  23810. * @returns the new MorphTargetManager
  23811. */
  23812. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23813. }
  23814. }
  23815. declare module "babylonjs/Meshes/meshLODLevel" {
  23816. import { Mesh } from "babylonjs/Meshes/mesh";
  23817. import { Nullable } from "babylonjs/types";
  23818. /**
  23819. * Class used to represent a specific level of detail of a mesh
  23820. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23821. */
  23822. export class MeshLODLevel {
  23823. /** Defines the distance where this level should start being displayed */
  23824. distance: number;
  23825. /** Defines the mesh to use to render this level */
  23826. mesh: Nullable<Mesh>;
  23827. /**
  23828. * Creates a new LOD level
  23829. * @param distance defines the distance where this level should star being displayed
  23830. * @param mesh defines the mesh to use to render this level
  23831. */
  23832. constructor(
  23833. /** Defines the distance where this level should start being displayed */
  23834. distance: number,
  23835. /** Defines the mesh to use to render this level */
  23836. mesh: Nullable<Mesh>);
  23837. }
  23838. }
  23839. declare module "babylonjs/Meshes/groundMesh" {
  23840. import { Scene } from "babylonjs/scene";
  23841. import { Vector3 } from "babylonjs/Maths/math.vector";
  23842. import { Mesh } from "babylonjs/Meshes/mesh";
  23843. /**
  23844. * Mesh representing the gorund
  23845. */
  23846. export class GroundMesh extends Mesh {
  23847. /** If octree should be generated */
  23848. generateOctree: boolean;
  23849. private _heightQuads;
  23850. /** @hidden */
  23851. _subdivisionsX: number;
  23852. /** @hidden */
  23853. _subdivisionsY: number;
  23854. /** @hidden */
  23855. _width: number;
  23856. /** @hidden */
  23857. _height: number;
  23858. /** @hidden */
  23859. _minX: number;
  23860. /** @hidden */
  23861. _maxX: number;
  23862. /** @hidden */
  23863. _minZ: number;
  23864. /** @hidden */
  23865. _maxZ: number;
  23866. constructor(name: string, scene: Scene);
  23867. /**
  23868. * "GroundMesh"
  23869. * @returns "GroundMesh"
  23870. */
  23871. getClassName(): string;
  23872. /**
  23873. * The minimum of x and y subdivisions
  23874. */
  23875. get subdivisions(): number;
  23876. /**
  23877. * X subdivisions
  23878. */
  23879. get subdivisionsX(): number;
  23880. /**
  23881. * Y subdivisions
  23882. */
  23883. get subdivisionsY(): number;
  23884. /**
  23885. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23886. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23887. * @param chunksCount the number of subdivisions for x and y
  23888. * @param octreeBlocksSize (Default: 32)
  23889. */
  23890. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23891. /**
  23892. * Returns a height (y) value in the Worl system :
  23893. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23894. * @param x x coordinate
  23895. * @param z z coordinate
  23896. * @returns the ground y position if (x, z) are outside the ground surface.
  23897. */
  23898. getHeightAtCoordinates(x: number, z: number): number;
  23899. /**
  23900. * Returns a normalized vector (Vector3) orthogonal to the ground
  23901. * at the ground coordinates (x, z) expressed in the World system.
  23902. * @param x x coordinate
  23903. * @param z z coordinate
  23904. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23905. */
  23906. getNormalAtCoordinates(x: number, z: number): Vector3;
  23907. /**
  23908. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23909. * at the ground coordinates (x, z) expressed in the World system.
  23910. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23911. * @param x x coordinate
  23912. * @param z z coordinate
  23913. * @param ref vector to store the result
  23914. * @returns the GroundMesh.
  23915. */
  23916. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23917. /**
  23918. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23919. * if the ground has been updated.
  23920. * This can be used in the render loop.
  23921. * @returns the GroundMesh.
  23922. */
  23923. updateCoordinateHeights(): GroundMesh;
  23924. private _getFacetAt;
  23925. private _initHeightQuads;
  23926. private _computeHeightQuads;
  23927. /**
  23928. * Serializes this ground mesh
  23929. * @param serializationObject object to write serialization to
  23930. */
  23931. serialize(serializationObject: any): void;
  23932. /**
  23933. * Parses a serialized ground mesh
  23934. * @param parsedMesh the serialized mesh
  23935. * @param scene the scene to create the ground mesh in
  23936. * @returns the created ground mesh
  23937. */
  23938. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23939. }
  23940. }
  23941. declare module "babylonjs/Physics/physicsJoint" {
  23942. import { Vector3 } from "babylonjs/Maths/math.vector";
  23943. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23944. /**
  23945. * Interface for Physics-Joint data
  23946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23947. */
  23948. export interface PhysicsJointData {
  23949. /**
  23950. * The main pivot of the joint
  23951. */
  23952. mainPivot?: Vector3;
  23953. /**
  23954. * The connected pivot of the joint
  23955. */
  23956. connectedPivot?: Vector3;
  23957. /**
  23958. * The main axis of the joint
  23959. */
  23960. mainAxis?: Vector3;
  23961. /**
  23962. * The connected axis of the joint
  23963. */
  23964. connectedAxis?: Vector3;
  23965. /**
  23966. * The collision of the joint
  23967. */
  23968. collision?: boolean;
  23969. /**
  23970. * Native Oimo/Cannon/Energy data
  23971. */
  23972. nativeParams?: any;
  23973. }
  23974. /**
  23975. * This is a holder class for the physics joint created by the physics plugin
  23976. * It holds a set of functions to control the underlying joint
  23977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23978. */
  23979. export class PhysicsJoint {
  23980. /**
  23981. * The type of the physics joint
  23982. */
  23983. type: number;
  23984. /**
  23985. * The data for the physics joint
  23986. */
  23987. jointData: PhysicsJointData;
  23988. private _physicsJoint;
  23989. protected _physicsPlugin: IPhysicsEnginePlugin;
  23990. /**
  23991. * Initializes the physics joint
  23992. * @param type The type of the physics joint
  23993. * @param jointData The data for the physics joint
  23994. */
  23995. constructor(
  23996. /**
  23997. * The type of the physics joint
  23998. */
  23999. type: number,
  24000. /**
  24001. * The data for the physics joint
  24002. */
  24003. jointData: PhysicsJointData);
  24004. /**
  24005. * Gets the physics joint
  24006. */
  24007. get physicsJoint(): any;
  24008. /**
  24009. * Sets the physics joint
  24010. */
  24011. set physicsJoint(newJoint: any);
  24012. /**
  24013. * Sets the physics plugin
  24014. */
  24015. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24016. /**
  24017. * Execute a function that is physics-plugin specific.
  24018. * @param {Function} func the function that will be executed.
  24019. * It accepts two parameters: the physics world and the physics joint
  24020. */
  24021. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24022. /**
  24023. * Distance-Joint type
  24024. */
  24025. static DistanceJoint: number;
  24026. /**
  24027. * Hinge-Joint type
  24028. */
  24029. static HingeJoint: number;
  24030. /**
  24031. * Ball-and-Socket joint type
  24032. */
  24033. static BallAndSocketJoint: number;
  24034. /**
  24035. * Wheel-Joint type
  24036. */
  24037. static WheelJoint: number;
  24038. /**
  24039. * Slider-Joint type
  24040. */
  24041. static SliderJoint: number;
  24042. /**
  24043. * Prismatic-Joint type
  24044. */
  24045. static PrismaticJoint: number;
  24046. /**
  24047. * Universal-Joint type
  24048. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24049. */
  24050. static UniversalJoint: number;
  24051. /**
  24052. * Hinge-Joint 2 type
  24053. */
  24054. static Hinge2Joint: number;
  24055. /**
  24056. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24057. */
  24058. static PointToPointJoint: number;
  24059. /**
  24060. * Spring-Joint type
  24061. */
  24062. static SpringJoint: number;
  24063. /**
  24064. * Lock-Joint type
  24065. */
  24066. static LockJoint: number;
  24067. }
  24068. /**
  24069. * A class representing a physics distance joint
  24070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24071. */
  24072. export class DistanceJoint extends PhysicsJoint {
  24073. /**
  24074. *
  24075. * @param jointData The data for the Distance-Joint
  24076. */
  24077. constructor(jointData: DistanceJointData);
  24078. /**
  24079. * Update the predefined distance.
  24080. * @param maxDistance The maximum preferred distance
  24081. * @param minDistance The minimum preferred distance
  24082. */
  24083. updateDistance(maxDistance: number, minDistance?: number): void;
  24084. }
  24085. /**
  24086. * Represents a Motor-Enabled Joint
  24087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24088. */
  24089. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24090. /**
  24091. * Initializes the Motor-Enabled Joint
  24092. * @param type The type of the joint
  24093. * @param jointData The physica joint data for the joint
  24094. */
  24095. constructor(type: number, jointData: PhysicsJointData);
  24096. /**
  24097. * Set the motor values.
  24098. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24099. * @param force the force to apply
  24100. * @param maxForce max force for this motor.
  24101. */
  24102. setMotor(force?: number, maxForce?: number): void;
  24103. /**
  24104. * Set the motor's limits.
  24105. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24106. * @param upperLimit The upper limit of the motor
  24107. * @param lowerLimit The lower limit of the motor
  24108. */
  24109. setLimit(upperLimit: number, lowerLimit?: number): void;
  24110. }
  24111. /**
  24112. * This class represents a single physics Hinge-Joint
  24113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24114. */
  24115. export class HingeJoint extends MotorEnabledJoint {
  24116. /**
  24117. * Initializes the Hinge-Joint
  24118. * @param jointData The joint data for the Hinge-Joint
  24119. */
  24120. constructor(jointData: PhysicsJointData);
  24121. /**
  24122. * Set the motor values.
  24123. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24124. * @param {number} force the force to apply
  24125. * @param {number} maxForce max force for this motor.
  24126. */
  24127. setMotor(force?: number, maxForce?: number): void;
  24128. /**
  24129. * Set the motor's limits.
  24130. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24131. * @param upperLimit The upper limit of the motor
  24132. * @param lowerLimit The lower limit of the motor
  24133. */
  24134. setLimit(upperLimit: number, lowerLimit?: number): void;
  24135. }
  24136. /**
  24137. * This class represents a dual hinge physics joint (same as wheel joint)
  24138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24139. */
  24140. export class Hinge2Joint extends MotorEnabledJoint {
  24141. /**
  24142. * Initializes the Hinge2-Joint
  24143. * @param jointData The joint data for the Hinge2-Joint
  24144. */
  24145. constructor(jointData: PhysicsJointData);
  24146. /**
  24147. * Set the motor values.
  24148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24149. * @param {number} targetSpeed the speed the motor is to reach
  24150. * @param {number} maxForce max force for this motor.
  24151. * @param {motorIndex} the motor's index, 0 or 1.
  24152. */
  24153. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24154. /**
  24155. * Set the motor limits.
  24156. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24157. * @param {number} upperLimit the upper limit
  24158. * @param {number} lowerLimit lower limit
  24159. * @param {motorIndex} the motor's index, 0 or 1.
  24160. */
  24161. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24162. }
  24163. /**
  24164. * Interface for a motor enabled joint
  24165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24166. */
  24167. export interface IMotorEnabledJoint {
  24168. /**
  24169. * Physics joint
  24170. */
  24171. physicsJoint: any;
  24172. /**
  24173. * Sets the motor of the motor-enabled joint
  24174. * @param force The force of the motor
  24175. * @param maxForce The maximum force of the motor
  24176. * @param motorIndex The index of the motor
  24177. */
  24178. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24179. /**
  24180. * Sets the limit of the motor
  24181. * @param upperLimit The upper limit of the motor
  24182. * @param lowerLimit The lower limit of the motor
  24183. * @param motorIndex The index of the motor
  24184. */
  24185. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24186. }
  24187. /**
  24188. * Joint data for a Distance-Joint
  24189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24190. */
  24191. export interface DistanceJointData extends PhysicsJointData {
  24192. /**
  24193. * Max distance the 2 joint objects can be apart
  24194. */
  24195. maxDistance: number;
  24196. }
  24197. /**
  24198. * Joint data from a spring joint
  24199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24200. */
  24201. export interface SpringJointData extends PhysicsJointData {
  24202. /**
  24203. * Length of the spring
  24204. */
  24205. length: number;
  24206. /**
  24207. * Stiffness of the spring
  24208. */
  24209. stiffness: number;
  24210. /**
  24211. * Damping of the spring
  24212. */
  24213. damping: number;
  24214. /** this callback will be called when applying the force to the impostors. */
  24215. forceApplicationCallback: () => void;
  24216. }
  24217. }
  24218. declare module "babylonjs/Physics/physicsRaycastResult" {
  24219. import { Vector3 } from "babylonjs/Maths/math.vector";
  24220. /**
  24221. * Holds the data for the raycast result
  24222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24223. */
  24224. export class PhysicsRaycastResult {
  24225. private _hasHit;
  24226. private _hitDistance;
  24227. private _hitNormalWorld;
  24228. private _hitPointWorld;
  24229. private _rayFromWorld;
  24230. private _rayToWorld;
  24231. /**
  24232. * Gets if there was a hit
  24233. */
  24234. get hasHit(): boolean;
  24235. /**
  24236. * Gets the distance from the hit
  24237. */
  24238. get hitDistance(): number;
  24239. /**
  24240. * Gets the hit normal/direction in the world
  24241. */
  24242. get hitNormalWorld(): Vector3;
  24243. /**
  24244. * Gets the hit point in the world
  24245. */
  24246. get hitPointWorld(): Vector3;
  24247. /**
  24248. * Gets the ray "start point" of the ray in the world
  24249. */
  24250. get rayFromWorld(): Vector3;
  24251. /**
  24252. * Gets the ray "end point" of the ray in the world
  24253. */
  24254. get rayToWorld(): Vector3;
  24255. /**
  24256. * Sets the hit data (normal & point in world space)
  24257. * @param hitNormalWorld defines the normal in world space
  24258. * @param hitPointWorld defines the point in world space
  24259. */
  24260. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24261. /**
  24262. * Sets the distance from the start point to the hit point
  24263. * @param distance
  24264. */
  24265. setHitDistance(distance: number): void;
  24266. /**
  24267. * Calculates the distance manually
  24268. */
  24269. calculateHitDistance(): void;
  24270. /**
  24271. * Resets all the values to default
  24272. * @param from The from point on world space
  24273. * @param to The to point on world space
  24274. */
  24275. reset(from?: Vector3, to?: Vector3): void;
  24276. }
  24277. /**
  24278. * Interface for the size containing width and height
  24279. */
  24280. interface IXYZ {
  24281. /**
  24282. * X
  24283. */
  24284. x: number;
  24285. /**
  24286. * Y
  24287. */
  24288. y: number;
  24289. /**
  24290. * Z
  24291. */
  24292. z: number;
  24293. }
  24294. }
  24295. declare module "babylonjs/Physics/IPhysicsEngine" {
  24296. import { Nullable } from "babylonjs/types";
  24297. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24299. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24300. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24301. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24302. /**
  24303. * Interface used to describe a physics joint
  24304. */
  24305. export interface PhysicsImpostorJoint {
  24306. /** Defines the main impostor to which the joint is linked */
  24307. mainImpostor: PhysicsImpostor;
  24308. /** Defines the impostor that is connected to the main impostor using this joint */
  24309. connectedImpostor: PhysicsImpostor;
  24310. /** Defines the joint itself */
  24311. joint: PhysicsJoint;
  24312. }
  24313. /** @hidden */
  24314. export interface IPhysicsEnginePlugin {
  24315. world: any;
  24316. name: string;
  24317. setGravity(gravity: Vector3): void;
  24318. setTimeStep(timeStep: number): void;
  24319. getTimeStep(): number;
  24320. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24321. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24322. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24323. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24324. removePhysicsBody(impostor: PhysicsImpostor): void;
  24325. generateJoint(joint: PhysicsImpostorJoint): void;
  24326. removeJoint(joint: PhysicsImpostorJoint): void;
  24327. isSupported(): boolean;
  24328. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24329. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24330. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24331. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24332. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24333. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24334. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24335. getBodyMass(impostor: PhysicsImpostor): number;
  24336. getBodyFriction(impostor: PhysicsImpostor): number;
  24337. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24338. getBodyRestitution(impostor: PhysicsImpostor): number;
  24339. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24340. getBodyPressure?(impostor: PhysicsImpostor): number;
  24341. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24342. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24343. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24344. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24345. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24346. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24347. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24348. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24349. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24350. sleepBody(impostor: PhysicsImpostor): void;
  24351. wakeUpBody(impostor: PhysicsImpostor): void;
  24352. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24353. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24354. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24355. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24356. getRadius(impostor: PhysicsImpostor): number;
  24357. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24358. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24359. dispose(): void;
  24360. }
  24361. /**
  24362. * Interface used to define a physics engine
  24363. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24364. */
  24365. export interface IPhysicsEngine {
  24366. /**
  24367. * Gets the gravity vector used by the simulation
  24368. */
  24369. gravity: Vector3;
  24370. /**
  24371. * Sets the gravity vector used by the simulation
  24372. * @param gravity defines the gravity vector to use
  24373. */
  24374. setGravity(gravity: Vector3): void;
  24375. /**
  24376. * Set the time step of the physics engine.
  24377. * Default is 1/60.
  24378. * To slow it down, enter 1/600 for example.
  24379. * To speed it up, 1/30
  24380. * @param newTimeStep the new timestep to apply to this world.
  24381. */
  24382. setTimeStep(newTimeStep: number): void;
  24383. /**
  24384. * Get the time step of the physics engine.
  24385. * @returns the current time step
  24386. */
  24387. getTimeStep(): number;
  24388. /**
  24389. * Set the sub time step of the physics engine.
  24390. * Default is 0 meaning there is no sub steps
  24391. * To increase physics resolution precision, set a small value (like 1 ms)
  24392. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24393. */
  24394. setSubTimeStep(subTimeStep: number): void;
  24395. /**
  24396. * Get the sub time step of the physics engine.
  24397. * @returns the current sub time step
  24398. */
  24399. getSubTimeStep(): number;
  24400. /**
  24401. * Release all resources
  24402. */
  24403. dispose(): void;
  24404. /**
  24405. * Gets the name of the current physics plugin
  24406. * @returns the name of the plugin
  24407. */
  24408. getPhysicsPluginName(): string;
  24409. /**
  24410. * Adding a new impostor for the impostor tracking.
  24411. * This will be done by the impostor itself.
  24412. * @param impostor the impostor to add
  24413. */
  24414. addImpostor(impostor: PhysicsImpostor): void;
  24415. /**
  24416. * Remove an impostor from the engine.
  24417. * This impostor and its mesh will not longer be updated by the physics engine.
  24418. * @param impostor the impostor to remove
  24419. */
  24420. removeImpostor(impostor: PhysicsImpostor): void;
  24421. /**
  24422. * Add a joint to the physics engine
  24423. * @param mainImpostor defines the main impostor to which the joint is added.
  24424. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24425. * @param joint defines the joint that will connect both impostors.
  24426. */
  24427. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24428. /**
  24429. * Removes a joint from the simulation
  24430. * @param mainImpostor defines the impostor used with the joint
  24431. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24432. * @param joint defines the joint to remove
  24433. */
  24434. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24435. /**
  24436. * Gets the current plugin used to run the simulation
  24437. * @returns current plugin
  24438. */
  24439. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24440. /**
  24441. * Gets the list of physic impostors
  24442. * @returns an array of PhysicsImpostor
  24443. */
  24444. getImpostors(): Array<PhysicsImpostor>;
  24445. /**
  24446. * Gets the impostor for a physics enabled object
  24447. * @param object defines the object impersonated by the impostor
  24448. * @returns the PhysicsImpostor or null if not found
  24449. */
  24450. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24451. /**
  24452. * Gets the impostor for a physics body object
  24453. * @param body defines physics body used by the impostor
  24454. * @returns the PhysicsImpostor or null if not found
  24455. */
  24456. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24457. /**
  24458. * Does a raycast in the physics world
  24459. * @param from when should the ray start?
  24460. * @param to when should the ray end?
  24461. * @returns PhysicsRaycastResult
  24462. */
  24463. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24464. /**
  24465. * Called by the scene. No need to call it.
  24466. * @param delta defines the timespam between frames
  24467. */
  24468. _step(delta: number): void;
  24469. }
  24470. }
  24471. declare module "babylonjs/Physics/physicsImpostor" {
  24472. import { Nullable, IndicesArray } from "babylonjs/types";
  24473. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24474. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24476. import { Scene } from "babylonjs/scene";
  24477. import { Bone } from "babylonjs/Bones/bone";
  24478. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24479. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24480. import { Space } from "babylonjs/Maths/math.axis";
  24481. /**
  24482. * The interface for the physics imposter parameters
  24483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24484. */
  24485. export interface PhysicsImpostorParameters {
  24486. /**
  24487. * The mass of the physics imposter
  24488. */
  24489. mass: number;
  24490. /**
  24491. * The friction of the physics imposter
  24492. */
  24493. friction?: number;
  24494. /**
  24495. * The coefficient of restitution of the physics imposter
  24496. */
  24497. restitution?: number;
  24498. /**
  24499. * The native options of the physics imposter
  24500. */
  24501. nativeOptions?: any;
  24502. /**
  24503. * Specifies if the parent should be ignored
  24504. */
  24505. ignoreParent?: boolean;
  24506. /**
  24507. * Specifies if bi-directional transformations should be disabled
  24508. */
  24509. disableBidirectionalTransformation?: boolean;
  24510. /**
  24511. * The pressure inside the physics imposter, soft object only
  24512. */
  24513. pressure?: number;
  24514. /**
  24515. * The stiffness the physics imposter, soft object only
  24516. */
  24517. stiffness?: number;
  24518. /**
  24519. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24520. */
  24521. velocityIterations?: number;
  24522. /**
  24523. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24524. */
  24525. positionIterations?: number;
  24526. /**
  24527. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24528. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24529. * Add to fix multiple points
  24530. */
  24531. fixedPoints?: number;
  24532. /**
  24533. * The collision margin around a soft object
  24534. */
  24535. margin?: number;
  24536. /**
  24537. * The collision margin around a soft object
  24538. */
  24539. damping?: number;
  24540. /**
  24541. * The path for a rope based on an extrusion
  24542. */
  24543. path?: any;
  24544. /**
  24545. * The shape of an extrusion used for a rope based on an extrusion
  24546. */
  24547. shape?: any;
  24548. }
  24549. /**
  24550. * Interface for a physics-enabled object
  24551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24552. */
  24553. export interface IPhysicsEnabledObject {
  24554. /**
  24555. * The position of the physics-enabled object
  24556. */
  24557. position: Vector3;
  24558. /**
  24559. * The rotation of the physics-enabled object
  24560. */
  24561. rotationQuaternion: Nullable<Quaternion>;
  24562. /**
  24563. * The scale of the physics-enabled object
  24564. */
  24565. scaling: Vector3;
  24566. /**
  24567. * The rotation of the physics-enabled object
  24568. */
  24569. rotation?: Vector3;
  24570. /**
  24571. * The parent of the physics-enabled object
  24572. */
  24573. parent?: any;
  24574. /**
  24575. * The bounding info of the physics-enabled object
  24576. * @returns The bounding info of the physics-enabled object
  24577. */
  24578. getBoundingInfo(): BoundingInfo;
  24579. /**
  24580. * Computes the world matrix
  24581. * @param force Specifies if the world matrix should be computed by force
  24582. * @returns A world matrix
  24583. */
  24584. computeWorldMatrix(force: boolean): Matrix;
  24585. /**
  24586. * Gets the world matrix
  24587. * @returns A world matrix
  24588. */
  24589. getWorldMatrix?(): Matrix;
  24590. /**
  24591. * Gets the child meshes
  24592. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24593. * @returns An array of abstract meshes
  24594. */
  24595. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24596. /**
  24597. * Gets the vertex data
  24598. * @param kind The type of vertex data
  24599. * @returns A nullable array of numbers, or a float32 array
  24600. */
  24601. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24602. /**
  24603. * Gets the indices from the mesh
  24604. * @returns A nullable array of index arrays
  24605. */
  24606. getIndices?(): Nullable<IndicesArray>;
  24607. /**
  24608. * Gets the scene from the mesh
  24609. * @returns the indices array or null
  24610. */
  24611. getScene?(): Scene;
  24612. /**
  24613. * Gets the absolute position from the mesh
  24614. * @returns the absolute position
  24615. */
  24616. getAbsolutePosition(): Vector3;
  24617. /**
  24618. * Gets the absolute pivot point from the mesh
  24619. * @returns the absolute pivot point
  24620. */
  24621. getAbsolutePivotPoint(): Vector3;
  24622. /**
  24623. * Rotates the mesh
  24624. * @param axis The axis of rotation
  24625. * @param amount The amount of rotation
  24626. * @param space The space of the rotation
  24627. * @returns The rotation transform node
  24628. */
  24629. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24630. /**
  24631. * Translates the mesh
  24632. * @param axis The axis of translation
  24633. * @param distance The distance of translation
  24634. * @param space The space of the translation
  24635. * @returns The transform node
  24636. */
  24637. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24638. /**
  24639. * Sets the absolute position of the mesh
  24640. * @param absolutePosition The absolute position of the mesh
  24641. * @returns The transform node
  24642. */
  24643. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24644. /**
  24645. * Gets the class name of the mesh
  24646. * @returns The class name
  24647. */
  24648. getClassName(): string;
  24649. }
  24650. /**
  24651. * Represents a physics imposter
  24652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24653. */
  24654. export class PhysicsImpostor {
  24655. /**
  24656. * The physics-enabled object used as the physics imposter
  24657. */
  24658. object: IPhysicsEnabledObject;
  24659. /**
  24660. * The type of the physics imposter
  24661. */
  24662. type: number;
  24663. private _options;
  24664. private _scene?;
  24665. /**
  24666. * The default object size of the imposter
  24667. */
  24668. static DEFAULT_OBJECT_SIZE: Vector3;
  24669. /**
  24670. * The identity quaternion of the imposter
  24671. */
  24672. static IDENTITY_QUATERNION: Quaternion;
  24673. /** @hidden */
  24674. _pluginData: any;
  24675. private _physicsEngine;
  24676. private _physicsBody;
  24677. private _bodyUpdateRequired;
  24678. private _onBeforePhysicsStepCallbacks;
  24679. private _onAfterPhysicsStepCallbacks;
  24680. /** @hidden */
  24681. _onPhysicsCollideCallbacks: Array<{
  24682. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24683. otherImpostors: Array<PhysicsImpostor>;
  24684. }>;
  24685. private _deltaPosition;
  24686. private _deltaRotation;
  24687. private _deltaRotationConjugated;
  24688. /** @hidden */
  24689. _isFromLine: boolean;
  24690. private _parent;
  24691. private _isDisposed;
  24692. private static _tmpVecs;
  24693. private static _tmpQuat;
  24694. /**
  24695. * Specifies if the physics imposter is disposed
  24696. */
  24697. get isDisposed(): boolean;
  24698. /**
  24699. * Gets the mass of the physics imposter
  24700. */
  24701. get mass(): number;
  24702. set mass(value: number);
  24703. /**
  24704. * Gets the coefficient of friction
  24705. */
  24706. get friction(): number;
  24707. /**
  24708. * Sets the coefficient of friction
  24709. */
  24710. set friction(value: number);
  24711. /**
  24712. * Gets the coefficient of restitution
  24713. */
  24714. get restitution(): number;
  24715. /**
  24716. * Sets the coefficient of restitution
  24717. */
  24718. set restitution(value: number);
  24719. /**
  24720. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24721. */
  24722. get pressure(): number;
  24723. /**
  24724. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24725. */
  24726. set pressure(value: number);
  24727. /**
  24728. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24729. */
  24730. get stiffness(): number;
  24731. /**
  24732. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24733. */
  24734. set stiffness(value: number);
  24735. /**
  24736. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24737. */
  24738. get velocityIterations(): number;
  24739. /**
  24740. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24741. */
  24742. set velocityIterations(value: number);
  24743. /**
  24744. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24745. */
  24746. get positionIterations(): number;
  24747. /**
  24748. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24749. */
  24750. set positionIterations(value: number);
  24751. /**
  24752. * The unique id of the physics imposter
  24753. * set by the physics engine when adding this impostor to the array
  24754. */
  24755. uniqueId: number;
  24756. /**
  24757. * @hidden
  24758. */
  24759. soft: boolean;
  24760. /**
  24761. * @hidden
  24762. */
  24763. segments: number;
  24764. private _joints;
  24765. /**
  24766. * Initializes the physics imposter
  24767. * @param object The physics-enabled object used as the physics imposter
  24768. * @param type The type of the physics imposter
  24769. * @param _options The options for the physics imposter
  24770. * @param _scene The Babylon scene
  24771. */
  24772. constructor(
  24773. /**
  24774. * The physics-enabled object used as the physics imposter
  24775. */
  24776. object: IPhysicsEnabledObject,
  24777. /**
  24778. * The type of the physics imposter
  24779. */
  24780. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24781. /**
  24782. * This function will completly initialize this impostor.
  24783. * It will create a new body - but only if this mesh has no parent.
  24784. * If it has, this impostor will not be used other than to define the impostor
  24785. * of the child mesh.
  24786. * @hidden
  24787. */
  24788. _init(): void;
  24789. private _getPhysicsParent;
  24790. /**
  24791. * Should a new body be generated.
  24792. * @returns boolean specifying if body initialization is required
  24793. */
  24794. isBodyInitRequired(): boolean;
  24795. /**
  24796. * Sets the updated scaling
  24797. * @param updated Specifies if the scaling is updated
  24798. */
  24799. setScalingUpdated(): void;
  24800. /**
  24801. * Force a regeneration of this or the parent's impostor's body.
  24802. * Use under cautious - This will remove all joints already implemented.
  24803. */
  24804. forceUpdate(): void;
  24805. /**
  24806. * Gets the body that holds this impostor. Either its own, or its parent.
  24807. */
  24808. get physicsBody(): any;
  24809. /**
  24810. * Get the parent of the physics imposter
  24811. * @returns Physics imposter or null
  24812. */
  24813. get parent(): Nullable<PhysicsImpostor>;
  24814. /**
  24815. * Sets the parent of the physics imposter
  24816. */
  24817. set parent(value: Nullable<PhysicsImpostor>);
  24818. /**
  24819. * Set the physics body. Used mainly by the physics engine/plugin
  24820. */
  24821. set physicsBody(physicsBody: any);
  24822. /**
  24823. * Resets the update flags
  24824. */
  24825. resetUpdateFlags(): void;
  24826. /**
  24827. * Gets the object extend size
  24828. * @returns the object extend size
  24829. */
  24830. getObjectExtendSize(): Vector3;
  24831. /**
  24832. * Gets the object center
  24833. * @returns The object center
  24834. */
  24835. getObjectCenter(): Vector3;
  24836. /**
  24837. * Get a specific parameter from the options parameters
  24838. * @param paramName The object parameter name
  24839. * @returns The object parameter
  24840. */
  24841. getParam(paramName: string): any;
  24842. /**
  24843. * Sets a specific parameter in the options given to the physics plugin
  24844. * @param paramName The parameter name
  24845. * @param value The value of the parameter
  24846. */
  24847. setParam(paramName: string, value: number): void;
  24848. /**
  24849. * Specifically change the body's mass option. Won't recreate the physics body object
  24850. * @param mass The mass of the physics imposter
  24851. */
  24852. setMass(mass: number): void;
  24853. /**
  24854. * Gets the linear velocity
  24855. * @returns linear velocity or null
  24856. */
  24857. getLinearVelocity(): Nullable<Vector3>;
  24858. /**
  24859. * Sets the linear velocity
  24860. * @param velocity linear velocity or null
  24861. */
  24862. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24863. /**
  24864. * Gets the angular velocity
  24865. * @returns angular velocity or null
  24866. */
  24867. getAngularVelocity(): Nullable<Vector3>;
  24868. /**
  24869. * Sets the angular velocity
  24870. * @param velocity The velocity or null
  24871. */
  24872. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24873. /**
  24874. * Execute a function with the physics plugin native code
  24875. * Provide a function the will have two variables - the world object and the physics body object
  24876. * @param func The function to execute with the physics plugin native code
  24877. */
  24878. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24879. /**
  24880. * Register a function that will be executed before the physics world is stepping forward
  24881. * @param func The function to execute before the physics world is stepped forward
  24882. */
  24883. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24884. /**
  24885. * Unregister a function that will be executed before the physics world is stepping forward
  24886. * @param func The function to execute before the physics world is stepped forward
  24887. */
  24888. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24889. /**
  24890. * Register a function that will be executed after the physics step
  24891. * @param func The function to execute after physics step
  24892. */
  24893. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24894. /**
  24895. * Unregisters a function that will be executed after the physics step
  24896. * @param func The function to execute after physics step
  24897. */
  24898. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24899. /**
  24900. * register a function that will be executed when this impostor collides against a different body
  24901. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24902. * @param func Callback that is executed on collision
  24903. */
  24904. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24905. /**
  24906. * Unregisters the physics imposter on contact
  24907. * @param collideAgainst The physics object to collide against
  24908. * @param func Callback to execute on collision
  24909. */
  24910. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24911. private _tmpQuat;
  24912. private _tmpQuat2;
  24913. /**
  24914. * Get the parent rotation
  24915. * @returns The parent rotation
  24916. */
  24917. getParentsRotation(): Quaternion;
  24918. /**
  24919. * this function is executed by the physics engine.
  24920. */
  24921. beforeStep: () => void;
  24922. /**
  24923. * this function is executed by the physics engine
  24924. */
  24925. afterStep: () => void;
  24926. /**
  24927. * Legacy collision detection event support
  24928. */
  24929. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24930. /**
  24931. * event and body object due to cannon's event-based architecture.
  24932. */
  24933. onCollide: (e: {
  24934. body: any;
  24935. }) => void;
  24936. /**
  24937. * Apply a force
  24938. * @param force The force to apply
  24939. * @param contactPoint The contact point for the force
  24940. * @returns The physics imposter
  24941. */
  24942. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24943. /**
  24944. * Apply an impulse
  24945. * @param force The impulse force
  24946. * @param contactPoint The contact point for the impulse force
  24947. * @returns The physics imposter
  24948. */
  24949. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24950. /**
  24951. * A help function to create a joint
  24952. * @param otherImpostor A physics imposter used to create a joint
  24953. * @param jointType The type of joint
  24954. * @param jointData The data for the joint
  24955. * @returns The physics imposter
  24956. */
  24957. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24958. /**
  24959. * Add a joint to this impostor with a different impostor
  24960. * @param otherImpostor A physics imposter used to add a joint
  24961. * @param joint The joint to add
  24962. * @returns The physics imposter
  24963. */
  24964. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24965. /**
  24966. * Add an anchor to a cloth impostor
  24967. * @param otherImpostor rigid impostor to anchor to
  24968. * @param width ratio across width from 0 to 1
  24969. * @param height ratio up height from 0 to 1
  24970. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24971. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24972. * @returns impostor the soft imposter
  24973. */
  24974. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24975. /**
  24976. * Add a hook to a rope impostor
  24977. * @param otherImpostor rigid impostor to anchor to
  24978. * @param length ratio across rope from 0 to 1
  24979. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24980. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24981. * @returns impostor the rope imposter
  24982. */
  24983. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24984. /**
  24985. * Will keep this body still, in a sleep mode.
  24986. * @returns the physics imposter
  24987. */
  24988. sleep(): PhysicsImpostor;
  24989. /**
  24990. * Wake the body up.
  24991. * @returns The physics imposter
  24992. */
  24993. wakeUp(): PhysicsImpostor;
  24994. /**
  24995. * Clones the physics imposter
  24996. * @param newObject The physics imposter clones to this physics-enabled object
  24997. * @returns A nullable physics imposter
  24998. */
  24999. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25000. /**
  25001. * Disposes the physics imposter
  25002. */
  25003. dispose(): void;
  25004. /**
  25005. * Sets the delta position
  25006. * @param position The delta position amount
  25007. */
  25008. setDeltaPosition(position: Vector3): void;
  25009. /**
  25010. * Sets the delta rotation
  25011. * @param rotation The delta rotation amount
  25012. */
  25013. setDeltaRotation(rotation: Quaternion): void;
  25014. /**
  25015. * Gets the box size of the physics imposter and stores the result in the input parameter
  25016. * @param result Stores the box size
  25017. * @returns The physics imposter
  25018. */
  25019. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25020. /**
  25021. * Gets the radius of the physics imposter
  25022. * @returns Radius of the physics imposter
  25023. */
  25024. getRadius(): number;
  25025. /**
  25026. * Sync a bone with this impostor
  25027. * @param bone The bone to sync to the impostor.
  25028. * @param boneMesh The mesh that the bone is influencing.
  25029. * @param jointPivot The pivot of the joint / bone in local space.
  25030. * @param distToJoint Optional distance from the impostor to the joint.
  25031. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25032. */
  25033. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25034. /**
  25035. * Sync impostor to a bone
  25036. * @param bone The bone that the impostor will be synced to.
  25037. * @param boneMesh The mesh that the bone is influencing.
  25038. * @param jointPivot The pivot of the joint / bone in local space.
  25039. * @param distToJoint Optional distance from the impostor to the joint.
  25040. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25041. * @param boneAxis Optional vector3 axis the bone is aligned with
  25042. */
  25043. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25044. /**
  25045. * No-Imposter type
  25046. */
  25047. static NoImpostor: number;
  25048. /**
  25049. * Sphere-Imposter type
  25050. */
  25051. static SphereImpostor: number;
  25052. /**
  25053. * Box-Imposter type
  25054. */
  25055. static BoxImpostor: number;
  25056. /**
  25057. * Plane-Imposter type
  25058. */
  25059. static PlaneImpostor: number;
  25060. /**
  25061. * Mesh-imposter type
  25062. */
  25063. static MeshImpostor: number;
  25064. /**
  25065. * Capsule-Impostor type (Ammo.js plugin only)
  25066. */
  25067. static CapsuleImpostor: number;
  25068. /**
  25069. * Cylinder-Imposter type
  25070. */
  25071. static CylinderImpostor: number;
  25072. /**
  25073. * Particle-Imposter type
  25074. */
  25075. static ParticleImpostor: number;
  25076. /**
  25077. * Heightmap-Imposter type
  25078. */
  25079. static HeightmapImpostor: number;
  25080. /**
  25081. * ConvexHull-Impostor type (Ammo.js plugin only)
  25082. */
  25083. static ConvexHullImpostor: number;
  25084. /**
  25085. * Custom-Imposter type (Ammo.js plugin only)
  25086. */
  25087. static CustomImpostor: number;
  25088. /**
  25089. * Rope-Imposter type
  25090. */
  25091. static RopeImpostor: number;
  25092. /**
  25093. * Cloth-Imposter type
  25094. */
  25095. static ClothImpostor: number;
  25096. /**
  25097. * Softbody-Imposter type
  25098. */
  25099. static SoftbodyImpostor: number;
  25100. }
  25101. }
  25102. declare module "babylonjs/Meshes/mesh" {
  25103. import { Observable } from "babylonjs/Misc/observable";
  25104. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25105. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25106. import { Camera } from "babylonjs/Cameras/camera";
  25107. import { Scene } from "babylonjs/scene";
  25108. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25109. import { Color4 } from "babylonjs/Maths/math.color";
  25110. import { Engine } from "babylonjs/Engines/engine";
  25111. import { Node } from "babylonjs/node";
  25112. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25113. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25114. import { Buffer } from "babylonjs/Meshes/buffer";
  25115. import { Geometry } from "babylonjs/Meshes/geometry";
  25116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25117. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25118. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25119. import { Effect } from "babylonjs/Materials/effect";
  25120. import { Material } from "babylonjs/Materials/material";
  25121. import { Skeleton } from "babylonjs/Bones/skeleton";
  25122. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25123. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25124. import { Path3D } from "babylonjs/Maths/math.path";
  25125. import { Plane } from "babylonjs/Maths/math.plane";
  25126. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25127. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25128. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25129. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25130. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25131. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25132. /**
  25133. * @hidden
  25134. **/
  25135. export class _CreationDataStorage {
  25136. closePath?: boolean;
  25137. closeArray?: boolean;
  25138. idx: number[];
  25139. dashSize: number;
  25140. gapSize: number;
  25141. path3D: Path3D;
  25142. pathArray: Vector3[][];
  25143. arc: number;
  25144. radius: number;
  25145. cap: number;
  25146. tessellation: number;
  25147. }
  25148. /**
  25149. * @hidden
  25150. **/
  25151. class _InstanceDataStorage {
  25152. visibleInstances: any;
  25153. batchCache: _InstancesBatch;
  25154. instancesBufferSize: number;
  25155. instancesBuffer: Nullable<Buffer>;
  25156. instancesData: Float32Array;
  25157. overridenInstanceCount: number;
  25158. isFrozen: boolean;
  25159. previousBatch: Nullable<_InstancesBatch>;
  25160. hardwareInstancedRendering: boolean;
  25161. sideOrientation: number;
  25162. manualUpdate: boolean;
  25163. }
  25164. /**
  25165. * @hidden
  25166. **/
  25167. export class _InstancesBatch {
  25168. mustReturn: boolean;
  25169. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25170. renderSelf: boolean[];
  25171. hardwareInstancedRendering: boolean[];
  25172. }
  25173. /**
  25174. * Class used to represent renderable models
  25175. */
  25176. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25177. /**
  25178. * Mesh side orientation : usually the external or front surface
  25179. */
  25180. static readonly FRONTSIDE: number;
  25181. /**
  25182. * Mesh side orientation : usually the internal or back surface
  25183. */
  25184. static readonly BACKSIDE: number;
  25185. /**
  25186. * Mesh side orientation : both internal and external or front and back surfaces
  25187. */
  25188. static readonly DOUBLESIDE: number;
  25189. /**
  25190. * Mesh side orientation : by default, `FRONTSIDE`
  25191. */
  25192. static readonly DEFAULTSIDE: number;
  25193. /**
  25194. * Mesh cap setting : no cap
  25195. */
  25196. static readonly NO_CAP: number;
  25197. /**
  25198. * Mesh cap setting : one cap at the beginning of the mesh
  25199. */
  25200. static readonly CAP_START: number;
  25201. /**
  25202. * Mesh cap setting : one cap at the end of the mesh
  25203. */
  25204. static readonly CAP_END: number;
  25205. /**
  25206. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25207. */
  25208. static readonly CAP_ALL: number;
  25209. /**
  25210. * Mesh pattern setting : no flip or rotate
  25211. */
  25212. static readonly NO_FLIP: number;
  25213. /**
  25214. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25215. */
  25216. static readonly FLIP_TILE: number;
  25217. /**
  25218. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25219. */
  25220. static readonly ROTATE_TILE: number;
  25221. /**
  25222. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25223. */
  25224. static readonly FLIP_ROW: number;
  25225. /**
  25226. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25227. */
  25228. static readonly ROTATE_ROW: number;
  25229. /**
  25230. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25231. */
  25232. static readonly FLIP_N_ROTATE_TILE: number;
  25233. /**
  25234. * Mesh pattern setting : rotate pattern and rotate
  25235. */
  25236. static readonly FLIP_N_ROTATE_ROW: number;
  25237. /**
  25238. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25239. */
  25240. static readonly CENTER: number;
  25241. /**
  25242. * Mesh tile positioning : part tiles on left
  25243. */
  25244. static readonly LEFT: number;
  25245. /**
  25246. * Mesh tile positioning : part tiles on right
  25247. */
  25248. static readonly RIGHT: number;
  25249. /**
  25250. * Mesh tile positioning : part tiles on top
  25251. */
  25252. static readonly TOP: number;
  25253. /**
  25254. * Mesh tile positioning : part tiles on bottom
  25255. */
  25256. static readonly BOTTOM: number;
  25257. /**
  25258. * Gets the default side orientation.
  25259. * @param orientation the orientation to value to attempt to get
  25260. * @returns the default orientation
  25261. * @hidden
  25262. */
  25263. static _GetDefaultSideOrientation(orientation?: number): number;
  25264. private _internalMeshDataInfo;
  25265. /**
  25266. * An event triggered before rendering the mesh
  25267. */
  25268. get onBeforeRenderObservable(): Observable<Mesh>;
  25269. /**
  25270. * An event triggered before binding the mesh
  25271. */
  25272. get onBeforeBindObservable(): Observable<Mesh>;
  25273. /**
  25274. * An event triggered after rendering the mesh
  25275. */
  25276. get onAfterRenderObservable(): Observable<Mesh>;
  25277. /**
  25278. * An event triggered before drawing the mesh
  25279. */
  25280. get onBeforeDrawObservable(): Observable<Mesh>;
  25281. private _onBeforeDrawObserver;
  25282. /**
  25283. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25284. */
  25285. set onBeforeDraw(callback: () => void);
  25286. get hasInstances(): boolean;
  25287. /**
  25288. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25289. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25290. */
  25291. delayLoadState: number;
  25292. /**
  25293. * Gets the list of instances created from this mesh
  25294. * it is not supposed to be modified manually.
  25295. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25296. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25297. */
  25298. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25299. /**
  25300. * Gets the file containing delay loading data for this mesh
  25301. */
  25302. delayLoadingFile: string;
  25303. /** @hidden */
  25304. _binaryInfo: any;
  25305. /**
  25306. * User defined function used to change how LOD level selection is done
  25307. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25308. */
  25309. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25310. /**
  25311. * Gets or sets the morph target manager
  25312. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25313. */
  25314. get morphTargetManager(): Nullable<MorphTargetManager>;
  25315. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25316. /** @hidden */
  25317. _creationDataStorage: Nullable<_CreationDataStorage>;
  25318. /** @hidden */
  25319. _geometry: Nullable<Geometry>;
  25320. /** @hidden */
  25321. _delayInfo: Array<string>;
  25322. /** @hidden */
  25323. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25324. /** @hidden */
  25325. _instanceDataStorage: _InstanceDataStorage;
  25326. private _effectiveMaterial;
  25327. /** @hidden */
  25328. _shouldGenerateFlatShading: boolean;
  25329. /** @hidden */
  25330. _originalBuilderSideOrientation: number;
  25331. /**
  25332. * Use this property to change the original side orientation defined at construction time
  25333. */
  25334. overrideMaterialSideOrientation: Nullable<number>;
  25335. /**
  25336. * Gets the source mesh (the one used to clone this one from)
  25337. */
  25338. get source(): Nullable<Mesh>;
  25339. /**
  25340. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25341. */
  25342. get isUnIndexed(): boolean;
  25343. set isUnIndexed(value: boolean);
  25344. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25345. get worldMatrixInstancedBuffer(): Float32Array;
  25346. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25347. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25348. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25349. /**
  25350. * @constructor
  25351. * @param name The value used by scene.getMeshByName() to do a lookup.
  25352. * @param scene The scene to add this mesh to.
  25353. * @param parent The parent of this mesh, if it has one
  25354. * @param source An optional Mesh from which geometry is shared, cloned.
  25355. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25356. * When false, achieved by calling a clone(), also passing False.
  25357. * This will make creation of children, recursive.
  25358. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25359. */
  25360. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25361. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25362. doNotInstantiate: boolean;
  25363. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25364. /**
  25365. * Gets the class name
  25366. * @returns the string "Mesh".
  25367. */
  25368. getClassName(): string;
  25369. /** @hidden */
  25370. get _isMesh(): boolean;
  25371. /**
  25372. * Returns a description of this mesh
  25373. * @param fullDetails define if full details about this mesh must be used
  25374. * @returns a descriptive string representing this mesh
  25375. */
  25376. toString(fullDetails?: boolean): string;
  25377. /** @hidden */
  25378. _unBindEffect(): void;
  25379. /**
  25380. * Gets a boolean indicating if this mesh has LOD
  25381. */
  25382. get hasLODLevels(): boolean;
  25383. /**
  25384. * Gets the list of MeshLODLevel associated with the current mesh
  25385. * @returns an array of MeshLODLevel
  25386. */
  25387. getLODLevels(): MeshLODLevel[];
  25388. private _sortLODLevels;
  25389. /**
  25390. * Add a mesh as LOD level triggered at the given distance.
  25391. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25392. * @param distance The distance from the center of the object to show this level
  25393. * @param mesh The mesh to be added as LOD level (can be null)
  25394. * @return This mesh (for chaining)
  25395. */
  25396. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25397. /**
  25398. * Returns the LOD level mesh at the passed distance or null if not found.
  25399. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25400. * @param distance The distance from the center of the object to show this level
  25401. * @returns a Mesh or `null`
  25402. */
  25403. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25404. /**
  25405. * Remove a mesh from the LOD array
  25406. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25407. * @param mesh defines the mesh to be removed
  25408. * @return This mesh (for chaining)
  25409. */
  25410. removeLODLevel(mesh: Mesh): Mesh;
  25411. /**
  25412. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25413. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25414. * @param camera defines the camera to use to compute distance
  25415. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25416. * @return This mesh (for chaining)
  25417. */
  25418. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25419. /**
  25420. * Gets the mesh internal Geometry object
  25421. */
  25422. get geometry(): Nullable<Geometry>;
  25423. /**
  25424. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25425. * @returns the total number of vertices
  25426. */
  25427. getTotalVertices(): number;
  25428. /**
  25429. * Returns the content of an associated vertex buffer
  25430. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25431. * - VertexBuffer.PositionKind
  25432. * - VertexBuffer.UVKind
  25433. * - VertexBuffer.UV2Kind
  25434. * - VertexBuffer.UV3Kind
  25435. * - VertexBuffer.UV4Kind
  25436. * - VertexBuffer.UV5Kind
  25437. * - VertexBuffer.UV6Kind
  25438. * - VertexBuffer.ColorKind
  25439. * - VertexBuffer.MatricesIndicesKind
  25440. * - VertexBuffer.MatricesIndicesExtraKind
  25441. * - VertexBuffer.MatricesWeightsKind
  25442. * - VertexBuffer.MatricesWeightsExtraKind
  25443. * @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
  25444. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25445. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25446. */
  25447. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25448. /**
  25449. * Returns the mesh VertexBuffer object from the requested `kind`
  25450. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25451. * - VertexBuffer.PositionKind
  25452. * - VertexBuffer.NormalKind
  25453. * - VertexBuffer.UVKind
  25454. * - VertexBuffer.UV2Kind
  25455. * - VertexBuffer.UV3Kind
  25456. * - VertexBuffer.UV4Kind
  25457. * - VertexBuffer.UV5Kind
  25458. * - VertexBuffer.UV6Kind
  25459. * - VertexBuffer.ColorKind
  25460. * - VertexBuffer.MatricesIndicesKind
  25461. * - VertexBuffer.MatricesIndicesExtraKind
  25462. * - VertexBuffer.MatricesWeightsKind
  25463. * - VertexBuffer.MatricesWeightsExtraKind
  25464. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25465. */
  25466. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25467. /**
  25468. * Tests if a specific vertex buffer is associated with this mesh
  25469. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25470. * - VertexBuffer.PositionKind
  25471. * - VertexBuffer.NormalKind
  25472. * - VertexBuffer.UVKind
  25473. * - VertexBuffer.UV2Kind
  25474. * - VertexBuffer.UV3Kind
  25475. * - VertexBuffer.UV4Kind
  25476. * - VertexBuffer.UV5Kind
  25477. * - VertexBuffer.UV6Kind
  25478. * - VertexBuffer.ColorKind
  25479. * - VertexBuffer.MatricesIndicesKind
  25480. * - VertexBuffer.MatricesIndicesExtraKind
  25481. * - VertexBuffer.MatricesWeightsKind
  25482. * - VertexBuffer.MatricesWeightsExtraKind
  25483. * @returns a boolean
  25484. */
  25485. isVerticesDataPresent(kind: string): boolean;
  25486. /**
  25487. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25488. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25489. * - VertexBuffer.PositionKind
  25490. * - VertexBuffer.UVKind
  25491. * - VertexBuffer.UV2Kind
  25492. * - VertexBuffer.UV3Kind
  25493. * - VertexBuffer.UV4Kind
  25494. * - VertexBuffer.UV5Kind
  25495. * - VertexBuffer.UV6Kind
  25496. * - VertexBuffer.ColorKind
  25497. * - VertexBuffer.MatricesIndicesKind
  25498. * - VertexBuffer.MatricesIndicesExtraKind
  25499. * - VertexBuffer.MatricesWeightsKind
  25500. * - VertexBuffer.MatricesWeightsExtraKind
  25501. * @returns a boolean
  25502. */
  25503. isVertexBufferUpdatable(kind: string): boolean;
  25504. /**
  25505. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25506. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25507. * - VertexBuffer.PositionKind
  25508. * - VertexBuffer.NormalKind
  25509. * - VertexBuffer.UVKind
  25510. * - VertexBuffer.UV2Kind
  25511. * - VertexBuffer.UV3Kind
  25512. * - VertexBuffer.UV4Kind
  25513. * - VertexBuffer.UV5Kind
  25514. * - VertexBuffer.UV6Kind
  25515. * - VertexBuffer.ColorKind
  25516. * - VertexBuffer.MatricesIndicesKind
  25517. * - VertexBuffer.MatricesIndicesExtraKind
  25518. * - VertexBuffer.MatricesWeightsKind
  25519. * - VertexBuffer.MatricesWeightsExtraKind
  25520. * @returns an array of strings
  25521. */
  25522. getVerticesDataKinds(): string[];
  25523. /**
  25524. * Returns a positive integer : the total number of indices in this mesh geometry.
  25525. * @returns the numner of indices or zero if the mesh has no geometry.
  25526. */
  25527. getTotalIndices(): number;
  25528. /**
  25529. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25530. * @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.
  25531. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25532. * @returns the indices array or an empty array if the mesh has no geometry
  25533. */
  25534. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25535. get isBlocked(): boolean;
  25536. /**
  25537. * Determine if the current mesh is ready to be rendered
  25538. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25539. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25540. * @returns true if all associated assets are ready (material, textures, shaders)
  25541. */
  25542. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25543. /**
  25544. * 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.
  25545. */
  25546. get areNormalsFrozen(): boolean;
  25547. /**
  25548. * 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.
  25549. * @returns the current mesh
  25550. */
  25551. freezeNormals(): Mesh;
  25552. /**
  25553. * 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
  25554. * @returns the current mesh
  25555. */
  25556. unfreezeNormals(): Mesh;
  25557. /**
  25558. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25559. */
  25560. set overridenInstanceCount(count: number);
  25561. /** @hidden */
  25562. _preActivate(): Mesh;
  25563. /** @hidden */
  25564. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25565. /** @hidden */
  25566. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25567. /**
  25568. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25569. * This means the mesh underlying bounding box and sphere are recomputed.
  25570. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25571. * @returns the current mesh
  25572. */
  25573. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25574. /** @hidden */
  25575. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25576. /**
  25577. * This function will subdivide the mesh into multiple submeshes
  25578. * @param count defines the expected number of submeshes
  25579. */
  25580. subdivide(count: number): void;
  25581. /**
  25582. * Copy a FloatArray into a specific associated vertex buffer
  25583. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25584. * - VertexBuffer.PositionKind
  25585. * - VertexBuffer.UVKind
  25586. * - VertexBuffer.UV2Kind
  25587. * - VertexBuffer.UV3Kind
  25588. * - VertexBuffer.UV4Kind
  25589. * - VertexBuffer.UV5Kind
  25590. * - VertexBuffer.UV6Kind
  25591. * - VertexBuffer.ColorKind
  25592. * - VertexBuffer.MatricesIndicesKind
  25593. * - VertexBuffer.MatricesIndicesExtraKind
  25594. * - VertexBuffer.MatricesWeightsKind
  25595. * - VertexBuffer.MatricesWeightsExtraKind
  25596. * @param data defines the data source
  25597. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25598. * @param stride defines the data stride size (can be null)
  25599. * @returns the current mesh
  25600. */
  25601. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25602. /**
  25603. * Delete a vertex buffer associated with this mesh
  25604. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25605. * - VertexBuffer.PositionKind
  25606. * - VertexBuffer.UVKind
  25607. * - VertexBuffer.UV2Kind
  25608. * - VertexBuffer.UV3Kind
  25609. * - VertexBuffer.UV4Kind
  25610. * - VertexBuffer.UV5Kind
  25611. * - VertexBuffer.UV6Kind
  25612. * - VertexBuffer.ColorKind
  25613. * - VertexBuffer.MatricesIndicesKind
  25614. * - VertexBuffer.MatricesIndicesExtraKind
  25615. * - VertexBuffer.MatricesWeightsKind
  25616. * - VertexBuffer.MatricesWeightsExtraKind
  25617. */
  25618. removeVerticesData(kind: string): void;
  25619. /**
  25620. * Flags an associated vertex buffer as updatable
  25621. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25622. * - VertexBuffer.PositionKind
  25623. * - VertexBuffer.UVKind
  25624. * - VertexBuffer.UV2Kind
  25625. * - VertexBuffer.UV3Kind
  25626. * - VertexBuffer.UV4Kind
  25627. * - VertexBuffer.UV5Kind
  25628. * - VertexBuffer.UV6Kind
  25629. * - VertexBuffer.ColorKind
  25630. * - VertexBuffer.MatricesIndicesKind
  25631. * - VertexBuffer.MatricesIndicesExtraKind
  25632. * - VertexBuffer.MatricesWeightsKind
  25633. * - VertexBuffer.MatricesWeightsExtraKind
  25634. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25635. */
  25636. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25637. /**
  25638. * Sets the mesh global Vertex Buffer
  25639. * @param buffer defines the buffer to use
  25640. * @returns the current mesh
  25641. */
  25642. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25643. /**
  25644. * Update a specific associated vertex buffer
  25645. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25646. * - VertexBuffer.PositionKind
  25647. * - VertexBuffer.UVKind
  25648. * - VertexBuffer.UV2Kind
  25649. * - VertexBuffer.UV3Kind
  25650. * - VertexBuffer.UV4Kind
  25651. * - VertexBuffer.UV5Kind
  25652. * - VertexBuffer.UV6Kind
  25653. * - VertexBuffer.ColorKind
  25654. * - VertexBuffer.MatricesIndicesKind
  25655. * - VertexBuffer.MatricesIndicesExtraKind
  25656. * - VertexBuffer.MatricesWeightsKind
  25657. * - VertexBuffer.MatricesWeightsExtraKind
  25658. * @param data defines the data source
  25659. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25660. * @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)
  25661. * @returns the current mesh
  25662. */
  25663. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25664. /**
  25665. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25666. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25667. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25668. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25669. * @returns the current mesh
  25670. */
  25671. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25672. /**
  25673. * Creates a un-shared specific occurence of the geometry for the mesh.
  25674. * @returns the current mesh
  25675. */
  25676. makeGeometryUnique(): Mesh;
  25677. /**
  25678. * Set the index buffer of this mesh
  25679. * @param indices defines the source data
  25680. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25681. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25682. * @returns the current mesh
  25683. */
  25684. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25685. /**
  25686. * Update the current index buffer
  25687. * @param indices defines the source data
  25688. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25689. * @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)
  25690. * @returns the current mesh
  25691. */
  25692. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25693. /**
  25694. * Invert the geometry to move from a right handed system to a left handed one.
  25695. * @returns the current mesh
  25696. */
  25697. toLeftHanded(): Mesh;
  25698. /** @hidden */
  25699. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25700. /** @hidden */
  25701. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25702. /**
  25703. * Registers for this mesh a javascript function called just before the rendering process
  25704. * @param func defines the function to call before rendering this mesh
  25705. * @returns the current mesh
  25706. */
  25707. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25708. /**
  25709. * Disposes a previously registered javascript function called before the rendering
  25710. * @param func defines the function to remove
  25711. * @returns the current mesh
  25712. */
  25713. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25714. /**
  25715. * Registers for this mesh a javascript function called just after the rendering is complete
  25716. * @param func defines the function to call after rendering this mesh
  25717. * @returns the current mesh
  25718. */
  25719. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25720. /**
  25721. * Disposes a previously registered javascript function called after the rendering.
  25722. * @param func defines the function to remove
  25723. * @returns the current mesh
  25724. */
  25725. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25726. /** @hidden */
  25727. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25728. /** @hidden */
  25729. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25730. /** @hidden */
  25731. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25732. /** @hidden */
  25733. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25734. /** @hidden */
  25735. _rebuild(): void;
  25736. /** @hidden */
  25737. _freeze(): void;
  25738. /** @hidden */
  25739. _unFreeze(): void;
  25740. /**
  25741. * 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
  25742. * @param subMesh defines the subMesh to render
  25743. * @param enableAlphaMode defines if alpha mode can be changed
  25744. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25745. * @returns the current mesh
  25746. */
  25747. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25748. private _onBeforeDraw;
  25749. /**
  25750. * Renormalize the mesh and patch it up if there are no weights
  25751. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25752. * However in the case of zero weights then we set just a single influence to 1.
  25753. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25754. */
  25755. cleanMatrixWeights(): void;
  25756. private normalizeSkinFourWeights;
  25757. private normalizeSkinWeightsAndExtra;
  25758. /**
  25759. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25760. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25761. * the user know there was an issue with importing the mesh
  25762. * @returns a validation object with skinned, valid and report string
  25763. */
  25764. validateSkinning(): {
  25765. skinned: boolean;
  25766. valid: boolean;
  25767. report: string;
  25768. };
  25769. /** @hidden */
  25770. _checkDelayState(): Mesh;
  25771. private _queueLoad;
  25772. /**
  25773. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25774. * A mesh is in the frustum if its bounding box intersects the frustum
  25775. * @param frustumPlanes defines the frustum to test
  25776. * @returns true if the mesh is in the frustum planes
  25777. */
  25778. isInFrustum(frustumPlanes: Plane[]): boolean;
  25779. /**
  25780. * Sets the mesh material by the material or multiMaterial `id` property
  25781. * @param id is a string identifying the material or the multiMaterial
  25782. * @returns the current mesh
  25783. */
  25784. setMaterialByID(id: string): Mesh;
  25785. /**
  25786. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25787. * @returns an array of IAnimatable
  25788. */
  25789. getAnimatables(): IAnimatable[];
  25790. /**
  25791. * Modifies the mesh geometry according to the passed transformation matrix.
  25792. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25793. * The mesh normals are modified using the same transformation.
  25794. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25795. * @param transform defines the transform matrix to use
  25796. * @see http://doc.babylonjs.com/resources/baking_transformations
  25797. * @returns the current mesh
  25798. */
  25799. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25800. /**
  25801. * Modifies the mesh geometry according to its own current World Matrix.
  25802. * The mesh World Matrix is then reset.
  25803. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25804. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25805. * @see http://doc.babylonjs.com/resources/baking_transformations
  25806. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25807. * @returns the current mesh
  25808. */
  25809. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25810. /** @hidden */
  25811. get _positions(): Nullable<Vector3[]>;
  25812. /** @hidden */
  25813. _resetPointsArrayCache(): Mesh;
  25814. /** @hidden */
  25815. _generatePointsArray(): boolean;
  25816. /**
  25817. * Returns a new Mesh object generated from the current mesh properties.
  25818. * This method must not get confused with createInstance()
  25819. * @param name is a string, the name given to the new mesh
  25820. * @param newParent can be any Node object (default `null`)
  25821. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25822. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25823. * @returns a new mesh
  25824. */
  25825. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25826. /**
  25827. * Releases resources associated with this mesh.
  25828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25830. */
  25831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25832. /** @hidden */
  25833. _disposeInstanceSpecificData(): void;
  25834. /**
  25835. * Modifies the mesh geometry according to a displacement map.
  25836. * 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.
  25837. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25838. * @param url is a string, the URL from the image file is to be downloaded.
  25839. * @param minHeight is the lower limit of the displacement.
  25840. * @param maxHeight is the upper limit of the displacement.
  25841. * @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.
  25842. * @param uvOffset is an optional vector2 used to offset UV.
  25843. * @param uvScale is an optional vector2 used to scale UV.
  25844. * @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.
  25845. * @returns the Mesh.
  25846. */
  25847. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25848. /**
  25849. * Modifies the mesh geometry according to a displacementMap buffer.
  25850. * 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.
  25851. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25852. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25853. * @param heightMapWidth is the width of the buffer image.
  25854. * @param heightMapHeight is the height of the buffer image.
  25855. * @param minHeight is the lower limit of the displacement.
  25856. * @param maxHeight is the upper limit of the displacement.
  25857. * @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.
  25858. * @param uvOffset is an optional vector2 used to offset UV.
  25859. * @param uvScale is an optional vector2 used to scale UV.
  25860. * @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.
  25861. * @returns the Mesh.
  25862. */
  25863. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25864. /**
  25865. * Modify the mesh to get a flat shading rendering.
  25866. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25867. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25868. * @returns current mesh
  25869. */
  25870. convertToFlatShadedMesh(): Mesh;
  25871. /**
  25872. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25873. * In other words, more vertices, no more indices and a single bigger VBO.
  25874. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25875. * @returns current mesh
  25876. */
  25877. convertToUnIndexedMesh(): Mesh;
  25878. /**
  25879. * Inverses facet orientations.
  25880. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25881. * @param flipNormals will also inverts the normals
  25882. * @returns current mesh
  25883. */
  25884. flipFaces(flipNormals?: boolean): Mesh;
  25885. /**
  25886. * Increase the number of facets and hence vertices in a mesh
  25887. * Vertex normals are interpolated from existing vertex normals
  25888. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25889. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25890. */
  25891. increaseVertices(numberPerEdge: number): void;
  25892. /**
  25893. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25894. * This will undo any application of covertToFlatShadedMesh
  25895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25896. */
  25897. forceSharedVertices(): void;
  25898. /** @hidden */
  25899. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25900. /** @hidden */
  25901. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25902. /**
  25903. * Creates a new InstancedMesh object from the mesh model.
  25904. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25905. * @param name defines the name of the new instance
  25906. * @returns a new InstancedMesh
  25907. */
  25908. createInstance(name: string): InstancedMesh;
  25909. /**
  25910. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25911. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25912. * @returns the current mesh
  25913. */
  25914. synchronizeInstances(): Mesh;
  25915. /**
  25916. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25917. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25918. * This should be used together with the simplification to avoid disappearing triangles.
  25919. * @param successCallback an optional success callback to be called after the optimization finished.
  25920. * @returns the current mesh
  25921. */
  25922. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25923. /**
  25924. * Serialize current mesh
  25925. * @param serializationObject defines the object which will receive the serialization data
  25926. */
  25927. serialize(serializationObject: any): void;
  25928. /** @hidden */
  25929. _syncGeometryWithMorphTargetManager(): void;
  25930. /** @hidden */
  25931. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25932. /**
  25933. * Returns a new Mesh object parsed from the source provided.
  25934. * @param parsedMesh is the source
  25935. * @param scene defines the hosting scene
  25936. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25937. * @returns a new Mesh
  25938. */
  25939. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25940. /**
  25941. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25942. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25943. * @param name defines the name of the mesh to create
  25944. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25945. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25946. * @param closePath creates a seam between the first and the last points of each path of the path array
  25947. * @param offset is taken in account only if the `pathArray` is containing a single path
  25948. * @param scene defines the hosting scene
  25949. * @param updatable defines if the mesh must be flagged as updatable
  25950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25951. * @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)
  25952. * @returns a new Mesh
  25953. */
  25954. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25955. /**
  25956. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25957. * @param name defines the name of the mesh to create
  25958. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25959. * @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
  25960. * @param scene defines the hosting scene
  25961. * @param updatable defines if the mesh must be flagged as updatable
  25962. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25963. * @returns a new Mesh
  25964. */
  25965. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25966. /**
  25967. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25968. * @param name defines the name of the mesh to create
  25969. * @param size sets the size (float) of each box side (default 1)
  25970. * @param scene defines the hosting scene
  25971. * @param updatable defines if the mesh must be flagged as updatable
  25972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25973. * @returns a new Mesh
  25974. */
  25975. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25976. /**
  25977. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25978. * @param name defines the name of the mesh to create
  25979. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25980. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25981. * @param scene defines the hosting scene
  25982. * @param updatable defines if the mesh must be flagged as updatable
  25983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25984. * @returns a new Mesh
  25985. */
  25986. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25987. /**
  25988. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25989. * @param name defines the name of the mesh to create
  25990. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25991. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25992. * @param scene defines the hosting scene
  25993. * @returns a new Mesh
  25994. */
  25995. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25996. /**
  25997. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25998. * @param name defines the name of the mesh to create
  25999. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26000. * @param diameterTop set the top cap diameter (floats, default 1)
  26001. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26002. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26003. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26004. * @param scene defines the hosting scene
  26005. * @param updatable defines if the mesh must be flagged as updatable
  26006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26007. * @returns a new Mesh
  26008. */
  26009. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26010. /**
  26011. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26012. * @param name defines the name of the mesh to create
  26013. * @param diameter sets the diameter size (float) of the torus (default 1)
  26014. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26015. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26016. * @param scene defines the hosting scene
  26017. * @param updatable defines if the mesh must be flagged as updatable
  26018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26019. * @returns a new Mesh
  26020. */
  26021. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26022. /**
  26023. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26024. * @param name defines the name of the mesh to create
  26025. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26026. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26027. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26028. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26029. * @param p the number of windings on X axis (positive integers, default 2)
  26030. * @param q the number of windings on Y axis (positive integers, default 3)
  26031. * @param scene defines the hosting scene
  26032. * @param updatable defines if the mesh must be flagged as updatable
  26033. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26034. * @returns a new Mesh
  26035. */
  26036. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26037. /**
  26038. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26039. * @param name defines the name of the mesh to create
  26040. * @param points is an array successive Vector3
  26041. * @param scene defines the hosting scene
  26042. * @param updatable defines if the mesh must be flagged as updatable
  26043. * @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).
  26044. * @returns a new Mesh
  26045. */
  26046. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26047. /**
  26048. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26049. * @param name defines the name of the mesh to create
  26050. * @param points is an array successive Vector3
  26051. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26052. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26053. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26054. * @param scene defines the hosting scene
  26055. * @param updatable defines if the mesh must be flagged as updatable
  26056. * @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)
  26057. * @returns a new Mesh
  26058. */
  26059. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26060. /**
  26061. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26062. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26063. * 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.
  26064. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26065. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26066. * Remember you can only change the shape positions, not their number when updating a polygon.
  26067. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26068. * @param name defines the name of the mesh to create
  26069. * @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
  26070. * @param scene defines the hosting scene
  26071. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26072. * @param updatable defines if the mesh must be flagged as updatable
  26073. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26074. * @param earcutInjection can be used to inject your own earcut reference
  26075. * @returns a new Mesh
  26076. */
  26077. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26078. /**
  26079. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26080. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26081. * @param name defines the name of the mesh to create
  26082. * @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
  26083. * @param depth defines the height of extrusion
  26084. * @param scene defines the hosting scene
  26085. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26086. * @param updatable defines if the mesh must be flagged as updatable
  26087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26088. * @param earcutInjection can be used to inject your own earcut reference
  26089. * @returns a new Mesh
  26090. */
  26091. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26092. /**
  26093. * Creates an extruded shape mesh.
  26094. * 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
  26095. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26096. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26097. * @param name defines the name of the mesh to create
  26098. * @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
  26099. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26100. * @param scale is the value to scale the shape
  26101. * @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
  26102. * @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
  26103. * @param scene defines the hosting scene
  26104. * @param updatable defines if the mesh must be flagged as updatable
  26105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26106. * @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)
  26107. * @returns a new Mesh
  26108. */
  26109. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26110. /**
  26111. * Creates an custom extruded shape mesh.
  26112. * The custom extrusion is a parametric shape.
  26113. * It has no predefined shape. Its final shape will depend on the input parameters.
  26114. * Please consider using the same method from the MeshBuilder class instead
  26115. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26116. * @param name defines the name of the mesh to create
  26117. * @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
  26118. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26119. * @param scaleFunction is a custom Javascript function called on each path point
  26120. * @param rotationFunction is a custom Javascript function called on each path point
  26121. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26122. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26123. * @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
  26124. * @param scene defines the hosting scene
  26125. * @param updatable defines if the mesh must be flagged as updatable
  26126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26127. * @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)
  26128. * @returns a new Mesh
  26129. */
  26130. 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;
  26131. /**
  26132. * Creates lathe mesh.
  26133. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26134. * Please consider using the same method from the MeshBuilder class instead
  26135. * @param name defines the name of the mesh to create
  26136. * @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
  26137. * @param radius is the radius value of the lathe
  26138. * @param tessellation is the side number of the lathe.
  26139. * @param scene defines the hosting scene
  26140. * @param updatable defines if the mesh must be flagged as updatable
  26141. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26142. * @returns a new Mesh
  26143. */
  26144. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26145. /**
  26146. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26147. * @param name defines the name of the mesh to create
  26148. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26149. * @param scene defines the hosting scene
  26150. * @param updatable defines if the mesh must be flagged as updatable
  26151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26152. * @returns a new Mesh
  26153. */
  26154. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26155. /**
  26156. * Creates a ground mesh.
  26157. * Please consider using the same method from the MeshBuilder class instead
  26158. * @param name defines the name of the mesh to create
  26159. * @param width set the width of the ground
  26160. * @param height set the height of the ground
  26161. * @param subdivisions sets the number of subdivisions per side
  26162. * @param scene defines the hosting scene
  26163. * @param updatable defines if the mesh must be flagged as updatable
  26164. * @returns a new Mesh
  26165. */
  26166. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26167. /**
  26168. * Creates a tiled ground mesh.
  26169. * Please consider using the same method from the MeshBuilder class instead
  26170. * @param name defines the name of the mesh to create
  26171. * @param xmin set the ground minimum X coordinate
  26172. * @param zmin set the ground minimum Y coordinate
  26173. * @param xmax set the ground maximum X coordinate
  26174. * @param zmax set the ground maximum Z coordinate
  26175. * @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
  26176. * @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
  26177. * @param scene defines the hosting scene
  26178. * @param updatable defines if the mesh must be flagged as updatable
  26179. * @returns a new Mesh
  26180. */
  26181. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26182. w: number;
  26183. h: number;
  26184. }, precision: {
  26185. w: number;
  26186. h: number;
  26187. }, scene: Scene, updatable?: boolean): Mesh;
  26188. /**
  26189. * Creates a ground mesh from a height map.
  26190. * Please consider using the same method from the MeshBuilder class instead
  26191. * @see http://doc.babylonjs.com/babylon101/height_map
  26192. * @param name defines the name of the mesh to create
  26193. * @param url sets the URL of the height map image resource
  26194. * @param width set the ground width size
  26195. * @param height set the ground height size
  26196. * @param subdivisions sets the number of subdivision per side
  26197. * @param minHeight is the minimum altitude on the ground
  26198. * @param maxHeight is the maximum altitude on the ground
  26199. * @param scene defines the hosting scene
  26200. * @param updatable defines if the mesh must be flagged as updatable
  26201. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26202. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26203. * @returns a new Mesh
  26204. */
  26205. 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;
  26206. /**
  26207. * Creates a tube mesh.
  26208. * The tube is a parametric shape.
  26209. * It has no predefined shape. Its final shape will depend on the input parameters.
  26210. * Please consider using the same method from the MeshBuilder class instead
  26211. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26212. * @param name defines the name of the mesh to create
  26213. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26214. * @param radius sets the tube radius size
  26215. * @param tessellation is the number of sides on the tubular surface
  26216. * @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
  26217. * @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
  26218. * @param scene defines the hosting scene
  26219. * @param updatable defines if the mesh must be flagged as updatable
  26220. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26221. * @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)
  26222. * @returns a new Mesh
  26223. */
  26224. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26225. (i: number, distance: number): number;
  26226. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26227. /**
  26228. * Creates a polyhedron mesh.
  26229. * Please consider using the same method from the MeshBuilder class instead.
  26230. * * 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
  26231. * * The parameter `size` (positive float, default 1) sets the polygon size
  26232. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26233. * * 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`
  26234. * * 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
  26235. * * 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)`)
  26236. * * 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
  26237. * * 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
  26238. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26239. * * If you create a double-sided mesh, you can choose what parts of 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
  26240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26241. * @param name defines the name of the mesh to create
  26242. * @param options defines the options used to create the mesh
  26243. * @param scene defines the hosting scene
  26244. * @returns a new Mesh
  26245. */
  26246. static CreatePolyhedron(name: string, options: {
  26247. type?: number;
  26248. size?: number;
  26249. sizeX?: number;
  26250. sizeY?: number;
  26251. sizeZ?: number;
  26252. custom?: any;
  26253. faceUV?: Vector4[];
  26254. faceColors?: Color4[];
  26255. updatable?: boolean;
  26256. sideOrientation?: number;
  26257. }, scene: Scene): Mesh;
  26258. /**
  26259. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26260. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26261. * * 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`)
  26262. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26263. * * 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
  26264. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26265. * * If you create a double-sided mesh, you can choose what parts of 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
  26266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26267. * @param name defines the name of the mesh
  26268. * @param options defines the options used to create the mesh
  26269. * @param scene defines the hosting scene
  26270. * @returns a new Mesh
  26271. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26272. */
  26273. static CreateIcoSphere(name: string, options: {
  26274. radius?: number;
  26275. flat?: boolean;
  26276. subdivisions?: number;
  26277. sideOrientation?: number;
  26278. updatable?: boolean;
  26279. }, scene: Scene): Mesh;
  26280. /**
  26281. * Creates a decal mesh.
  26282. * Please consider using the same method from the MeshBuilder class instead.
  26283. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26284. * @param name defines the name of the mesh
  26285. * @param sourceMesh defines the mesh receiving the decal
  26286. * @param position sets the position of the decal in world coordinates
  26287. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26288. * @param size sets the decal scaling
  26289. * @param angle sets the angle to rotate the decal
  26290. * @returns a new Mesh
  26291. */
  26292. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26293. /**
  26294. * Prepare internal position array for software CPU skinning
  26295. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26296. */
  26297. setPositionsForCPUSkinning(): Float32Array;
  26298. /**
  26299. * Prepare internal normal array for software CPU skinning
  26300. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26301. */
  26302. setNormalsForCPUSkinning(): Float32Array;
  26303. /**
  26304. * Updates the vertex buffer by applying transformation from the bones
  26305. * @param skeleton defines the skeleton to apply to current mesh
  26306. * @returns the current mesh
  26307. */
  26308. applySkeleton(skeleton: Skeleton): Mesh;
  26309. /**
  26310. * 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
  26311. * @param meshes defines the list of meshes to scan
  26312. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26313. */
  26314. static MinMax(meshes: AbstractMesh[]): {
  26315. min: Vector3;
  26316. max: Vector3;
  26317. };
  26318. /**
  26319. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26320. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26321. * @returns a vector3
  26322. */
  26323. static Center(meshesOrMinMaxVector: {
  26324. min: Vector3;
  26325. max: Vector3;
  26326. } | AbstractMesh[]): Vector3;
  26327. /**
  26328. * Merge the array of meshes into a single mesh for performance reasons.
  26329. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26330. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26331. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26332. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26333. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26334. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26335. * @returns a new mesh
  26336. */
  26337. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26338. /** @hidden */
  26339. addInstance(instance: InstancedMesh): void;
  26340. /** @hidden */
  26341. removeInstance(instance: InstancedMesh): void;
  26342. }
  26343. }
  26344. declare module "babylonjs/Cameras/camera" {
  26345. import { SmartArray } from "babylonjs/Misc/smartArray";
  26346. import { Observable } from "babylonjs/Misc/observable";
  26347. import { Nullable } from "babylonjs/types";
  26348. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26349. import { Scene } from "babylonjs/scene";
  26350. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26351. import { Node } from "babylonjs/node";
  26352. import { Mesh } from "babylonjs/Meshes/mesh";
  26353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26354. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26355. import { Viewport } from "babylonjs/Maths/math.viewport";
  26356. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26357. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26358. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26359. import { Ray } from "babylonjs/Culling/ray";
  26360. /**
  26361. * This is the base class of all the camera used in the application.
  26362. * @see http://doc.babylonjs.com/features/cameras
  26363. */
  26364. export class Camera extends Node {
  26365. /** @hidden */
  26366. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26367. /**
  26368. * This is the default projection mode used by the cameras.
  26369. * It helps recreating a feeling of perspective and better appreciate depth.
  26370. * This is the best way to simulate real life cameras.
  26371. */
  26372. static readonly PERSPECTIVE_CAMERA: number;
  26373. /**
  26374. * This helps creating camera with an orthographic mode.
  26375. * 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.
  26376. */
  26377. static readonly ORTHOGRAPHIC_CAMERA: number;
  26378. /**
  26379. * This is the default FOV mode for perspective cameras.
  26380. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26381. */
  26382. static readonly FOVMODE_VERTICAL_FIXED: number;
  26383. /**
  26384. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26385. */
  26386. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26387. /**
  26388. * This specifies ther is no need for a camera rig.
  26389. * Basically only one eye is rendered corresponding to the camera.
  26390. */
  26391. static readonly RIG_MODE_NONE: number;
  26392. /**
  26393. * Simulates a camera Rig with one blue eye and one red eye.
  26394. * This can be use with 3d blue and red glasses.
  26395. */
  26396. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26397. /**
  26398. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26399. */
  26400. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26401. /**
  26402. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26403. */
  26404. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26405. /**
  26406. * Defines that both eyes of the camera will be rendered over under each other.
  26407. */
  26408. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26409. /**
  26410. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26411. */
  26412. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26413. /**
  26414. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26415. */
  26416. static readonly RIG_MODE_VR: number;
  26417. /**
  26418. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26419. */
  26420. static readonly RIG_MODE_WEBVR: number;
  26421. /**
  26422. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26423. */
  26424. static readonly RIG_MODE_CUSTOM: number;
  26425. /**
  26426. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26427. */
  26428. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26429. /**
  26430. * Define the input manager associated with the camera.
  26431. */
  26432. inputs: CameraInputsManager<Camera>;
  26433. /** @hidden */
  26434. _position: Vector3;
  26435. /**
  26436. * Define the current local position of the camera in the scene
  26437. */
  26438. get position(): Vector3;
  26439. set position(newPosition: Vector3);
  26440. /**
  26441. * The vector the camera should consider as up.
  26442. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26443. */
  26444. upVector: Vector3;
  26445. /**
  26446. * Define the current limit on the left side for an orthographic camera
  26447. * In scene unit
  26448. */
  26449. orthoLeft: Nullable<number>;
  26450. /**
  26451. * Define the current limit on the right side for an orthographic camera
  26452. * In scene unit
  26453. */
  26454. orthoRight: Nullable<number>;
  26455. /**
  26456. * Define the current limit on the bottom side for an orthographic camera
  26457. * In scene unit
  26458. */
  26459. orthoBottom: Nullable<number>;
  26460. /**
  26461. * Define the current limit on the top side for an orthographic camera
  26462. * In scene unit
  26463. */
  26464. orthoTop: Nullable<number>;
  26465. /**
  26466. * Field Of View is set in Radians. (default is 0.8)
  26467. */
  26468. fov: number;
  26469. /**
  26470. * Define the minimum distance the camera can see from.
  26471. * This is important to note that the depth buffer are not infinite and the closer it starts
  26472. * the more your scene might encounter depth fighting issue.
  26473. */
  26474. minZ: number;
  26475. /**
  26476. * Define the maximum distance the camera can see to.
  26477. * This is important to note that the depth buffer are not infinite and the further it end
  26478. * the more your scene might encounter depth fighting issue.
  26479. */
  26480. maxZ: number;
  26481. /**
  26482. * Define the default inertia of the camera.
  26483. * This helps giving a smooth feeling to the camera movement.
  26484. */
  26485. inertia: number;
  26486. /**
  26487. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26488. */
  26489. mode: number;
  26490. /**
  26491. * Define whether the camera is intermediate.
  26492. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26493. */
  26494. isIntermediate: boolean;
  26495. /**
  26496. * Define the viewport of the camera.
  26497. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26498. */
  26499. viewport: Viewport;
  26500. /**
  26501. * Restricts the camera to viewing objects with the same layerMask.
  26502. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26503. */
  26504. layerMask: number;
  26505. /**
  26506. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26507. */
  26508. fovMode: number;
  26509. /**
  26510. * Rig mode of the camera.
  26511. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26512. * This is normally controlled byt the camera themselves as internal use.
  26513. */
  26514. cameraRigMode: number;
  26515. /**
  26516. * Defines the distance between both "eyes" in case of a RIG
  26517. */
  26518. interaxialDistance: number;
  26519. /**
  26520. * Defines if stereoscopic rendering is done side by side or over under.
  26521. */
  26522. isStereoscopicSideBySide: boolean;
  26523. /**
  26524. * 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
  26525. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26526. * else in the scene. (Eg. security camera)
  26527. *
  26528. * 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)
  26529. */
  26530. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26531. /**
  26532. * When set, the camera will render to this render target instead of the default canvas
  26533. *
  26534. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26535. */
  26536. outputRenderTarget: Nullable<RenderTargetTexture>;
  26537. /**
  26538. * Observable triggered when the camera view matrix has changed.
  26539. */
  26540. onViewMatrixChangedObservable: Observable<Camera>;
  26541. /**
  26542. * Observable triggered when the camera Projection matrix has changed.
  26543. */
  26544. onProjectionMatrixChangedObservable: Observable<Camera>;
  26545. /**
  26546. * Observable triggered when the inputs have been processed.
  26547. */
  26548. onAfterCheckInputsObservable: Observable<Camera>;
  26549. /**
  26550. * Observable triggered when reset has been called and applied to the camera.
  26551. */
  26552. onRestoreStateObservable: Observable<Camera>;
  26553. /**
  26554. * Is this camera a part of a rig system?
  26555. */
  26556. isRigCamera: boolean;
  26557. /**
  26558. * If isRigCamera set to true this will be set with the parent camera.
  26559. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26560. */
  26561. rigParent?: Camera;
  26562. /** @hidden */
  26563. _cameraRigParams: any;
  26564. /** @hidden */
  26565. _rigCameras: Camera[];
  26566. /** @hidden */
  26567. _rigPostProcess: Nullable<PostProcess>;
  26568. protected _webvrViewMatrix: Matrix;
  26569. /** @hidden */
  26570. _skipRendering: boolean;
  26571. /** @hidden */
  26572. _projectionMatrix: Matrix;
  26573. /** @hidden */
  26574. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26575. /** @hidden */
  26576. _activeMeshes: SmartArray<AbstractMesh>;
  26577. protected _globalPosition: Vector3;
  26578. /** @hidden */
  26579. _computedViewMatrix: Matrix;
  26580. private _doNotComputeProjectionMatrix;
  26581. private _transformMatrix;
  26582. private _frustumPlanes;
  26583. private _refreshFrustumPlanes;
  26584. private _storedFov;
  26585. private _stateStored;
  26586. /**
  26587. * Instantiates a new camera object.
  26588. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26589. * @see http://doc.babylonjs.com/features/cameras
  26590. * @param name Defines the name of the camera in the scene
  26591. * @param position Defines the position of the camera
  26592. * @param scene Defines the scene the camera belongs too
  26593. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26594. */
  26595. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26596. /**
  26597. * Store current camera state (fov, position, etc..)
  26598. * @returns the camera
  26599. */
  26600. storeState(): Camera;
  26601. /**
  26602. * Restores the camera state values if it has been stored. You must call storeState() first
  26603. */
  26604. protected _restoreStateValues(): boolean;
  26605. /**
  26606. * Restored camera state. You must call storeState() first.
  26607. * @returns true if restored and false otherwise
  26608. */
  26609. restoreState(): boolean;
  26610. /**
  26611. * Gets the class name of the camera.
  26612. * @returns the class name
  26613. */
  26614. getClassName(): string;
  26615. /** @hidden */
  26616. readonly _isCamera: boolean;
  26617. /**
  26618. * Gets a string representation of the camera useful for debug purpose.
  26619. * @param fullDetails Defines that a more verboe level of logging is required
  26620. * @returns the string representation
  26621. */
  26622. toString(fullDetails?: boolean): string;
  26623. /**
  26624. * Gets the current world space position of the camera.
  26625. */
  26626. get globalPosition(): Vector3;
  26627. /**
  26628. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26629. * @returns the active meshe list
  26630. */
  26631. getActiveMeshes(): SmartArray<AbstractMesh>;
  26632. /**
  26633. * Check whether a mesh is part of the current active mesh list of the camera
  26634. * @param mesh Defines the mesh to check
  26635. * @returns true if active, false otherwise
  26636. */
  26637. isActiveMesh(mesh: Mesh): boolean;
  26638. /**
  26639. * Is this camera ready to be used/rendered
  26640. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26641. * @return true if the camera is ready
  26642. */
  26643. isReady(completeCheck?: boolean): boolean;
  26644. /** @hidden */
  26645. _initCache(): void;
  26646. /** @hidden */
  26647. _updateCache(ignoreParentClass?: boolean): void;
  26648. /** @hidden */
  26649. _isSynchronized(): boolean;
  26650. /** @hidden */
  26651. _isSynchronizedViewMatrix(): boolean;
  26652. /** @hidden */
  26653. _isSynchronizedProjectionMatrix(): boolean;
  26654. /**
  26655. * Attach the input controls to a specific dom element to get the input from.
  26656. * @param element Defines the element the controls should be listened from
  26657. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26658. */
  26659. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26660. /**
  26661. * Detach the current controls from the specified dom element.
  26662. * @param element Defines the element to stop listening the inputs from
  26663. */
  26664. detachControl(element: HTMLElement): void;
  26665. /**
  26666. * Update the camera state according to the different inputs gathered during the frame.
  26667. */
  26668. update(): void;
  26669. /** @hidden */
  26670. _checkInputs(): void;
  26671. /** @hidden */
  26672. get rigCameras(): Camera[];
  26673. /**
  26674. * Gets the post process used by the rig cameras
  26675. */
  26676. get rigPostProcess(): Nullable<PostProcess>;
  26677. /**
  26678. * Internal, gets the first post proces.
  26679. * @returns the first post process to be run on this camera.
  26680. */
  26681. _getFirstPostProcess(): Nullable<PostProcess>;
  26682. private _cascadePostProcessesToRigCams;
  26683. /**
  26684. * Attach a post process to the camera.
  26685. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26686. * @param postProcess The post process to attach to the camera
  26687. * @param insertAt The position of the post process in case several of them are in use in the scene
  26688. * @returns the position the post process has been inserted at
  26689. */
  26690. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26691. /**
  26692. * Detach a post process to the camera.
  26693. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26694. * @param postProcess The post process to detach from the camera
  26695. */
  26696. detachPostProcess(postProcess: PostProcess): void;
  26697. /**
  26698. * Gets the current world matrix of the camera
  26699. */
  26700. getWorldMatrix(): Matrix;
  26701. /** @hidden */
  26702. _getViewMatrix(): Matrix;
  26703. /**
  26704. * Gets the current view matrix of the camera.
  26705. * @param force forces the camera to recompute the matrix without looking at the cached state
  26706. * @returns the view matrix
  26707. */
  26708. getViewMatrix(force?: boolean): Matrix;
  26709. /**
  26710. * Freeze the projection matrix.
  26711. * It will prevent the cache check of the camera projection compute and can speed up perf
  26712. * if no parameter of the camera are meant to change
  26713. * @param projection Defines manually a projection if necessary
  26714. */
  26715. freezeProjectionMatrix(projection?: Matrix): void;
  26716. /**
  26717. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26718. */
  26719. unfreezeProjectionMatrix(): void;
  26720. /**
  26721. * Gets the current projection matrix of the camera.
  26722. * @param force forces the camera to recompute the matrix without looking at the cached state
  26723. * @returns the projection matrix
  26724. */
  26725. getProjectionMatrix(force?: boolean): Matrix;
  26726. /**
  26727. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26728. * @returns a Matrix
  26729. */
  26730. getTransformationMatrix(): Matrix;
  26731. private _updateFrustumPlanes;
  26732. /**
  26733. * Checks if a cullable object (mesh...) is in the camera frustum
  26734. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26735. * @param target The object to check
  26736. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26737. * @returns true if the object is in frustum otherwise false
  26738. */
  26739. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26740. /**
  26741. * Checks if a cullable object (mesh...) is in the camera frustum
  26742. * Unlike isInFrustum this cheks the full bounding box
  26743. * @param target The object to check
  26744. * @returns true if the object is in frustum otherwise false
  26745. */
  26746. isCompletelyInFrustum(target: ICullable): boolean;
  26747. /**
  26748. * Gets a ray in the forward direction from the camera.
  26749. * @param length Defines the length of the ray to create
  26750. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26751. * @param origin Defines the start point of the ray which defaults to the camera position
  26752. * @returns the forward ray
  26753. */
  26754. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26755. /**
  26756. * Releases resources associated with this node.
  26757. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26758. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26759. */
  26760. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26761. /** @hidden */
  26762. _isLeftCamera: boolean;
  26763. /**
  26764. * Gets the left camera of a rig setup in case of Rigged Camera
  26765. */
  26766. get isLeftCamera(): boolean;
  26767. /** @hidden */
  26768. _isRightCamera: boolean;
  26769. /**
  26770. * Gets the right camera of a rig setup in case of Rigged Camera
  26771. */
  26772. get isRightCamera(): boolean;
  26773. /**
  26774. * Gets the left camera of a rig setup in case of Rigged Camera
  26775. */
  26776. get leftCamera(): Nullable<FreeCamera>;
  26777. /**
  26778. * Gets the right camera of a rig setup in case of Rigged Camera
  26779. */
  26780. get rightCamera(): Nullable<FreeCamera>;
  26781. /**
  26782. * Gets the left camera target of a rig setup in case of Rigged Camera
  26783. * @returns the target position
  26784. */
  26785. getLeftTarget(): Nullable<Vector3>;
  26786. /**
  26787. * Gets the right camera target of a rig setup in case of Rigged Camera
  26788. * @returns the target position
  26789. */
  26790. getRightTarget(): Nullable<Vector3>;
  26791. /**
  26792. * @hidden
  26793. */
  26794. setCameraRigMode(mode: number, rigParams: any): void;
  26795. /** @hidden */
  26796. static _setStereoscopicRigMode(camera: Camera): void;
  26797. /** @hidden */
  26798. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26799. /** @hidden */
  26800. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26801. /** @hidden */
  26802. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26803. /** @hidden */
  26804. _getVRProjectionMatrix(): Matrix;
  26805. protected _updateCameraRotationMatrix(): void;
  26806. protected _updateWebVRCameraRotationMatrix(): void;
  26807. /**
  26808. * This function MUST be overwritten by the different WebVR cameras available.
  26809. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26810. * @hidden
  26811. */
  26812. _getWebVRProjectionMatrix(): Matrix;
  26813. /**
  26814. * This function MUST be overwritten by the different WebVR cameras available.
  26815. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26816. * @hidden
  26817. */
  26818. _getWebVRViewMatrix(): Matrix;
  26819. /** @hidden */
  26820. setCameraRigParameter(name: string, value: any): void;
  26821. /**
  26822. * needs to be overridden by children so sub has required properties to be copied
  26823. * @hidden
  26824. */
  26825. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26826. /**
  26827. * May need to be overridden by children
  26828. * @hidden
  26829. */
  26830. _updateRigCameras(): void;
  26831. /** @hidden */
  26832. _setupInputs(): void;
  26833. /**
  26834. * Serialiaze the camera setup to a json represention
  26835. * @returns the JSON representation
  26836. */
  26837. serialize(): any;
  26838. /**
  26839. * Clones the current camera.
  26840. * @param name The cloned camera name
  26841. * @returns the cloned camera
  26842. */
  26843. clone(name: string): Camera;
  26844. /**
  26845. * Gets the direction of the camera relative to a given local axis.
  26846. * @param localAxis Defines the reference axis to provide a relative direction.
  26847. * @return the direction
  26848. */
  26849. getDirection(localAxis: Vector3): Vector3;
  26850. /**
  26851. * Returns the current camera absolute rotation
  26852. */
  26853. get absoluteRotation(): Quaternion;
  26854. /**
  26855. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26856. * @param localAxis Defines the reference axis to provide a relative direction.
  26857. * @param result Defines the vector to store the result in
  26858. */
  26859. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26860. /**
  26861. * Gets a camera constructor for a given camera type
  26862. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26863. * @param name The name of the camera the result will be able to instantiate
  26864. * @param scene The scene the result will construct the camera in
  26865. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26866. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26867. * @returns a factory method to construc the camera
  26868. */
  26869. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26870. /**
  26871. * Compute the world matrix of the camera.
  26872. * @returns the camera world matrix
  26873. */
  26874. computeWorldMatrix(): Matrix;
  26875. /**
  26876. * Parse a JSON and creates the camera from the parsed information
  26877. * @param parsedCamera The JSON to parse
  26878. * @param scene The scene to instantiate the camera in
  26879. * @returns the newly constructed camera
  26880. */
  26881. static Parse(parsedCamera: any, scene: Scene): Camera;
  26882. }
  26883. }
  26884. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26885. import { Nullable } from "babylonjs/types";
  26886. import { Scene } from "babylonjs/scene";
  26887. import { Vector4 } from "babylonjs/Maths/math.vector";
  26888. import { Mesh } from "babylonjs/Meshes/mesh";
  26889. /**
  26890. * Class containing static functions to help procedurally build meshes
  26891. */
  26892. export class DiscBuilder {
  26893. /**
  26894. * Creates a plane polygonal mesh. By default, this is a disc
  26895. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26896. * * 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
  26897. * * 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
  26898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26901. * @param name defines the name of the mesh
  26902. * @param options defines the options used to create the mesh
  26903. * @param scene defines the hosting scene
  26904. * @returns the plane polygonal mesh
  26905. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26906. */
  26907. static CreateDisc(name: string, options: {
  26908. radius?: number;
  26909. tessellation?: number;
  26910. arc?: number;
  26911. updatable?: boolean;
  26912. sideOrientation?: number;
  26913. frontUVs?: Vector4;
  26914. backUVs?: Vector4;
  26915. }, scene?: Nullable<Scene>): Mesh;
  26916. }
  26917. }
  26918. declare module "babylonjs/Materials/fresnelParameters" {
  26919. import { DeepImmutable } from "babylonjs/types";
  26920. import { Color3 } from "babylonjs/Maths/math.color";
  26921. /**
  26922. * Options to be used when creating a FresnelParameters.
  26923. */
  26924. export type IFresnelParametersCreationOptions = {
  26925. /**
  26926. * Define the color used on edges (grazing angle)
  26927. */
  26928. leftColor?: Color3;
  26929. /**
  26930. * Define the color used on center
  26931. */
  26932. rightColor?: Color3;
  26933. /**
  26934. * Define bias applied to computed fresnel term
  26935. */
  26936. bias?: number;
  26937. /**
  26938. * Defined the power exponent applied to fresnel term
  26939. */
  26940. power?: number;
  26941. /**
  26942. * Define if the fresnel effect is enable or not.
  26943. */
  26944. isEnabled?: boolean;
  26945. };
  26946. /**
  26947. * Serialized format for FresnelParameters.
  26948. */
  26949. export type IFresnelParametersSerialized = {
  26950. /**
  26951. * Define the color used on edges (grazing angle) [as an array]
  26952. */
  26953. leftColor: number[];
  26954. /**
  26955. * Define the color used on center [as an array]
  26956. */
  26957. rightColor: number[];
  26958. /**
  26959. * Define bias applied to computed fresnel term
  26960. */
  26961. bias: number;
  26962. /**
  26963. * Defined the power exponent applied to fresnel term
  26964. */
  26965. power?: number;
  26966. /**
  26967. * Define if the fresnel effect is enable or not.
  26968. */
  26969. isEnabled: boolean;
  26970. };
  26971. /**
  26972. * This represents all the required information to add a fresnel effect on a material:
  26973. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26974. */
  26975. export class FresnelParameters {
  26976. private _isEnabled;
  26977. /**
  26978. * Define if the fresnel effect is enable or not.
  26979. */
  26980. get isEnabled(): boolean;
  26981. set isEnabled(value: boolean);
  26982. /**
  26983. * Define the color used on edges (grazing angle)
  26984. */
  26985. leftColor: Color3;
  26986. /**
  26987. * Define the color used on center
  26988. */
  26989. rightColor: Color3;
  26990. /**
  26991. * Define bias applied to computed fresnel term
  26992. */
  26993. bias: number;
  26994. /**
  26995. * Defined the power exponent applied to fresnel term
  26996. */
  26997. power: number;
  26998. /**
  26999. * Creates a new FresnelParameters object.
  27000. *
  27001. * @param options provide your own settings to optionally to override defaults
  27002. */
  27003. constructor(options?: IFresnelParametersCreationOptions);
  27004. /**
  27005. * Clones the current fresnel and its valuues
  27006. * @returns a clone fresnel configuration
  27007. */
  27008. clone(): FresnelParameters;
  27009. /**
  27010. * Determines equality between FresnelParameters objects
  27011. * @param otherFresnelParameters defines the second operand
  27012. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27013. */
  27014. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27015. /**
  27016. * Serializes the current fresnel parameters to a JSON representation.
  27017. * @return the JSON serialization
  27018. */
  27019. serialize(): IFresnelParametersSerialized;
  27020. /**
  27021. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27022. * @param parsedFresnelParameters Define the JSON representation
  27023. * @returns the parsed parameters
  27024. */
  27025. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27026. }
  27027. }
  27028. declare module "babylonjs/Materials/pushMaterial" {
  27029. import { Nullable } from "babylonjs/types";
  27030. import { Scene } from "babylonjs/scene";
  27031. import { Matrix } from "babylonjs/Maths/math.vector";
  27032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27033. import { Mesh } from "babylonjs/Meshes/mesh";
  27034. import { Material } from "babylonjs/Materials/material";
  27035. import { Effect } from "babylonjs/Materials/effect";
  27036. /**
  27037. * Base class of materials working in push mode in babylon JS
  27038. * @hidden
  27039. */
  27040. export class PushMaterial extends Material {
  27041. protected _activeEffect: Effect;
  27042. protected _normalMatrix: Matrix;
  27043. /**
  27044. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27045. * This means that the material can keep using a previous shader while a new one is being compiled.
  27046. * This is mostly used when shader parallel compilation is supported (true by default)
  27047. */
  27048. allowShaderHotSwapping: boolean;
  27049. constructor(name: string, scene: Scene);
  27050. getEffect(): Effect;
  27051. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27052. /**
  27053. * Binds the given world matrix to the active effect
  27054. *
  27055. * @param world the matrix to bind
  27056. */
  27057. bindOnlyWorldMatrix(world: Matrix): void;
  27058. /**
  27059. * Binds the given normal matrix to the active effect
  27060. *
  27061. * @param normalMatrix the matrix to bind
  27062. */
  27063. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27064. bind(world: Matrix, mesh?: Mesh): void;
  27065. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27066. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27067. }
  27068. }
  27069. declare module "babylonjs/Materials/materialFlags" {
  27070. /**
  27071. * This groups all the flags used to control the materials channel.
  27072. */
  27073. export class MaterialFlags {
  27074. private static _DiffuseTextureEnabled;
  27075. /**
  27076. * Are diffuse textures enabled in the application.
  27077. */
  27078. static get DiffuseTextureEnabled(): boolean;
  27079. static set DiffuseTextureEnabled(value: boolean);
  27080. private static _AmbientTextureEnabled;
  27081. /**
  27082. * Are ambient textures enabled in the application.
  27083. */
  27084. static get AmbientTextureEnabled(): boolean;
  27085. static set AmbientTextureEnabled(value: boolean);
  27086. private static _OpacityTextureEnabled;
  27087. /**
  27088. * Are opacity textures enabled in the application.
  27089. */
  27090. static get OpacityTextureEnabled(): boolean;
  27091. static set OpacityTextureEnabled(value: boolean);
  27092. private static _ReflectionTextureEnabled;
  27093. /**
  27094. * Are reflection textures enabled in the application.
  27095. */
  27096. static get ReflectionTextureEnabled(): boolean;
  27097. static set ReflectionTextureEnabled(value: boolean);
  27098. private static _EmissiveTextureEnabled;
  27099. /**
  27100. * Are emissive textures enabled in the application.
  27101. */
  27102. static get EmissiveTextureEnabled(): boolean;
  27103. static set EmissiveTextureEnabled(value: boolean);
  27104. private static _SpecularTextureEnabled;
  27105. /**
  27106. * Are specular textures enabled in the application.
  27107. */
  27108. static get SpecularTextureEnabled(): boolean;
  27109. static set SpecularTextureEnabled(value: boolean);
  27110. private static _BumpTextureEnabled;
  27111. /**
  27112. * Are bump textures enabled in the application.
  27113. */
  27114. static get BumpTextureEnabled(): boolean;
  27115. static set BumpTextureEnabled(value: boolean);
  27116. private static _LightmapTextureEnabled;
  27117. /**
  27118. * Are lightmap textures enabled in the application.
  27119. */
  27120. static get LightmapTextureEnabled(): boolean;
  27121. static set LightmapTextureEnabled(value: boolean);
  27122. private static _RefractionTextureEnabled;
  27123. /**
  27124. * Are refraction textures enabled in the application.
  27125. */
  27126. static get RefractionTextureEnabled(): boolean;
  27127. static set RefractionTextureEnabled(value: boolean);
  27128. private static _ColorGradingTextureEnabled;
  27129. /**
  27130. * Are color grading textures enabled in the application.
  27131. */
  27132. static get ColorGradingTextureEnabled(): boolean;
  27133. static set ColorGradingTextureEnabled(value: boolean);
  27134. private static _FresnelEnabled;
  27135. /**
  27136. * Are fresnels enabled in the application.
  27137. */
  27138. static get FresnelEnabled(): boolean;
  27139. static set FresnelEnabled(value: boolean);
  27140. private static _ClearCoatTextureEnabled;
  27141. /**
  27142. * Are clear coat textures enabled in the application.
  27143. */
  27144. static get ClearCoatTextureEnabled(): boolean;
  27145. static set ClearCoatTextureEnabled(value: boolean);
  27146. private static _ClearCoatBumpTextureEnabled;
  27147. /**
  27148. * Are clear coat bump textures enabled in the application.
  27149. */
  27150. static get ClearCoatBumpTextureEnabled(): boolean;
  27151. static set ClearCoatBumpTextureEnabled(value: boolean);
  27152. private static _ClearCoatTintTextureEnabled;
  27153. /**
  27154. * Are clear coat tint textures enabled in the application.
  27155. */
  27156. static get ClearCoatTintTextureEnabled(): boolean;
  27157. static set ClearCoatTintTextureEnabled(value: boolean);
  27158. private static _SheenTextureEnabled;
  27159. /**
  27160. * Are sheen textures enabled in the application.
  27161. */
  27162. static get SheenTextureEnabled(): boolean;
  27163. static set SheenTextureEnabled(value: boolean);
  27164. private static _AnisotropicTextureEnabled;
  27165. /**
  27166. * Are anisotropic textures enabled in the application.
  27167. */
  27168. static get AnisotropicTextureEnabled(): boolean;
  27169. static set AnisotropicTextureEnabled(value: boolean);
  27170. private static _ThicknessTextureEnabled;
  27171. /**
  27172. * Are thickness textures enabled in the application.
  27173. */
  27174. static get ThicknessTextureEnabled(): boolean;
  27175. static set ThicknessTextureEnabled(value: boolean);
  27176. }
  27177. }
  27178. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27179. /** @hidden */
  27180. export var defaultFragmentDeclaration: {
  27181. name: string;
  27182. shader: string;
  27183. };
  27184. }
  27185. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27186. /** @hidden */
  27187. export var defaultUboDeclaration: {
  27188. name: string;
  27189. shader: string;
  27190. };
  27191. }
  27192. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27193. /** @hidden */
  27194. export var lightFragmentDeclaration: {
  27195. name: string;
  27196. shader: string;
  27197. };
  27198. }
  27199. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27200. /** @hidden */
  27201. export var lightUboDeclaration: {
  27202. name: string;
  27203. shader: string;
  27204. };
  27205. }
  27206. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27207. /** @hidden */
  27208. export var lightsFragmentFunctions: {
  27209. name: string;
  27210. shader: string;
  27211. };
  27212. }
  27213. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27214. /** @hidden */
  27215. export var shadowsFragmentFunctions: {
  27216. name: string;
  27217. shader: string;
  27218. };
  27219. }
  27220. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27221. /** @hidden */
  27222. export var fresnelFunction: {
  27223. name: string;
  27224. shader: string;
  27225. };
  27226. }
  27227. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27228. /** @hidden */
  27229. export var reflectionFunction: {
  27230. name: string;
  27231. shader: string;
  27232. };
  27233. }
  27234. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27235. /** @hidden */
  27236. export var bumpFragmentFunctions: {
  27237. name: string;
  27238. shader: string;
  27239. };
  27240. }
  27241. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27242. /** @hidden */
  27243. export var logDepthDeclaration: {
  27244. name: string;
  27245. shader: string;
  27246. };
  27247. }
  27248. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27249. /** @hidden */
  27250. export var bumpFragment: {
  27251. name: string;
  27252. shader: string;
  27253. };
  27254. }
  27255. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27256. /** @hidden */
  27257. export var depthPrePass: {
  27258. name: string;
  27259. shader: string;
  27260. };
  27261. }
  27262. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27263. /** @hidden */
  27264. export var lightFragment: {
  27265. name: string;
  27266. shader: string;
  27267. };
  27268. }
  27269. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27270. /** @hidden */
  27271. export var logDepthFragment: {
  27272. name: string;
  27273. shader: string;
  27274. };
  27275. }
  27276. declare module "babylonjs/Shaders/default.fragment" {
  27277. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27278. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27279. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27280. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27281. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27282. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27283. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27284. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27285. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27286. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27287. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27288. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27289. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27290. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27291. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27292. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27293. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27294. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27295. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27296. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27297. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27298. /** @hidden */
  27299. export var defaultPixelShader: {
  27300. name: string;
  27301. shader: string;
  27302. };
  27303. }
  27304. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27305. /** @hidden */
  27306. export var defaultVertexDeclaration: {
  27307. name: string;
  27308. shader: string;
  27309. };
  27310. }
  27311. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27312. /** @hidden */
  27313. export var bumpVertexDeclaration: {
  27314. name: string;
  27315. shader: string;
  27316. };
  27317. }
  27318. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27319. /** @hidden */
  27320. export var bumpVertex: {
  27321. name: string;
  27322. shader: string;
  27323. };
  27324. }
  27325. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27326. /** @hidden */
  27327. export var fogVertex: {
  27328. name: string;
  27329. shader: string;
  27330. };
  27331. }
  27332. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27333. /** @hidden */
  27334. export var shadowsVertex: {
  27335. name: string;
  27336. shader: string;
  27337. };
  27338. }
  27339. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27340. /** @hidden */
  27341. export var pointCloudVertex: {
  27342. name: string;
  27343. shader: string;
  27344. };
  27345. }
  27346. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27347. /** @hidden */
  27348. export var logDepthVertex: {
  27349. name: string;
  27350. shader: string;
  27351. };
  27352. }
  27353. declare module "babylonjs/Shaders/default.vertex" {
  27354. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27355. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27356. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27357. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27358. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27359. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27360. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27361. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27362. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27363. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27364. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27365. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27366. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27368. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27369. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27370. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27371. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27372. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27373. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27374. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27375. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27376. /** @hidden */
  27377. export var defaultVertexShader: {
  27378. name: string;
  27379. shader: string;
  27380. };
  27381. }
  27382. declare module "babylonjs/Materials/standardMaterial" {
  27383. import { SmartArray } from "babylonjs/Misc/smartArray";
  27384. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27385. import { Nullable } from "babylonjs/types";
  27386. import { Scene } from "babylonjs/scene";
  27387. import { Matrix } from "babylonjs/Maths/math.vector";
  27388. import { Color3 } from "babylonjs/Maths/math.color";
  27389. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27391. import { Mesh } from "babylonjs/Meshes/mesh";
  27392. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27393. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27394. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27395. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27396. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27398. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27399. import "babylonjs/Shaders/default.fragment";
  27400. import "babylonjs/Shaders/default.vertex";
  27401. /** @hidden */
  27402. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27403. MAINUV1: boolean;
  27404. MAINUV2: boolean;
  27405. DIFFUSE: boolean;
  27406. DIFFUSEDIRECTUV: number;
  27407. AMBIENT: boolean;
  27408. AMBIENTDIRECTUV: number;
  27409. OPACITY: boolean;
  27410. OPACITYDIRECTUV: number;
  27411. OPACITYRGB: boolean;
  27412. REFLECTION: boolean;
  27413. EMISSIVE: boolean;
  27414. EMISSIVEDIRECTUV: number;
  27415. SPECULAR: boolean;
  27416. SPECULARDIRECTUV: number;
  27417. BUMP: boolean;
  27418. BUMPDIRECTUV: number;
  27419. PARALLAX: boolean;
  27420. PARALLAXOCCLUSION: boolean;
  27421. SPECULAROVERALPHA: boolean;
  27422. CLIPPLANE: boolean;
  27423. CLIPPLANE2: boolean;
  27424. CLIPPLANE3: boolean;
  27425. CLIPPLANE4: boolean;
  27426. CLIPPLANE5: boolean;
  27427. CLIPPLANE6: boolean;
  27428. ALPHATEST: boolean;
  27429. DEPTHPREPASS: boolean;
  27430. ALPHAFROMDIFFUSE: boolean;
  27431. POINTSIZE: boolean;
  27432. FOG: boolean;
  27433. SPECULARTERM: boolean;
  27434. DIFFUSEFRESNEL: boolean;
  27435. OPACITYFRESNEL: boolean;
  27436. REFLECTIONFRESNEL: boolean;
  27437. REFRACTIONFRESNEL: boolean;
  27438. EMISSIVEFRESNEL: boolean;
  27439. FRESNEL: boolean;
  27440. NORMAL: boolean;
  27441. UV1: boolean;
  27442. UV2: boolean;
  27443. VERTEXCOLOR: boolean;
  27444. VERTEXALPHA: boolean;
  27445. NUM_BONE_INFLUENCERS: number;
  27446. BonesPerMesh: number;
  27447. BONETEXTURE: boolean;
  27448. INSTANCES: boolean;
  27449. GLOSSINESS: boolean;
  27450. ROUGHNESS: boolean;
  27451. EMISSIVEASILLUMINATION: boolean;
  27452. LINKEMISSIVEWITHDIFFUSE: boolean;
  27453. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27454. LIGHTMAP: boolean;
  27455. LIGHTMAPDIRECTUV: number;
  27456. OBJECTSPACE_NORMALMAP: boolean;
  27457. USELIGHTMAPASSHADOWMAP: boolean;
  27458. REFLECTIONMAP_3D: boolean;
  27459. REFLECTIONMAP_SPHERICAL: boolean;
  27460. REFLECTIONMAP_PLANAR: boolean;
  27461. REFLECTIONMAP_CUBIC: boolean;
  27462. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27463. REFLECTIONMAP_PROJECTION: boolean;
  27464. REFLECTIONMAP_SKYBOX: boolean;
  27465. REFLECTIONMAP_EXPLICIT: boolean;
  27466. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27467. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27468. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27469. INVERTCUBICMAP: boolean;
  27470. LOGARITHMICDEPTH: boolean;
  27471. REFRACTION: boolean;
  27472. REFRACTIONMAP_3D: boolean;
  27473. REFLECTIONOVERALPHA: boolean;
  27474. TWOSIDEDLIGHTING: boolean;
  27475. SHADOWFLOAT: boolean;
  27476. MORPHTARGETS: boolean;
  27477. MORPHTARGETS_NORMAL: boolean;
  27478. MORPHTARGETS_TANGENT: boolean;
  27479. MORPHTARGETS_UV: boolean;
  27480. NUM_MORPH_INFLUENCERS: number;
  27481. NONUNIFORMSCALING: boolean;
  27482. PREMULTIPLYALPHA: boolean;
  27483. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27484. ALPHABLEND: boolean;
  27485. IMAGEPROCESSING: boolean;
  27486. VIGNETTE: boolean;
  27487. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27488. VIGNETTEBLENDMODEOPAQUE: boolean;
  27489. TONEMAPPING: boolean;
  27490. TONEMAPPING_ACES: boolean;
  27491. CONTRAST: boolean;
  27492. COLORCURVES: boolean;
  27493. COLORGRADING: boolean;
  27494. COLORGRADING3D: boolean;
  27495. SAMPLER3DGREENDEPTH: boolean;
  27496. SAMPLER3DBGRMAP: boolean;
  27497. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27498. MULTIVIEW: boolean;
  27499. /**
  27500. * If the reflection texture on this material is in linear color space
  27501. * @hidden
  27502. */
  27503. IS_REFLECTION_LINEAR: boolean;
  27504. /**
  27505. * If the refraction texture on this material is in linear color space
  27506. * @hidden
  27507. */
  27508. IS_REFRACTION_LINEAR: boolean;
  27509. EXPOSURE: boolean;
  27510. constructor();
  27511. setReflectionMode(modeToEnable: string): void;
  27512. }
  27513. /**
  27514. * This is the default material used in Babylon. It is the best trade off between quality
  27515. * and performances.
  27516. * @see http://doc.babylonjs.com/babylon101/materials
  27517. */
  27518. export class StandardMaterial extends PushMaterial {
  27519. private _diffuseTexture;
  27520. /**
  27521. * The basic texture of the material as viewed under a light.
  27522. */
  27523. diffuseTexture: Nullable<BaseTexture>;
  27524. private _ambientTexture;
  27525. /**
  27526. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27527. */
  27528. ambientTexture: Nullable<BaseTexture>;
  27529. private _opacityTexture;
  27530. /**
  27531. * Define the transparency of the material from a texture.
  27532. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27533. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27534. */
  27535. opacityTexture: Nullable<BaseTexture>;
  27536. private _reflectionTexture;
  27537. /**
  27538. * Define the texture used to display the reflection.
  27539. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27540. */
  27541. reflectionTexture: Nullable<BaseTexture>;
  27542. private _emissiveTexture;
  27543. /**
  27544. * Define texture of the material as if self lit.
  27545. * This will be mixed in the final result even in the absence of light.
  27546. */
  27547. emissiveTexture: Nullable<BaseTexture>;
  27548. private _specularTexture;
  27549. /**
  27550. * Define how the color and intensity of the highlight given by the light in the material.
  27551. */
  27552. specularTexture: Nullable<BaseTexture>;
  27553. private _bumpTexture;
  27554. /**
  27555. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27556. * 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.
  27557. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27558. */
  27559. bumpTexture: Nullable<BaseTexture>;
  27560. private _lightmapTexture;
  27561. /**
  27562. * Complex lighting can be computationally expensive to compute at runtime.
  27563. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27564. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27565. */
  27566. lightmapTexture: Nullable<BaseTexture>;
  27567. private _refractionTexture;
  27568. /**
  27569. * Define the texture used to display the refraction.
  27570. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27571. */
  27572. refractionTexture: Nullable<BaseTexture>;
  27573. /**
  27574. * The color of the material lit by the environmental background lighting.
  27575. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27576. */
  27577. ambientColor: Color3;
  27578. /**
  27579. * The basic color of the material as viewed under a light.
  27580. */
  27581. diffuseColor: Color3;
  27582. /**
  27583. * Define how the color and intensity of the highlight given by the light in the material.
  27584. */
  27585. specularColor: Color3;
  27586. /**
  27587. * Define the color of the material as if self lit.
  27588. * This will be mixed in the final result even in the absence of light.
  27589. */
  27590. emissiveColor: Color3;
  27591. /**
  27592. * Defines how sharp are the highlights in the material.
  27593. * The bigger the value the sharper giving a more glossy feeling to the result.
  27594. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27595. */
  27596. specularPower: number;
  27597. private _useAlphaFromDiffuseTexture;
  27598. /**
  27599. * Does the transparency come from the diffuse texture alpha channel.
  27600. */
  27601. useAlphaFromDiffuseTexture: boolean;
  27602. private _useEmissiveAsIllumination;
  27603. /**
  27604. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27605. */
  27606. useEmissiveAsIllumination: boolean;
  27607. private _linkEmissiveWithDiffuse;
  27608. /**
  27609. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27610. * the emissive level when the final color is close to one.
  27611. */
  27612. linkEmissiveWithDiffuse: boolean;
  27613. private _useSpecularOverAlpha;
  27614. /**
  27615. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27616. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27617. */
  27618. useSpecularOverAlpha: boolean;
  27619. private _useReflectionOverAlpha;
  27620. /**
  27621. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27622. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27623. */
  27624. useReflectionOverAlpha: boolean;
  27625. private _disableLighting;
  27626. /**
  27627. * Does lights from the scene impacts this material.
  27628. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27629. */
  27630. disableLighting: boolean;
  27631. private _useObjectSpaceNormalMap;
  27632. /**
  27633. * Allows using an object space normal map (instead of tangent space).
  27634. */
  27635. useObjectSpaceNormalMap: boolean;
  27636. private _useParallax;
  27637. /**
  27638. * Is parallax enabled or not.
  27639. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27640. */
  27641. useParallax: boolean;
  27642. private _useParallaxOcclusion;
  27643. /**
  27644. * Is parallax occlusion enabled or not.
  27645. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27646. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27647. */
  27648. useParallaxOcclusion: boolean;
  27649. /**
  27650. * 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.
  27651. */
  27652. parallaxScaleBias: number;
  27653. private _roughness;
  27654. /**
  27655. * Helps to define how blurry the reflections should appears in the material.
  27656. */
  27657. roughness: number;
  27658. /**
  27659. * In case of refraction, define the value of the index of refraction.
  27660. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27661. */
  27662. indexOfRefraction: number;
  27663. /**
  27664. * Invert the refraction texture alongside the y axis.
  27665. * It can be useful with procedural textures or probe for instance.
  27666. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27667. */
  27668. invertRefractionY: boolean;
  27669. /**
  27670. * Defines the alpha limits in alpha test mode.
  27671. */
  27672. alphaCutOff: number;
  27673. private _useLightmapAsShadowmap;
  27674. /**
  27675. * In case of light mapping, define whether the map contains light or shadow informations.
  27676. */
  27677. useLightmapAsShadowmap: boolean;
  27678. private _diffuseFresnelParameters;
  27679. /**
  27680. * Define the diffuse fresnel parameters of the material.
  27681. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27682. */
  27683. diffuseFresnelParameters: FresnelParameters;
  27684. private _opacityFresnelParameters;
  27685. /**
  27686. * Define the opacity fresnel parameters of the material.
  27687. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27688. */
  27689. opacityFresnelParameters: FresnelParameters;
  27690. private _reflectionFresnelParameters;
  27691. /**
  27692. * Define the reflection fresnel parameters of the material.
  27693. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27694. */
  27695. reflectionFresnelParameters: FresnelParameters;
  27696. private _refractionFresnelParameters;
  27697. /**
  27698. * Define the refraction fresnel parameters of the material.
  27699. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27700. */
  27701. refractionFresnelParameters: FresnelParameters;
  27702. private _emissiveFresnelParameters;
  27703. /**
  27704. * Define the emissive fresnel parameters of the material.
  27705. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27706. */
  27707. emissiveFresnelParameters: FresnelParameters;
  27708. private _useReflectionFresnelFromSpecular;
  27709. /**
  27710. * If true automatically deducts the fresnels values from the material specularity.
  27711. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27712. */
  27713. useReflectionFresnelFromSpecular: boolean;
  27714. private _useGlossinessFromSpecularMapAlpha;
  27715. /**
  27716. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27717. */
  27718. useGlossinessFromSpecularMapAlpha: boolean;
  27719. private _maxSimultaneousLights;
  27720. /**
  27721. * Defines the maximum number of lights that can be used in the material
  27722. */
  27723. maxSimultaneousLights: number;
  27724. private _invertNormalMapX;
  27725. /**
  27726. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27727. */
  27728. invertNormalMapX: boolean;
  27729. private _invertNormalMapY;
  27730. /**
  27731. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27732. */
  27733. invertNormalMapY: boolean;
  27734. private _twoSidedLighting;
  27735. /**
  27736. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27737. */
  27738. twoSidedLighting: boolean;
  27739. /**
  27740. * Default configuration related to image processing available in the standard Material.
  27741. */
  27742. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27743. /**
  27744. * Gets the image processing configuration used either in this material.
  27745. */
  27746. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27747. /**
  27748. * Sets the Default image processing configuration used either in the this material.
  27749. *
  27750. * If sets to null, the scene one is in use.
  27751. */
  27752. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27753. /**
  27754. * Keep track of the image processing observer to allow dispose and replace.
  27755. */
  27756. private _imageProcessingObserver;
  27757. /**
  27758. * Attaches a new image processing configuration to the Standard Material.
  27759. * @param configuration
  27760. */
  27761. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27762. /**
  27763. * Gets wether the color curves effect is enabled.
  27764. */
  27765. get cameraColorCurvesEnabled(): boolean;
  27766. /**
  27767. * Sets wether the color curves effect is enabled.
  27768. */
  27769. set cameraColorCurvesEnabled(value: boolean);
  27770. /**
  27771. * Gets wether the color grading effect is enabled.
  27772. */
  27773. get cameraColorGradingEnabled(): boolean;
  27774. /**
  27775. * Gets wether the color grading effect is enabled.
  27776. */
  27777. set cameraColorGradingEnabled(value: boolean);
  27778. /**
  27779. * Gets wether tonemapping is enabled or not.
  27780. */
  27781. get cameraToneMappingEnabled(): boolean;
  27782. /**
  27783. * Sets wether tonemapping is enabled or not
  27784. */
  27785. set cameraToneMappingEnabled(value: boolean);
  27786. /**
  27787. * The camera exposure used on this material.
  27788. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27789. * This corresponds to a photographic exposure.
  27790. */
  27791. get cameraExposure(): number;
  27792. /**
  27793. * The camera exposure used on this material.
  27794. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27795. * This corresponds to a photographic exposure.
  27796. */
  27797. set cameraExposure(value: number);
  27798. /**
  27799. * Gets The camera contrast used on this material.
  27800. */
  27801. get cameraContrast(): number;
  27802. /**
  27803. * Sets The camera contrast used on this material.
  27804. */
  27805. set cameraContrast(value: number);
  27806. /**
  27807. * Gets the Color Grading 2D Lookup Texture.
  27808. */
  27809. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27810. /**
  27811. * Sets the Color Grading 2D Lookup Texture.
  27812. */
  27813. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27814. /**
  27815. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27816. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27817. * 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;
  27818. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27819. */
  27820. get cameraColorCurves(): Nullable<ColorCurves>;
  27821. /**
  27822. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27823. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27824. * 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;
  27825. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27826. */
  27827. set cameraColorCurves(value: Nullable<ColorCurves>);
  27828. /**
  27829. * Custom callback helping to override the default shader used in the material.
  27830. */
  27831. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27832. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27833. protected _worldViewProjectionMatrix: Matrix;
  27834. protected _globalAmbientColor: Color3;
  27835. protected _useLogarithmicDepth: boolean;
  27836. protected _rebuildInParallel: boolean;
  27837. /**
  27838. * Instantiates a new standard material.
  27839. * This is the default material used in Babylon. It is the best trade off between quality
  27840. * and performances.
  27841. * @see http://doc.babylonjs.com/babylon101/materials
  27842. * @param name Define the name of the material in the scene
  27843. * @param scene Define the scene the material belong to
  27844. */
  27845. constructor(name: string, scene: Scene);
  27846. /**
  27847. * Gets a boolean indicating that current material needs to register RTT
  27848. */
  27849. get hasRenderTargetTextures(): boolean;
  27850. /**
  27851. * Gets the current class name of the material e.g. "StandardMaterial"
  27852. * Mainly use in serialization.
  27853. * @returns the class name
  27854. */
  27855. getClassName(): string;
  27856. /**
  27857. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27858. * You can try switching to logarithmic depth.
  27859. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27860. */
  27861. get useLogarithmicDepth(): boolean;
  27862. set useLogarithmicDepth(value: boolean);
  27863. /**
  27864. * Specifies if the material will require alpha blending
  27865. * @returns a boolean specifying if alpha blending is needed
  27866. */
  27867. needAlphaBlending(): boolean;
  27868. /**
  27869. * Specifies if this material should be rendered in alpha test mode
  27870. * @returns a boolean specifying if an alpha test is needed.
  27871. */
  27872. needAlphaTesting(): boolean;
  27873. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27874. /**
  27875. * Get the texture used for alpha test purpose.
  27876. * @returns the diffuse texture in case of the standard material.
  27877. */
  27878. getAlphaTestTexture(): Nullable<BaseTexture>;
  27879. /**
  27880. * Get if the submesh is ready to be used and all its information available.
  27881. * Child classes can use it to update shaders
  27882. * @param mesh defines the mesh to check
  27883. * @param subMesh defines which submesh to check
  27884. * @param useInstances specifies that instances should be used
  27885. * @returns a boolean indicating that the submesh is ready or not
  27886. */
  27887. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27888. /**
  27889. * Builds the material UBO layouts.
  27890. * Used internally during the effect preparation.
  27891. */
  27892. buildUniformLayout(): void;
  27893. /**
  27894. * Unbinds the material from the mesh
  27895. */
  27896. unbind(): void;
  27897. /**
  27898. * Binds the submesh to this material by preparing the effect and shader to draw
  27899. * @param world defines the world transformation matrix
  27900. * @param mesh defines the mesh containing the submesh
  27901. * @param subMesh defines the submesh to bind the material to
  27902. */
  27903. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27904. /**
  27905. * Get the list of animatables in the material.
  27906. * @returns the list of animatables object used in the material
  27907. */
  27908. getAnimatables(): IAnimatable[];
  27909. /**
  27910. * Gets the active textures from the material
  27911. * @returns an array of textures
  27912. */
  27913. getActiveTextures(): BaseTexture[];
  27914. /**
  27915. * Specifies if the material uses a texture
  27916. * @param texture defines the texture to check against the material
  27917. * @returns a boolean specifying if the material uses the texture
  27918. */
  27919. hasTexture(texture: BaseTexture): boolean;
  27920. /**
  27921. * Disposes the material
  27922. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27923. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27924. */
  27925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27926. /**
  27927. * Makes a duplicate of the material, and gives it a new name
  27928. * @param name defines the new name for the duplicated material
  27929. * @returns the cloned material
  27930. */
  27931. clone(name: string): StandardMaterial;
  27932. /**
  27933. * Serializes this material in a JSON representation
  27934. * @returns the serialized material object
  27935. */
  27936. serialize(): any;
  27937. /**
  27938. * Creates a standard material from parsed material data
  27939. * @param source defines the JSON representation of the material
  27940. * @param scene defines the hosting scene
  27941. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27942. * @returns a new standard material
  27943. */
  27944. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27945. /**
  27946. * Are diffuse textures enabled in the application.
  27947. */
  27948. static get DiffuseTextureEnabled(): boolean;
  27949. static set DiffuseTextureEnabled(value: boolean);
  27950. /**
  27951. * Are ambient textures enabled in the application.
  27952. */
  27953. static get AmbientTextureEnabled(): boolean;
  27954. static set AmbientTextureEnabled(value: boolean);
  27955. /**
  27956. * Are opacity textures enabled in the application.
  27957. */
  27958. static get OpacityTextureEnabled(): boolean;
  27959. static set OpacityTextureEnabled(value: boolean);
  27960. /**
  27961. * Are reflection textures enabled in the application.
  27962. */
  27963. static get ReflectionTextureEnabled(): boolean;
  27964. static set ReflectionTextureEnabled(value: boolean);
  27965. /**
  27966. * Are emissive textures enabled in the application.
  27967. */
  27968. static get EmissiveTextureEnabled(): boolean;
  27969. static set EmissiveTextureEnabled(value: boolean);
  27970. /**
  27971. * Are specular textures enabled in the application.
  27972. */
  27973. static get SpecularTextureEnabled(): boolean;
  27974. static set SpecularTextureEnabled(value: boolean);
  27975. /**
  27976. * Are bump textures enabled in the application.
  27977. */
  27978. static get BumpTextureEnabled(): boolean;
  27979. static set BumpTextureEnabled(value: boolean);
  27980. /**
  27981. * Are lightmap textures enabled in the application.
  27982. */
  27983. static get LightmapTextureEnabled(): boolean;
  27984. static set LightmapTextureEnabled(value: boolean);
  27985. /**
  27986. * Are refraction textures enabled in the application.
  27987. */
  27988. static get RefractionTextureEnabled(): boolean;
  27989. static set RefractionTextureEnabled(value: boolean);
  27990. /**
  27991. * Are color grading textures enabled in the application.
  27992. */
  27993. static get ColorGradingTextureEnabled(): boolean;
  27994. static set ColorGradingTextureEnabled(value: boolean);
  27995. /**
  27996. * Are fresnels enabled in the application.
  27997. */
  27998. static get FresnelEnabled(): boolean;
  27999. static set FresnelEnabled(value: boolean);
  28000. }
  28001. }
  28002. declare module "babylonjs/Particles/solidParticleSystem" {
  28003. import { Nullable } from "babylonjs/types";
  28004. import { Vector3 } from "babylonjs/Maths/math.vector";
  28005. import { Mesh } from "babylonjs/Meshes/mesh";
  28006. import { Scene, IDisposable } from "babylonjs/scene";
  28007. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  28008. import { Material } from "babylonjs/Materials/material";
  28009. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28010. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28011. /**
  28012. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28013. *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.
  28014. * The SPS is also a particle system. It provides some methods to manage the particles.
  28015. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28016. *
  28017. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28018. */
  28019. export class SolidParticleSystem implements IDisposable {
  28020. /**
  28021. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28022. * Example : var p = SPS.particles[i];
  28023. */
  28024. particles: SolidParticle[];
  28025. /**
  28026. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28027. */
  28028. nbParticles: number;
  28029. /**
  28030. * If the particles must ever face the camera (default false). Useful for planar particles.
  28031. */
  28032. billboard: boolean;
  28033. /**
  28034. * Recompute normals when adding a shape
  28035. */
  28036. recomputeNormals: boolean;
  28037. /**
  28038. * This a counter ofr your own usage. It's not set by any SPS functions.
  28039. */
  28040. counter: number;
  28041. /**
  28042. * The SPS name. This name is also given to the underlying mesh.
  28043. */
  28044. name: string;
  28045. /**
  28046. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28047. */
  28048. mesh: Mesh;
  28049. /**
  28050. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28051. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28052. */
  28053. vars: any;
  28054. /**
  28055. * This array is populated when the SPS is set as 'pickable'.
  28056. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28057. * Each element of this array is an object `{idx: int, faceId: int}`.
  28058. * `idx` is the picked particle index in the `SPS.particles` array
  28059. * `faceId` is the picked face index counted within this particle.
  28060. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28061. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28062. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28063. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28064. */
  28065. pickedParticles: {
  28066. idx: number;
  28067. faceId: number;
  28068. }[];
  28069. /**
  28070. * This array is populated when the SPS is set as 'pickable'
  28071. * Each key of this array is a submesh index.
  28072. * Each element of this array is a second array defined like this :
  28073. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28074. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28075. * `idx` is the picked particle index in the `SPS.particles` array
  28076. * `faceId` is the picked face index counted within this particle.
  28077. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28078. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28079. */
  28080. pickedBySubMesh: {
  28081. idx: number;
  28082. faceId: number;
  28083. }[][];
  28084. /**
  28085. * This array is populated when `enableDepthSort` is set to true.
  28086. * Each element of this array is an instance of the class DepthSortedParticle.
  28087. */
  28088. depthSortedParticles: DepthSortedParticle[];
  28089. /**
  28090. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28091. * @hidden
  28092. */
  28093. _bSphereOnly: boolean;
  28094. /**
  28095. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28096. * @hidden
  28097. */
  28098. _bSphereRadiusFactor: number;
  28099. private _scene;
  28100. private _positions;
  28101. private _indices;
  28102. private _normals;
  28103. private _colors;
  28104. private _uvs;
  28105. private _indices32;
  28106. private _positions32;
  28107. private _normals32;
  28108. private _fixedNormal32;
  28109. private _colors32;
  28110. private _uvs32;
  28111. private _index;
  28112. private _updatable;
  28113. private _pickable;
  28114. private _isVisibilityBoxLocked;
  28115. private _alwaysVisible;
  28116. private _depthSort;
  28117. private _expandable;
  28118. private _shapeCounter;
  28119. private _copy;
  28120. private _color;
  28121. private _computeParticleColor;
  28122. private _computeParticleTexture;
  28123. private _computeParticleRotation;
  28124. private _computeParticleVertex;
  28125. private _computeBoundingBox;
  28126. private _depthSortParticles;
  28127. private _camera;
  28128. private _mustUnrotateFixedNormals;
  28129. private _particlesIntersect;
  28130. private _needs32Bits;
  28131. private _isNotBuilt;
  28132. private _lastParticleId;
  28133. private _idxOfId;
  28134. private _multimaterialEnabled;
  28135. private _useModelMaterial;
  28136. private _indicesByMaterial;
  28137. private _materialIndexes;
  28138. private _depthSortFunction;
  28139. private _materialSortFunction;
  28140. private _materials;
  28141. private _multimaterial;
  28142. private _materialIndexesById;
  28143. private _defaultMaterial;
  28144. private _autoUpdateSubMeshes;
  28145. /**
  28146. * Creates a SPS (Solid Particle System) object.
  28147. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28148. * @param scene (Scene) is the scene in which the SPS is added.
  28149. * @param options defines the options of the sps e.g.
  28150. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28151. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28152. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28153. * * 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.
  28154. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28155. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28156. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28157. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28158. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28159. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28160. */
  28161. constructor(name: string, scene: Scene, options?: {
  28162. updatable?: boolean;
  28163. isPickable?: boolean;
  28164. enableDepthSort?: boolean;
  28165. particleIntersection?: boolean;
  28166. boundingSphereOnly?: boolean;
  28167. bSphereRadiusFactor?: number;
  28168. expandable?: boolean;
  28169. useModelMaterial?: boolean;
  28170. enableMultiMaterial?: boolean;
  28171. });
  28172. /**
  28173. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28174. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28175. * @returns the created mesh
  28176. */
  28177. buildMesh(): Mesh;
  28178. /**
  28179. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28180. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28181. * Thus the particles generated from `digest()` have their property `position` set yet.
  28182. * @param mesh ( Mesh ) is the mesh to be digested
  28183. * @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
  28184. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28185. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28186. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28187. * @returns the current SPS
  28188. */
  28189. digest(mesh: Mesh, options?: {
  28190. facetNb?: number;
  28191. number?: number;
  28192. delta?: number;
  28193. storage?: [];
  28194. }): SolidParticleSystem;
  28195. /**
  28196. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28197. * @hidden
  28198. */
  28199. private _unrotateFixedNormals;
  28200. /**
  28201. * Resets the temporary working copy particle
  28202. * @hidden
  28203. */
  28204. private _resetCopy;
  28205. /**
  28206. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28207. * @param p the current index in the positions array to be updated
  28208. * @param ind the current index in the indices array
  28209. * @param shape a Vector3 array, the shape geometry
  28210. * @param positions the positions array to be updated
  28211. * @param meshInd the shape indices array
  28212. * @param indices the indices array to be updated
  28213. * @param meshUV the shape uv array
  28214. * @param uvs the uv array to be updated
  28215. * @param meshCol the shape color array
  28216. * @param colors the color array to be updated
  28217. * @param meshNor the shape normals array
  28218. * @param normals the normals array to be updated
  28219. * @param idx the particle index
  28220. * @param idxInShape the particle index in its shape
  28221. * @param options the addShape() method passed options
  28222. * @model the particle model
  28223. * @hidden
  28224. */
  28225. private _meshBuilder;
  28226. /**
  28227. * Returns a shape Vector3 array from positions float array
  28228. * @param positions float array
  28229. * @returns a vector3 array
  28230. * @hidden
  28231. */
  28232. private _posToShape;
  28233. /**
  28234. * Returns a shapeUV array from a float uvs (array deep copy)
  28235. * @param uvs as a float array
  28236. * @returns a shapeUV array
  28237. * @hidden
  28238. */
  28239. private _uvsToShapeUV;
  28240. /**
  28241. * Adds a new particle object in the particles array
  28242. * @param idx particle index in particles array
  28243. * @param id particle id
  28244. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28245. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28246. * @param model particle ModelShape object
  28247. * @param shapeId model shape identifier
  28248. * @param idxInShape index of the particle in the current model
  28249. * @param bInfo model bounding info object
  28250. * @param storage target storage array, if any
  28251. * @hidden
  28252. */
  28253. private _addParticle;
  28254. /**
  28255. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28256. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28257. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28258. * @param nb (positive integer) the number of particles to be created from this model
  28259. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28260. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28261. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28262. * @returns the number of shapes in the system
  28263. */
  28264. addShape(mesh: Mesh, nb: number, options?: {
  28265. positionFunction?: any;
  28266. vertexFunction?: any;
  28267. storage?: [];
  28268. }): number;
  28269. /**
  28270. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28271. * @hidden
  28272. */
  28273. private _rebuildParticle;
  28274. /**
  28275. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28276. * @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.
  28277. * @returns the SPS.
  28278. */
  28279. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28280. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28281. * Returns an array with the removed particles.
  28282. * 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.
  28283. * The SPS can't be empty so at least one particle needs to remain in place.
  28284. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28285. * @param start index of the first particle to remove
  28286. * @param end index of the last particle to remove (included)
  28287. * @returns an array populated with the removed particles
  28288. */
  28289. removeParticles(start: number, end: number): SolidParticle[];
  28290. /**
  28291. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28292. * @param solidParticleArray an array populated with Solid Particles objects
  28293. * @returns the SPS
  28294. */
  28295. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28296. /**
  28297. * Creates a new particle and modifies the SPS mesh geometry :
  28298. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28299. * - calls _addParticle() to populate the particle array
  28300. * factorized code from addShape() and insertParticlesFromArray()
  28301. * @param idx particle index in the particles array
  28302. * @param i particle index in its shape
  28303. * @param modelShape particle ModelShape object
  28304. * @param shape shape vertex array
  28305. * @param meshInd shape indices array
  28306. * @param meshUV shape uv array
  28307. * @param meshCol shape color array
  28308. * @param meshNor shape normals array
  28309. * @param bbInfo shape bounding info
  28310. * @param storage target particle storage
  28311. * @options addShape() passed options
  28312. * @hidden
  28313. */
  28314. private _insertNewParticle;
  28315. /**
  28316. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28317. * This method calls `updateParticle()` for each particle of the SPS.
  28318. * For an animated SPS, it is usually called within the render loop.
  28319. * 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.
  28320. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28321. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28322. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28323. * @returns the SPS.
  28324. */
  28325. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28326. /**
  28327. * Disposes the SPS.
  28328. */
  28329. dispose(): void;
  28330. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28331. * idx is the particle index in the SPS
  28332. * faceId is the picked face index counted within this particle.
  28333. * Returns null if the pickInfo can't identify a picked particle.
  28334. * @param pickingInfo (PickingInfo object)
  28335. * @returns {idx: number, faceId: number} or null
  28336. */
  28337. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28338. idx: number;
  28339. faceId: number;
  28340. }>;
  28341. /**
  28342. * Returns a SolidParticle object from its identifier : particle.id
  28343. * @param id (integer) the particle Id
  28344. * @returns the searched particle or null if not found in the SPS.
  28345. */
  28346. getParticleById(id: number): Nullable<SolidParticle>;
  28347. /**
  28348. * Returns a new array populated with the particles having the passed shapeId.
  28349. * @param shapeId (integer) the shape identifier
  28350. * @returns a new solid particle array
  28351. */
  28352. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28353. /**
  28354. * Populates the passed array "ref" with the particles having the passed shapeId.
  28355. * @param shapeId the shape identifier
  28356. * @returns the SPS
  28357. * @param ref
  28358. */
  28359. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28360. /**
  28361. * Computes the required SubMeshes according the materials assigned to the particles.
  28362. * @returns the solid particle system.
  28363. * Does nothing if called before the SPS mesh is built.
  28364. */
  28365. computeSubMeshes(): SolidParticleSystem;
  28366. /**
  28367. * Sorts the solid particles by material when MultiMaterial is enabled.
  28368. * Updates the indices32 array.
  28369. * Updates the indicesByMaterial array.
  28370. * Updates the mesh indices array.
  28371. * @returns the SPS
  28372. * @hidden
  28373. */
  28374. private _sortParticlesByMaterial;
  28375. /**
  28376. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28377. * @hidden
  28378. */
  28379. private _setMaterialIndexesById;
  28380. /**
  28381. * Returns an array with unique values of Materials from the passed array
  28382. * @param array the material array to be checked and filtered
  28383. * @hidden
  28384. */
  28385. private _filterUniqueMaterialId;
  28386. /**
  28387. * Sets a new Standard Material as _defaultMaterial if not already set.
  28388. * @hidden
  28389. */
  28390. private _setDefaultMaterial;
  28391. /**
  28392. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28393. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28394. * @returns the SPS.
  28395. */
  28396. refreshVisibleSize(): SolidParticleSystem;
  28397. /**
  28398. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28399. * @param size the size (float) of the visibility box
  28400. * note : this doesn't lock the SPS mesh bounding box.
  28401. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28402. */
  28403. setVisibilityBox(size: number): void;
  28404. /**
  28405. * Gets whether the SPS as always visible or not
  28406. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28407. */
  28408. get isAlwaysVisible(): boolean;
  28409. /**
  28410. * Sets the SPS as always visible or not
  28411. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28412. */
  28413. set isAlwaysVisible(val: boolean);
  28414. /**
  28415. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28416. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28417. */
  28418. set isVisibilityBoxLocked(val: boolean);
  28419. /**
  28420. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28421. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28422. */
  28423. get isVisibilityBoxLocked(): boolean;
  28424. /**
  28425. * Tells to `setParticles()` to compute the particle rotations or not.
  28426. * Default value : true. The SPS is faster when it's set to false.
  28427. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28428. */
  28429. set computeParticleRotation(val: boolean);
  28430. /**
  28431. * Tells to `setParticles()` to compute the particle colors or not.
  28432. * Default value : true. The SPS is faster when it's set to false.
  28433. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28434. */
  28435. set computeParticleColor(val: boolean);
  28436. set computeParticleTexture(val: boolean);
  28437. /**
  28438. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28439. * Default value : false. The SPS is faster when it's set to false.
  28440. * Note : the particle custom vertex positions aren't stored values.
  28441. */
  28442. set computeParticleVertex(val: boolean);
  28443. /**
  28444. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28445. */
  28446. set computeBoundingBox(val: boolean);
  28447. /**
  28448. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28449. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28450. * Default : `true`
  28451. */
  28452. set depthSortParticles(val: boolean);
  28453. /**
  28454. * Gets if `setParticles()` computes the particle rotations or not.
  28455. * Default value : true. The SPS is faster when it's set to false.
  28456. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28457. */
  28458. get computeParticleRotation(): boolean;
  28459. /**
  28460. * Gets if `setParticles()` computes the particle colors or not.
  28461. * Default value : true. The SPS is faster when it's set to false.
  28462. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28463. */
  28464. get computeParticleColor(): boolean;
  28465. /**
  28466. * Gets if `setParticles()` computes the particle textures or not.
  28467. * Default value : true. The SPS is faster when it's set to false.
  28468. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28469. */
  28470. get computeParticleTexture(): boolean;
  28471. /**
  28472. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28473. * Default value : false. The SPS is faster when it's set to false.
  28474. * Note : the particle custom vertex positions aren't stored values.
  28475. */
  28476. get computeParticleVertex(): boolean;
  28477. /**
  28478. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28479. */
  28480. get computeBoundingBox(): boolean;
  28481. /**
  28482. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28483. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28484. * Default : `true`
  28485. */
  28486. get depthSortParticles(): boolean;
  28487. /**
  28488. * Gets if the SPS is created as expandable at construction time.
  28489. * Default : `false`
  28490. */
  28491. get expandable(): boolean;
  28492. /**
  28493. * Gets if the SPS supports the Multi Materials
  28494. */
  28495. get multimaterialEnabled(): boolean;
  28496. /**
  28497. * Gets if the SPS uses the model materials for its own multimaterial.
  28498. */
  28499. get useModelMaterial(): boolean;
  28500. /**
  28501. * The SPS used material array.
  28502. */
  28503. get materials(): Material[];
  28504. /**
  28505. * Sets the SPS MultiMaterial from the passed materials.
  28506. * Note : the passed array is internally copied and not used then by reference.
  28507. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28508. */
  28509. setMultiMaterial(materials: Material[]): void;
  28510. /**
  28511. * The SPS computed multimaterial object
  28512. */
  28513. get multimaterial(): MultiMaterial;
  28514. set multimaterial(mm: MultiMaterial);
  28515. /**
  28516. * If the subMeshes must be updated on the next call to setParticles()
  28517. */
  28518. get autoUpdateSubMeshes(): boolean;
  28519. set autoUpdateSubMeshes(val: boolean);
  28520. /**
  28521. * This function does nothing. It may be overwritten to set all the particle first values.
  28522. * The SPS doesn't call this function, you may have to call it by your own.
  28523. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28524. */
  28525. initParticles(): void;
  28526. /**
  28527. * This function does nothing. It may be overwritten to recycle a particle.
  28528. * The SPS doesn't call this function, you may have to call it by your own.
  28529. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28530. * @param particle The particle to recycle
  28531. * @returns the recycled particle
  28532. */
  28533. recycleParticle(particle: SolidParticle): SolidParticle;
  28534. /**
  28535. * Updates a particle : this function should be overwritten by the user.
  28536. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28537. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28538. * @example : just set a particle position or velocity and recycle conditions
  28539. * @param particle The particle to update
  28540. * @returns the updated particle
  28541. */
  28542. updateParticle(particle: SolidParticle): SolidParticle;
  28543. /**
  28544. * Updates a vertex of a particle : it can be overwritten by the user.
  28545. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28546. * @param particle the current particle
  28547. * @param vertex the current index of the current particle
  28548. * @param pt the index of the current vertex in the particle shape
  28549. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28550. * @example : just set a vertex particle position
  28551. * @returns the updated vertex
  28552. */
  28553. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28554. /**
  28555. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28556. * This does nothing and may be overwritten by the user.
  28557. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28558. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28559. * @param update the boolean update value actually passed to setParticles()
  28560. */
  28561. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28562. /**
  28563. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28564. * This will be passed three parameters.
  28565. * This does nothing and may be overwritten by the user.
  28566. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28567. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28568. * @param update the boolean update value actually passed to setParticles()
  28569. */
  28570. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28571. }
  28572. }
  28573. declare module "babylonjs/Particles/solidParticle" {
  28574. import { Nullable } from "babylonjs/types";
  28575. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28576. import { Color4 } from "babylonjs/Maths/math.color";
  28577. import { Mesh } from "babylonjs/Meshes/mesh";
  28578. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28579. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28580. import { Plane } from "babylonjs/Maths/math.plane";
  28581. import { Material } from "babylonjs/Materials/material";
  28582. /**
  28583. * Represents one particle of a solid particle system.
  28584. */
  28585. export class SolidParticle {
  28586. /**
  28587. * particle global index
  28588. */
  28589. idx: number;
  28590. /**
  28591. * particle identifier
  28592. */
  28593. id: number;
  28594. /**
  28595. * The color of the particle
  28596. */
  28597. color: Nullable<Color4>;
  28598. /**
  28599. * The world space position of the particle.
  28600. */
  28601. position: Vector3;
  28602. /**
  28603. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28604. */
  28605. rotation: Vector3;
  28606. /**
  28607. * The world space rotation quaternion of the particle.
  28608. */
  28609. rotationQuaternion: Nullable<Quaternion>;
  28610. /**
  28611. * The scaling of the particle.
  28612. */
  28613. scaling: Vector3;
  28614. /**
  28615. * The uvs of the particle.
  28616. */
  28617. uvs: Vector4;
  28618. /**
  28619. * The current speed of the particle.
  28620. */
  28621. velocity: Vector3;
  28622. /**
  28623. * The pivot point in the particle local space.
  28624. */
  28625. pivot: Vector3;
  28626. /**
  28627. * Must the particle be translated from its pivot point in its local space ?
  28628. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28629. * Default : false
  28630. */
  28631. translateFromPivot: boolean;
  28632. /**
  28633. * Is the particle active or not ?
  28634. */
  28635. alive: boolean;
  28636. /**
  28637. * Is the particle visible or not ?
  28638. */
  28639. isVisible: boolean;
  28640. /**
  28641. * Index of this particle in the global "positions" array (Internal use)
  28642. * @hidden
  28643. */
  28644. _pos: number;
  28645. /**
  28646. * @hidden Index of this particle in the global "indices" array (Internal use)
  28647. */
  28648. _ind: number;
  28649. /**
  28650. * @hidden ModelShape of this particle (Internal use)
  28651. */
  28652. _model: ModelShape;
  28653. /**
  28654. * ModelShape id of this particle
  28655. */
  28656. shapeId: number;
  28657. /**
  28658. * Index of the particle in its shape id
  28659. */
  28660. idxInShape: number;
  28661. /**
  28662. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28663. */
  28664. _modelBoundingInfo: BoundingInfo;
  28665. /**
  28666. * @hidden Particle BoundingInfo object (Internal use)
  28667. */
  28668. _boundingInfo: BoundingInfo;
  28669. /**
  28670. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28671. */
  28672. _sps: SolidParticleSystem;
  28673. /**
  28674. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28675. */
  28676. _stillInvisible: boolean;
  28677. /**
  28678. * @hidden Last computed particle rotation matrix
  28679. */
  28680. _rotationMatrix: number[];
  28681. /**
  28682. * Parent particle Id, if any.
  28683. * Default null.
  28684. */
  28685. parentId: Nullable<number>;
  28686. /**
  28687. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28688. */
  28689. materialIndex: Nullable<number>;
  28690. /**
  28691. * Custom object or properties.
  28692. */
  28693. props: Nullable<any>;
  28694. /**
  28695. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28696. * The possible values are :
  28697. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28698. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28699. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28700. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28701. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28702. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28703. * */
  28704. cullingStrategy: number;
  28705. /**
  28706. * @hidden Internal global position in the SPS.
  28707. */
  28708. _globalPosition: Vector3;
  28709. /**
  28710. * Creates a Solid Particle object.
  28711. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28712. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28713. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28714. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28715. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28716. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28717. * @param shapeId (integer) is the model shape identifier in the SPS.
  28718. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28719. * @param sps defines the sps it is associated to
  28720. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28721. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28722. */
  28723. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28724. /**
  28725. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28726. * @param target the particle target
  28727. * @returns the current particle
  28728. */
  28729. copyToRef(target: SolidParticle): SolidParticle;
  28730. /**
  28731. * Legacy support, changed scale to scaling
  28732. */
  28733. get scale(): Vector3;
  28734. /**
  28735. * Legacy support, changed scale to scaling
  28736. */
  28737. set scale(scale: Vector3);
  28738. /**
  28739. * Legacy support, changed quaternion to rotationQuaternion
  28740. */
  28741. get quaternion(): Nullable<Quaternion>;
  28742. /**
  28743. * Legacy support, changed quaternion to rotationQuaternion
  28744. */
  28745. set quaternion(q: Nullable<Quaternion>);
  28746. /**
  28747. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28748. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28749. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28750. * @returns true if it intersects
  28751. */
  28752. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28753. /**
  28754. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28755. * A particle is in the frustum if its bounding box intersects the frustum
  28756. * @param frustumPlanes defines the frustum to test
  28757. * @returns true if the particle is in the frustum planes
  28758. */
  28759. isInFrustum(frustumPlanes: Plane[]): boolean;
  28760. /**
  28761. * get the rotation matrix of the particle
  28762. * @hidden
  28763. */
  28764. getRotationMatrix(m: Matrix): void;
  28765. }
  28766. /**
  28767. * Represents the shape of the model used by one particle of a solid particle system.
  28768. * SPS internal tool, don't use it manually.
  28769. */
  28770. export class ModelShape {
  28771. /**
  28772. * The shape id
  28773. * @hidden
  28774. */
  28775. shapeID: number;
  28776. /**
  28777. * flat array of model positions (internal use)
  28778. * @hidden
  28779. */
  28780. _shape: Vector3[];
  28781. /**
  28782. * flat array of model UVs (internal use)
  28783. * @hidden
  28784. */
  28785. _shapeUV: number[];
  28786. /**
  28787. * color array of the model
  28788. * @hidden
  28789. */
  28790. _shapeColors: number[];
  28791. /**
  28792. * indices array of the model
  28793. * @hidden
  28794. */
  28795. _indices: number[];
  28796. /**
  28797. * normals array of the model
  28798. * @hidden
  28799. */
  28800. _normals: number[];
  28801. /**
  28802. * length of the shape in the model indices array (internal use)
  28803. * @hidden
  28804. */
  28805. _indicesLength: number;
  28806. /**
  28807. * Custom position function (internal use)
  28808. * @hidden
  28809. */
  28810. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28811. /**
  28812. * Custom vertex function (internal use)
  28813. * @hidden
  28814. */
  28815. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28816. /**
  28817. * Model material (internal use)
  28818. * @hidden
  28819. */
  28820. _material: Nullable<Material>;
  28821. /**
  28822. * 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.
  28823. * SPS internal tool, don't use it manually.
  28824. * @hidden
  28825. */
  28826. 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>);
  28827. }
  28828. /**
  28829. * Represents a Depth Sorted Particle in the solid particle system.
  28830. * @hidden
  28831. */
  28832. export class DepthSortedParticle {
  28833. /**
  28834. * Particle index
  28835. */
  28836. idx: number;
  28837. /**
  28838. * Index of the particle in the "indices" array
  28839. */
  28840. ind: number;
  28841. /**
  28842. * Length of the particle shape in the "indices" array
  28843. */
  28844. indicesLength: number;
  28845. /**
  28846. * Squared distance from the particle to the camera
  28847. */
  28848. sqDistance: number;
  28849. /**
  28850. * Material index when used with MultiMaterials
  28851. */
  28852. materialIndex: number;
  28853. /**
  28854. * Creates a new sorted particle
  28855. * @param materialIndex
  28856. */
  28857. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28858. }
  28859. }
  28860. declare module "babylonjs/Collisions/meshCollisionData" {
  28861. import { Collider } from "babylonjs/Collisions/collider";
  28862. import { Vector3 } from "babylonjs/Maths/math.vector";
  28863. import { Nullable } from "babylonjs/types";
  28864. import { Observer } from "babylonjs/Misc/observable";
  28865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28866. /**
  28867. * @hidden
  28868. */
  28869. export class _MeshCollisionData {
  28870. _checkCollisions: boolean;
  28871. _collisionMask: number;
  28872. _collisionGroup: number;
  28873. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28874. _collider: Nullable<Collider>;
  28875. _oldPositionForCollisions: Vector3;
  28876. _diffPositionForCollisions: Vector3;
  28877. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28878. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28879. }
  28880. }
  28881. declare module "babylonjs/Meshes/abstractMesh" {
  28882. import { Observable } from "babylonjs/Misc/observable";
  28883. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28884. import { Camera } from "babylonjs/Cameras/camera";
  28885. import { Scene, IDisposable } from "babylonjs/scene";
  28886. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28887. import { Node } from "babylonjs/node";
  28888. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28889. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28890. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28891. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28892. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28893. import { Material } from "babylonjs/Materials/material";
  28894. import { Light } from "babylonjs/Lights/light";
  28895. import { Skeleton } from "babylonjs/Bones/skeleton";
  28896. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28897. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28898. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28899. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28900. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28901. import { Plane } from "babylonjs/Maths/math.plane";
  28902. import { Ray } from "babylonjs/Culling/ray";
  28903. import { Collider } from "babylonjs/Collisions/collider";
  28904. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28905. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28906. /** @hidden */
  28907. class _FacetDataStorage {
  28908. facetPositions: Vector3[];
  28909. facetNormals: Vector3[];
  28910. facetPartitioning: number[][];
  28911. facetNb: number;
  28912. partitioningSubdivisions: number;
  28913. partitioningBBoxRatio: number;
  28914. facetDataEnabled: boolean;
  28915. facetParameters: any;
  28916. bbSize: Vector3;
  28917. subDiv: {
  28918. max: number;
  28919. X: number;
  28920. Y: number;
  28921. Z: number;
  28922. };
  28923. facetDepthSort: boolean;
  28924. facetDepthSortEnabled: boolean;
  28925. depthSortedIndices: IndicesArray;
  28926. depthSortedFacets: {
  28927. ind: number;
  28928. sqDistance: number;
  28929. }[];
  28930. facetDepthSortFunction: (f1: {
  28931. ind: number;
  28932. sqDistance: number;
  28933. }, f2: {
  28934. ind: number;
  28935. sqDistance: number;
  28936. }) => number;
  28937. facetDepthSortFrom: Vector3;
  28938. facetDepthSortOrigin: Vector3;
  28939. invertedMatrix: Matrix;
  28940. }
  28941. /**
  28942. * @hidden
  28943. **/
  28944. class _InternalAbstractMeshDataInfo {
  28945. _hasVertexAlpha: boolean;
  28946. _useVertexColors: boolean;
  28947. _numBoneInfluencers: number;
  28948. _applyFog: boolean;
  28949. _receiveShadows: boolean;
  28950. _facetData: _FacetDataStorage;
  28951. _visibility: number;
  28952. _skeleton: Nullable<Skeleton>;
  28953. _layerMask: number;
  28954. _computeBonesUsingShaders: boolean;
  28955. _isActive: boolean;
  28956. _onlyForInstances: boolean;
  28957. _isActiveIntermediate: boolean;
  28958. _onlyForInstancesIntermediate: boolean;
  28959. _actAsRegularMesh: boolean;
  28960. }
  28961. /**
  28962. * Class used to store all common mesh properties
  28963. */
  28964. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28965. /** No occlusion */
  28966. static OCCLUSION_TYPE_NONE: number;
  28967. /** Occlusion set to optimisitic */
  28968. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28969. /** Occlusion set to strict */
  28970. static OCCLUSION_TYPE_STRICT: number;
  28971. /** Use an accurante occlusion algorithm */
  28972. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28973. /** Use a conservative occlusion algorithm */
  28974. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28975. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28976. * Test order :
  28977. * Is the bounding sphere outside the frustum ?
  28978. * If not, are the bounding box vertices outside the frustum ?
  28979. * It not, then the cullable object is in the frustum.
  28980. */
  28981. static readonly CULLINGSTRATEGY_STANDARD: number;
  28982. /** Culling strategy : Bounding Sphere Only.
  28983. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28984. * It's also less accurate than the standard because some not visible objects can still be selected.
  28985. * Test : is the bounding sphere outside the frustum ?
  28986. * If not, then the cullable object is in the frustum.
  28987. */
  28988. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28989. /** Culling strategy : Optimistic Inclusion.
  28990. * This in an inclusion test first, then the standard exclusion test.
  28991. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28992. * 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.
  28993. * Anyway, it's as accurate as the standard strategy.
  28994. * Test :
  28995. * Is the cullable object bounding sphere center in the frustum ?
  28996. * If not, apply the default culling strategy.
  28997. */
  28998. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28999. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29000. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29001. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29002. * 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.
  29003. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29004. * Test :
  29005. * Is the cullable object bounding sphere center in the frustum ?
  29006. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29007. */
  29008. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29009. /**
  29010. * No billboard
  29011. */
  29012. static get BILLBOARDMODE_NONE(): number;
  29013. /** Billboard on X axis */
  29014. static get BILLBOARDMODE_X(): number;
  29015. /** Billboard on Y axis */
  29016. static get BILLBOARDMODE_Y(): number;
  29017. /** Billboard on Z axis */
  29018. static get BILLBOARDMODE_Z(): number;
  29019. /** Billboard on all axes */
  29020. static get BILLBOARDMODE_ALL(): number;
  29021. /** Billboard on using position instead of orientation */
  29022. static get BILLBOARDMODE_USE_POSITION(): number;
  29023. /** @hidden */
  29024. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29025. /**
  29026. * The culling strategy to use to check whether the mesh must be rendered or not.
  29027. * This value can be changed at any time and will be used on the next render mesh selection.
  29028. * The possible values are :
  29029. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29030. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29031. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29032. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29033. * Please read each static variable documentation to get details about the culling process.
  29034. * */
  29035. cullingStrategy: number;
  29036. /**
  29037. * Gets the number of facets in the mesh
  29038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29039. */
  29040. get facetNb(): number;
  29041. /**
  29042. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29043. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29044. */
  29045. get partitioningSubdivisions(): number;
  29046. set partitioningSubdivisions(nb: number);
  29047. /**
  29048. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29049. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29051. */
  29052. get partitioningBBoxRatio(): number;
  29053. set partitioningBBoxRatio(ratio: number);
  29054. /**
  29055. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29056. * Works only for updatable meshes.
  29057. * Doesn't work with multi-materials
  29058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29059. */
  29060. get mustDepthSortFacets(): boolean;
  29061. set mustDepthSortFacets(sort: boolean);
  29062. /**
  29063. * The location (Vector3) where the facet depth sort must be computed from.
  29064. * By default, the active camera position.
  29065. * Used only when facet depth sort is enabled
  29066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29067. */
  29068. get facetDepthSortFrom(): Vector3;
  29069. set facetDepthSortFrom(location: Vector3);
  29070. /**
  29071. * gets a boolean indicating if facetData is enabled
  29072. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29073. */
  29074. get isFacetDataEnabled(): boolean;
  29075. /** @hidden */
  29076. _updateNonUniformScalingState(value: boolean): boolean;
  29077. /**
  29078. * An event triggered when this mesh collides with another one
  29079. */
  29080. onCollideObservable: Observable<AbstractMesh>;
  29081. /** Set a function to call when this mesh collides with another one */
  29082. set onCollide(callback: () => void);
  29083. /**
  29084. * An event triggered when the collision's position changes
  29085. */
  29086. onCollisionPositionChangeObservable: Observable<Vector3>;
  29087. /** Set a function to call when the collision's position changes */
  29088. set onCollisionPositionChange(callback: () => void);
  29089. /**
  29090. * An event triggered when material is changed
  29091. */
  29092. onMaterialChangedObservable: Observable<AbstractMesh>;
  29093. /**
  29094. * Gets or sets the orientation for POV movement & rotation
  29095. */
  29096. definedFacingForward: boolean;
  29097. /** @hidden */
  29098. _occlusionQuery: Nullable<WebGLQuery>;
  29099. /** @hidden */
  29100. _renderingGroup: Nullable<RenderingGroup>;
  29101. /**
  29102. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29103. */
  29104. get visibility(): number;
  29105. /**
  29106. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29107. */
  29108. set visibility(value: number);
  29109. /** Gets or sets the alpha index used to sort transparent meshes
  29110. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29111. */
  29112. alphaIndex: number;
  29113. /**
  29114. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29115. */
  29116. isVisible: boolean;
  29117. /**
  29118. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29119. */
  29120. isPickable: boolean;
  29121. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29122. showSubMeshesBoundingBox: boolean;
  29123. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29124. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29125. */
  29126. isBlocker: boolean;
  29127. /**
  29128. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29129. */
  29130. enablePointerMoveEvents: boolean;
  29131. /**
  29132. * Specifies the rendering group id for this mesh (0 by default)
  29133. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29134. */
  29135. renderingGroupId: number;
  29136. private _material;
  29137. /** Gets or sets current material */
  29138. get material(): Nullable<Material>;
  29139. set material(value: Nullable<Material>);
  29140. /**
  29141. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29142. * @see http://doc.babylonjs.com/babylon101/shadows
  29143. */
  29144. get receiveShadows(): boolean;
  29145. set receiveShadows(value: boolean);
  29146. /** Defines color to use when rendering outline */
  29147. outlineColor: Color3;
  29148. /** Define width to use when rendering outline */
  29149. outlineWidth: number;
  29150. /** Defines color to use when rendering overlay */
  29151. overlayColor: Color3;
  29152. /** Defines alpha to use when rendering overlay */
  29153. overlayAlpha: number;
  29154. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29155. get hasVertexAlpha(): boolean;
  29156. set hasVertexAlpha(value: boolean);
  29157. /** 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) */
  29158. get useVertexColors(): boolean;
  29159. set useVertexColors(value: boolean);
  29160. /**
  29161. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29162. */
  29163. get computeBonesUsingShaders(): boolean;
  29164. set computeBonesUsingShaders(value: boolean);
  29165. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29166. get numBoneInfluencers(): number;
  29167. set numBoneInfluencers(value: number);
  29168. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29169. get applyFog(): boolean;
  29170. set applyFog(value: boolean);
  29171. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29172. useOctreeForRenderingSelection: boolean;
  29173. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29174. useOctreeForPicking: boolean;
  29175. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29176. useOctreeForCollisions: boolean;
  29177. /**
  29178. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29179. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29180. */
  29181. get layerMask(): number;
  29182. set layerMask(value: number);
  29183. /**
  29184. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29185. */
  29186. alwaysSelectAsActiveMesh: boolean;
  29187. /**
  29188. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29189. */
  29190. doNotSyncBoundingInfo: boolean;
  29191. /**
  29192. * Gets or sets the current action manager
  29193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29194. */
  29195. actionManager: Nullable<AbstractActionManager>;
  29196. private _meshCollisionData;
  29197. /**
  29198. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29199. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29200. */
  29201. ellipsoid: Vector3;
  29202. /**
  29203. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29204. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29205. */
  29206. ellipsoidOffset: Vector3;
  29207. /**
  29208. * Gets or sets a collision mask used to mask collisions (default is -1).
  29209. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29210. */
  29211. get collisionMask(): number;
  29212. set collisionMask(mask: number);
  29213. /**
  29214. * Gets or sets the current collision group mask (-1 by default).
  29215. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29216. */
  29217. get collisionGroup(): number;
  29218. set collisionGroup(mask: number);
  29219. /**
  29220. * Gets or sets current surrounding meshes (null by default).
  29221. *
  29222. * By default collision detection is tested against every mesh in the scene.
  29223. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29224. * meshes will be tested for the collision.
  29225. *
  29226. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29227. */
  29228. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29229. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29230. /**
  29231. * Defines edge width used when edgesRenderer is enabled
  29232. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29233. */
  29234. edgesWidth: number;
  29235. /**
  29236. * Defines edge color used when edgesRenderer is enabled
  29237. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29238. */
  29239. edgesColor: Color4;
  29240. /** @hidden */
  29241. _edgesRenderer: Nullable<IEdgesRenderer>;
  29242. /** @hidden */
  29243. _masterMesh: Nullable<AbstractMesh>;
  29244. /** @hidden */
  29245. _boundingInfo: Nullable<BoundingInfo>;
  29246. /** @hidden */
  29247. _renderId: number;
  29248. /**
  29249. * Gets or sets the list of subMeshes
  29250. * @see http://doc.babylonjs.com/how_to/multi_materials
  29251. */
  29252. subMeshes: SubMesh[];
  29253. /** @hidden */
  29254. _intersectionsInProgress: AbstractMesh[];
  29255. /** @hidden */
  29256. _unIndexed: boolean;
  29257. /** @hidden */
  29258. _lightSources: Light[];
  29259. /** Gets the list of lights affecting that mesh */
  29260. get lightSources(): Light[];
  29261. /** @hidden */
  29262. get _positions(): Nullable<Vector3[]>;
  29263. /** @hidden */
  29264. _waitingData: {
  29265. lods: Nullable<any>;
  29266. actions: Nullable<any>;
  29267. freezeWorldMatrix: Nullable<boolean>;
  29268. };
  29269. /** @hidden */
  29270. _bonesTransformMatrices: Nullable<Float32Array>;
  29271. /** @hidden */
  29272. _transformMatrixTexture: Nullable<RawTexture>;
  29273. /**
  29274. * Gets or sets a skeleton to apply skining transformations
  29275. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29276. */
  29277. set skeleton(value: Nullable<Skeleton>);
  29278. get skeleton(): Nullable<Skeleton>;
  29279. /**
  29280. * An event triggered when the mesh is rebuilt.
  29281. */
  29282. onRebuildObservable: Observable<AbstractMesh>;
  29283. /**
  29284. * Creates a new AbstractMesh
  29285. * @param name defines the name of the mesh
  29286. * @param scene defines the hosting scene
  29287. */
  29288. constructor(name: string, scene?: Nullable<Scene>);
  29289. /**
  29290. * Returns the string "AbstractMesh"
  29291. * @returns "AbstractMesh"
  29292. */
  29293. getClassName(): string;
  29294. /**
  29295. * Gets a string representation of the current mesh
  29296. * @param fullDetails defines a boolean indicating if full details must be included
  29297. * @returns a string representation of the current mesh
  29298. */
  29299. toString(fullDetails?: boolean): string;
  29300. /**
  29301. * @hidden
  29302. */
  29303. protected _getEffectiveParent(): Nullable<Node>;
  29304. /** @hidden */
  29305. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29306. /** @hidden */
  29307. _rebuild(): void;
  29308. /** @hidden */
  29309. _resyncLightSources(): void;
  29310. /** @hidden */
  29311. _resyncLightSource(light: Light): void;
  29312. /** @hidden */
  29313. _unBindEffect(): void;
  29314. /** @hidden */
  29315. _removeLightSource(light: Light, dispose: boolean): void;
  29316. private _markSubMeshesAsDirty;
  29317. /** @hidden */
  29318. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29319. /** @hidden */
  29320. _markSubMeshesAsAttributesDirty(): void;
  29321. /** @hidden */
  29322. _markSubMeshesAsMiscDirty(): void;
  29323. /**
  29324. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29325. */
  29326. get scaling(): Vector3;
  29327. set scaling(newScaling: Vector3);
  29328. /**
  29329. * Returns true if the mesh is blocked. Implemented by child classes
  29330. */
  29331. get isBlocked(): boolean;
  29332. /**
  29333. * Returns the mesh itself by default. Implemented by child classes
  29334. * @param camera defines the camera to use to pick the right LOD level
  29335. * @returns the currentAbstractMesh
  29336. */
  29337. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29338. /**
  29339. * Returns 0 by default. Implemented by child classes
  29340. * @returns an integer
  29341. */
  29342. getTotalVertices(): number;
  29343. /**
  29344. * Returns a positive integer : the total number of indices in this mesh geometry.
  29345. * @returns the numner of indices or zero if the mesh has no geometry.
  29346. */
  29347. getTotalIndices(): number;
  29348. /**
  29349. * Returns null by default. Implemented by child classes
  29350. * @returns null
  29351. */
  29352. getIndices(): Nullable<IndicesArray>;
  29353. /**
  29354. * Returns the array of the requested vertex data kind. Implemented by child classes
  29355. * @param kind defines the vertex data kind to use
  29356. * @returns null
  29357. */
  29358. getVerticesData(kind: string): Nullable<FloatArray>;
  29359. /**
  29360. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29361. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29362. * Note that a new underlying VertexBuffer object is created each call.
  29363. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29364. * @param kind defines vertex data kind:
  29365. * * VertexBuffer.PositionKind
  29366. * * VertexBuffer.UVKind
  29367. * * VertexBuffer.UV2Kind
  29368. * * VertexBuffer.UV3Kind
  29369. * * VertexBuffer.UV4Kind
  29370. * * VertexBuffer.UV5Kind
  29371. * * VertexBuffer.UV6Kind
  29372. * * VertexBuffer.ColorKind
  29373. * * VertexBuffer.MatricesIndicesKind
  29374. * * VertexBuffer.MatricesIndicesExtraKind
  29375. * * VertexBuffer.MatricesWeightsKind
  29376. * * VertexBuffer.MatricesWeightsExtraKind
  29377. * @param data defines the data source
  29378. * @param updatable defines if the data must be flagged as updatable (or static)
  29379. * @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
  29380. * @returns the current mesh
  29381. */
  29382. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29383. /**
  29384. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29385. * If the mesh has no geometry, it is simply returned as it is.
  29386. * @param kind defines vertex data kind:
  29387. * * VertexBuffer.PositionKind
  29388. * * VertexBuffer.UVKind
  29389. * * VertexBuffer.UV2Kind
  29390. * * VertexBuffer.UV3Kind
  29391. * * VertexBuffer.UV4Kind
  29392. * * VertexBuffer.UV5Kind
  29393. * * VertexBuffer.UV6Kind
  29394. * * VertexBuffer.ColorKind
  29395. * * VertexBuffer.MatricesIndicesKind
  29396. * * VertexBuffer.MatricesIndicesExtraKind
  29397. * * VertexBuffer.MatricesWeightsKind
  29398. * * VertexBuffer.MatricesWeightsExtraKind
  29399. * @param data defines the data source
  29400. * @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
  29401. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29402. * @returns the current mesh
  29403. */
  29404. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29405. /**
  29406. * Sets the mesh indices,
  29407. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29408. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29409. * @param totalVertices Defines the total number of vertices
  29410. * @returns the current mesh
  29411. */
  29412. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29413. /**
  29414. * Gets a boolean indicating if specific vertex data is present
  29415. * @param kind defines the vertex data kind to use
  29416. * @returns true is data kind is present
  29417. */
  29418. isVerticesDataPresent(kind: string): boolean;
  29419. /**
  29420. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29421. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29422. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29423. * @returns a BoundingInfo
  29424. */
  29425. getBoundingInfo(): BoundingInfo;
  29426. /**
  29427. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29428. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29429. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29430. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29431. * @returns the current mesh
  29432. */
  29433. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29434. /**
  29435. * Overwrite the current bounding info
  29436. * @param boundingInfo defines the new bounding info
  29437. * @returns the current mesh
  29438. */
  29439. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29440. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29441. get useBones(): boolean;
  29442. /** @hidden */
  29443. _preActivate(): void;
  29444. /** @hidden */
  29445. _preActivateForIntermediateRendering(renderId: number): void;
  29446. /** @hidden */
  29447. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29448. /** @hidden */
  29449. _postActivate(): void;
  29450. /** @hidden */
  29451. _freeze(): void;
  29452. /** @hidden */
  29453. _unFreeze(): void;
  29454. /**
  29455. * Gets the current world matrix
  29456. * @returns a Matrix
  29457. */
  29458. getWorldMatrix(): Matrix;
  29459. /** @hidden */
  29460. _getWorldMatrixDeterminant(): number;
  29461. /**
  29462. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29463. */
  29464. get isAnInstance(): boolean;
  29465. /**
  29466. * Gets a boolean indicating if this mesh has instances
  29467. */
  29468. get hasInstances(): boolean;
  29469. /**
  29470. * Perform relative position change from the point of view of behind the front of the mesh.
  29471. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29472. * Supports definition of mesh facing forward or backward
  29473. * @param amountRight defines the distance on the right axis
  29474. * @param amountUp defines the distance on the up axis
  29475. * @param amountForward defines the distance on the forward axis
  29476. * @returns the current mesh
  29477. */
  29478. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29479. /**
  29480. * Calculate relative position change from the point of view of behind the front of the mesh.
  29481. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29482. * Supports definition of mesh facing forward or backward
  29483. * @param amountRight defines the distance on the right axis
  29484. * @param amountUp defines the distance on the up axis
  29485. * @param amountForward defines the distance on the forward axis
  29486. * @returns the new displacement vector
  29487. */
  29488. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29489. /**
  29490. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29491. * Supports definition of mesh facing forward or backward
  29492. * @param flipBack defines the flip
  29493. * @param twirlClockwise defines the twirl
  29494. * @param tiltRight defines the tilt
  29495. * @returns the current mesh
  29496. */
  29497. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29498. /**
  29499. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29500. * Supports definition of mesh facing forward or backward.
  29501. * @param flipBack defines the flip
  29502. * @param twirlClockwise defines the twirl
  29503. * @param tiltRight defines the tilt
  29504. * @returns the new rotation vector
  29505. */
  29506. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29507. /**
  29508. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29509. * This means the mesh underlying bounding box and sphere are recomputed.
  29510. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29511. * @returns the current mesh
  29512. */
  29513. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29514. /** @hidden */
  29515. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29516. /** @hidden */
  29517. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29518. /** @hidden */
  29519. _updateBoundingInfo(): AbstractMesh;
  29520. /** @hidden */
  29521. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29522. /** @hidden */
  29523. protected _afterComputeWorldMatrix(): void;
  29524. /** @hidden */
  29525. get _effectiveMesh(): AbstractMesh;
  29526. /**
  29527. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29528. * A mesh is in the frustum if its bounding box intersects the frustum
  29529. * @param frustumPlanes defines the frustum to test
  29530. * @returns true if the mesh is in the frustum planes
  29531. */
  29532. isInFrustum(frustumPlanes: Plane[]): boolean;
  29533. /**
  29534. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29535. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29536. * @param frustumPlanes defines the frustum to test
  29537. * @returns true if the mesh is completely in the frustum planes
  29538. */
  29539. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29540. /**
  29541. * True if the mesh intersects another mesh or a SolidParticle object
  29542. * @param mesh defines a target mesh or SolidParticle to test
  29543. * @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)
  29544. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29545. * @returns true if there is an intersection
  29546. */
  29547. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29548. /**
  29549. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29550. * @param point defines the point to test
  29551. * @returns true if there is an intersection
  29552. */
  29553. intersectsPoint(point: Vector3): boolean;
  29554. /**
  29555. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29556. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29557. */
  29558. get checkCollisions(): boolean;
  29559. set checkCollisions(collisionEnabled: boolean);
  29560. /**
  29561. * Gets Collider object used to compute collisions (not physics)
  29562. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29563. */
  29564. get collider(): Nullable<Collider>;
  29565. /**
  29566. * Move the mesh using collision engine
  29567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29568. * @param displacement defines the requested displacement vector
  29569. * @returns the current mesh
  29570. */
  29571. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29572. private _onCollisionPositionChange;
  29573. /** @hidden */
  29574. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29575. /** @hidden */
  29576. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29577. /** @hidden */
  29578. _checkCollision(collider: Collider): AbstractMesh;
  29579. /** @hidden */
  29580. _generatePointsArray(): boolean;
  29581. /**
  29582. * Checks if the passed Ray intersects with the mesh
  29583. * @param ray defines the ray to use
  29584. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29585. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29586. * @returns the picking info
  29587. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29588. */
  29589. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29590. /**
  29591. * Clones the current mesh
  29592. * @param name defines the mesh name
  29593. * @param newParent defines the new mesh parent
  29594. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29595. * @returns the new mesh
  29596. */
  29597. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29598. /**
  29599. * Disposes all the submeshes of the current meshnp
  29600. * @returns the current mesh
  29601. */
  29602. releaseSubMeshes(): AbstractMesh;
  29603. /**
  29604. * Releases resources associated with this abstract mesh.
  29605. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29606. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29607. */
  29608. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29609. /**
  29610. * Adds the passed mesh as a child to the current mesh
  29611. * @param mesh defines the child mesh
  29612. * @returns the current mesh
  29613. */
  29614. addChild(mesh: AbstractMesh): AbstractMesh;
  29615. /**
  29616. * Removes the passed mesh from the current mesh children list
  29617. * @param mesh defines the child mesh
  29618. * @returns the current mesh
  29619. */
  29620. removeChild(mesh: AbstractMesh): AbstractMesh;
  29621. /** @hidden */
  29622. private _initFacetData;
  29623. /**
  29624. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29625. * This method can be called within the render loop.
  29626. * 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
  29627. * @returns the current mesh
  29628. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29629. */
  29630. updateFacetData(): AbstractMesh;
  29631. /**
  29632. * Returns the facetLocalNormals array.
  29633. * The normals are expressed in the mesh local spac
  29634. * @returns an array of Vector3
  29635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29636. */
  29637. getFacetLocalNormals(): Vector3[];
  29638. /**
  29639. * Returns the facetLocalPositions array.
  29640. * The facet positions are expressed in the mesh local space
  29641. * @returns an array of Vector3
  29642. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29643. */
  29644. getFacetLocalPositions(): Vector3[];
  29645. /**
  29646. * Returns the facetLocalPartioning array
  29647. * @returns an array of array of numbers
  29648. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29649. */
  29650. getFacetLocalPartitioning(): number[][];
  29651. /**
  29652. * Returns the i-th facet position in the world system.
  29653. * This method allocates a new Vector3 per call
  29654. * @param i defines the facet index
  29655. * @returns a new Vector3
  29656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29657. */
  29658. getFacetPosition(i: number): Vector3;
  29659. /**
  29660. * Sets the reference Vector3 with the i-th facet position in the world system
  29661. * @param i defines the facet index
  29662. * @param ref defines the target vector
  29663. * @returns the current mesh
  29664. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29665. */
  29666. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29667. /**
  29668. * Returns the i-th facet normal in the world system.
  29669. * This method allocates a new Vector3 per call
  29670. * @param i defines the facet index
  29671. * @returns a new Vector3
  29672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29673. */
  29674. getFacetNormal(i: number): Vector3;
  29675. /**
  29676. * Sets the reference Vector3 with the i-th facet normal in the world system
  29677. * @param i defines the facet index
  29678. * @param ref defines the target vector
  29679. * @returns the current mesh
  29680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29681. */
  29682. getFacetNormalToRef(i: number, ref: Vector3): this;
  29683. /**
  29684. * 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)
  29685. * @param x defines x coordinate
  29686. * @param y defines y coordinate
  29687. * @param z defines z coordinate
  29688. * @returns the array of facet indexes
  29689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29690. */
  29691. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29692. /**
  29693. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29694. * @param projected sets as the (x,y,z) world projection on the facet
  29695. * @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
  29696. * @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
  29697. * @param x defines x coordinate
  29698. * @param y defines y coordinate
  29699. * @param z defines z coordinate
  29700. * @returns the face index if found (or null instead)
  29701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29702. */
  29703. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29704. /**
  29705. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29706. * @param projected sets as the (x,y,z) local projection on the facet
  29707. * @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
  29708. * @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
  29709. * @param x defines x coordinate
  29710. * @param y defines y coordinate
  29711. * @param z defines z coordinate
  29712. * @returns the face index if found (or null instead)
  29713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29714. */
  29715. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29716. /**
  29717. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29718. * @returns the parameters
  29719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29720. */
  29721. getFacetDataParameters(): any;
  29722. /**
  29723. * Disables the feature FacetData and frees the related memory
  29724. * @returns the current mesh
  29725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29726. */
  29727. disableFacetData(): AbstractMesh;
  29728. /**
  29729. * Updates the AbstractMesh indices array
  29730. * @param indices defines the data source
  29731. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29732. * @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)
  29733. * @returns the current mesh
  29734. */
  29735. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29736. /**
  29737. * Creates new normals data for the mesh
  29738. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29739. * @returns the current mesh
  29740. */
  29741. createNormals(updatable: boolean): AbstractMesh;
  29742. /**
  29743. * Align the mesh with a normal
  29744. * @param normal defines the normal to use
  29745. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29746. * @returns the current mesh
  29747. */
  29748. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29749. /** @hidden */
  29750. _checkOcclusionQuery(): boolean;
  29751. /**
  29752. * Disables the mesh edge rendering mode
  29753. * @returns the currentAbstractMesh
  29754. */
  29755. disableEdgesRendering(): AbstractMesh;
  29756. /**
  29757. * Enables the edge rendering mode on the mesh.
  29758. * This mode makes the mesh edges visible
  29759. * @param epsilon defines the maximal distance between two angles to detect a face
  29760. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29761. * @returns the currentAbstractMesh
  29762. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29763. */
  29764. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29765. }
  29766. }
  29767. declare module "babylonjs/Actions/actionEvent" {
  29768. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29769. import { Nullable } from "babylonjs/types";
  29770. import { Sprite } from "babylonjs/Sprites/sprite";
  29771. import { Scene } from "babylonjs/scene";
  29772. import { Vector2 } from "babylonjs/Maths/math.vector";
  29773. /**
  29774. * Interface used to define ActionEvent
  29775. */
  29776. export interface IActionEvent {
  29777. /** The mesh or sprite that triggered the action */
  29778. source: any;
  29779. /** The X mouse cursor position at the time of the event */
  29780. pointerX: number;
  29781. /** The Y mouse cursor position at the time of the event */
  29782. pointerY: number;
  29783. /** The mesh that is currently pointed at (can be null) */
  29784. meshUnderPointer: Nullable<AbstractMesh>;
  29785. /** the original (browser) event that triggered the ActionEvent */
  29786. sourceEvent?: any;
  29787. /** additional data for the event */
  29788. additionalData?: any;
  29789. }
  29790. /**
  29791. * ActionEvent is the event being sent when an action is triggered.
  29792. */
  29793. export class ActionEvent implements IActionEvent {
  29794. /** The mesh or sprite that triggered the action */
  29795. source: any;
  29796. /** The X mouse cursor position at the time of the event */
  29797. pointerX: number;
  29798. /** The Y mouse cursor position at the time of the event */
  29799. pointerY: number;
  29800. /** The mesh that is currently pointed at (can be null) */
  29801. meshUnderPointer: Nullable<AbstractMesh>;
  29802. /** the original (browser) event that triggered the ActionEvent */
  29803. sourceEvent?: any;
  29804. /** additional data for the event */
  29805. additionalData?: any;
  29806. /**
  29807. * Creates a new ActionEvent
  29808. * @param source The mesh or sprite that triggered the action
  29809. * @param pointerX The X mouse cursor position at the time of the event
  29810. * @param pointerY The Y mouse cursor position at the time of the event
  29811. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29812. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29813. * @param additionalData additional data for the event
  29814. */
  29815. constructor(
  29816. /** The mesh or sprite that triggered the action */
  29817. source: any,
  29818. /** The X mouse cursor position at the time of the event */
  29819. pointerX: number,
  29820. /** The Y mouse cursor position at the time of the event */
  29821. pointerY: number,
  29822. /** The mesh that is currently pointed at (can be null) */
  29823. meshUnderPointer: Nullable<AbstractMesh>,
  29824. /** the original (browser) event that triggered the ActionEvent */
  29825. sourceEvent?: any,
  29826. /** additional data for the event */
  29827. additionalData?: any);
  29828. /**
  29829. * Helper function to auto-create an ActionEvent from a source mesh.
  29830. * @param source The source mesh that triggered the event
  29831. * @param evt The original (browser) event
  29832. * @param additionalData additional data for the event
  29833. * @returns the new ActionEvent
  29834. */
  29835. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29836. /**
  29837. * Helper function to auto-create an ActionEvent from a source sprite
  29838. * @param source The source sprite that triggered the event
  29839. * @param scene Scene associated with the sprite
  29840. * @param evt The original (browser) event
  29841. * @param additionalData additional data for the event
  29842. * @returns the new ActionEvent
  29843. */
  29844. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29845. /**
  29846. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29847. * @param scene the scene where the event occurred
  29848. * @param evt The original (browser) event
  29849. * @returns the new ActionEvent
  29850. */
  29851. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29852. /**
  29853. * Helper function to auto-create an ActionEvent from a primitive
  29854. * @param prim defines the target primitive
  29855. * @param pointerPos defines the pointer position
  29856. * @param evt The original (browser) event
  29857. * @param additionalData additional data for the event
  29858. * @returns the new ActionEvent
  29859. */
  29860. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29861. }
  29862. }
  29863. declare module "babylonjs/Actions/abstractActionManager" {
  29864. import { IDisposable } from "babylonjs/scene";
  29865. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29866. import { IAction } from "babylonjs/Actions/action";
  29867. import { Nullable } from "babylonjs/types";
  29868. /**
  29869. * Abstract class used to decouple action Manager from scene and meshes.
  29870. * Do not instantiate.
  29871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29872. */
  29873. export abstract class AbstractActionManager implements IDisposable {
  29874. /** Gets the list of active triggers */
  29875. static Triggers: {
  29876. [key: string]: number;
  29877. };
  29878. /** Gets the cursor to use when hovering items */
  29879. hoverCursor: string;
  29880. /** Gets the list of actions */
  29881. actions: IAction[];
  29882. /**
  29883. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29884. */
  29885. isRecursive: boolean;
  29886. /**
  29887. * Releases all associated resources
  29888. */
  29889. abstract dispose(): void;
  29890. /**
  29891. * Does this action manager has pointer triggers
  29892. */
  29893. abstract get hasPointerTriggers(): boolean;
  29894. /**
  29895. * Does this action manager has pick triggers
  29896. */
  29897. abstract get hasPickTriggers(): boolean;
  29898. /**
  29899. * Process a specific trigger
  29900. * @param trigger defines the trigger to process
  29901. * @param evt defines the event details to be processed
  29902. */
  29903. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29904. /**
  29905. * Does this action manager handles actions of any of the given triggers
  29906. * @param triggers defines the triggers to be tested
  29907. * @return a boolean indicating whether one (or more) of the triggers is handled
  29908. */
  29909. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29910. /**
  29911. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29912. * speed.
  29913. * @param triggerA defines the trigger to be tested
  29914. * @param triggerB defines the trigger to be tested
  29915. * @return a boolean indicating whether one (or more) of the triggers is handled
  29916. */
  29917. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29918. /**
  29919. * Does this action manager handles actions of a given trigger
  29920. * @param trigger defines the trigger to be tested
  29921. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29922. * @return whether the trigger is handled
  29923. */
  29924. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29925. /**
  29926. * Serialize this manager to a JSON object
  29927. * @param name defines the property name to store this manager
  29928. * @returns a JSON representation of this manager
  29929. */
  29930. abstract serialize(name: string): any;
  29931. /**
  29932. * Registers an action to this action manager
  29933. * @param action defines the action to be registered
  29934. * @return the action amended (prepared) after registration
  29935. */
  29936. abstract registerAction(action: IAction): Nullable<IAction>;
  29937. /**
  29938. * Unregisters an action to this action manager
  29939. * @param action defines the action to be unregistered
  29940. * @return a boolean indicating whether the action has been unregistered
  29941. */
  29942. abstract unregisterAction(action: IAction): Boolean;
  29943. /**
  29944. * Does exist one action manager with at least one trigger
  29945. **/
  29946. static get HasTriggers(): boolean;
  29947. /**
  29948. * Does exist one action manager with at least one pick trigger
  29949. **/
  29950. static get HasPickTriggers(): boolean;
  29951. /**
  29952. * Does exist one action manager that handles actions of a given trigger
  29953. * @param trigger defines the trigger to be tested
  29954. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29955. **/
  29956. static HasSpecificTrigger(trigger: number): boolean;
  29957. }
  29958. }
  29959. declare module "babylonjs/node" {
  29960. import { Scene } from "babylonjs/scene";
  29961. import { Nullable } from "babylonjs/types";
  29962. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29963. import { Engine } from "babylonjs/Engines/engine";
  29964. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29965. import { Observable } from "babylonjs/Misc/observable";
  29966. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29967. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29968. import { Animatable } from "babylonjs/Animations/animatable";
  29969. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29970. import { Animation } from "babylonjs/Animations/animation";
  29971. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29973. /**
  29974. * Defines how a node can be built from a string name.
  29975. */
  29976. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29977. /**
  29978. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29979. */
  29980. export class Node implements IBehaviorAware<Node> {
  29981. /** @hidden */
  29982. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29983. private static _NodeConstructors;
  29984. /**
  29985. * Add a new node constructor
  29986. * @param type defines the type name of the node to construct
  29987. * @param constructorFunc defines the constructor function
  29988. */
  29989. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29990. /**
  29991. * Returns a node constructor based on type name
  29992. * @param type defines the type name
  29993. * @param name defines the new node name
  29994. * @param scene defines the hosting scene
  29995. * @param options defines optional options to transmit to constructors
  29996. * @returns the new constructor or null
  29997. */
  29998. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29999. /**
  30000. * Gets or sets the name of the node
  30001. */
  30002. name: string;
  30003. /**
  30004. * Gets or sets the id of the node
  30005. */
  30006. id: string;
  30007. /**
  30008. * Gets or sets the unique id of the node
  30009. */
  30010. uniqueId: number;
  30011. /**
  30012. * Gets or sets a string used to store user defined state for the node
  30013. */
  30014. state: string;
  30015. /**
  30016. * Gets or sets an object used to store user defined information for the node
  30017. */
  30018. metadata: any;
  30019. /**
  30020. * For internal use only. Please do not use.
  30021. */
  30022. reservedDataStore: any;
  30023. /**
  30024. * List of inspectable custom properties (used by the Inspector)
  30025. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30026. */
  30027. inspectableCustomProperties: IInspectable[];
  30028. private _doNotSerialize;
  30029. /**
  30030. * Gets or sets a boolean used to define if the node must be serialized
  30031. */
  30032. get doNotSerialize(): boolean;
  30033. set doNotSerialize(value: boolean);
  30034. /** @hidden */
  30035. _isDisposed: boolean;
  30036. /**
  30037. * Gets a list of Animations associated with the node
  30038. */
  30039. animations: import("babylonjs/Animations/animation").Animation[];
  30040. protected _ranges: {
  30041. [name: string]: Nullable<AnimationRange>;
  30042. };
  30043. /**
  30044. * Callback raised when the node is ready to be used
  30045. */
  30046. onReady: Nullable<(node: Node) => void>;
  30047. private _isEnabled;
  30048. private _isParentEnabled;
  30049. private _isReady;
  30050. /** @hidden */
  30051. _currentRenderId: number;
  30052. private _parentUpdateId;
  30053. /** @hidden */
  30054. _childUpdateId: number;
  30055. /** @hidden */
  30056. _waitingParentId: Nullable<string>;
  30057. /** @hidden */
  30058. _scene: Scene;
  30059. /** @hidden */
  30060. _cache: any;
  30061. private _parentNode;
  30062. private _children;
  30063. /** @hidden */
  30064. _worldMatrix: Matrix;
  30065. /** @hidden */
  30066. _worldMatrixDeterminant: number;
  30067. /** @hidden */
  30068. _worldMatrixDeterminantIsDirty: boolean;
  30069. /** @hidden */
  30070. private _sceneRootNodesIndex;
  30071. /**
  30072. * Gets a boolean indicating if the node has been disposed
  30073. * @returns true if the node was disposed
  30074. */
  30075. isDisposed(): boolean;
  30076. /**
  30077. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30078. * @see https://doc.babylonjs.com/how_to/parenting
  30079. */
  30080. set parent(parent: Nullable<Node>);
  30081. get parent(): Nullable<Node>;
  30082. /** @hidden */
  30083. _addToSceneRootNodes(): void;
  30084. /** @hidden */
  30085. _removeFromSceneRootNodes(): void;
  30086. private _animationPropertiesOverride;
  30087. /**
  30088. * Gets or sets the animation properties override
  30089. */
  30090. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30091. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30092. /**
  30093. * Gets a string idenfifying the name of the class
  30094. * @returns "Node" string
  30095. */
  30096. getClassName(): string;
  30097. /** @hidden */
  30098. readonly _isNode: boolean;
  30099. /**
  30100. * An event triggered when the mesh is disposed
  30101. */
  30102. onDisposeObservable: Observable<Node>;
  30103. private _onDisposeObserver;
  30104. /**
  30105. * Sets a callback that will be raised when the node will be disposed
  30106. */
  30107. set onDispose(callback: () => void);
  30108. /**
  30109. * Creates a new Node
  30110. * @param name the name and id to be given to this node
  30111. * @param scene the scene this node will be added to
  30112. */
  30113. constructor(name: string, scene?: Nullable<Scene>);
  30114. /**
  30115. * Gets the scene of the node
  30116. * @returns a scene
  30117. */
  30118. getScene(): Scene;
  30119. /**
  30120. * Gets the engine of the node
  30121. * @returns a Engine
  30122. */
  30123. getEngine(): Engine;
  30124. private _behaviors;
  30125. /**
  30126. * Attach a behavior to the node
  30127. * @see http://doc.babylonjs.com/features/behaviour
  30128. * @param behavior defines the behavior to attach
  30129. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30130. * @returns the current Node
  30131. */
  30132. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30133. /**
  30134. * Remove an attached behavior
  30135. * @see http://doc.babylonjs.com/features/behaviour
  30136. * @param behavior defines the behavior to attach
  30137. * @returns the current Node
  30138. */
  30139. removeBehavior(behavior: Behavior<Node>): Node;
  30140. /**
  30141. * Gets the list of attached behaviors
  30142. * @see http://doc.babylonjs.com/features/behaviour
  30143. */
  30144. get behaviors(): Behavior<Node>[];
  30145. /**
  30146. * Gets an attached behavior by name
  30147. * @param name defines the name of the behavior to look for
  30148. * @see http://doc.babylonjs.com/features/behaviour
  30149. * @returns null if behavior was not found else the requested behavior
  30150. */
  30151. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30152. /**
  30153. * Returns the latest update of the World matrix
  30154. * @returns a Matrix
  30155. */
  30156. getWorldMatrix(): Matrix;
  30157. /** @hidden */
  30158. _getWorldMatrixDeterminant(): number;
  30159. /**
  30160. * Returns directly the latest state of the mesh World matrix.
  30161. * A Matrix is returned.
  30162. */
  30163. get worldMatrixFromCache(): Matrix;
  30164. /** @hidden */
  30165. _initCache(): void;
  30166. /** @hidden */
  30167. updateCache(force?: boolean): void;
  30168. /** @hidden */
  30169. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30170. /** @hidden */
  30171. _updateCache(ignoreParentClass?: boolean): void;
  30172. /** @hidden */
  30173. _isSynchronized(): boolean;
  30174. /** @hidden */
  30175. _markSyncedWithParent(): void;
  30176. /** @hidden */
  30177. isSynchronizedWithParent(): boolean;
  30178. /** @hidden */
  30179. isSynchronized(): boolean;
  30180. /**
  30181. * Is this node ready to be used/rendered
  30182. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30183. * @return true if the node is ready
  30184. */
  30185. isReady(completeCheck?: boolean): boolean;
  30186. /**
  30187. * Is this node enabled?
  30188. * 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
  30189. * @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
  30190. * @return whether this node (and its parent) is enabled
  30191. */
  30192. isEnabled(checkAncestors?: boolean): boolean;
  30193. /** @hidden */
  30194. protected _syncParentEnabledState(): void;
  30195. /**
  30196. * Set the enabled state of this node
  30197. * @param value defines the new enabled state
  30198. */
  30199. setEnabled(value: boolean): void;
  30200. /**
  30201. * Is this node a descendant of the given node?
  30202. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30203. * @param ancestor defines the parent node to inspect
  30204. * @returns a boolean indicating if this node is a descendant of the given node
  30205. */
  30206. isDescendantOf(ancestor: Node): boolean;
  30207. /** @hidden */
  30208. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30209. /**
  30210. * Will return all nodes that have this node as ascendant
  30211. * @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
  30212. * @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
  30213. * @return all children nodes of all types
  30214. */
  30215. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30216. /**
  30217. * Get all child-meshes of this node
  30218. * @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)
  30219. * @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
  30220. * @returns an array of AbstractMesh
  30221. */
  30222. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30223. /**
  30224. * Get all direct children of this node
  30225. * @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
  30226. * @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)
  30227. * @returns an array of Node
  30228. */
  30229. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30230. /** @hidden */
  30231. _setReady(state: boolean): void;
  30232. /**
  30233. * Get an animation by name
  30234. * @param name defines the name of the animation to look for
  30235. * @returns null if not found else the requested animation
  30236. */
  30237. getAnimationByName(name: string): Nullable<Animation>;
  30238. /**
  30239. * Creates an animation range for this node
  30240. * @param name defines the name of the range
  30241. * @param from defines the starting key
  30242. * @param to defines the end key
  30243. */
  30244. createAnimationRange(name: string, from: number, to: number): void;
  30245. /**
  30246. * Delete a specific animation range
  30247. * @param name defines the name of the range to delete
  30248. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30249. */
  30250. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30251. /**
  30252. * Get an animation range by name
  30253. * @param name defines the name of the animation range to look for
  30254. * @returns null if not found else the requested animation range
  30255. */
  30256. getAnimationRange(name: string): Nullable<AnimationRange>;
  30257. /**
  30258. * Gets the list of all animation ranges defined on this node
  30259. * @returns an array
  30260. */
  30261. getAnimationRanges(): Nullable<AnimationRange>[];
  30262. /**
  30263. * Will start the animation sequence
  30264. * @param name defines the range frames for animation sequence
  30265. * @param loop defines if the animation should loop (false by default)
  30266. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30267. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30268. * @returns the object created for this animation. If range does not exist, it will return null
  30269. */
  30270. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30271. /**
  30272. * Serialize animation ranges into a JSON compatible object
  30273. * @returns serialization object
  30274. */
  30275. serializeAnimationRanges(): any;
  30276. /**
  30277. * Computes the world matrix of the node
  30278. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30279. * @returns the world matrix
  30280. */
  30281. computeWorldMatrix(force?: boolean): Matrix;
  30282. /**
  30283. * Releases resources associated with this node.
  30284. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30285. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30286. */
  30287. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30288. /**
  30289. * Parse animation range data from a serialization object and store them into a given node
  30290. * @param node defines where to store the animation ranges
  30291. * @param parsedNode defines the serialization object to read data from
  30292. * @param scene defines the hosting scene
  30293. */
  30294. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30295. /**
  30296. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30297. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30298. * @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
  30299. * @returns the new bounding vectors
  30300. */
  30301. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30302. min: Vector3;
  30303. max: Vector3;
  30304. };
  30305. }
  30306. }
  30307. declare module "babylonjs/Animations/animation" {
  30308. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30309. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30310. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30311. import { Nullable } from "babylonjs/types";
  30312. import { Scene } from "babylonjs/scene";
  30313. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30314. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30315. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30316. import { Node } from "babylonjs/node";
  30317. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30318. import { Size } from "babylonjs/Maths/math.size";
  30319. import { Animatable } from "babylonjs/Animations/animatable";
  30320. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30321. /**
  30322. * @hidden
  30323. */
  30324. export class _IAnimationState {
  30325. key: number;
  30326. repeatCount: number;
  30327. workValue?: any;
  30328. loopMode?: number;
  30329. offsetValue?: any;
  30330. highLimitValue?: any;
  30331. }
  30332. /**
  30333. * Class used to store any kind of animation
  30334. */
  30335. export class Animation {
  30336. /**Name of the animation */
  30337. name: string;
  30338. /**Property to animate */
  30339. targetProperty: string;
  30340. /**The frames per second of the animation */
  30341. framePerSecond: number;
  30342. /**The data type of the animation */
  30343. dataType: number;
  30344. /**The loop mode of the animation */
  30345. loopMode?: number | undefined;
  30346. /**Specifies if blending should be enabled */
  30347. enableBlending?: boolean | undefined;
  30348. /**
  30349. * Use matrix interpolation instead of using direct key value when animating matrices
  30350. */
  30351. static AllowMatricesInterpolation: boolean;
  30352. /**
  30353. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30354. */
  30355. static AllowMatrixDecomposeForInterpolation: boolean;
  30356. /**
  30357. * Stores the key frames of the animation
  30358. */
  30359. private _keys;
  30360. /**
  30361. * Stores the easing function of the animation
  30362. */
  30363. private _easingFunction;
  30364. /**
  30365. * @hidden Internal use only
  30366. */
  30367. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30368. /**
  30369. * The set of event that will be linked to this animation
  30370. */
  30371. private _events;
  30372. /**
  30373. * Stores an array of target property paths
  30374. */
  30375. targetPropertyPath: string[];
  30376. /**
  30377. * Stores the blending speed of the animation
  30378. */
  30379. blendingSpeed: number;
  30380. /**
  30381. * Stores the animation ranges for the animation
  30382. */
  30383. private _ranges;
  30384. /**
  30385. * @hidden Internal use
  30386. */
  30387. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30388. /**
  30389. * Sets up an animation
  30390. * @param property The property to animate
  30391. * @param animationType The animation type to apply
  30392. * @param framePerSecond The frames per second of the animation
  30393. * @param easingFunction The easing function used in the animation
  30394. * @returns The created animation
  30395. */
  30396. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30397. /**
  30398. * Create and start an animation on a node
  30399. * @param name defines the name of the global animation that will be run on all nodes
  30400. * @param node defines the root node where the animation will take place
  30401. * @param targetProperty defines property to animate
  30402. * @param framePerSecond defines the number of frame per second yo use
  30403. * @param totalFrame defines the number of frames in total
  30404. * @param from defines the initial value
  30405. * @param to defines the final value
  30406. * @param loopMode defines which loop mode you want to use (off by default)
  30407. * @param easingFunction defines the easing function to use (linear by default)
  30408. * @param onAnimationEnd defines the callback to call when animation end
  30409. * @returns the animatable created for this animation
  30410. */
  30411. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30412. /**
  30413. * Create and start an animation on a node and its descendants
  30414. * @param name defines the name of the global animation that will be run on all nodes
  30415. * @param node defines the root node where the animation will take place
  30416. * @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
  30417. * @param targetProperty defines property to animate
  30418. * @param framePerSecond defines the number of frame per second to use
  30419. * @param totalFrame defines the number of frames in total
  30420. * @param from defines the initial value
  30421. * @param to defines the final value
  30422. * @param loopMode defines which loop mode you want to use (off by default)
  30423. * @param easingFunction defines the easing function to use (linear by default)
  30424. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30425. * @returns the list of animatables created for all nodes
  30426. * @example https://www.babylonjs-playground.com/#MH0VLI
  30427. */
  30428. 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[]>;
  30429. /**
  30430. * Creates a new animation, merges it with the existing animations and starts it
  30431. * @param name Name of the animation
  30432. * @param node Node which contains the scene that begins the animations
  30433. * @param targetProperty Specifies which property to animate
  30434. * @param framePerSecond The frames per second of the animation
  30435. * @param totalFrame The total number of frames
  30436. * @param from The frame at the beginning of the animation
  30437. * @param to The frame at the end of the animation
  30438. * @param loopMode Specifies the loop mode of the animation
  30439. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30440. * @param onAnimationEnd Callback to run once the animation is complete
  30441. * @returns Nullable animation
  30442. */
  30443. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30444. /**
  30445. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30446. * @param sourceAnimation defines the Animation containing keyframes to convert
  30447. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30448. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30449. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30450. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30451. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30452. */
  30453. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30454. /**
  30455. * Transition property of an host to the target Value
  30456. * @param property The property to transition
  30457. * @param targetValue The target Value of the property
  30458. * @param host The object where the property to animate belongs
  30459. * @param scene Scene used to run the animation
  30460. * @param frameRate Framerate (in frame/s) to use
  30461. * @param transition The transition type we want to use
  30462. * @param duration The duration of the animation, in milliseconds
  30463. * @param onAnimationEnd Callback trigger at the end of the animation
  30464. * @returns Nullable animation
  30465. */
  30466. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30467. /**
  30468. * Return the array of runtime animations currently using this animation
  30469. */
  30470. get runtimeAnimations(): RuntimeAnimation[];
  30471. /**
  30472. * Specifies if any of the runtime animations are currently running
  30473. */
  30474. get hasRunningRuntimeAnimations(): boolean;
  30475. /**
  30476. * Initializes the animation
  30477. * @param name Name of the animation
  30478. * @param targetProperty Property to animate
  30479. * @param framePerSecond The frames per second of the animation
  30480. * @param dataType The data type of the animation
  30481. * @param loopMode The loop mode of the animation
  30482. * @param enableBlending Specifies if blending should be enabled
  30483. */
  30484. constructor(
  30485. /**Name of the animation */
  30486. name: string,
  30487. /**Property to animate */
  30488. targetProperty: string,
  30489. /**The frames per second of the animation */
  30490. framePerSecond: number,
  30491. /**The data type of the animation */
  30492. dataType: number,
  30493. /**The loop mode of the animation */
  30494. loopMode?: number | undefined,
  30495. /**Specifies if blending should be enabled */
  30496. enableBlending?: boolean | undefined);
  30497. /**
  30498. * Converts the animation to a string
  30499. * @param fullDetails support for multiple levels of logging within scene loading
  30500. * @returns String form of the animation
  30501. */
  30502. toString(fullDetails?: boolean): string;
  30503. /**
  30504. * Add an event to this animation
  30505. * @param event Event to add
  30506. */
  30507. addEvent(event: AnimationEvent): void;
  30508. /**
  30509. * Remove all events found at the given frame
  30510. * @param frame The frame to remove events from
  30511. */
  30512. removeEvents(frame: number): void;
  30513. /**
  30514. * Retrieves all the events from the animation
  30515. * @returns Events from the animation
  30516. */
  30517. getEvents(): AnimationEvent[];
  30518. /**
  30519. * Creates an animation range
  30520. * @param name Name of the animation range
  30521. * @param from Starting frame of the animation range
  30522. * @param to Ending frame of the animation
  30523. */
  30524. createRange(name: string, from: number, to: number): void;
  30525. /**
  30526. * Deletes an animation range by name
  30527. * @param name Name of the animation range to delete
  30528. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30529. */
  30530. deleteRange(name: string, deleteFrames?: boolean): void;
  30531. /**
  30532. * Gets the animation range by name, or null if not defined
  30533. * @param name Name of the animation range
  30534. * @returns Nullable animation range
  30535. */
  30536. getRange(name: string): Nullable<AnimationRange>;
  30537. /**
  30538. * Gets the key frames from the animation
  30539. * @returns The key frames of the animation
  30540. */
  30541. getKeys(): Array<IAnimationKey>;
  30542. /**
  30543. * Gets the highest frame rate of the animation
  30544. * @returns Highest frame rate of the animation
  30545. */
  30546. getHighestFrame(): number;
  30547. /**
  30548. * Gets the easing function of the animation
  30549. * @returns Easing function of the animation
  30550. */
  30551. getEasingFunction(): IEasingFunction;
  30552. /**
  30553. * Sets the easing function of the animation
  30554. * @param easingFunction A custom mathematical formula for animation
  30555. */
  30556. setEasingFunction(easingFunction: EasingFunction): void;
  30557. /**
  30558. * Interpolates a scalar linearly
  30559. * @param startValue Start value of the animation curve
  30560. * @param endValue End value of the animation curve
  30561. * @param gradient Scalar amount to interpolate
  30562. * @returns Interpolated scalar value
  30563. */
  30564. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30565. /**
  30566. * Interpolates a scalar cubically
  30567. * @param startValue Start value of the animation curve
  30568. * @param outTangent End tangent of the animation
  30569. * @param endValue End value of the animation curve
  30570. * @param inTangent Start tangent of the animation curve
  30571. * @param gradient Scalar amount to interpolate
  30572. * @returns Interpolated scalar value
  30573. */
  30574. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30575. /**
  30576. * Interpolates a quaternion using a spherical linear interpolation
  30577. * @param startValue Start value of the animation curve
  30578. * @param endValue End value of the animation curve
  30579. * @param gradient Scalar amount to interpolate
  30580. * @returns Interpolated quaternion value
  30581. */
  30582. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30583. /**
  30584. * Interpolates a quaternion cubically
  30585. * @param startValue Start value of the animation curve
  30586. * @param outTangent End tangent of the animation curve
  30587. * @param endValue End value of the animation curve
  30588. * @param inTangent Start tangent of the animation curve
  30589. * @param gradient Scalar amount to interpolate
  30590. * @returns Interpolated quaternion value
  30591. */
  30592. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30593. /**
  30594. * Interpolates a Vector3 linearl
  30595. * @param startValue Start value of the animation curve
  30596. * @param endValue End value of the animation curve
  30597. * @param gradient Scalar amount to interpolate
  30598. * @returns Interpolated scalar value
  30599. */
  30600. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30601. /**
  30602. * Interpolates a Vector3 cubically
  30603. * @param startValue Start value of the animation curve
  30604. * @param outTangent End tangent of the animation
  30605. * @param endValue End value of the animation curve
  30606. * @param inTangent Start tangent of the animation curve
  30607. * @param gradient Scalar amount to interpolate
  30608. * @returns InterpolatedVector3 value
  30609. */
  30610. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30611. /**
  30612. * Interpolates a Vector2 linearly
  30613. * @param startValue Start value of the animation curve
  30614. * @param endValue End value of the animation curve
  30615. * @param gradient Scalar amount to interpolate
  30616. * @returns Interpolated Vector2 value
  30617. */
  30618. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30619. /**
  30620. * Interpolates a Vector2 cubically
  30621. * @param startValue Start value of the animation curve
  30622. * @param outTangent End tangent of the animation
  30623. * @param endValue End value of the animation curve
  30624. * @param inTangent Start tangent of the animation curve
  30625. * @param gradient Scalar amount to interpolate
  30626. * @returns Interpolated Vector2 value
  30627. */
  30628. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30629. /**
  30630. * Interpolates a size linearly
  30631. * @param startValue Start value of the animation curve
  30632. * @param endValue End value of the animation curve
  30633. * @param gradient Scalar amount to interpolate
  30634. * @returns Interpolated Size value
  30635. */
  30636. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30637. /**
  30638. * Interpolates a Color3 linearly
  30639. * @param startValue Start value of the animation curve
  30640. * @param endValue End value of the animation curve
  30641. * @param gradient Scalar amount to interpolate
  30642. * @returns Interpolated Color3 value
  30643. */
  30644. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30645. /**
  30646. * Interpolates a Color4 linearly
  30647. * @param startValue Start value of the animation curve
  30648. * @param endValue End value of the animation curve
  30649. * @param gradient Scalar amount to interpolate
  30650. * @returns Interpolated Color3 value
  30651. */
  30652. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30653. /**
  30654. * @hidden Internal use only
  30655. */
  30656. _getKeyValue(value: any): any;
  30657. /**
  30658. * @hidden Internal use only
  30659. */
  30660. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30661. /**
  30662. * Defines the function to use to interpolate matrices
  30663. * @param startValue defines the start matrix
  30664. * @param endValue defines the end matrix
  30665. * @param gradient defines the gradient between both matrices
  30666. * @param result defines an optional target matrix where to store the interpolation
  30667. * @returns the interpolated matrix
  30668. */
  30669. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30670. /**
  30671. * Makes a copy of the animation
  30672. * @returns Cloned animation
  30673. */
  30674. clone(): Animation;
  30675. /**
  30676. * Sets the key frames of the animation
  30677. * @param values The animation key frames to set
  30678. */
  30679. setKeys(values: Array<IAnimationKey>): void;
  30680. /**
  30681. * Serializes the animation to an object
  30682. * @returns Serialized object
  30683. */
  30684. serialize(): any;
  30685. /**
  30686. * Float animation type
  30687. */
  30688. static readonly ANIMATIONTYPE_FLOAT: number;
  30689. /**
  30690. * Vector3 animation type
  30691. */
  30692. static readonly ANIMATIONTYPE_VECTOR3: number;
  30693. /**
  30694. * Quaternion animation type
  30695. */
  30696. static readonly ANIMATIONTYPE_QUATERNION: number;
  30697. /**
  30698. * Matrix animation type
  30699. */
  30700. static readonly ANIMATIONTYPE_MATRIX: number;
  30701. /**
  30702. * Color3 animation type
  30703. */
  30704. static readonly ANIMATIONTYPE_COLOR3: number;
  30705. /**
  30706. * Color3 animation type
  30707. */
  30708. static readonly ANIMATIONTYPE_COLOR4: number;
  30709. /**
  30710. * Vector2 animation type
  30711. */
  30712. static readonly ANIMATIONTYPE_VECTOR2: number;
  30713. /**
  30714. * Size animation type
  30715. */
  30716. static readonly ANIMATIONTYPE_SIZE: number;
  30717. /**
  30718. * Relative Loop Mode
  30719. */
  30720. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30721. /**
  30722. * Cycle Loop Mode
  30723. */
  30724. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30725. /**
  30726. * Constant Loop Mode
  30727. */
  30728. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30729. /** @hidden */
  30730. static _UniversalLerp(left: any, right: any, amount: number): any;
  30731. /**
  30732. * Parses an animation object and creates an animation
  30733. * @param parsedAnimation Parsed animation object
  30734. * @returns Animation object
  30735. */
  30736. static Parse(parsedAnimation: any): Animation;
  30737. /**
  30738. * Appends the serialized animations from the source animations
  30739. * @param source Source containing the animations
  30740. * @param destination Target to store the animations
  30741. */
  30742. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30743. }
  30744. }
  30745. declare module "babylonjs/Animations/animatable.interface" {
  30746. import { Nullable } from "babylonjs/types";
  30747. import { Animation } from "babylonjs/Animations/animation";
  30748. /**
  30749. * Interface containing an array of animations
  30750. */
  30751. export interface IAnimatable {
  30752. /**
  30753. * Array of animations
  30754. */
  30755. animations: Nullable<Array<Animation>>;
  30756. }
  30757. }
  30758. declare module "babylonjs/Misc/decorators" {
  30759. import { Nullable } from "babylonjs/types";
  30760. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30761. import { Scene } from "babylonjs/scene";
  30762. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30763. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30764. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30765. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30766. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30767. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30768. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30769. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30770. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30771. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30772. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30773. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30774. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30775. /**
  30776. * Decorator used to define property that can be serialized as reference to a camera
  30777. * @param sourceName defines the name of the property to decorate
  30778. */
  30779. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30780. /**
  30781. * Class used to help serialization objects
  30782. */
  30783. export class SerializationHelper {
  30784. /** @hidden */
  30785. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30786. /** @hidden */
  30787. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30788. /** @hidden */
  30789. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30790. /** @hidden */
  30791. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30792. /**
  30793. * Appends the serialized animations from the source animations
  30794. * @param source Source containing the animations
  30795. * @param destination Target to store the animations
  30796. */
  30797. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30798. /**
  30799. * Static function used to serialized a specific entity
  30800. * @param entity defines the entity to serialize
  30801. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30802. * @returns a JSON compatible object representing the serialization of the entity
  30803. */
  30804. static Serialize<T>(entity: T, serializationObject?: any): any;
  30805. /**
  30806. * Creates a new entity from a serialization data object
  30807. * @param creationFunction defines a function used to instanciated the new entity
  30808. * @param source defines the source serialization data
  30809. * @param scene defines the hosting scene
  30810. * @param rootUrl defines the root url for resources
  30811. * @returns a new entity
  30812. */
  30813. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30814. /**
  30815. * Clones an object
  30816. * @param creationFunction defines the function used to instanciate the new object
  30817. * @param source defines the source object
  30818. * @returns the cloned object
  30819. */
  30820. static Clone<T>(creationFunction: () => T, source: T): T;
  30821. /**
  30822. * Instanciates a new object based on a source one (some data will be shared between both object)
  30823. * @param creationFunction defines the function used to instanciate the new object
  30824. * @param source defines the source object
  30825. * @returns the new object
  30826. */
  30827. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30828. }
  30829. }
  30830. declare module "babylonjs/Misc/guid" {
  30831. /**
  30832. * Class used to manipulate GUIDs
  30833. */
  30834. export class GUID {
  30835. /**
  30836. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30837. * Be aware Math.random() could cause collisions, but:
  30838. * "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"
  30839. * @returns a pseudo random id
  30840. */
  30841. static RandomId(): string;
  30842. }
  30843. }
  30844. declare module "babylonjs/Materials/Textures/baseTexture" {
  30845. import { Observable } from "babylonjs/Misc/observable";
  30846. import { Nullable } from "babylonjs/types";
  30847. import { Scene } from "babylonjs/scene";
  30848. import { Matrix } from "babylonjs/Maths/math.vector";
  30849. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30850. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30851. import { ISize } from "babylonjs/Maths/math.size";
  30852. import "babylonjs/Misc/fileTools";
  30853. /**
  30854. * Base class of all the textures in babylon.
  30855. * It groups all the common properties the materials, post process, lights... might need
  30856. * in order to make a correct use of the texture.
  30857. */
  30858. export class BaseTexture implements IAnimatable {
  30859. /**
  30860. * Default anisotropic filtering level for the application.
  30861. * It is set to 4 as a good tradeoff between perf and quality.
  30862. */
  30863. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30864. /**
  30865. * Gets or sets the unique id of the texture
  30866. */
  30867. uniqueId: number;
  30868. /**
  30869. * Define the name of the texture.
  30870. */
  30871. name: string;
  30872. /**
  30873. * Gets or sets an object used to store user defined information.
  30874. */
  30875. metadata: any;
  30876. /**
  30877. * For internal use only. Please do not use.
  30878. */
  30879. reservedDataStore: any;
  30880. private _hasAlpha;
  30881. /**
  30882. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30883. */
  30884. set hasAlpha(value: boolean);
  30885. get hasAlpha(): boolean;
  30886. /**
  30887. * Defines if the alpha value should be determined via the rgb values.
  30888. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30889. */
  30890. getAlphaFromRGB: boolean;
  30891. /**
  30892. * Intensity or strength of the texture.
  30893. * It is commonly used by materials to fine tune the intensity of the texture
  30894. */
  30895. level: number;
  30896. /**
  30897. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30898. * This is part of the texture as textures usually maps to one uv set.
  30899. */
  30900. coordinatesIndex: number;
  30901. private _coordinatesMode;
  30902. /**
  30903. * How a texture is mapped.
  30904. *
  30905. * | Value | Type | Description |
  30906. * | ----- | ----------------------------------- | ----------- |
  30907. * | 0 | EXPLICIT_MODE | |
  30908. * | 1 | SPHERICAL_MODE | |
  30909. * | 2 | PLANAR_MODE | |
  30910. * | 3 | CUBIC_MODE | |
  30911. * | 4 | PROJECTION_MODE | |
  30912. * | 5 | SKYBOX_MODE | |
  30913. * | 6 | INVCUBIC_MODE | |
  30914. * | 7 | EQUIRECTANGULAR_MODE | |
  30915. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30916. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30917. */
  30918. set coordinatesMode(value: number);
  30919. get coordinatesMode(): number;
  30920. /**
  30921. * | Value | Type | Description |
  30922. * | ----- | ------------------ | ----------- |
  30923. * | 0 | CLAMP_ADDRESSMODE | |
  30924. * | 1 | WRAP_ADDRESSMODE | |
  30925. * | 2 | MIRROR_ADDRESSMODE | |
  30926. */
  30927. wrapU: number;
  30928. /**
  30929. * | Value | Type | Description |
  30930. * | ----- | ------------------ | ----------- |
  30931. * | 0 | CLAMP_ADDRESSMODE | |
  30932. * | 1 | WRAP_ADDRESSMODE | |
  30933. * | 2 | MIRROR_ADDRESSMODE | |
  30934. */
  30935. wrapV: number;
  30936. /**
  30937. * | Value | Type | Description |
  30938. * | ----- | ------------------ | ----------- |
  30939. * | 0 | CLAMP_ADDRESSMODE | |
  30940. * | 1 | WRAP_ADDRESSMODE | |
  30941. * | 2 | MIRROR_ADDRESSMODE | |
  30942. */
  30943. wrapR: number;
  30944. /**
  30945. * With compliant hardware and browser (supporting anisotropic filtering)
  30946. * this defines the level of anisotropic filtering in the texture.
  30947. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30948. */
  30949. anisotropicFilteringLevel: number;
  30950. /**
  30951. * Define if the texture is a cube texture or if false a 2d texture.
  30952. */
  30953. get isCube(): boolean;
  30954. set isCube(value: boolean);
  30955. /**
  30956. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30957. */
  30958. get is3D(): boolean;
  30959. set is3D(value: boolean);
  30960. /**
  30961. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30962. */
  30963. get is2DArray(): boolean;
  30964. set is2DArray(value: boolean);
  30965. /**
  30966. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30967. * HDR texture are usually stored in linear space.
  30968. * This only impacts the PBR and Background materials
  30969. */
  30970. gammaSpace: boolean;
  30971. /**
  30972. * Gets or sets whether or not the texture contains RGBD data.
  30973. */
  30974. get isRGBD(): boolean;
  30975. set isRGBD(value: boolean);
  30976. /**
  30977. * Is Z inverted in the texture (useful in a cube texture).
  30978. */
  30979. invertZ: boolean;
  30980. /**
  30981. * Are mip maps generated for this texture or not.
  30982. */
  30983. get noMipmap(): boolean;
  30984. /**
  30985. * @hidden
  30986. */
  30987. lodLevelInAlpha: boolean;
  30988. /**
  30989. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30990. */
  30991. get lodGenerationOffset(): number;
  30992. set lodGenerationOffset(value: number);
  30993. /**
  30994. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30995. */
  30996. get lodGenerationScale(): number;
  30997. set lodGenerationScale(value: number);
  30998. /**
  30999. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31000. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31001. * average roughness values.
  31002. */
  31003. get linearSpecularLOD(): boolean;
  31004. set linearSpecularLOD(value: boolean);
  31005. /**
  31006. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31007. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31008. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31009. */
  31010. get irradianceTexture(): Nullable<BaseTexture>;
  31011. set irradianceTexture(value: Nullable<BaseTexture>);
  31012. /**
  31013. * Define if the texture is a render target.
  31014. */
  31015. isRenderTarget: boolean;
  31016. /**
  31017. * Define the unique id of the texture in the scene.
  31018. */
  31019. get uid(): string;
  31020. /**
  31021. * Return a string representation of the texture.
  31022. * @returns the texture as a string
  31023. */
  31024. toString(): string;
  31025. /**
  31026. * Get the class name of the texture.
  31027. * @returns "BaseTexture"
  31028. */
  31029. getClassName(): string;
  31030. /**
  31031. * Define the list of animation attached to the texture.
  31032. */
  31033. animations: import("babylonjs/Animations/animation").Animation[];
  31034. /**
  31035. * An event triggered when the texture is disposed.
  31036. */
  31037. onDisposeObservable: Observable<BaseTexture>;
  31038. private _onDisposeObserver;
  31039. /**
  31040. * Callback triggered when the texture has been disposed.
  31041. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31042. */
  31043. set onDispose(callback: () => void);
  31044. /**
  31045. * Define the current state of the loading sequence when in delayed load mode.
  31046. */
  31047. delayLoadState: number;
  31048. private _scene;
  31049. /** @hidden */
  31050. _texture: Nullable<InternalTexture>;
  31051. private _uid;
  31052. /**
  31053. * Define if the texture is preventinga material to render or not.
  31054. * If not and the texture is not ready, the engine will use a default black texture instead.
  31055. */
  31056. get isBlocking(): boolean;
  31057. /**
  31058. * Instantiates a new BaseTexture.
  31059. * Base class of all the textures in babylon.
  31060. * It groups all the common properties the materials, post process, lights... might need
  31061. * in order to make a correct use of the texture.
  31062. * @param scene Define the scene the texture blongs to
  31063. */
  31064. constructor(scene: Nullable<Scene>);
  31065. /**
  31066. * Get the scene the texture belongs to.
  31067. * @returns the scene or null if undefined
  31068. */
  31069. getScene(): Nullable<Scene>;
  31070. /**
  31071. * Get the texture transform matrix used to offset tile the texture for istance.
  31072. * @returns the transformation matrix
  31073. */
  31074. getTextureMatrix(): Matrix;
  31075. /**
  31076. * Get the texture reflection matrix used to rotate/transform the reflection.
  31077. * @returns the reflection matrix
  31078. */
  31079. getReflectionTextureMatrix(): Matrix;
  31080. /**
  31081. * Get the underlying lower level texture from Babylon.
  31082. * @returns the insternal texture
  31083. */
  31084. getInternalTexture(): Nullable<InternalTexture>;
  31085. /**
  31086. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31087. * @returns true if ready or not blocking
  31088. */
  31089. isReadyOrNotBlocking(): boolean;
  31090. /**
  31091. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31092. * @returns true if fully ready
  31093. */
  31094. isReady(): boolean;
  31095. private _cachedSize;
  31096. /**
  31097. * Get the size of the texture.
  31098. * @returns the texture size.
  31099. */
  31100. getSize(): ISize;
  31101. /**
  31102. * Get the base size of the texture.
  31103. * It can be different from the size if the texture has been resized for POT for instance
  31104. * @returns the base size
  31105. */
  31106. getBaseSize(): ISize;
  31107. /**
  31108. * Update the sampling mode of the texture.
  31109. * Default is Trilinear mode.
  31110. *
  31111. * | Value | Type | Description |
  31112. * | ----- | ------------------ | ----------- |
  31113. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31114. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31115. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31116. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31117. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31118. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31119. * | 7 | NEAREST_LINEAR | |
  31120. * | 8 | NEAREST_NEAREST | |
  31121. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31122. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31123. * | 11 | LINEAR_LINEAR | |
  31124. * | 12 | LINEAR_NEAREST | |
  31125. *
  31126. * > _mag_: magnification filter (close to the viewer)
  31127. * > _min_: minification filter (far from the viewer)
  31128. * > _mip_: filter used between mip map levels
  31129. *@param samplingMode Define the new sampling mode of the texture
  31130. */
  31131. updateSamplingMode(samplingMode: number): void;
  31132. /**
  31133. * Scales the texture if is `canRescale()`
  31134. * @param ratio the resize factor we want to use to rescale
  31135. */
  31136. scale(ratio: number): void;
  31137. /**
  31138. * Get if the texture can rescale.
  31139. */
  31140. get canRescale(): boolean;
  31141. /** @hidden */
  31142. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31143. /** @hidden */
  31144. _rebuild(): void;
  31145. /**
  31146. * Triggers the load sequence in delayed load mode.
  31147. */
  31148. delayLoad(): void;
  31149. /**
  31150. * Clones the texture.
  31151. * @returns the cloned texture
  31152. */
  31153. clone(): Nullable<BaseTexture>;
  31154. /**
  31155. * Get the texture underlying type (INT, FLOAT...)
  31156. */
  31157. get textureType(): number;
  31158. /**
  31159. * Get the texture underlying format (RGB, RGBA...)
  31160. */
  31161. get textureFormat(): number;
  31162. /**
  31163. * Indicates that textures need to be re-calculated for all materials
  31164. */
  31165. protected _markAllSubMeshesAsTexturesDirty(): void;
  31166. /**
  31167. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31168. * This will returns an RGBA array buffer containing either in values (0-255) or
  31169. * float values (0-1) depending of the underlying buffer type.
  31170. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31171. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31172. * @param buffer defines a user defined buffer to fill with data (can be null)
  31173. * @returns The Array buffer containing the pixels data.
  31174. */
  31175. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31176. /**
  31177. * Release and destroy the underlying lower level texture aka internalTexture.
  31178. */
  31179. releaseInternalTexture(): void;
  31180. /** @hidden */
  31181. get _lodTextureHigh(): Nullable<BaseTexture>;
  31182. /** @hidden */
  31183. get _lodTextureMid(): Nullable<BaseTexture>;
  31184. /** @hidden */
  31185. get _lodTextureLow(): Nullable<BaseTexture>;
  31186. /**
  31187. * Dispose the texture and release its associated resources.
  31188. */
  31189. dispose(): void;
  31190. /**
  31191. * Serialize the texture into a JSON representation that can be parsed later on.
  31192. * @returns the JSON representation of the texture
  31193. */
  31194. serialize(): any;
  31195. /**
  31196. * Helper function to be called back once a list of texture contains only ready textures.
  31197. * @param textures Define the list of textures to wait for
  31198. * @param callback Define the callback triggered once the entire list will be ready
  31199. */
  31200. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31201. }
  31202. }
  31203. declare module "babylonjs/Materials/effect" {
  31204. import { Observable } from "babylonjs/Misc/observable";
  31205. import { Nullable } from "babylonjs/types";
  31206. import { IDisposable } from "babylonjs/scene";
  31207. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31208. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31209. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31211. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31212. import { Engine } from "babylonjs/Engines/engine";
  31213. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31215. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31216. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31217. /**
  31218. * Options to be used when creating an effect.
  31219. */
  31220. export interface IEffectCreationOptions {
  31221. /**
  31222. * Atrributes that will be used in the shader.
  31223. */
  31224. attributes: string[];
  31225. /**
  31226. * Uniform varible names that will be set in the shader.
  31227. */
  31228. uniformsNames: string[];
  31229. /**
  31230. * Uniform buffer variable names that will be set in the shader.
  31231. */
  31232. uniformBuffersNames: string[];
  31233. /**
  31234. * Sampler texture variable names that will be set in the shader.
  31235. */
  31236. samplers: string[];
  31237. /**
  31238. * Define statements that will be set in the shader.
  31239. */
  31240. defines: any;
  31241. /**
  31242. * Possible fallbacks for this effect to improve performance when needed.
  31243. */
  31244. fallbacks: Nullable<IEffectFallbacks>;
  31245. /**
  31246. * Callback that will be called when the shader is compiled.
  31247. */
  31248. onCompiled: Nullable<(effect: Effect) => void>;
  31249. /**
  31250. * Callback that will be called if an error occurs during shader compilation.
  31251. */
  31252. onError: Nullable<(effect: Effect, errors: string) => void>;
  31253. /**
  31254. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31255. */
  31256. indexParameters?: any;
  31257. /**
  31258. * Max number of lights that can be used in the shader.
  31259. */
  31260. maxSimultaneousLights?: number;
  31261. /**
  31262. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31263. */
  31264. transformFeedbackVaryings?: Nullable<string[]>;
  31265. }
  31266. /**
  31267. * Effect containing vertex and fragment shader that can be executed on an object.
  31268. */
  31269. export class Effect implements IDisposable {
  31270. /**
  31271. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31272. */
  31273. static ShadersRepository: string;
  31274. /**
  31275. * Enable logging of the shader code when a compilation error occurs
  31276. */
  31277. static LogShaderCodeOnCompilationError: boolean;
  31278. /**
  31279. * Name of the effect.
  31280. */
  31281. name: any;
  31282. /**
  31283. * String container all the define statements that should be set on the shader.
  31284. */
  31285. defines: string;
  31286. /**
  31287. * Callback that will be called when the shader is compiled.
  31288. */
  31289. onCompiled: Nullable<(effect: Effect) => void>;
  31290. /**
  31291. * Callback that will be called if an error occurs during shader compilation.
  31292. */
  31293. onError: Nullable<(effect: Effect, errors: string) => void>;
  31294. /**
  31295. * Callback that will be called when effect is bound.
  31296. */
  31297. onBind: Nullable<(effect: Effect) => void>;
  31298. /**
  31299. * Unique ID of the effect.
  31300. */
  31301. uniqueId: number;
  31302. /**
  31303. * Observable that will be called when the shader is compiled.
  31304. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31305. */
  31306. onCompileObservable: Observable<Effect>;
  31307. /**
  31308. * Observable that will be called if an error occurs during shader compilation.
  31309. */
  31310. onErrorObservable: Observable<Effect>;
  31311. /** @hidden */
  31312. _onBindObservable: Nullable<Observable<Effect>>;
  31313. /**
  31314. * @hidden
  31315. * Specifies if the effect was previously ready
  31316. */
  31317. _wasPreviouslyReady: boolean;
  31318. /**
  31319. * Observable that will be called when effect is bound.
  31320. */
  31321. get onBindObservable(): Observable<Effect>;
  31322. /** @hidden */
  31323. _bonesComputationForcedToCPU: boolean;
  31324. private static _uniqueIdSeed;
  31325. private _engine;
  31326. private _uniformBuffersNames;
  31327. private _uniformsNames;
  31328. private _samplerList;
  31329. private _samplers;
  31330. private _isReady;
  31331. private _compilationError;
  31332. private _allFallbacksProcessed;
  31333. private _attributesNames;
  31334. private _attributes;
  31335. private _attributeLocationByName;
  31336. private _uniforms;
  31337. /**
  31338. * Key for the effect.
  31339. * @hidden
  31340. */
  31341. _key: string;
  31342. private _indexParameters;
  31343. private _fallbacks;
  31344. private _vertexSourceCode;
  31345. private _fragmentSourceCode;
  31346. private _vertexSourceCodeOverride;
  31347. private _fragmentSourceCodeOverride;
  31348. private _transformFeedbackVaryings;
  31349. /**
  31350. * Compiled shader to webGL program.
  31351. * @hidden
  31352. */
  31353. _pipelineContext: Nullable<IPipelineContext>;
  31354. private _valueCache;
  31355. private static _baseCache;
  31356. /**
  31357. * Instantiates an effect.
  31358. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31359. * @param baseName Name of the effect.
  31360. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31361. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31362. * @param samplers List of sampler variables that will be passed to the shader.
  31363. * @param engine Engine to be used to render the effect
  31364. * @param defines Define statements to be added to the shader.
  31365. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31366. * @param onCompiled Callback that will be called when the shader is compiled.
  31367. * @param onError Callback that will be called if an error occurs during shader compilation.
  31368. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31369. */
  31370. 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);
  31371. private _useFinalCode;
  31372. /**
  31373. * Unique key for this effect
  31374. */
  31375. get key(): string;
  31376. /**
  31377. * If the effect has been compiled and prepared.
  31378. * @returns if the effect is compiled and prepared.
  31379. */
  31380. isReady(): boolean;
  31381. private _isReadyInternal;
  31382. /**
  31383. * The engine the effect was initialized with.
  31384. * @returns the engine.
  31385. */
  31386. getEngine(): Engine;
  31387. /**
  31388. * The pipeline context for this effect
  31389. * @returns the associated pipeline context
  31390. */
  31391. getPipelineContext(): Nullable<IPipelineContext>;
  31392. /**
  31393. * The set of names of attribute variables for the shader.
  31394. * @returns An array of attribute names.
  31395. */
  31396. getAttributesNames(): string[];
  31397. /**
  31398. * Returns the attribute at the given index.
  31399. * @param index The index of the attribute.
  31400. * @returns The location of the attribute.
  31401. */
  31402. getAttributeLocation(index: number): number;
  31403. /**
  31404. * Returns the attribute based on the name of the variable.
  31405. * @param name of the attribute to look up.
  31406. * @returns the attribute location.
  31407. */
  31408. getAttributeLocationByName(name: string): number;
  31409. /**
  31410. * The number of attributes.
  31411. * @returns the numnber of attributes.
  31412. */
  31413. getAttributesCount(): number;
  31414. /**
  31415. * Gets the index of a uniform variable.
  31416. * @param uniformName of the uniform to look up.
  31417. * @returns the index.
  31418. */
  31419. getUniformIndex(uniformName: string): number;
  31420. /**
  31421. * Returns the attribute based on the name of the variable.
  31422. * @param uniformName of the uniform to look up.
  31423. * @returns the location of the uniform.
  31424. */
  31425. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31426. /**
  31427. * Returns an array of sampler variable names
  31428. * @returns The array of sampler variable neames.
  31429. */
  31430. getSamplers(): string[];
  31431. /**
  31432. * The error from the last compilation.
  31433. * @returns the error string.
  31434. */
  31435. getCompilationError(): string;
  31436. /**
  31437. * Gets a boolean indicating that all fallbacks were used during compilation
  31438. * @returns true if all fallbacks were used
  31439. */
  31440. allFallbacksProcessed(): boolean;
  31441. /**
  31442. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31443. * @param func The callback to be used.
  31444. */
  31445. executeWhenCompiled(func: (effect: Effect) => void): void;
  31446. private _checkIsReady;
  31447. private _loadShader;
  31448. /**
  31449. * Recompiles the webGL program
  31450. * @param vertexSourceCode The source code for the vertex shader.
  31451. * @param fragmentSourceCode The source code for the fragment shader.
  31452. * @param onCompiled Callback called when completed.
  31453. * @param onError Callback called on error.
  31454. * @hidden
  31455. */
  31456. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31457. /**
  31458. * Prepares the effect
  31459. * @hidden
  31460. */
  31461. _prepareEffect(): void;
  31462. private _getShaderCodeAndErrorLine;
  31463. private _processCompilationErrors;
  31464. /**
  31465. * Checks if the effect is supported. (Must be called after compilation)
  31466. */
  31467. get isSupported(): boolean;
  31468. /**
  31469. * Binds a texture to the engine to be used as output of the shader.
  31470. * @param channel Name of the output variable.
  31471. * @param texture Texture to bind.
  31472. * @hidden
  31473. */
  31474. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31475. /**
  31476. * Sets a texture on the engine to be used in the shader.
  31477. * @param channel Name of the sampler variable.
  31478. * @param texture Texture to set.
  31479. */
  31480. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31481. /**
  31482. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31483. * @param channel Name of the sampler variable.
  31484. * @param texture Texture to set.
  31485. */
  31486. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31487. /**
  31488. * Sets an array of textures on the engine to be used in the shader.
  31489. * @param channel Name of the variable.
  31490. * @param textures Textures to set.
  31491. */
  31492. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31493. /**
  31494. * 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)
  31495. * @param channel Name of the sampler variable.
  31496. * @param postProcess Post process to get the input texture from.
  31497. */
  31498. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31499. /**
  31500. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31501. * 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)
  31502. * @param channel Name of the sampler variable.
  31503. * @param postProcess Post process to get the output texture from.
  31504. */
  31505. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31506. /** @hidden */
  31507. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31508. /** @hidden */
  31509. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31510. /** @hidden */
  31511. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31512. /** @hidden */
  31513. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31514. /**
  31515. * Binds a buffer to a uniform.
  31516. * @param buffer Buffer to bind.
  31517. * @param name Name of the uniform variable to bind to.
  31518. */
  31519. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31520. /**
  31521. * Binds block to a uniform.
  31522. * @param blockName Name of the block to bind.
  31523. * @param index Index to bind.
  31524. */
  31525. bindUniformBlock(blockName: string, index: number): void;
  31526. /**
  31527. * Sets an interger value on a uniform variable.
  31528. * @param uniformName Name of the variable.
  31529. * @param value Value to be set.
  31530. * @returns this effect.
  31531. */
  31532. setInt(uniformName: string, value: number): Effect;
  31533. /**
  31534. * Sets an int array on a uniform variable.
  31535. * @param uniformName Name of the variable.
  31536. * @param array array to be set.
  31537. * @returns this effect.
  31538. */
  31539. setIntArray(uniformName: string, array: Int32Array): Effect;
  31540. /**
  31541. * 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)
  31542. * @param uniformName Name of the variable.
  31543. * @param array array to be set.
  31544. * @returns this effect.
  31545. */
  31546. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31547. /**
  31548. * 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)
  31549. * @param uniformName Name of the variable.
  31550. * @param array array to be set.
  31551. * @returns this effect.
  31552. */
  31553. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31554. /**
  31555. * 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)
  31556. * @param uniformName Name of the variable.
  31557. * @param array array to be set.
  31558. * @returns this effect.
  31559. */
  31560. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31561. /**
  31562. * Sets an float array on a uniform variable.
  31563. * @param uniformName Name of the variable.
  31564. * @param array array to be set.
  31565. * @returns this effect.
  31566. */
  31567. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31568. /**
  31569. * 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)
  31570. * @param uniformName Name of the variable.
  31571. * @param array array to be set.
  31572. * @returns this effect.
  31573. */
  31574. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31575. /**
  31576. * 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)
  31577. * @param uniformName Name of the variable.
  31578. * @param array array to be set.
  31579. * @returns this effect.
  31580. */
  31581. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31582. /**
  31583. * 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)
  31584. * @param uniformName Name of the variable.
  31585. * @param array array to be set.
  31586. * @returns this effect.
  31587. */
  31588. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31589. /**
  31590. * Sets an array on a uniform variable.
  31591. * @param uniformName Name of the variable.
  31592. * @param array array to be set.
  31593. * @returns this effect.
  31594. */
  31595. setArray(uniformName: string, array: number[]): Effect;
  31596. /**
  31597. * 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)
  31598. * @param uniformName Name of the variable.
  31599. * @param array array to be set.
  31600. * @returns this effect.
  31601. */
  31602. setArray2(uniformName: string, array: number[]): Effect;
  31603. /**
  31604. * 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)
  31605. * @param uniformName Name of the variable.
  31606. * @param array array to be set.
  31607. * @returns this effect.
  31608. */
  31609. setArray3(uniformName: string, array: number[]): Effect;
  31610. /**
  31611. * 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)
  31612. * @param uniformName Name of the variable.
  31613. * @param array array to be set.
  31614. * @returns this effect.
  31615. */
  31616. setArray4(uniformName: string, array: number[]): Effect;
  31617. /**
  31618. * Sets matrices on a uniform variable.
  31619. * @param uniformName Name of the variable.
  31620. * @param matrices matrices to be set.
  31621. * @returns this effect.
  31622. */
  31623. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31624. /**
  31625. * Sets matrix on a uniform variable.
  31626. * @param uniformName Name of the variable.
  31627. * @param matrix matrix to be set.
  31628. * @returns this effect.
  31629. */
  31630. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31631. /**
  31632. * 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)
  31633. * @param uniformName Name of the variable.
  31634. * @param matrix matrix to be set.
  31635. * @returns this effect.
  31636. */
  31637. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31638. /**
  31639. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31640. * @param uniformName Name of the variable.
  31641. * @param matrix matrix to be set.
  31642. * @returns this effect.
  31643. */
  31644. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31645. /**
  31646. * Sets a float on a uniform variable.
  31647. * @param uniformName Name of the variable.
  31648. * @param value value to be set.
  31649. * @returns this effect.
  31650. */
  31651. setFloat(uniformName: string, value: number): Effect;
  31652. /**
  31653. * Sets a boolean on a uniform variable.
  31654. * @param uniformName Name of the variable.
  31655. * @param bool value to be set.
  31656. * @returns this effect.
  31657. */
  31658. setBool(uniformName: string, bool: boolean): Effect;
  31659. /**
  31660. * Sets a Vector2 on a uniform variable.
  31661. * @param uniformName Name of the variable.
  31662. * @param vector2 vector2 to be set.
  31663. * @returns this effect.
  31664. */
  31665. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31666. /**
  31667. * Sets a float2 on a uniform variable.
  31668. * @param uniformName Name of the variable.
  31669. * @param x First float in float2.
  31670. * @param y Second float in float2.
  31671. * @returns this effect.
  31672. */
  31673. setFloat2(uniformName: string, x: number, y: number): Effect;
  31674. /**
  31675. * Sets a Vector3 on a uniform variable.
  31676. * @param uniformName Name of the variable.
  31677. * @param vector3 Value to be set.
  31678. * @returns this effect.
  31679. */
  31680. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31681. /**
  31682. * Sets a float3 on a uniform variable.
  31683. * @param uniformName Name of the variable.
  31684. * @param x First float in float3.
  31685. * @param y Second float in float3.
  31686. * @param z Third float in float3.
  31687. * @returns this effect.
  31688. */
  31689. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31690. /**
  31691. * Sets a Vector4 on a uniform variable.
  31692. * @param uniformName Name of the variable.
  31693. * @param vector4 Value to be set.
  31694. * @returns this effect.
  31695. */
  31696. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31697. /**
  31698. * Sets a float4 on a uniform variable.
  31699. * @param uniformName Name of the variable.
  31700. * @param x First float in float4.
  31701. * @param y Second float in float4.
  31702. * @param z Third float in float4.
  31703. * @param w Fourth float in float4.
  31704. * @returns this effect.
  31705. */
  31706. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31707. /**
  31708. * Sets a Color3 on a uniform variable.
  31709. * @param uniformName Name of the variable.
  31710. * @param color3 Value to be set.
  31711. * @returns this effect.
  31712. */
  31713. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31714. /**
  31715. * Sets a Color4 on a uniform variable.
  31716. * @param uniformName Name of the variable.
  31717. * @param color3 Value to be set.
  31718. * @param alpha Alpha value to be set.
  31719. * @returns this effect.
  31720. */
  31721. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31722. /**
  31723. * Sets a Color4 on a uniform variable
  31724. * @param uniformName defines the name of the variable
  31725. * @param color4 defines the value to be set
  31726. * @returns this effect.
  31727. */
  31728. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31729. /** Release all associated resources */
  31730. dispose(): void;
  31731. /**
  31732. * This function will add a new shader to the shader store
  31733. * @param name the name of the shader
  31734. * @param pixelShader optional pixel shader content
  31735. * @param vertexShader optional vertex shader content
  31736. */
  31737. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31738. /**
  31739. * Store of each shader (The can be looked up using effect.key)
  31740. */
  31741. static ShadersStore: {
  31742. [key: string]: string;
  31743. };
  31744. /**
  31745. * Store of each included file for a shader (The can be looked up using effect.key)
  31746. */
  31747. static IncludesShadersStore: {
  31748. [key: string]: string;
  31749. };
  31750. /**
  31751. * Resets the cache of effects.
  31752. */
  31753. static ResetCache(): void;
  31754. }
  31755. }
  31756. declare module "babylonjs/Engines/engineCapabilities" {
  31757. /**
  31758. * Interface used to describe the capabilities of the engine relatively to the current browser
  31759. */
  31760. export interface EngineCapabilities {
  31761. /** Maximum textures units per fragment shader */
  31762. maxTexturesImageUnits: number;
  31763. /** Maximum texture units per vertex shader */
  31764. maxVertexTextureImageUnits: number;
  31765. /** Maximum textures units in the entire pipeline */
  31766. maxCombinedTexturesImageUnits: number;
  31767. /** Maximum texture size */
  31768. maxTextureSize: number;
  31769. /** Maximum texture samples */
  31770. maxSamples?: number;
  31771. /** Maximum cube texture size */
  31772. maxCubemapTextureSize: number;
  31773. /** Maximum render texture size */
  31774. maxRenderTextureSize: number;
  31775. /** Maximum number of vertex attributes */
  31776. maxVertexAttribs: number;
  31777. /** Maximum number of varyings */
  31778. maxVaryingVectors: number;
  31779. /** Maximum number of uniforms per vertex shader */
  31780. maxVertexUniformVectors: number;
  31781. /** Maximum number of uniforms per fragment shader */
  31782. maxFragmentUniformVectors: number;
  31783. /** Defines if standard derivates (dx/dy) are supported */
  31784. standardDerivatives: boolean;
  31785. /** Defines if s3tc texture compression is supported */
  31786. s3tc?: WEBGL_compressed_texture_s3tc;
  31787. /** Defines if pvrtc texture compression is supported */
  31788. pvrtc: any;
  31789. /** Defines if etc1 texture compression is supported */
  31790. etc1: any;
  31791. /** Defines if etc2 texture compression is supported */
  31792. etc2: any;
  31793. /** Defines if astc texture compression is supported */
  31794. astc: any;
  31795. /** Defines if float textures are supported */
  31796. textureFloat: boolean;
  31797. /** Defines if vertex array objects are supported */
  31798. vertexArrayObject: boolean;
  31799. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31800. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31801. /** Gets the maximum level of anisotropy supported */
  31802. maxAnisotropy: number;
  31803. /** Defines if instancing is supported */
  31804. instancedArrays: boolean;
  31805. /** Defines if 32 bits indices are supported */
  31806. uintIndices: boolean;
  31807. /** Defines if high precision shaders are supported */
  31808. highPrecisionShaderSupported: boolean;
  31809. /** Defines if depth reading in the fragment shader is supported */
  31810. fragmentDepthSupported: boolean;
  31811. /** Defines if float texture linear filtering is supported*/
  31812. textureFloatLinearFiltering: boolean;
  31813. /** Defines if rendering to float textures is supported */
  31814. textureFloatRender: boolean;
  31815. /** Defines if half float textures are supported*/
  31816. textureHalfFloat: boolean;
  31817. /** Defines if half float texture linear filtering is supported*/
  31818. textureHalfFloatLinearFiltering: boolean;
  31819. /** Defines if rendering to half float textures is supported */
  31820. textureHalfFloatRender: boolean;
  31821. /** Defines if textureLOD shader command is supported */
  31822. textureLOD: boolean;
  31823. /** Defines if draw buffers extension is supported */
  31824. drawBuffersExtension: boolean;
  31825. /** Defines if depth textures are supported */
  31826. depthTextureExtension: boolean;
  31827. /** Defines if float color buffer are supported */
  31828. colorBufferFloat: boolean;
  31829. /** Gets disjoint timer query extension (null if not supported) */
  31830. timerQuery?: EXT_disjoint_timer_query;
  31831. /** Defines if timestamp can be used with timer query */
  31832. canUseTimestampForTimerQuery: boolean;
  31833. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31834. multiview?: any;
  31835. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31836. oculusMultiview?: any;
  31837. /** Function used to let the system compiles shaders in background */
  31838. parallelShaderCompile?: {
  31839. COMPLETION_STATUS_KHR: number;
  31840. };
  31841. /** Max number of texture samples for MSAA */
  31842. maxMSAASamples: number;
  31843. /** Defines if the blend min max extension is supported */
  31844. blendMinMax: boolean;
  31845. }
  31846. }
  31847. declare module "babylonjs/States/depthCullingState" {
  31848. import { Nullable } from "babylonjs/types";
  31849. /**
  31850. * @hidden
  31851. **/
  31852. export class DepthCullingState {
  31853. private _isDepthTestDirty;
  31854. private _isDepthMaskDirty;
  31855. private _isDepthFuncDirty;
  31856. private _isCullFaceDirty;
  31857. private _isCullDirty;
  31858. private _isZOffsetDirty;
  31859. private _isFrontFaceDirty;
  31860. private _depthTest;
  31861. private _depthMask;
  31862. private _depthFunc;
  31863. private _cull;
  31864. private _cullFace;
  31865. private _zOffset;
  31866. private _frontFace;
  31867. /**
  31868. * Initializes the state.
  31869. */
  31870. constructor();
  31871. get isDirty(): boolean;
  31872. get zOffset(): number;
  31873. set zOffset(value: number);
  31874. get cullFace(): Nullable<number>;
  31875. set cullFace(value: Nullable<number>);
  31876. get cull(): Nullable<boolean>;
  31877. set cull(value: Nullable<boolean>);
  31878. get depthFunc(): Nullable<number>;
  31879. set depthFunc(value: Nullable<number>);
  31880. get depthMask(): boolean;
  31881. set depthMask(value: boolean);
  31882. get depthTest(): boolean;
  31883. set depthTest(value: boolean);
  31884. get frontFace(): Nullable<number>;
  31885. set frontFace(value: Nullable<number>);
  31886. reset(): void;
  31887. apply(gl: WebGLRenderingContext): void;
  31888. }
  31889. }
  31890. declare module "babylonjs/States/stencilState" {
  31891. /**
  31892. * @hidden
  31893. **/
  31894. export class StencilState {
  31895. /** 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 */
  31896. static readonly ALWAYS: number;
  31897. /** Passed to stencilOperation to specify that stencil value must be kept */
  31898. static readonly KEEP: number;
  31899. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31900. static readonly REPLACE: number;
  31901. private _isStencilTestDirty;
  31902. private _isStencilMaskDirty;
  31903. private _isStencilFuncDirty;
  31904. private _isStencilOpDirty;
  31905. private _stencilTest;
  31906. private _stencilMask;
  31907. private _stencilFunc;
  31908. private _stencilFuncRef;
  31909. private _stencilFuncMask;
  31910. private _stencilOpStencilFail;
  31911. private _stencilOpDepthFail;
  31912. private _stencilOpStencilDepthPass;
  31913. get isDirty(): boolean;
  31914. get stencilFunc(): number;
  31915. set stencilFunc(value: number);
  31916. get stencilFuncRef(): number;
  31917. set stencilFuncRef(value: number);
  31918. get stencilFuncMask(): number;
  31919. set stencilFuncMask(value: number);
  31920. get stencilOpStencilFail(): number;
  31921. set stencilOpStencilFail(value: number);
  31922. get stencilOpDepthFail(): number;
  31923. set stencilOpDepthFail(value: number);
  31924. get stencilOpStencilDepthPass(): number;
  31925. set stencilOpStencilDepthPass(value: number);
  31926. get stencilMask(): number;
  31927. set stencilMask(value: number);
  31928. get stencilTest(): boolean;
  31929. set stencilTest(value: boolean);
  31930. constructor();
  31931. reset(): void;
  31932. apply(gl: WebGLRenderingContext): void;
  31933. }
  31934. }
  31935. declare module "babylonjs/States/alphaCullingState" {
  31936. /**
  31937. * @hidden
  31938. **/
  31939. export class AlphaState {
  31940. private _isAlphaBlendDirty;
  31941. private _isBlendFunctionParametersDirty;
  31942. private _isBlendEquationParametersDirty;
  31943. private _isBlendConstantsDirty;
  31944. private _alphaBlend;
  31945. private _blendFunctionParameters;
  31946. private _blendEquationParameters;
  31947. private _blendConstants;
  31948. /**
  31949. * Initializes the state.
  31950. */
  31951. constructor();
  31952. get isDirty(): boolean;
  31953. get alphaBlend(): boolean;
  31954. set alphaBlend(value: boolean);
  31955. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31956. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31957. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31958. reset(): void;
  31959. apply(gl: WebGLRenderingContext): void;
  31960. }
  31961. }
  31962. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31963. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31964. /** @hidden */
  31965. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31966. attributeProcessor(attribute: string): string;
  31967. varyingProcessor(varying: string, isFragment: boolean): string;
  31968. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31969. }
  31970. }
  31971. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31972. /**
  31973. * Interface for attribute information associated with buffer instanciation
  31974. */
  31975. export interface InstancingAttributeInfo {
  31976. /**
  31977. * Name of the GLSL attribute
  31978. * if attribute index is not specified, this is used to retrieve the index from the effect
  31979. */
  31980. attributeName: string;
  31981. /**
  31982. * Index/offset of the attribute in the vertex shader
  31983. * if not specified, this will be computes from the name.
  31984. */
  31985. index?: number;
  31986. /**
  31987. * size of the attribute, 1, 2, 3 or 4
  31988. */
  31989. attributeSize: number;
  31990. /**
  31991. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31992. */
  31993. offset: number;
  31994. /**
  31995. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31996. * default to 1
  31997. */
  31998. divisor?: number;
  31999. /**
  32000. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32001. * default is FLOAT
  32002. */
  32003. attributeType?: number;
  32004. /**
  32005. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32006. */
  32007. normalized?: boolean;
  32008. }
  32009. }
  32010. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32011. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32012. import { Nullable } from "babylonjs/types";
  32013. module "babylonjs/Engines/thinEngine" {
  32014. interface ThinEngine {
  32015. /**
  32016. * Update a video texture
  32017. * @param texture defines the texture to update
  32018. * @param video defines the video element to use
  32019. * @param invertY defines if data must be stored with Y axis inverted
  32020. */
  32021. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32022. }
  32023. }
  32024. }
  32025. declare module "babylonjs/Materials/Textures/videoTexture" {
  32026. import { Observable } from "babylonjs/Misc/observable";
  32027. import { Nullable } from "babylonjs/types";
  32028. import { Scene } from "babylonjs/scene";
  32029. import { Texture } from "babylonjs/Materials/Textures/texture";
  32030. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32031. /**
  32032. * Settings for finer control over video usage
  32033. */
  32034. export interface VideoTextureSettings {
  32035. /**
  32036. * Applies `autoplay` to video, if specified
  32037. */
  32038. autoPlay?: boolean;
  32039. /**
  32040. * Applies `loop` to video, if specified
  32041. */
  32042. loop?: boolean;
  32043. /**
  32044. * Automatically updates internal texture from video at every frame in the render loop
  32045. */
  32046. autoUpdateTexture: boolean;
  32047. /**
  32048. * Image src displayed during the video loading or until the user interacts with the video.
  32049. */
  32050. poster?: string;
  32051. }
  32052. /**
  32053. * If you want to display a video in your scene, this is the special texture for that.
  32054. * This special texture works similar to other textures, with the exception of a few parameters.
  32055. * @see https://doc.babylonjs.com/how_to/video_texture
  32056. */
  32057. export class VideoTexture extends Texture {
  32058. /**
  32059. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32060. */
  32061. readonly autoUpdateTexture: boolean;
  32062. /**
  32063. * The video instance used by the texture internally
  32064. */
  32065. readonly video: HTMLVideoElement;
  32066. private _onUserActionRequestedObservable;
  32067. /**
  32068. * Event triggerd when a dom action is required by the user to play the video.
  32069. * This happens due to recent changes in browser policies preventing video to auto start.
  32070. */
  32071. get onUserActionRequestedObservable(): Observable<Texture>;
  32072. private _generateMipMaps;
  32073. private _engine;
  32074. private _stillImageCaptured;
  32075. private _displayingPosterTexture;
  32076. private _settings;
  32077. private _createInternalTextureOnEvent;
  32078. private _frameId;
  32079. private _currentSrc;
  32080. /**
  32081. * Creates a video texture.
  32082. * If you want to display a video in your scene, this is the special texture for that.
  32083. * This special texture works similar to other textures, with the exception of a few parameters.
  32084. * @see https://doc.babylonjs.com/how_to/video_texture
  32085. * @param name optional name, will detect from video source, if not defined
  32086. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32087. * @param scene is obviously the current scene.
  32088. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32089. * @param invertY is false by default but can be used to invert video on Y axis
  32090. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32091. * @param settings allows finer control over video usage
  32092. */
  32093. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32094. private _getName;
  32095. private _getVideo;
  32096. private _createInternalTexture;
  32097. private reset;
  32098. /**
  32099. * @hidden Internal method to initiate `update`.
  32100. */
  32101. _rebuild(): void;
  32102. /**
  32103. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32104. */
  32105. update(): void;
  32106. /**
  32107. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32108. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32109. */
  32110. updateTexture(isVisible: boolean): void;
  32111. protected _updateInternalTexture: () => void;
  32112. /**
  32113. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32114. * @param url New url.
  32115. */
  32116. updateURL(url: string): void;
  32117. /**
  32118. * Clones the texture.
  32119. * @returns the cloned texture
  32120. */
  32121. clone(): VideoTexture;
  32122. /**
  32123. * Dispose the texture and release its associated resources.
  32124. */
  32125. dispose(): void;
  32126. /**
  32127. * Creates a video texture straight from a stream.
  32128. * @param scene Define the scene the texture should be created in
  32129. * @param stream Define the stream the texture should be created from
  32130. * @returns The created video texture as a promise
  32131. */
  32132. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32133. /**
  32134. * Creates a video texture straight from your WebCam video feed.
  32135. * @param scene Define the scene the texture should be created in
  32136. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32137. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32138. * @returns The created video texture as a promise
  32139. */
  32140. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32141. minWidth: number;
  32142. maxWidth: number;
  32143. minHeight: number;
  32144. maxHeight: number;
  32145. deviceId: string;
  32146. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32147. /**
  32148. * Creates a video texture straight from your WebCam video feed.
  32149. * @param scene Define the scene the texture should be created in
  32150. * @param onReady Define a callback to triggered once the texture will be ready
  32151. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32152. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32153. */
  32154. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32155. minWidth: number;
  32156. maxWidth: number;
  32157. minHeight: number;
  32158. maxHeight: number;
  32159. deviceId: string;
  32160. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32161. }
  32162. }
  32163. declare module "babylonjs/Engines/thinEngine" {
  32164. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32165. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32167. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32168. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32169. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32170. import { Observable } from "babylonjs/Misc/observable";
  32171. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32172. import { StencilState } from "babylonjs/States/stencilState";
  32173. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32174. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32175. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32176. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32177. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32178. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32179. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32180. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32181. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32183. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32184. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32185. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32186. import { WebRequest } from "babylonjs/Misc/webRequest";
  32187. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32188. /**
  32189. * Defines the interface used by objects working like Scene
  32190. * @hidden
  32191. */
  32192. export interface ISceneLike {
  32193. _addPendingData(data: any): void;
  32194. _removePendingData(data: any): void;
  32195. offlineProvider: IOfflineProvider;
  32196. }
  32197. /** Interface defining initialization parameters for Engine class */
  32198. export interface EngineOptions extends WebGLContextAttributes {
  32199. /**
  32200. * Defines if the engine should no exceed a specified device ratio
  32201. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32202. */
  32203. limitDeviceRatio?: number;
  32204. /**
  32205. * Defines if webvr should be enabled automatically
  32206. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32207. */
  32208. autoEnableWebVR?: boolean;
  32209. /**
  32210. * Defines if webgl2 should be turned off even if supported
  32211. * @see http://doc.babylonjs.com/features/webgl2
  32212. */
  32213. disableWebGL2Support?: boolean;
  32214. /**
  32215. * Defines if webaudio should be initialized as well
  32216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32217. */
  32218. audioEngine?: boolean;
  32219. /**
  32220. * Defines if animations should run using a deterministic lock step
  32221. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32222. */
  32223. deterministicLockstep?: boolean;
  32224. /** Defines the maximum steps to use with deterministic lock step mode */
  32225. lockstepMaxSteps?: number;
  32226. /** Defines the seconds between each deterministic lock step */
  32227. timeStep?: number;
  32228. /**
  32229. * Defines that engine should ignore context lost events
  32230. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32231. */
  32232. doNotHandleContextLost?: boolean;
  32233. /**
  32234. * Defines that engine should ignore modifying touch action attribute and style
  32235. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32236. */
  32237. doNotHandleTouchAction?: boolean;
  32238. /**
  32239. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32240. */
  32241. useHighPrecisionFloats?: boolean;
  32242. }
  32243. /**
  32244. * The base engine class (root of all engines)
  32245. */
  32246. export class ThinEngine {
  32247. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32248. static ExceptionList: ({
  32249. key: string;
  32250. capture: string;
  32251. captureConstraint: number;
  32252. targets: string[];
  32253. } | {
  32254. key: string;
  32255. capture: null;
  32256. captureConstraint: null;
  32257. targets: string[];
  32258. })[];
  32259. /** @hidden */
  32260. static _TextureLoaders: IInternalTextureLoader[];
  32261. /**
  32262. * Returns the current npm package of the sdk
  32263. */
  32264. static get NpmPackage(): string;
  32265. /**
  32266. * Returns the current version of the framework
  32267. */
  32268. static get Version(): string;
  32269. /**
  32270. * Returns a string describing the current engine
  32271. */
  32272. get description(): string;
  32273. /**
  32274. * Gets or sets the epsilon value used by collision engine
  32275. */
  32276. static CollisionsEpsilon: number;
  32277. /**
  32278. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32279. */
  32280. static get ShadersRepository(): string;
  32281. static set ShadersRepository(value: string);
  32282. /** @hidden */
  32283. _shaderProcessor: IShaderProcessor;
  32284. /**
  32285. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32286. */
  32287. forcePOTTextures: boolean;
  32288. /**
  32289. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32290. */
  32291. isFullscreen: boolean;
  32292. /**
  32293. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32294. */
  32295. cullBackFaces: boolean;
  32296. /**
  32297. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32298. */
  32299. renderEvenInBackground: boolean;
  32300. /**
  32301. * Gets or sets a boolean indicating that cache can be kept between frames
  32302. */
  32303. preventCacheWipeBetweenFrames: boolean;
  32304. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32305. validateShaderPrograms: boolean;
  32306. /**
  32307. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32308. * This can provide greater z depth for distant objects.
  32309. */
  32310. useReverseDepthBuffer: boolean;
  32311. /**
  32312. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32313. */
  32314. disableUniformBuffers: boolean;
  32315. /** @hidden */
  32316. _uniformBuffers: UniformBuffer[];
  32317. /**
  32318. * Gets a boolean indicating that the engine supports uniform buffers
  32319. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32320. */
  32321. get supportsUniformBuffers(): boolean;
  32322. /** @hidden */
  32323. _gl: WebGLRenderingContext;
  32324. /** @hidden */
  32325. _webGLVersion: number;
  32326. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32327. protected _windowIsBackground: boolean;
  32328. protected _creationOptions: EngineOptions;
  32329. protected _highPrecisionShadersAllowed: boolean;
  32330. /** @hidden */
  32331. get _shouldUseHighPrecisionShader(): boolean;
  32332. /**
  32333. * Gets a boolean indicating that only power of 2 textures are supported
  32334. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32335. */
  32336. get needPOTTextures(): boolean;
  32337. /** @hidden */
  32338. _badOS: boolean;
  32339. /** @hidden */
  32340. _badDesktopOS: boolean;
  32341. private _hardwareScalingLevel;
  32342. /** @hidden */
  32343. _caps: EngineCapabilities;
  32344. private _isStencilEnable;
  32345. private _glVersion;
  32346. private _glRenderer;
  32347. private _glVendor;
  32348. /** @hidden */
  32349. _videoTextureSupported: boolean;
  32350. protected _renderingQueueLaunched: boolean;
  32351. protected _activeRenderLoops: (() => void)[];
  32352. /**
  32353. * Observable signaled when a context lost event is raised
  32354. */
  32355. onContextLostObservable: Observable<ThinEngine>;
  32356. /**
  32357. * Observable signaled when a context restored event is raised
  32358. */
  32359. onContextRestoredObservable: Observable<ThinEngine>;
  32360. private _onContextLost;
  32361. private _onContextRestored;
  32362. protected _contextWasLost: boolean;
  32363. /** @hidden */
  32364. _doNotHandleContextLost: boolean;
  32365. /**
  32366. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32368. */
  32369. get doNotHandleContextLost(): boolean;
  32370. set doNotHandleContextLost(value: boolean);
  32371. /**
  32372. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32373. */
  32374. disableVertexArrayObjects: boolean;
  32375. /** @hidden */
  32376. protected _colorWrite: boolean;
  32377. /** @hidden */
  32378. protected _colorWriteChanged: boolean;
  32379. /** @hidden */
  32380. protected _depthCullingState: DepthCullingState;
  32381. /** @hidden */
  32382. protected _stencilState: StencilState;
  32383. /** @hidden */
  32384. _alphaState: AlphaState;
  32385. /** @hidden */
  32386. _alphaMode: number;
  32387. /** @hidden */
  32388. _alphaEquation: number;
  32389. /** @hidden */
  32390. _internalTexturesCache: InternalTexture[];
  32391. /** @hidden */
  32392. protected _activeChannel: number;
  32393. private _currentTextureChannel;
  32394. /** @hidden */
  32395. protected _boundTexturesCache: {
  32396. [key: string]: Nullable<InternalTexture>;
  32397. };
  32398. /** @hidden */
  32399. protected _currentEffect: Nullable<Effect>;
  32400. /** @hidden */
  32401. protected _currentProgram: Nullable<WebGLProgram>;
  32402. private _compiledEffects;
  32403. private _vertexAttribArraysEnabled;
  32404. /** @hidden */
  32405. protected _cachedViewport: Nullable<IViewportLike>;
  32406. private _cachedVertexArrayObject;
  32407. /** @hidden */
  32408. protected _cachedVertexBuffers: any;
  32409. /** @hidden */
  32410. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32411. /** @hidden */
  32412. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32413. /** @hidden */
  32414. _currentRenderTarget: Nullable<InternalTexture>;
  32415. private _uintIndicesCurrentlySet;
  32416. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32417. /** @hidden */
  32418. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32419. private _currentBufferPointers;
  32420. private _currentInstanceLocations;
  32421. private _currentInstanceBuffers;
  32422. private _textureUnits;
  32423. /** @hidden */
  32424. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32425. /** @hidden */
  32426. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32427. /** @hidden */
  32428. _boundRenderFunction: any;
  32429. private _vaoRecordInProgress;
  32430. private _mustWipeVertexAttributes;
  32431. private _emptyTexture;
  32432. private _emptyCubeTexture;
  32433. private _emptyTexture3D;
  32434. private _emptyTexture2DArray;
  32435. /** @hidden */
  32436. _frameHandler: number;
  32437. private _nextFreeTextureSlots;
  32438. private _maxSimultaneousTextures;
  32439. private _activeRequests;
  32440. /** @hidden */
  32441. _transformTextureUrl: Nullable<(url: string) => string>;
  32442. protected get _supportsHardwareTextureRescaling(): boolean;
  32443. private _framebufferDimensionsObject;
  32444. /**
  32445. * sets the object from which width and height will be taken from when getting render width and height
  32446. * Will fallback to the gl object
  32447. * @param dimensions the framebuffer width and height that will be used.
  32448. */
  32449. set framebufferDimensionsObject(dimensions: Nullable<{
  32450. framebufferWidth: number;
  32451. framebufferHeight: number;
  32452. }>);
  32453. /**
  32454. * Gets the current viewport
  32455. */
  32456. get currentViewport(): Nullable<IViewportLike>;
  32457. /**
  32458. * Gets the default empty texture
  32459. */
  32460. get emptyTexture(): InternalTexture;
  32461. /**
  32462. * Gets the default empty 3D texture
  32463. */
  32464. get emptyTexture3D(): InternalTexture;
  32465. /**
  32466. * Gets the default empty 2D array texture
  32467. */
  32468. get emptyTexture2DArray(): InternalTexture;
  32469. /**
  32470. * Gets the default empty cube texture
  32471. */
  32472. get emptyCubeTexture(): InternalTexture;
  32473. /**
  32474. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32475. */
  32476. readonly premultipliedAlpha: boolean;
  32477. /**
  32478. * Observable event triggered before each texture is initialized
  32479. */
  32480. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32481. /**
  32482. * Creates a new engine
  32483. * @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
  32484. * @param antialias defines enable antialiasing (default: false)
  32485. * @param options defines further options to be sent to the getContext() function
  32486. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32487. */
  32488. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32489. private _rebuildInternalTextures;
  32490. private _rebuildEffects;
  32491. /**
  32492. * Gets a boolean indicating if all created effects are ready
  32493. * @returns true if all effects are ready
  32494. */
  32495. areAllEffectsReady(): boolean;
  32496. protected _rebuildBuffers(): void;
  32497. protected _initGLContext(): void;
  32498. /**
  32499. * Gets version of the current webGL context
  32500. */
  32501. get webGLVersion(): number;
  32502. /**
  32503. * Gets a string idenfifying the name of the class
  32504. * @returns "Engine" string
  32505. */
  32506. getClassName(): string;
  32507. /**
  32508. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32509. */
  32510. get isStencilEnable(): boolean;
  32511. /** @hidden */
  32512. _prepareWorkingCanvas(): void;
  32513. /**
  32514. * Reset the texture cache to empty state
  32515. */
  32516. resetTextureCache(): void;
  32517. /**
  32518. * Gets an object containing information about the current webGL context
  32519. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32520. */
  32521. getGlInfo(): {
  32522. vendor: string;
  32523. renderer: string;
  32524. version: string;
  32525. };
  32526. /**
  32527. * Defines the hardware scaling level.
  32528. * By default the hardware scaling level is computed from the window device ratio.
  32529. * 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.
  32530. * @param level defines the level to use
  32531. */
  32532. setHardwareScalingLevel(level: number): void;
  32533. /**
  32534. * Gets the current hardware scaling level.
  32535. * By default the hardware scaling level is computed from the window device ratio.
  32536. * 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.
  32537. * @returns a number indicating the current hardware scaling level
  32538. */
  32539. getHardwareScalingLevel(): number;
  32540. /**
  32541. * Gets the list of loaded textures
  32542. * @returns an array containing all loaded textures
  32543. */
  32544. getLoadedTexturesCache(): InternalTexture[];
  32545. /**
  32546. * Gets the object containing all engine capabilities
  32547. * @returns the EngineCapabilities object
  32548. */
  32549. getCaps(): EngineCapabilities;
  32550. /**
  32551. * stop executing a render loop function and remove it from the execution array
  32552. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32553. */
  32554. stopRenderLoop(renderFunction?: () => void): void;
  32555. /** @hidden */
  32556. _renderLoop(): void;
  32557. /**
  32558. * Gets the HTML canvas attached with the current webGL context
  32559. * @returns a HTML canvas
  32560. */
  32561. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32562. /**
  32563. * Gets host window
  32564. * @returns the host window object
  32565. */
  32566. getHostWindow(): Nullable<Window>;
  32567. /**
  32568. * Gets the current render width
  32569. * @param useScreen defines if screen size must be used (or the current render target if any)
  32570. * @returns a number defining the current render width
  32571. */
  32572. getRenderWidth(useScreen?: boolean): number;
  32573. /**
  32574. * Gets the current render height
  32575. * @param useScreen defines if screen size must be used (or the current render target if any)
  32576. * @returns a number defining the current render height
  32577. */
  32578. getRenderHeight(useScreen?: boolean): number;
  32579. /**
  32580. * Can be used to override the current requestAnimationFrame requester.
  32581. * @hidden
  32582. */
  32583. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32584. /**
  32585. * Register and execute a render loop. The engine can have more than one render function
  32586. * @param renderFunction defines the function to continuously execute
  32587. */
  32588. runRenderLoop(renderFunction: () => void): void;
  32589. /**
  32590. * Clear the current render buffer or the current render target (if any is set up)
  32591. * @param color defines the color to use
  32592. * @param backBuffer defines if the back buffer must be cleared
  32593. * @param depth defines if the depth buffer must be cleared
  32594. * @param stencil defines if the stencil buffer must be cleared
  32595. */
  32596. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32597. private _viewportCached;
  32598. /** @hidden */
  32599. _viewport(x: number, y: number, width: number, height: number): void;
  32600. /**
  32601. * Set the WebGL's viewport
  32602. * @param viewport defines the viewport element to be used
  32603. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32604. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32605. */
  32606. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32607. /**
  32608. * Begin a new frame
  32609. */
  32610. beginFrame(): void;
  32611. /**
  32612. * Enf the current frame
  32613. */
  32614. endFrame(): void;
  32615. /**
  32616. * Resize the view according to the canvas' size
  32617. */
  32618. resize(): void;
  32619. /**
  32620. * Force a specific size of the canvas
  32621. * @param width defines the new canvas' width
  32622. * @param height defines the new canvas' height
  32623. */
  32624. setSize(width: number, height: number): void;
  32625. /**
  32626. * Binds the frame buffer to the specified texture.
  32627. * @param texture The texture to render to or null for the default canvas
  32628. * @param faceIndex The face of the texture to render to in case of cube texture
  32629. * @param requiredWidth The width of the target to render to
  32630. * @param requiredHeight The height of the target to render to
  32631. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32632. * @param lodLevel defines the lod level to bind to the frame buffer
  32633. * @param layer defines the 2d array index to bind to frame buffer to
  32634. */
  32635. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32636. /** @hidden */
  32637. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32638. /**
  32639. * Unbind the current render target texture from the webGL context
  32640. * @param texture defines the render target texture to unbind
  32641. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32642. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32643. */
  32644. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32645. /**
  32646. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32647. */
  32648. flushFramebuffer(): void;
  32649. /**
  32650. * Unbind the current render target and bind the default framebuffer
  32651. */
  32652. restoreDefaultFramebuffer(): void;
  32653. /** @hidden */
  32654. protected _resetVertexBufferBinding(): void;
  32655. /**
  32656. * Creates a vertex buffer
  32657. * @param data the data for the vertex buffer
  32658. * @returns the new WebGL static buffer
  32659. */
  32660. createVertexBuffer(data: DataArray): DataBuffer;
  32661. private _createVertexBuffer;
  32662. /**
  32663. * Creates a dynamic vertex buffer
  32664. * @param data the data for the dynamic vertex buffer
  32665. * @returns the new WebGL dynamic buffer
  32666. */
  32667. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32668. protected _resetIndexBufferBinding(): void;
  32669. /**
  32670. * Creates a new index buffer
  32671. * @param indices defines the content of the index buffer
  32672. * @param updatable defines if the index buffer must be updatable
  32673. * @returns a new webGL buffer
  32674. */
  32675. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32676. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32677. /**
  32678. * Bind a webGL buffer to the webGL context
  32679. * @param buffer defines the buffer to bind
  32680. */
  32681. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32682. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32683. private bindBuffer;
  32684. /**
  32685. * update the bound buffer with the given data
  32686. * @param data defines the data to update
  32687. */
  32688. updateArrayBuffer(data: Float32Array): void;
  32689. private _vertexAttribPointer;
  32690. /** @hidden */
  32691. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32692. private _bindVertexBuffersAttributes;
  32693. /**
  32694. * Records a vertex array object
  32695. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32696. * @param vertexBuffers defines the list of vertex buffers to store
  32697. * @param indexBuffer defines the index buffer to store
  32698. * @param effect defines the effect to store
  32699. * @returns the new vertex array object
  32700. */
  32701. recordVertexArrayObject(vertexBuffers: {
  32702. [key: string]: VertexBuffer;
  32703. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32704. /**
  32705. * Bind a specific vertex array object
  32706. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32707. * @param vertexArrayObject defines the vertex array object to bind
  32708. * @param indexBuffer defines the index buffer to bind
  32709. */
  32710. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32711. /**
  32712. * Bind webGl buffers directly to the webGL context
  32713. * @param vertexBuffer defines the vertex buffer to bind
  32714. * @param indexBuffer defines the index buffer to bind
  32715. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32716. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32717. * @param effect defines the effect associated with the vertex buffer
  32718. */
  32719. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32720. private _unbindVertexArrayObject;
  32721. /**
  32722. * Bind a list of vertex buffers to the webGL context
  32723. * @param vertexBuffers defines the list of vertex buffers to bind
  32724. * @param indexBuffer defines the index buffer to bind
  32725. * @param effect defines the effect associated with the vertex buffers
  32726. */
  32727. bindBuffers(vertexBuffers: {
  32728. [key: string]: Nullable<VertexBuffer>;
  32729. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32730. /**
  32731. * Unbind all instance attributes
  32732. */
  32733. unbindInstanceAttributes(): void;
  32734. /**
  32735. * Release and free the memory of a vertex array object
  32736. * @param vao defines the vertex array object to delete
  32737. */
  32738. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32739. /** @hidden */
  32740. _releaseBuffer(buffer: DataBuffer): boolean;
  32741. protected _deleteBuffer(buffer: DataBuffer): void;
  32742. /**
  32743. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32744. * @param instancesBuffer defines the webGL buffer to update and bind
  32745. * @param data defines the data to store in the buffer
  32746. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32747. */
  32748. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32749. /**
  32750. * Bind the content of a webGL buffer used with instantiation
  32751. * @param instancesBuffer defines the webGL buffer to bind
  32752. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32753. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32754. */
  32755. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32756. /**
  32757. * Disable the instance attribute corresponding to the name in parameter
  32758. * @param name defines the name of the attribute to disable
  32759. */
  32760. disableInstanceAttributeByName(name: string): void;
  32761. /**
  32762. * Disable the instance attribute corresponding to the location in parameter
  32763. * @param attributeLocation defines the attribute location of the attribute to disable
  32764. */
  32765. disableInstanceAttribute(attributeLocation: number): void;
  32766. /**
  32767. * Disable the attribute corresponding to the location in parameter
  32768. * @param attributeLocation defines the attribute location of the attribute to disable
  32769. */
  32770. disableAttributeByIndex(attributeLocation: number): void;
  32771. /**
  32772. * Send a draw order
  32773. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32774. * @param indexStart defines the starting index
  32775. * @param indexCount defines the number of index to draw
  32776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32777. */
  32778. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32779. /**
  32780. * Draw a list of points
  32781. * @param verticesStart defines the index of first vertex to draw
  32782. * @param verticesCount defines the count of vertices to draw
  32783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32784. */
  32785. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32786. /**
  32787. * Draw a list of unindexed primitives
  32788. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32789. * @param verticesStart defines the index of first vertex to draw
  32790. * @param verticesCount defines the count of vertices to draw
  32791. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32792. */
  32793. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32794. /**
  32795. * Draw a list of indexed primitives
  32796. * @param fillMode defines the primitive to use
  32797. * @param indexStart defines the starting index
  32798. * @param indexCount defines the number of index to draw
  32799. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32800. */
  32801. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32802. /**
  32803. * Draw a list of unindexed primitives
  32804. * @param fillMode defines the primitive to use
  32805. * @param verticesStart defines the index of first vertex to draw
  32806. * @param verticesCount defines the count of vertices to draw
  32807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32808. */
  32809. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32810. private _drawMode;
  32811. /** @hidden */
  32812. protected _reportDrawCall(): void;
  32813. /** @hidden */
  32814. _releaseEffect(effect: Effect): void;
  32815. /** @hidden */
  32816. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32817. /**
  32818. * Create a new effect (used to store vertex/fragment shaders)
  32819. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32820. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32821. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32822. * @param samplers defines an array of string used to represent textures
  32823. * @param defines defines the string containing the defines to use to compile the shaders
  32824. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32825. * @param onCompiled defines a function to call when the effect creation is successful
  32826. * @param onError defines a function to call when the effect creation has failed
  32827. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32828. * @returns the new Effect
  32829. */
  32830. 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;
  32831. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32832. private _compileShader;
  32833. private _compileRawShader;
  32834. /** @hidden */
  32835. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32836. /**
  32837. * Directly creates a webGL program
  32838. * @param pipelineContext defines the pipeline context to attach to
  32839. * @param vertexCode defines the vertex shader code to use
  32840. * @param fragmentCode defines the fragment shader code to use
  32841. * @param context defines the webGL context to use (if not set, the current one will be used)
  32842. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32843. * @returns the new webGL program
  32844. */
  32845. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32846. /**
  32847. * Creates a webGL program
  32848. * @param pipelineContext defines the pipeline context to attach to
  32849. * @param vertexCode defines the vertex shader code to use
  32850. * @param fragmentCode defines the fragment shader code to use
  32851. * @param defines defines the string containing the defines to use to compile the shaders
  32852. * @param context defines the webGL context to use (if not set, the current one will be used)
  32853. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32854. * @returns the new webGL program
  32855. */
  32856. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32857. /**
  32858. * Creates a new pipeline context
  32859. * @returns the new pipeline
  32860. */
  32861. createPipelineContext(): IPipelineContext;
  32862. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32863. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32864. /** @hidden */
  32865. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32866. /** @hidden */
  32867. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32868. /** @hidden */
  32869. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32870. /**
  32871. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32872. * @param pipelineContext defines the pipeline context to use
  32873. * @param uniformsNames defines the list of uniform names
  32874. * @returns an array of webGL uniform locations
  32875. */
  32876. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32877. /**
  32878. * Gets the lsit of active attributes for a given webGL program
  32879. * @param pipelineContext defines the pipeline context to use
  32880. * @param attributesNames defines the list of attribute names to get
  32881. * @returns an array of indices indicating the offset of each attribute
  32882. */
  32883. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32884. /**
  32885. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32886. * @param effect defines the effect to activate
  32887. */
  32888. enableEffect(effect: Nullable<Effect>): void;
  32889. /**
  32890. * Set the value of an uniform to a number (int)
  32891. * @param uniform defines the webGL uniform location where to store the value
  32892. * @param value defines the int number to store
  32893. */
  32894. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32895. /**
  32896. * Set the value of an uniform to an array of int32
  32897. * @param uniform defines the webGL uniform location where to store the value
  32898. * @param array defines the array of int32 to store
  32899. */
  32900. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32901. /**
  32902. * Set the value of an uniform to an array of int32 (stored as vec2)
  32903. * @param uniform defines the webGL uniform location where to store the value
  32904. * @param array defines the array of int32 to store
  32905. */
  32906. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32907. /**
  32908. * Set the value of an uniform to an array of int32 (stored as vec3)
  32909. * @param uniform defines the webGL uniform location where to store the value
  32910. * @param array defines the array of int32 to store
  32911. */
  32912. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32913. /**
  32914. * Set the value of an uniform to an array of int32 (stored as vec4)
  32915. * @param uniform defines the webGL uniform location where to store the value
  32916. * @param array defines the array of int32 to store
  32917. */
  32918. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32919. /**
  32920. * Set the value of an uniform to an array of number
  32921. * @param uniform defines the webGL uniform location where to store the value
  32922. * @param array defines the array of number to store
  32923. */
  32924. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32925. /**
  32926. * Set the value of an uniform to an array of number (stored as vec2)
  32927. * @param uniform defines the webGL uniform location where to store the value
  32928. * @param array defines the array of number to store
  32929. */
  32930. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32931. /**
  32932. * Set the value of an uniform to an array of number (stored as vec3)
  32933. * @param uniform defines the webGL uniform location where to store the value
  32934. * @param array defines the array of number to store
  32935. */
  32936. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32937. /**
  32938. * Set the value of an uniform to an array of number (stored as vec4)
  32939. * @param uniform defines the webGL uniform location where to store the value
  32940. * @param array defines the array of number to store
  32941. */
  32942. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32943. /**
  32944. * Set the value of an uniform to an array of float32 (stored as matrices)
  32945. * @param uniform defines the webGL uniform location where to store the value
  32946. * @param matrices defines the array of float32 to store
  32947. */
  32948. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32949. /**
  32950. * Set the value of an uniform to a matrix (3x3)
  32951. * @param uniform defines the webGL uniform location where to store the value
  32952. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32953. */
  32954. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32955. /**
  32956. * Set the value of an uniform to a matrix (2x2)
  32957. * @param uniform defines the webGL uniform location where to store the value
  32958. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32959. */
  32960. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32961. /**
  32962. * Set the value of an uniform to a number (float)
  32963. * @param uniform defines the webGL uniform location where to store the value
  32964. * @param value defines the float number to store
  32965. */
  32966. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32967. /**
  32968. * Set the value of an uniform to a vec2
  32969. * @param uniform defines the webGL uniform location where to store the value
  32970. * @param x defines the 1st component of the value
  32971. * @param y defines the 2nd component of the value
  32972. */
  32973. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32974. /**
  32975. * Set the value of an uniform to a vec3
  32976. * @param uniform defines the webGL uniform location where to store the value
  32977. * @param x defines the 1st component of the value
  32978. * @param y defines the 2nd component of the value
  32979. * @param z defines the 3rd component of the value
  32980. */
  32981. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32982. /**
  32983. * Set the value of an uniform to a vec4
  32984. * @param uniform defines the webGL uniform location where to store the value
  32985. * @param x defines the 1st component of the value
  32986. * @param y defines the 2nd component of the value
  32987. * @param z defines the 3rd component of the value
  32988. * @param w defines the 4th component of the value
  32989. */
  32990. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32991. /**
  32992. * Apply all cached states (depth, culling, stencil and alpha)
  32993. */
  32994. applyStates(): void;
  32995. /**
  32996. * Enable or disable color writing
  32997. * @param enable defines the state to set
  32998. */
  32999. setColorWrite(enable: boolean): void;
  33000. /**
  33001. * Gets a boolean indicating if color writing is enabled
  33002. * @returns the current color writing state
  33003. */
  33004. getColorWrite(): boolean;
  33005. /**
  33006. * Gets the depth culling state manager
  33007. */
  33008. get depthCullingState(): DepthCullingState;
  33009. /**
  33010. * Gets the alpha state manager
  33011. */
  33012. get alphaState(): AlphaState;
  33013. /**
  33014. * Gets the stencil state manager
  33015. */
  33016. get stencilState(): StencilState;
  33017. /**
  33018. * Clears the list of texture accessible through engine.
  33019. * This can help preventing texture load conflict due to name collision.
  33020. */
  33021. clearInternalTexturesCache(): void;
  33022. /**
  33023. * Force the entire cache to be cleared
  33024. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33025. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33026. */
  33027. wipeCaches(bruteForce?: boolean): void;
  33028. /** @hidden */
  33029. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33030. min: number;
  33031. mag: number;
  33032. };
  33033. /** @hidden */
  33034. _createTexture(): WebGLTexture;
  33035. /**
  33036. * Usually called from Texture.ts.
  33037. * Passed information to create a WebGLTexture
  33038. * @param url defines a value which contains one of the following:
  33039. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33040. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33041. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33042. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33043. * @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)
  33044. * @param scene needed for loading to the correct scene
  33045. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33046. * @param onLoad optional callback to be called upon successful completion
  33047. * @param onError optional callback to be called upon failure
  33048. * @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
  33049. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33050. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33051. * @param forcedExtension defines the extension to use to pick the right loader
  33052. * @param mimeType defines an optional mime type
  33053. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33054. */
  33055. createTexture(url: 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;
  33056. /**
  33057. * Loads an image as an HTMLImageElement.
  33058. * @param input url string, ArrayBuffer, or Blob to load
  33059. * @param onLoad callback called when the image successfully loads
  33060. * @param onError callback called when the image fails to load
  33061. * @param offlineProvider offline provider for caching
  33062. * @param mimeType optional mime type
  33063. * @returns the HTMLImageElement of the loaded image
  33064. * @hidden
  33065. */
  33066. 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>;
  33067. /**
  33068. * @hidden
  33069. */
  33070. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33071. /**
  33072. * Creates a raw texture
  33073. * @param data defines the data to store in the texture
  33074. * @param width defines the width of the texture
  33075. * @param height defines the height of the texture
  33076. * @param format defines the format of the data
  33077. * @param generateMipMaps defines if the engine should generate the mip levels
  33078. * @param invertY defines if data must be stored with Y axis inverted
  33079. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  33080. * @param compression defines the compression used (null by default)
  33081. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  33082. * @returns the raw texture inside an InternalTexture
  33083. */
  33084. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  33085. /**
  33086. * Creates a new raw cube texture
  33087. * @param data defines the array of data to use to create each face
  33088. * @param size defines the size of the textures
  33089. * @param format defines the format of the data
  33090. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33091. * @param generateMipMaps defines if the engine should generate the mip levels
  33092. * @param invertY defines if data must be stored with Y axis inverted
  33093. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33094. * @param compression defines the compression used (null by default)
  33095. * @returns the cube texture as an InternalTexture
  33096. */
  33097. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  33098. /**
  33099. * Creates a new raw 3D texture
  33100. * @param data defines the data used to create the texture
  33101. * @param width defines the width of the texture
  33102. * @param height defines the height of the texture
  33103. * @param depth defines the depth of the texture
  33104. * @param format defines the format of the texture
  33105. * @param generateMipMaps defines if the engine must generate mip levels
  33106. * @param invertY defines if data must be stored with Y axis inverted
  33107. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33108. * @param compression defines the compressed used (can be null)
  33109. * @param textureType defines the compressed used (can be null)
  33110. * @returns a new raw 3D texture (stored in an InternalTexture)
  33111. */
  33112. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33113. /**
  33114. * Creates a new raw 2D array texture
  33115. * @param data defines the data used to create the texture
  33116. * @param width defines the width of the texture
  33117. * @param height defines the height of the texture
  33118. * @param depth defines the number of layers of the texture
  33119. * @param format defines the format of the texture
  33120. * @param generateMipMaps defines if the engine must generate mip levels
  33121. * @param invertY defines if data must be stored with Y axis inverted
  33122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33123. * @param compression defines the compressed used (can be null)
  33124. * @param textureType defines the compressed used (can be null)
  33125. * @returns a new raw 2D array texture (stored in an InternalTexture)
  33126. */
  33127. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33128. private _unpackFlipYCached;
  33129. /**
  33130. * In case you are sharing the context with other applications, it might
  33131. * be interested to not cache the unpack flip y state to ensure a consistent
  33132. * value would be set.
  33133. */
  33134. enableUnpackFlipYCached: boolean;
  33135. /** @hidden */
  33136. _unpackFlipY(value: boolean): void;
  33137. /** @hidden */
  33138. _getUnpackAlignement(): number;
  33139. private _getTextureTarget;
  33140. /**
  33141. * Update the sampling mode of a given texture
  33142. * @param samplingMode defines the required sampling mode
  33143. * @param texture defines the texture to update
  33144. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33145. */
  33146. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33147. /**
  33148. * Update the sampling mode of a given texture
  33149. * @param texture defines the texture to update
  33150. * @param wrapU defines the texture wrap mode of the u coordinates
  33151. * @param wrapV defines the texture wrap mode of the v coordinates
  33152. * @param wrapR defines the texture wrap mode of the r coordinates
  33153. */
  33154. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33155. /** @hidden */
  33156. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33157. width: number;
  33158. height: number;
  33159. layers?: number;
  33160. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33161. /** @hidden */
  33162. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33163. /** @hidden */
  33164. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33165. /**
  33166. * Update a portion of an internal texture
  33167. * @param texture defines the texture to update
  33168. * @param imageData defines the data to store into the texture
  33169. * @param xOffset defines the x coordinates of the update rectangle
  33170. * @param yOffset defines the y coordinates of the update rectangle
  33171. * @param width defines the width of the update rectangle
  33172. * @param height defines the height of the update rectangle
  33173. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33174. * @param lod defines the lod level to update (0 by default)
  33175. */
  33176. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33177. /** @hidden */
  33178. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33179. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33180. private _prepareWebGLTexture;
  33181. /** @hidden */
  33182. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33183. private _getDepthStencilBuffer;
  33184. /** @hidden */
  33185. _releaseFramebufferObjects(texture: InternalTexture): void;
  33186. /** @hidden */
  33187. _releaseTexture(texture: InternalTexture): void;
  33188. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33189. protected _setProgram(program: WebGLProgram): void;
  33190. protected _boundUniforms: {
  33191. [key: number]: WebGLUniformLocation;
  33192. };
  33193. /**
  33194. * Binds an effect to the webGL context
  33195. * @param effect defines the effect to bind
  33196. */
  33197. bindSamplers(effect: Effect): void;
  33198. private _activateCurrentTexture;
  33199. /** @hidden */
  33200. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33201. /** @hidden */
  33202. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33203. /**
  33204. * Unbind all textures from the webGL context
  33205. */
  33206. unbindAllTextures(): void;
  33207. /**
  33208. * Sets a texture to the according uniform.
  33209. * @param channel The texture channel
  33210. * @param uniform The uniform to set
  33211. * @param texture The texture to apply
  33212. */
  33213. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33214. private _bindSamplerUniformToChannel;
  33215. private _getTextureWrapMode;
  33216. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33217. /**
  33218. * Sets an array of texture to the webGL context
  33219. * @param channel defines the channel where the texture array must be set
  33220. * @param uniform defines the associated uniform location
  33221. * @param textures defines the array of textures to bind
  33222. */
  33223. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33224. /** @hidden */
  33225. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33226. private _setTextureParameterFloat;
  33227. private _setTextureParameterInteger;
  33228. /**
  33229. * Unbind all vertex attributes from the webGL context
  33230. */
  33231. unbindAllAttributes(): void;
  33232. /**
  33233. * 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
  33234. */
  33235. releaseEffects(): void;
  33236. /**
  33237. * Dispose and release all associated resources
  33238. */
  33239. dispose(): void;
  33240. /**
  33241. * Attach a new callback raised when context lost event is fired
  33242. * @param callback defines the callback to call
  33243. */
  33244. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33245. /**
  33246. * Attach a new callback raised when context restored event is fired
  33247. * @param callback defines the callback to call
  33248. */
  33249. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33250. /**
  33251. * Get the current error code of the webGL context
  33252. * @returns the error code
  33253. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33254. */
  33255. getError(): number;
  33256. private _canRenderToFloatFramebuffer;
  33257. private _canRenderToHalfFloatFramebuffer;
  33258. private _canRenderToFramebuffer;
  33259. /** @hidden */
  33260. _getWebGLTextureType(type: number): number;
  33261. /** @hidden */
  33262. _getInternalFormat(format: number): number;
  33263. /** @hidden */
  33264. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33265. /** @hidden */
  33266. _getRGBAMultiSampleBufferFormat(type: number): number;
  33267. /** @hidden */
  33268. _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;
  33269. /**
  33270. * Loads a file from a url
  33271. * @param url url to load
  33272. * @param onSuccess callback called when the file successfully loads
  33273. * @param onProgress callback called while file is loading (if the server supports this mode)
  33274. * @param offlineProvider defines the offline provider for caching
  33275. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33276. * @param onError callback called when the file fails to load
  33277. * @returns a file request object
  33278. * @hidden
  33279. */
  33280. 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;
  33281. /**
  33282. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33283. * @param x defines the x coordinate of the rectangle where pixels must be read
  33284. * @param y defines the y coordinate of the rectangle where pixels must be read
  33285. * @param width defines the width of the rectangle where pixels must be read
  33286. * @param height defines the height of the rectangle where pixels must be read
  33287. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33288. * @returns a Uint8Array containing RGBA colors
  33289. */
  33290. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33291. private static _isSupported;
  33292. /**
  33293. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33294. * @returns true if the engine can be created
  33295. * @ignorenaming
  33296. */
  33297. static isSupported(): boolean;
  33298. /**
  33299. * Find the next highest power of two.
  33300. * @param x Number to start search from.
  33301. * @return Next highest power of two.
  33302. */
  33303. static CeilingPOT(x: number): number;
  33304. /**
  33305. * Find the next lowest power of two.
  33306. * @param x Number to start search from.
  33307. * @return Next lowest power of two.
  33308. */
  33309. static FloorPOT(x: number): number;
  33310. /**
  33311. * Find the nearest power of two.
  33312. * @param x Number to start search from.
  33313. * @return Next nearest power of two.
  33314. */
  33315. static NearestPOT(x: number): number;
  33316. /**
  33317. * Get the closest exponent of two
  33318. * @param value defines the value to approximate
  33319. * @param max defines the maximum value to return
  33320. * @param mode defines how to define the closest value
  33321. * @returns closest exponent of two of the given value
  33322. */
  33323. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33324. /**
  33325. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33326. * @param func - the function to be called
  33327. * @param requester - the object that will request the next frame. Falls back to window.
  33328. * @returns frame number
  33329. */
  33330. static QueueNewFrame(func: () => void, requester?: any): number;
  33331. /**
  33332. * Gets host document
  33333. * @returns the host document object
  33334. */
  33335. getHostDocument(): Nullable<Document>;
  33336. }
  33337. }
  33338. declare module "babylonjs/Maths/sphericalPolynomial" {
  33339. import { Vector3 } from "babylonjs/Maths/math.vector";
  33340. import { Color3 } from "babylonjs/Maths/math.color";
  33341. /**
  33342. * Class representing spherical harmonics coefficients to the 3rd degree
  33343. */
  33344. export class SphericalHarmonics {
  33345. /**
  33346. * Defines whether or not the harmonics have been prescaled for rendering.
  33347. */
  33348. preScaled: boolean;
  33349. /**
  33350. * The l0,0 coefficients of the spherical harmonics
  33351. */
  33352. l00: Vector3;
  33353. /**
  33354. * The l1,-1 coefficients of the spherical harmonics
  33355. */
  33356. l1_1: Vector3;
  33357. /**
  33358. * The l1,0 coefficients of the spherical harmonics
  33359. */
  33360. l10: Vector3;
  33361. /**
  33362. * The l1,1 coefficients of the spherical harmonics
  33363. */
  33364. l11: Vector3;
  33365. /**
  33366. * The l2,-2 coefficients of the spherical harmonics
  33367. */
  33368. l2_2: Vector3;
  33369. /**
  33370. * The l2,-1 coefficients of the spherical harmonics
  33371. */
  33372. l2_1: Vector3;
  33373. /**
  33374. * The l2,0 coefficients of the spherical harmonics
  33375. */
  33376. l20: Vector3;
  33377. /**
  33378. * The l2,1 coefficients of the spherical harmonics
  33379. */
  33380. l21: Vector3;
  33381. /**
  33382. * The l2,2 coefficients of the spherical harmonics
  33383. */
  33384. l22: Vector3;
  33385. /**
  33386. * Adds a light to the spherical harmonics
  33387. * @param direction the direction of the light
  33388. * @param color the color of the light
  33389. * @param deltaSolidAngle the delta solid angle of the light
  33390. */
  33391. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33392. /**
  33393. * Scales the spherical harmonics by the given amount
  33394. * @param scale the amount to scale
  33395. */
  33396. scaleInPlace(scale: number): void;
  33397. /**
  33398. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33399. *
  33400. * ```
  33401. * E_lm = A_l * L_lm
  33402. * ```
  33403. *
  33404. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33405. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33406. * the scaling factors are given in equation 9.
  33407. */
  33408. convertIncidentRadianceToIrradiance(): void;
  33409. /**
  33410. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33411. *
  33412. * ```
  33413. * L = (1/pi) * E * rho
  33414. * ```
  33415. *
  33416. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33417. */
  33418. convertIrradianceToLambertianRadiance(): void;
  33419. /**
  33420. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33421. * required operations at run time.
  33422. *
  33423. * This is simply done by scaling back the SH with Ylm constants parameter.
  33424. * The trigonometric part being applied by the shader at run time.
  33425. */
  33426. preScaleForRendering(): void;
  33427. /**
  33428. * Constructs a spherical harmonics from an array.
  33429. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33430. * @returns the spherical harmonics
  33431. */
  33432. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33433. /**
  33434. * Gets the spherical harmonics from polynomial
  33435. * @param polynomial the spherical polynomial
  33436. * @returns the spherical harmonics
  33437. */
  33438. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33439. }
  33440. /**
  33441. * Class representing spherical polynomial coefficients to the 3rd degree
  33442. */
  33443. export class SphericalPolynomial {
  33444. private _harmonics;
  33445. /**
  33446. * The spherical harmonics used to create the polynomials.
  33447. */
  33448. get preScaledHarmonics(): SphericalHarmonics;
  33449. /**
  33450. * The x coefficients of the spherical polynomial
  33451. */
  33452. x: Vector3;
  33453. /**
  33454. * The y coefficients of the spherical polynomial
  33455. */
  33456. y: Vector3;
  33457. /**
  33458. * The z coefficients of the spherical polynomial
  33459. */
  33460. z: Vector3;
  33461. /**
  33462. * The xx coefficients of the spherical polynomial
  33463. */
  33464. xx: Vector3;
  33465. /**
  33466. * The yy coefficients of the spherical polynomial
  33467. */
  33468. yy: Vector3;
  33469. /**
  33470. * The zz coefficients of the spherical polynomial
  33471. */
  33472. zz: Vector3;
  33473. /**
  33474. * The xy coefficients of the spherical polynomial
  33475. */
  33476. xy: Vector3;
  33477. /**
  33478. * The yz coefficients of the spherical polynomial
  33479. */
  33480. yz: Vector3;
  33481. /**
  33482. * The zx coefficients of the spherical polynomial
  33483. */
  33484. zx: Vector3;
  33485. /**
  33486. * Adds an ambient color to the spherical polynomial
  33487. * @param color the color to add
  33488. */
  33489. addAmbient(color: Color3): void;
  33490. /**
  33491. * Scales the spherical polynomial by the given amount
  33492. * @param scale the amount to scale
  33493. */
  33494. scaleInPlace(scale: number): void;
  33495. /**
  33496. * Gets the spherical polynomial from harmonics
  33497. * @param harmonics the spherical harmonics
  33498. * @returns the spherical polynomial
  33499. */
  33500. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33501. /**
  33502. * Constructs a spherical polynomial from an array.
  33503. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33504. * @returns the spherical polynomial
  33505. */
  33506. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33507. }
  33508. }
  33509. declare module "babylonjs/Materials/Textures/internalTexture" {
  33510. import { Observable } from "babylonjs/Misc/observable";
  33511. import { Nullable, int } from "babylonjs/types";
  33512. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33514. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33515. /**
  33516. * Defines the source of the internal texture
  33517. */
  33518. export enum InternalTextureSource {
  33519. /**
  33520. * The source of the texture data is unknown
  33521. */
  33522. Unknown = 0,
  33523. /**
  33524. * Texture data comes from an URL
  33525. */
  33526. Url = 1,
  33527. /**
  33528. * Texture data is only used for temporary storage
  33529. */
  33530. Temp = 2,
  33531. /**
  33532. * Texture data comes from raw data (ArrayBuffer)
  33533. */
  33534. Raw = 3,
  33535. /**
  33536. * Texture content is dynamic (video or dynamic texture)
  33537. */
  33538. Dynamic = 4,
  33539. /**
  33540. * Texture content is generated by rendering to it
  33541. */
  33542. RenderTarget = 5,
  33543. /**
  33544. * Texture content is part of a multi render target process
  33545. */
  33546. MultiRenderTarget = 6,
  33547. /**
  33548. * Texture data comes from a cube data file
  33549. */
  33550. Cube = 7,
  33551. /**
  33552. * Texture data comes from a raw cube data
  33553. */
  33554. CubeRaw = 8,
  33555. /**
  33556. * Texture data come from a prefiltered cube data file
  33557. */
  33558. CubePrefiltered = 9,
  33559. /**
  33560. * Texture content is raw 3D data
  33561. */
  33562. Raw3D = 10,
  33563. /**
  33564. * Texture content is raw 2D array data
  33565. */
  33566. Raw2DArray = 11,
  33567. /**
  33568. * Texture content is a depth texture
  33569. */
  33570. Depth = 12,
  33571. /**
  33572. * Texture data comes from a raw cube data encoded with RGBD
  33573. */
  33574. CubeRawRGBD = 13
  33575. }
  33576. /**
  33577. * Class used to store data associated with WebGL texture data for the engine
  33578. * This class should not be used directly
  33579. */
  33580. export class InternalTexture {
  33581. /** @hidden */
  33582. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33583. /**
  33584. * Defines if the texture is ready
  33585. */
  33586. isReady: boolean;
  33587. /**
  33588. * Defines if the texture is a cube texture
  33589. */
  33590. isCube: boolean;
  33591. /**
  33592. * Defines if the texture contains 3D data
  33593. */
  33594. is3D: boolean;
  33595. /**
  33596. * Defines if the texture contains 2D array data
  33597. */
  33598. is2DArray: boolean;
  33599. /**
  33600. * Defines if the texture contains multiview data
  33601. */
  33602. isMultiview: boolean;
  33603. /**
  33604. * Gets the URL used to load this texture
  33605. */
  33606. url: string;
  33607. /**
  33608. * Gets the sampling mode of the texture
  33609. */
  33610. samplingMode: number;
  33611. /**
  33612. * Gets a boolean indicating if the texture needs mipmaps generation
  33613. */
  33614. generateMipMaps: boolean;
  33615. /**
  33616. * Gets the number of samples used by the texture (WebGL2+ only)
  33617. */
  33618. samples: number;
  33619. /**
  33620. * Gets the type of the texture (int, float...)
  33621. */
  33622. type: number;
  33623. /**
  33624. * Gets the format of the texture (RGB, RGBA...)
  33625. */
  33626. format: number;
  33627. /**
  33628. * Observable called when the texture is loaded
  33629. */
  33630. onLoadedObservable: Observable<InternalTexture>;
  33631. /**
  33632. * Gets the width of the texture
  33633. */
  33634. width: number;
  33635. /**
  33636. * Gets the height of the texture
  33637. */
  33638. height: number;
  33639. /**
  33640. * Gets the depth of the texture
  33641. */
  33642. depth: number;
  33643. /**
  33644. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33645. */
  33646. baseWidth: number;
  33647. /**
  33648. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33649. */
  33650. baseHeight: number;
  33651. /**
  33652. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33653. */
  33654. baseDepth: number;
  33655. /**
  33656. * Gets a boolean indicating if the texture is inverted on Y axis
  33657. */
  33658. invertY: boolean;
  33659. /** @hidden */
  33660. _invertVScale: boolean;
  33661. /** @hidden */
  33662. _associatedChannel: number;
  33663. /** @hidden */
  33664. _source: InternalTextureSource;
  33665. /** @hidden */
  33666. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33667. /** @hidden */
  33668. _bufferView: Nullable<ArrayBufferView>;
  33669. /** @hidden */
  33670. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33671. /** @hidden */
  33672. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33673. /** @hidden */
  33674. _size: number;
  33675. /** @hidden */
  33676. _extension: string;
  33677. /** @hidden */
  33678. _files: Nullable<string[]>;
  33679. /** @hidden */
  33680. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33681. /** @hidden */
  33682. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33683. /** @hidden */
  33684. _framebuffer: Nullable<WebGLFramebuffer>;
  33685. /** @hidden */
  33686. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33687. /** @hidden */
  33688. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33689. /** @hidden */
  33690. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33691. /** @hidden */
  33692. _attachments: Nullable<number[]>;
  33693. /** @hidden */
  33694. _cachedCoordinatesMode: Nullable<number>;
  33695. /** @hidden */
  33696. _cachedWrapU: Nullable<number>;
  33697. /** @hidden */
  33698. _cachedWrapV: Nullable<number>;
  33699. /** @hidden */
  33700. _cachedWrapR: Nullable<number>;
  33701. /** @hidden */
  33702. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33703. /** @hidden */
  33704. _isDisabled: boolean;
  33705. /** @hidden */
  33706. _compression: Nullable<string>;
  33707. /** @hidden */
  33708. _generateStencilBuffer: boolean;
  33709. /** @hidden */
  33710. _generateDepthBuffer: boolean;
  33711. /** @hidden */
  33712. _comparisonFunction: number;
  33713. /** @hidden */
  33714. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33715. /** @hidden */
  33716. _lodGenerationScale: number;
  33717. /** @hidden */
  33718. _lodGenerationOffset: number;
  33719. /** @hidden */
  33720. _depthStencilTexture: Nullable<InternalTexture>;
  33721. /** @hidden */
  33722. _colorTextureArray: Nullable<WebGLTexture>;
  33723. /** @hidden */
  33724. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33725. /** @hidden */
  33726. _lodTextureHigh: Nullable<BaseTexture>;
  33727. /** @hidden */
  33728. _lodTextureMid: Nullable<BaseTexture>;
  33729. /** @hidden */
  33730. _lodTextureLow: Nullable<BaseTexture>;
  33731. /** @hidden */
  33732. _isRGBD: boolean;
  33733. /** @hidden */
  33734. _linearSpecularLOD: boolean;
  33735. /** @hidden */
  33736. _irradianceTexture: Nullable<BaseTexture>;
  33737. /** @hidden */
  33738. _webGLTexture: Nullable<WebGLTexture>;
  33739. /** @hidden */
  33740. _references: number;
  33741. private _engine;
  33742. /**
  33743. * Gets the Engine the texture belongs to.
  33744. * @returns The babylon engine
  33745. */
  33746. getEngine(): ThinEngine;
  33747. /**
  33748. * Gets the data source type of the texture
  33749. */
  33750. get source(): InternalTextureSource;
  33751. /**
  33752. * Creates a new InternalTexture
  33753. * @param engine defines the engine to use
  33754. * @param source defines the type of data that will be used
  33755. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33756. */
  33757. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33758. /**
  33759. * Increments the number of references (ie. the number of Texture that point to it)
  33760. */
  33761. incrementReferences(): void;
  33762. /**
  33763. * Change the size of the texture (not the size of the content)
  33764. * @param width defines the new width
  33765. * @param height defines the new height
  33766. * @param depth defines the new depth (1 by default)
  33767. */
  33768. updateSize(width: int, height: int, depth?: int): void;
  33769. /** @hidden */
  33770. _rebuild(): void;
  33771. /** @hidden */
  33772. _swapAndDie(target: InternalTexture): void;
  33773. /**
  33774. * Dispose the current allocated resources
  33775. */
  33776. dispose(): void;
  33777. }
  33778. }
  33779. declare module "babylonjs/Audio/analyser" {
  33780. import { Scene } from "babylonjs/scene";
  33781. /**
  33782. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33784. */
  33785. export class Analyser {
  33786. /**
  33787. * Gets or sets the smoothing
  33788. * @ignorenaming
  33789. */
  33790. SMOOTHING: number;
  33791. /**
  33792. * Gets or sets the FFT table size
  33793. * @ignorenaming
  33794. */
  33795. FFT_SIZE: number;
  33796. /**
  33797. * Gets or sets the bar graph amplitude
  33798. * @ignorenaming
  33799. */
  33800. BARGRAPHAMPLITUDE: number;
  33801. /**
  33802. * Gets or sets the position of the debug canvas
  33803. * @ignorenaming
  33804. */
  33805. DEBUGCANVASPOS: {
  33806. x: number;
  33807. y: number;
  33808. };
  33809. /**
  33810. * Gets or sets the debug canvas size
  33811. * @ignorenaming
  33812. */
  33813. DEBUGCANVASSIZE: {
  33814. width: number;
  33815. height: number;
  33816. };
  33817. private _byteFreqs;
  33818. private _byteTime;
  33819. private _floatFreqs;
  33820. private _webAudioAnalyser;
  33821. private _debugCanvas;
  33822. private _debugCanvasContext;
  33823. private _scene;
  33824. private _registerFunc;
  33825. private _audioEngine;
  33826. /**
  33827. * Creates a new analyser
  33828. * @param scene defines hosting scene
  33829. */
  33830. constructor(scene: Scene);
  33831. /**
  33832. * Get the number of data values you will have to play with for the visualization
  33833. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33834. * @returns a number
  33835. */
  33836. getFrequencyBinCount(): number;
  33837. /**
  33838. * Gets the current frequency data as a byte array
  33839. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33840. * @returns a Uint8Array
  33841. */
  33842. getByteFrequencyData(): Uint8Array;
  33843. /**
  33844. * Gets the current waveform as a byte array
  33845. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33846. * @returns a Uint8Array
  33847. */
  33848. getByteTimeDomainData(): Uint8Array;
  33849. /**
  33850. * Gets the current frequency data as a float array
  33851. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33852. * @returns a Float32Array
  33853. */
  33854. getFloatFrequencyData(): Float32Array;
  33855. /**
  33856. * Renders the debug canvas
  33857. */
  33858. drawDebugCanvas(): void;
  33859. /**
  33860. * Stops rendering the debug canvas and removes it
  33861. */
  33862. stopDebugCanvas(): void;
  33863. /**
  33864. * Connects two audio nodes
  33865. * @param inputAudioNode defines first node to connect
  33866. * @param outputAudioNode defines second node to connect
  33867. */
  33868. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33869. /**
  33870. * Releases all associated resources
  33871. */
  33872. dispose(): void;
  33873. }
  33874. }
  33875. declare module "babylonjs/Audio/audioEngine" {
  33876. import { IDisposable } from "babylonjs/scene";
  33877. import { Analyser } from "babylonjs/Audio/analyser";
  33878. import { Nullable } from "babylonjs/types";
  33879. import { Observable } from "babylonjs/Misc/observable";
  33880. /**
  33881. * This represents an audio engine and it is responsible
  33882. * to play, synchronize and analyse sounds throughout the application.
  33883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33884. */
  33885. export interface IAudioEngine extends IDisposable {
  33886. /**
  33887. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33888. */
  33889. readonly canUseWebAudio: boolean;
  33890. /**
  33891. * Gets the current AudioContext if available.
  33892. */
  33893. readonly audioContext: Nullable<AudioContext>;
  33894. /**
  33895. * The master gain node defines the global audio volume of your audio engine.
  33896. */
  33897. readonly masterGain: GainNode;
  33898. /**
  33899. * Gets whether or not mp3 are supported by your browser.
  33900. */
  33901. readonly isMP3supported: boolean;
  33902. /**
  33903. * Gets whether or not ogg are supported by your browser.
  33904. */
  33905. readonly isOGGsupported: boolean;
  33906. /**
  33907. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33908. * @ignoreNaming
  33909. */
  33910. WarnedWebAudioUnsupported: boolean;
  33911. /**
  33912. * Defines if the audio engine relies on a custom unlocked button.
  33913. * In this case, the embedded button will not be displayed.
  33914. */
  33915. useCustomUnlockedButton: boolean;
  33916. /**
  33917. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33918. */
  33919. readonly unlocked: boolean;
  33920. /**
  33921. * Event raised when audio has been unlocked on the browser.
  33922. */
  33923. onAudioUnlockedObservable: Observable<AudioEngine>;
  33924. /**
  33925. * Event raised when audio has been locked on the browser.
  33926. */
  33927. onAudioLockedObservable: Observable<AudioEngine>;
  33928. /**
  33929. * Flags the audio engine in Locked state.
  33930. * This happens due to new browser policies preventing audio to autoplay.
  33931. */
  33932. lock(): void;
  33933. /**
  33934. * Unlocks the audio engine once a user action has been done on the dom.
  33935. * This is helpful to resume play once browser policies have been satisfied.
  33936. */
  33937. unlock(): void;
  33938. /**
  33939. * Gets the global volume sets on the master gain.
  33940. * @returns the global volume if set or -1 otherwise
  33941. */
  33942. getGlobalVolume(): number;
  33943. /**
  33944. * Sets the global volume of your experience (sets on the master gain).
  33945. * @param newVolume Defines the new global volume of the application
  33946. */
  33947. setGlobalVolume(newVolume: number): void;
  33948. /**
  33949. * Connect the audio engine to an audio analyser allowing some amazing
  33950. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33952. * @param analyser The analyser to connect to the engine
  33953. */
  33954. connectToAnalyser(analyser: Analyser): void;
  33955. }
  33956. /**
  33957. * This represents the default audio engine used in babylon.
  33958. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33960. */
  33961. export class AudioEngine implements IAudioEngine {
  33962. private _audioContext;
  33963. private _audioContextInitialized;
  33964. private _muteButton;
  33965. private _hostElement;
  33966. /**
  33967. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33968. */
  33969. canUseWebAudio: boolean;
  33970. /**
  33971. * The master gain node defines the global audio volume of your audio engine.
  33972. */
  33973. masterGain: GainNode;
  33974. /**
  33975. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33976. * @ignoreNaming
  33977. */
  33978. WarnedWebAudioUnsupported: boolean;
  33979. /**
  33980. * Gets whether or not mp3 are supported by your browser.
  33981. */
  33982. isMP3supported: boolean;
  33983. /**
  33984. * Gets whether or not ogg are supported by your browser.
  33985. */
  33986. isOGGsupported: boolean;
  33987. /**
  33988. * Gets whether audio has been unlocked on the device.
  33989. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33990. * a user interaction has happened.
  33991. */
  33992. unlocked: boolean;
  33993. /**
  33994. * Defines if the audio engine relies on a custom unlocked button.
  33995. * In this case, the embedded button will not be displayed.
  33996. */
  33997. useCustomUnlockedButton: boolean;
  33998. /**
  33999. * Event raised when audio has been unlocked on the browser.
  34000. */
  34001. onAudioUnlockedObservable: Observable<AudioEngine>;
  34002. /**
  34003. * Event raised when audio has been locked on the browser.
  34004. */
  34005. onAudioLockedObservable: Observable<AudioEngine>;
  34006. /**
  34007. * Gets the current AudioContext if available.
  34008. */
  34009. get audioContext(): Nullable<AudioContext>;
  34010. private _connectedAnalyser;
  34011. /**
  34012. * Instantiates a new audio engine.
  34013. *
  34014. * There should be only one per page as some browsers restrict the number
  34015. * of audio contexts you can create.
  34016. * @param hostElement defines the host element where to display the mute icon if necessary
  34017. */
  34018. constructor(hostElement?: Nullable<HTMLElement>);
  34019. /**
  34020. * Flags the audio engine in Locked state.
  34021. * This happens due to new browser policies preventing audio to autoplay.
  34022. */
  34023. lock(): void;
  34024. /**
  34025. * Unlocks the audio engine once a user action has been done on the dom.
  34026. * This is helpful to resume play once browser policies have been satisfied.
  34027. */
  34028. unlock(): void;
  34029. private _resumeAudioContext;
  34030. private _initializeAudioContext;
  34031. private _tryToRun;
  34032. private _triggerRunningState;
  34033. private _triggerSuspendedState;
  34034. private _displayMuteButton;
  34035. private _moveButtonToTopLeft;
  34036. private _onResize;
  34037. private _hideMuteButton;
  34038. /**
  34039. * Destroy and release the resources associated with the audio ccontext.
  34040. */
  34041. dispose(): void;
  34042. /**
  34043. * Gets the global volume sets on the master gain.
  34044. * @returns the global volume if set or -1 otherwise
  34045. */
  34046. getGlobalVolume(): number;
  34047. /**
  34048. * Sets the global volume of your experience (sets on the master gain).
  34049. * @param newVolume Defines the new global volume of the application
  34050. */
  34051. setGlobalVolume(newVolume: number): void;
  34052. /**
  34053. * Connect the audio engine to an audio analyser allowing some amazing
  34054. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34056. * @param analyser The analyser to connect to the engine
  34057. */
  34058. connectToAnalyser(analyser: Analyser): void;
  34059. }
  34060. }
  34061. declare module "babylonjs/Loading/loadingScreen" {
  34062. /**
  34063. * Interface used to present a loading screen while loading a scene
  34064. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34065. */
  34066. export interface ILoadingScreen {
  34067. /**
  34068. * Function called to display the loading screen
  34069. */
  34070. displayLoadingUI: () => void;
  34071. /**
  34072. * Function called to hide the loading screen
  34073. */
  34074. hideLoadingUI: () => void;
  34075. /**
  34076. * Gets or sets the color to use for the background
  34077. */
  34078. loadingUIBackgroundColor: string;
  34079. /**
  34080. * Gets or sets the text to display while loading
  34081. */
  34082. loadingUIText: string;
  34083. }
  34084. /**
  34085. * Class used for the default loading screen
  34086. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34087. */
  34088. export class DefaultLoadingScreen implements ILoadingScreen {
  34089. private _renderingCanvas;
  34090. private _loadingText;
  34091. private _loadingDivBackgroundColor;
  34092. private _loadingDiv;
  34093. private _loadingTextDiv;
  34094. /** Gets or sets the logo url to use for the default loading screen */
  34095. static DefaultLogoUrl: string;
  34096. /** Gets or sets the spinner url to use for the default loading screen */
  34097. static DefaultSpinnerUrl: string;
  34098. /**
  34099. * Creates a new default loading screen
  34100. * @param _renderingCanvas defines the canvas used to render the scene
  34101. * @param _loadingText defines the default text to display
  34102. * @param _loadingDivBackgroundColor defines the default background color
  34103. */
  34104. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34105. /**
  34106. * Function called to display the loading screen
  34107. */
  34108. displayLoadingUI(): void;
  34109. /**
  34110. * Function called to hide the loading screen
  34111. */
  34112. hideLoadingUI(): void;
  34113. /**
  34114. * Gets or sets the text to display while loading
  34115. */
  34116. set loadingUIText(text: string);
  34117. get loadingUIText(): string;
  34118. /**
  34119. * Gets or sets the color to use for the background
  34120. */
  34121. get loadingUIBackgroundColor(): string;
  34122. set loadingUIBackgroundColor(color: string);
  34123. private _resizeLoadingUI;
  34124. }
  34125. }
  34126. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34127. /**
  34128. * Interface for any object that can request an animation frame
  34129. */
  34130. export interface ICustomAnimationFrameRequester {
  34131. /**
  34132. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34133. */
  34134. renderFunction?: Function;
  34135. /**
  34136. * Called to request the next frame to render to
  34137. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34138. */
  34139. requestAnimationFrame: Function;
  34140. /**
  34141. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34142. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34143. */
  34144. requestID?: number;
  34145. }
  34146. }
  34147. declare module "babylonjs/Misc/performanceMonitor" {
  34148. /**
  34149. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34150. */
  34151. export class PerformanceMonitor {
  34152. private _enabled;
  34153. private _rollingFrameTime;
  34154. private _lastFrameTimeMs;
  34155. /**
  34156. * constructor
  34157. * @param frameSampleSize The number of samples required to saturate the sliding window
  34158. */
  34159. constructor(frameSampleSize?: number);
  34160. /**
  34161. * Samples current frame
  34162. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34163. */
  34164. sampleFrame(timeMs?: number): void;
  34165. /**
  34166. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34167. */
  34168. get averageFrameTime(): number;
  34169. /**
  34170. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34171. */
  34172. get averageFrameTimeVariance(): number;
  34173. /**
  34174. * Returns the frame time of the most recent frame
  34175. */
  34176. get instantaneousFrameTime(): number;
  34177. /**
  34178. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34179. */
  34180. get averageFPS(): number;
  34181. /**
  34182. * Returns the average framerate in frames per second using the most recent frame time
  34183. */
  34184. get instantaneousFPS(): number;
  34185. /**
  34186. * Returns true if enough samples have been taken to completely fill the sliding window
  34187. */
  34188. get isSaturated(): boolean;
  34189. /**
  34190. * Enables contributions to the sliding window sample set
  34191. */
  34192. enable(): void;
  34193. /**
  34194. * Disables contributions to the sliding window sample set
  34195. * Samples will not be interpolated over the disabled period
  34196. */
  34197. disable(): void;
  34198. /**
  34199. * Returns true if sampling is enabled
  34200. */
  34201. get isEnabled(): boolean;
  34202. /**
  34203. * Resets performance monitor
  34204. */
  34205. reset(): void;
  34206. }
  34207. /**
  34208. * RollingAverage
  34209. *
  34210. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34211. */
  34212. export class RollingAverage {
  34213. /**
  34214. * Current average
  34215. */
  34216. average: number;
  34217. /**
  34218. * Current variance
  34219. */
  34220. variance: number;
  34221. protected _samples: Array<number>;
  34222. protected _sampleCount: number;
  34223. protected _pos: number;
  34224. protected _m2: number;
  34225. /**
  34226. * constructor
  34227. * @param length The number of samples required to saturate the sliding window
  34228. */
  34229. constructor(length: number);
  34230. /**
  34231. * Adds a sample to the sample set
  34232. * @param v The sample value
  34233. */
  34234. add(v: number): void;
  34235. /**
  34236. * Returns previously added values or null if outside of history or outside the sliding window domain
  34237. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34238. * @return Value previously recorded with add() or null if outside of range
  34239. */
  34240. history(i: number): number;
  34241. /**
  34242. * Returns true if enough samples have been taken to completely fill the sliding window
  34243. * @return true if sample-set saturated
  34244. */
  34245. isSaturated(): boolean;
  34246. /**
  34247. * Resets the rolling average (equivalent to 0 samples taken so far)
  34248. */
  34249. reset(): void;
  34250. /**
  34251. * Wraps a value around the sample range boundaries
  34252. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34253. * @return Wrapped position in sample range
  34254. */
  34255. protected _wrapPosition(i: number): number;
  34256. }
  34257. }
  34258. declare module "babylonjs/Misc/perfCounter" {
  34259. /**
  34260. * This class is used to track a performance counter which is number based.
  34261. * The user has access to many properties which give statistics of different nature.
  34262. *
  34263. * The implementer can track two kinds of Performance Counter: time and count.
  34264. * 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.
  34265. * 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.
  34266. */
  34267. export class PerfCounter {
  34268. /**
  34269. * Gets or sets a global boolean to turn on and off all the counters
  34270. */
  34271. static Enabled: boolean;
  34272. /**
  34273. * Returns the smallest value ever
  34274. */
  34275. get min(): number;
  34276. /**
  34277. * Returns the biggest value ever
  34278. */
  34279. get max(): number;
  34280. /**
  34281. * Returns the average value since the performance counter is running
  34282. */
  34283. get average(): number;
  34284. /**
  34285. * Returns the average value of the last second the counter was monitored
  34286. */
  34287. get lastSecAverage(): number;
  34288. /**
  34289. * Returns the current value
  34290. */
  34291. get current(): number;
  34292. /**
  34293. * Gets the accumulated total
  34294. */
  34295. get total(): number;
  34296. /**
  34297. * Gets the total value count
  34298. */
  34299. get count(): number;
  34300. /**
  34301. * Creates a new counter
  34302. */
  34303. constructor();
  34304. /**
  34305. * Call this method to start monitoring a new frame.
  34306. * 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.
  34307. */
  34308. fetchNewFrame(): void;
  34309. /**
  34310. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34311. * @param newCount the count value to add to the monitored count
  34312. * @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.
  34313. */
  34314. addCount(newCount: number, fetchResult: boolean): void;
  34315. /**
  34316. * Start monitoring this performance counter
  34317. */
  34318. beginMonitoring(): void;
  34319. /**
  34320. * Compute the time lapsed since the previous beginMonitoring() call.
  34321. * @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
  34322. */
  34323. endMonitoring(newFrame?: boolean): void;
  34324. private _fetchResult;
  34325. private _startMonitoringTime;
  34326. private _min;
  34327. private _max;
  34328. private _average;
  34329. private _current;
  34330. private _totalValueCount;
  34331. private _totalAccumulated;
  34332. private _lastSecAverage;
  34333. private _lastSecAccumulated;
  34334. private _lastSecTime;
  34335. private _lastSecValueCount;
  34336. }
  34337. }
  34338. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34339. module "babylonjs/Engines/thinEngine" {
  34340. interface ThinEngine {
  34341. /**
  34342. * Sets alpha constants used by some alpha blending modes
  34343. * @param r defines the red component
  34344. * @param g defines the green component
  34345. * @param b defines the blue component
  34346. * @param a defines the alpha component
  34347. */
  34348. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34349. /**
  34350. * Sets the current alpha mode
  34351. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34352. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34353. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34354. */
  34355. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34356. /**
  34357. * Gets the current alpha mode
  34358. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34359. * @returns the current alpha mode
  34360. */
  34361. getAlphaMode(): number;
  34362. /**
  34363. * Sets the current alpha equation
  34364. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34365. */
  34366. setAlphaEquation(equation: number): void;
  34367. /**
  34368. * Gets the current alpha equation.
  34369. * @returns the current alpha equation
  34370. */
  34371. getAlphaEquation(): number;
  34372. }
  34373. }
  34374. }
  34375. declare module "babylonjs/Engines/engine" {
  34376. import { Observable } from "babylonjs/Misc/observable";
  34377. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34378. import { Scene } from "babylonjs/scene";
  34379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34380. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34381. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34382. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34383. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34384. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34385. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34386. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34387. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34389. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34390. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34391. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34392. import "babylonjs/Engines/Extensions/engine.alpha";
  34393. import { Material } from "babylonjs/Materials/material";
  34394. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34395. /**
  34396. * Defines the interface used by display changed events
  34397. */
  34398. export interface IDisplayChangedEventArgs {
  34399. /** Gets the vrDisplay object (if any) */
  34400. vrDisplay: Nullable<any>;
  34401. /** Gets a boolean indicating if webVR is supported */
  34402. vrSupported: boolean;
  34403. }
  34404. /**
  34405. * Defines the interface used by objects containing a viewport (like a camera)
  34406. */
  34407. interface IViewportOwnerLike {
  34408. /**
  34409. * Gets or sets the viewport
  34410. */
  34411. viewport: IViewportLike;
  34412. }
  34413. /**
  34414. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34415. */
  34416. export class Engine extends ThinEngine {
  34417. /** Defines that alpha blending is disabled */
  34418. static readonly ALPHA_DISABLE: number;
  34419. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34420. static readonly ALPHA_ADD: number;
  34421. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34422. static readonly ALPHA_COMBINE: number;
  34423. /** Defines that alpha blending to DEST - SRC * DEST */
  34424. static readonly ALPHA_SUBTRACT: number;
  34425. /** Defines that alpha blending to SRC * DEST */
  34426. static readonly ALPHA_MULTIPLY: number;
  34427. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34428. static readonly ALPHA_MAXIMIZED: number;
  34429. /** Defines that alpha blending to SRC + DEST */
  34430. static readonly ALPHA_ONEONE: number;
  34431. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34432. static readonly ALPHA_PREMULTIPLIED: number;
  34433. /**
  34434. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34435. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34436. */
  34437. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34438. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34439. static readonly ALPHA_INTERPOLATE: number;
  34440. /**
  34441. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34442. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34443. */
  34444. static readonly ALPHA_SCREENMODE: number;
  34445. /** Defines that the ressource is not delayed*/
  34446. static readonly DELAYLOADSTATE_NONE: number;
  34447. /** Defines that the ressource was successfully delay loaded */
  34448. static readonly DELAYLOADSTATE_LOADED: number;
  34449. /** Defines that the ressource is currently delay loading */
  34450. static readonly DELAYLOADSTATE_LOADING: number;
  34451. /** Defines that the ressource is delayed and has not started loading */
  34452. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34453. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34454. static readonly NEVER: number;
  34455. /** 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 */
  34456. static readonly ALWAYS: number;
  34457. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34458. static readonly LESS: number;
  34459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34460. static readonly EQUAL: number;
  34461. /** 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 */
  34462. static readonly LEQUAL: number;
  34463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34464. static readonly GREATER: number;
  34465. /** 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 */
  34466. static readonly GEQUAL: number;
  34467. /** 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 */
  34468. static readonly NOTEQUAL: number;
  34469. /** Passed to stencilOperation to specify that stencil value must be kept */
  34470. static readonly KEEP: number;
  34471. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34472. static readonly REPLACE: number;
  34473. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34474. static readonly INCR: number;
  34475. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34476. static readonly DECR: number;
  34477. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34478. static readonly INVERT: number;
  34479. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34480. static readonly INCR_WRAP: number;
  34481. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34482. static readonly DECR_WRAP: number;
  34483. /** Texture is not repeating outside of 0..1 UVs */
  34484. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34485. /** Texture is repeating outside of 0..1 UVs */
  34486. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34487. /** Texture is repeating and mirrored */
  34488. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34489. /** ALPHA */
  34490. static readonly TEXTUREFORMAT_ALPHA: number;
  34491. /** LUMINANCE */
  34492. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34493. /** LUMINANCE_ALPHA */
  34494. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34495. /** RGB */
  34496. static readonly TEXTUREFORMAT_RGB: number;
  34497. /** RGBA */
  34498. static readonly TEXTUREFORMAT_RGBA: number;
  34499. /** RED */
  34500. static readonly TEXTUREFORMAT_RED: number;
  34501. /** RED (2nd reference) */
  34502. static readonly TEXTUREFORMAT_R: number;
  34503. /** RG */
  34504. static readonly TEXTUREFORMAT_RG: number;
  34505. /** RED_INTEGER */
  34506. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34507. /** RED_INTEGER (2nd reference) */
  34508. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34509. /** RG_INTEGER */
  34510. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34511. /** RGB_INTEGER */
  34512. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34513. /** RGBA_INTEGER */
  34514. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34515. /** UNSIGNED_BYTE */
  34516. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34517. /** UNSIGNED_BYTE (2nd reference) */
  34518. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34519. /** FLOAT */
  34520. static readonly TEXTURETYPE_FLOAT: number;
  34521. /** HALF_FLOAT */
  34522. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34523. /** BYTE */
  34524. static readonly TEXTURETYPE_BYTE: number;
  34525. /** SHORT */
  34526. static readonly TEXTURETYPE_SHORT: number;
  34527. /** UNSIGNED_SHORT */
  34528. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34529. /** INT */
  34530. static readonly TEXTURETYPE_INT: number;
  34531. /** UNSIGNED_INT */
  34532. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34533. /** UNSIGNED_SHORT_4_4_4_4 */
  34534. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34535. /** UNSIGNED_SHORT_5_5_5_1 */
  34536. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34537. /** UNSIGNED_SHORT_5_6_5 */
  34538. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34539. /** UNSIGNED_INT_2_10_10_10_REV */
  34540. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34541. /** UNSIGNED_INT_24_8 */
  34542. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34543. /** UNSIGNED_INT_10F_11F_11F_REV */
  34544. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34545. /** UNSIGNED_INT_5_9_9_9_REV */
  34546. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34547. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34548. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34549. /** nearest is mag = nearest and min = nearest and mip = linear */
  34550. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34551. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34552. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34553. /** Trilinear is mag = linear and min = linear and mip = linear */
  34554. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34555. /** nearest is mag = nearest and min = nearest and mip = linear */
  34556. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34557. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34558. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34559. /** Trilinear is mag = linear and min = linear and mip = linear */
  34560. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34561. /** mag = nearest and min = nearest and mip = nearest */
  34562. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34563. /** mag = nearest and min = linear and mip = nearest */
  34564. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34565. /** mag = nearest and min = linear and mip = linear */
  34566. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34567. /** mag = nearest and min = linear and mip = none */
  34568. static readonly TEXTURE_NEAREST_LINEAR: number;
  34569. /** mag = nearest and min = nearest and mip = none */
  34570. static readonly TEXTURE_NEAREST_NEAREST: number;
  34571. /** mag = linear and min = nearest and mip = nearest */
  34572. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34573. /** mag = linear and min = nearest and mip = linear */
  34574. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34575. /** mag = linear and min = linear and mip = none */
  34576. static readonly TEXTURE_LINEAR_LINEAR: number;
  34577. /** mag = linear and min = nearest and mip = none */
  34578. static readonly TEXTURE_LINEAR_NEAREST: number;
  34579. /** Explicit coordinates mode */
  34580. static readonly TEXTURE_EXPLICIT_MODE: number;
  34581. /** Spherical coordinates mode */
  34582. static readonly TEXTURE_SPHERICAL_MODE: number;
  34583. /** Planar coordinates mode */
  34584. static readonly TEXTURE_PLANAR_MODE: number;
  34585. /** Cubic coordinates mode */
  34586. static readonly TEXTURE_CUBIC_MODE: number;
  34587. /** Projection coordinates mode */
  34588. static readonly TEXTURE_PROJECTION_MODE: number;
  34589. /** Skybox coordinates mode */
  34590. static readonly TEXTURE_SKYBOX_MODE: number;
  34591. /** Inverse Cubic coordinates mode */
  34592. static readonly TEXTURE_INVCUBIC_MODE: number;
  34593. /** Equirectangular coordinates mode */
  34594. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34595. /** Equirectangular Fixed coordinates mode */
  34596. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34597. /** Equirectangular Fixed Mirrored coordinates mode */
  34598. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34599. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34600. static readonly SCALEMODE_FLOOR: number;
  34601. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34602. static readonly SCALEMODE_NEAREST: number;
  34603. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34604. static readonly SCALEMODE_CEILING: number;
  34605. /**
  34606. * Returns the current npm package of the sdk
  34607. */
  34608. static get NpmPackage(): string;
  34609. /**
  34610. * Returns the current version of the framework
  34611. */
  34612. static get Version(): string;
  34613. /** Gets the list of created engines */
  34614. static get Instances(): Engine[];
  34615. /**
  34616. * Gets the latest created engine
  34617. */
  34618. static get LastCreatedEngine(): Nullable<Engine>;
  34619. /**
  34620. * Gets the latest created scene
  34621. */
  34622. static get LastCreatedScene(): Nullable<Scene>;
  34623. /**
  34624. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34625. * @param flag defines which part of the materials must be marked as dirty
  34626. * @param predicate defines a predicate used to filter which materials should be affected
  34627. */
  34628. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34629. /**
  34630. * Method called to create the default loading screen.
  34631. * This can be overriden in your own app.
  34632. * @param canvas The rendering canvas element
  34633. * @returns The loading screen
  34634. */
  34635. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34636. /**
  34637. * Method called to create the default rescale post process on each engine.
  34638. */
  34639. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34640. /**
  34641. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34642. **/
  34643. enableOfflineSupport: boolean;
  34644. /**
  34645. * 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)
  34646. **/
  34647. disableManifestCheck: boolean;
  34648. /**
  34649. * Gets the list of created scenes
  34650. */
  34651. scenes: Scene[];
  34652. /**
  34653. * Event raised when a new scene is created
  34654. */
  34655. onNewSceneAddedObservable: Observable<Scene>;
  34656. /**
  34657. * Gets the list of created postprocesses
  34658. */
  34659. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34660. /**
  34661. * Gets a boolean indicating if the pointer is currently locked
  34662. */
  34663. isPointerLock: boolean;
  34664. /**
  34665. * Observable event triggered each time the rendering canvas is resized
  34666. */
  34667. onResizeObservable: Observable<Engine>;
  34668. /**
  34669. * Observable event triggered each time the canvas loses focus
  34670. */
  34671. onCanvasBlurObservable: Observable<Engine>;
  34672. /**
  34673. * Observable event triggered each time the canvas gains focus
  34674. */
  34675. onCanvasFocusObservable: Observable<Engine>;
  34676. /**
  34677. * Observable event triggered each time the canvas receives pointerout event
  34678. */
  34679. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34680. /**
  34681. * Observable raised when the engine begins a new frame
  34682. */
  34683. onBeginFrameObservable: Observable<Engine>;
  34684. /**
  34685. * If set, will be used to request the next animation frame for the render loop
  34686. */
  34687. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34688. /**
  34689. * Observable raised when the engine ends the current frame
  34690. */
  34691. onEndFrameObservable: Observable<Engine>;
  34692. /**
  34693. * Observable raised when the engine is about to compile a shader
  34694. */
  34695. onBeforeShaderCompilationObservable: Observable<Engine>;
  34696. /**
  34697. * Observable raised when the engine has jsut compiled a shader
  34698. */
  34699. onAfterShaderCompilationObservable: Observable<Engine>;
  34700. /**
  34701. * Gets the audio engine
  34702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34703. * @ignorenaming
  34704. */
  34705. static audioEngine: IAudioEngine;
  34706. /**
  34707. * Default AudioEngine factory responsible of creating the Audio Engine.
  34708. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34709. */
  34710. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34711. /**
  34712. * Default offline support factory responsible of creating a tool used to store data locally.
  34713. * By default, this will create a Database object if the workload has been embedded.
  34714. */
  34715. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34716. private _loadingScreen;
  34717. private _pointerLockRequested;
  34718. private _dummyFramebuffer;
  34719. private _rescalePostProcess;
  34720. private _deterministicLockstep;
  34721. private _lockstepMaxSteps;
  34722. private _timeStep;
  34723. protected get _supportsHardwareTextureRescaling(): boolean;
  34724. private _fps;
  34725. private _deltaTime;
  34726. /** @hidden */
  34727. _drawCalls: PerfCounter;
  34728. /** 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 */
  34729. canvasTabIndex: number;
  34730. /**
  34731. * Turn this value on if you want to pause FPS computation when in background
  34732. */
  34733. disablePerformanceMonitorInBackground: boolean;
  34734. private _performanceMonitor;
  34735. /**
  34736. * Gets the performance monitor attached to this engine
  34737. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34738. */
  34739. get performanceMonitor(): PerformanceMonitor;
  34740. private _onFocus;
  34741. private _onBlur;
  34742. private _onCanvasPointerOut;
  34743. private _onCanvasBlur;
  34744. private _onCanvasFocus;
  34745. private _onFullscreenChange;
  34746. private _onPointerLockChange;
  34747. /**
  34748. * Gets the HTML element used to attach event listeners
  34749. * @returns a HTML element
  34750. */
  34751. getInputElement(): Nullable<HTMLElement>;
  34752. /**
  34753. * Creates a new engine
  34754. * @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
  34755. * @param antialias defines enable antialiasing (default: false)
  34756. * @param options defines further options to be sent to the getContext() function
  34757. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34758. */
  34759. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34760. /**
  34761. * Gets current aspect ratio
  34762. * @param viewportOwner defines the camera to use to get the aspect ratio
  34763. * @param useScreen defines if screen size must be used (or the current render target if any)
  34764. * @returns a number defining the aspect ratio
  34765. */
  34766. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34767. /**
  34768. * Gets current screen aspect ratio
  34769. * @returns a number defining the aspect ratio
  34770. */
  34771. getScreenAspectRatio(): number;
  34772. /**
  34773. * Gets the client rect of the HTML canvas attached with the current webGL context
  34774. * @returns a client rectanglee
  34775. */
  34776. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34777. /**
  34778. * Gets the client rect of the HTML element used for events
  34779. * @returns a client rectanglee
  34780. */
  34781. getInputElementClientRect(): Nullable<ClientRect>;
  34782. /**
  34783. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34784. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34785. * @returns true if engine is in deterministic lock step mode
  34786. */
  34787. isDeterministicLockStep(): boolean;
  34788. /**
  34789. * Gets the max steps when engine is running in deterministic lock step
  34790. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34791. * @returns the max steps
  34792. */
  34793. getLockstepMaxSteps(): number;
  34794. /**
  34795. * Returns the time in ms between steps when using deterministic lock step.
  34796. * @returns time step in (ms)
  34797. */
  34798. getTimeStep(): number;
  34799. /**
  34800. * Force the mipmap generation for the given render target texture
  34801. * @param texture defines the render target texture to use
  34802. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34803. */
  34804. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34805. /** States */
  34806. /**
  34807. * Set various states to the webGL context
  34808. * @param culling defines backface culling state
  34809. * @param zOffset defines the value to apply to zOffset (0 by default)
  34810. * @param force defines if states must be applied even if cache is up to date
  34811. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34812. */
  34813. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34814. /**
  34815. * Set the z offset to apply to current rendering
  34816. * @param value defines the offset to apply
  34817. */
  34818. setZOffset(value: number): void;
  34819. /**
  34820. * Gets the current value of the zOffset
  34821. * @returns the current zOffset state
  34822. */
  34823. getZOffset(): number;
  34824. /**
  34825. * Enable or disable depth buffering
  34826. * @param enable defines the state to set
  34827. */
  34828. setDepthBuffer(enable: boolean): void;
  34829. /**
  34830. * Gets a boolean indicating if depth writing is enabled
  34831. * @returns the current depth writing state
  34832. */
  34833. getDepthWrite(): boolean;
  34834. /**
  34835. * Enable or disable depth writing
  34836. * @param enable defines the state to set
  34837. */
  34838. setDepthWrite(enable: boolean): void;
  34839. /**
  34840. * Gets a boolean indicating if stencil buffer is enabled
  34841. * @returns the current stencil buffer state
  34842. */
  34843. getStencilBuffer(): boolean;
  34844. /**
  34845. * Enable or disable the stencil buffer
  34846. * @param enable defines if the stencil buffer must be enabled or disabled
  34847. */
  34848. setStencilBuffer(enable: boolean): void;
  34849. /**
  34850. * Gets the current stencil mask
  34851. * @returns a number defining the new stencil mask to use
  34852. */
  34853. getStencilMask(): number;
  34854. /**
  34855. * Sets the current stencil mask
  34856. * @param mask defines the new stencil mask to use
  34857. */
  34858. setStencilMask(mask: number): void;
  34859. /**
  34860. * Gets the current stencil function
  34861. * @returns a number defining the stencil function to use
  34862. */
  34863. getStencilFunction(): number;
  34864. /**
  34865. * Gets the current stencil reference value
  34866. * @returns a number defining the stencil reference value to use
  34867. */
  34868. getStencilFunctionReference(): number;
  34869. /**
  34870. * Gets the current stencil mask
  34871. * @returns a number defining the stencil mask to use
  34872. */
  34873. getStencilFunctionMask(): number;
  34874. /**
  34875. * Sets the current stencil function
  34876. * @param stencilFunc defines the new stencil function to use
  34877. */
  34878. setStencilFunction(stencilFunc: number): void;
  34879. /**
  34880. * Sets the current stencil reference
  34881. * @param reference defines the new stencil reference to use
  34882. */
  34883. setStencilFunctionReference(reference: number): void;
  34884. /**
  34885. * Sets the current stencil mask
  34886. * @param mask defines the new stencil mask to use
  34887. */
  34888. setStencilFunctionMask(mask: number): void;
  34889. /**
  34890. * Gets the current stencil operation when stencil fails
  34891. * @returns a number defining stencil operation to use when stencil fails
  34892. */
  34893. getStencilOperationFail(): number;
  34894. /**
  34895. * Gets the current stencil operation when depth fails
  34896. * @returns a number defining stencil operation to use when depth fails
  34897. */
  34898. getStencilOperationDepthFail(): number;
  34899. /**
  34900. * Gets the current stencil operation when stencil passes
  34901. * @returns a number defining stencil operation to use when stencil passes
  34902. */
  34903. getStencilOperationPass(): number;
  34904. /**
  34905. * Sets the stencil operation to use when stencil fails
  34906. * @param operation defines the stencil operation to use when stencil fails
  34907. */
  34908. setStencilOperationFail(operation: number): void;
  34909. /**
  34910. * Sets the stencil operation to use when depth fails
  34911. * @param operation defines the stencil operation to use when depth fails
  34912. */
  34913. setStencilOperationDepthFail(operation: number): void;
  34914. /**
  34915. * Sets the stencil operation to use when stencil passes
  34916. * @param operation defines the stencil operation to use when stencil passes
  34917. */
  34918. setStencilOperationPass(operation: number): void;
  34919. /**
  34920. * Sets a boolean indicating if the dithering state is enabled or disabled
  34921. * @param value defines the dithering state
  34922. */
  34923. setDitheringState(value: boolean): void;
  34924. /**
  34925. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34926. * @param value defines the rasterizer state
  34927. */
  34928. setRasterizerState(value: boolean): void;
  34929. /**
  34930. * Gets the current depth function
  34931. * @returns a number defining the depth function
  34932. */
  34933. getDepthFunction(): Nullable<number>;
  34934. /**
  34935. * Sets the current depth function
  34936. * @param depthFunc defines the function to use
  34937. */
  34938. setDepthFunction(depthFunc: number): void;
  34939. /**
  34940. * Sets the current depth function to GREATER
  34941. */
  34942. setDepthFunctionToGreater(): void;
  34943. /**
  34944. * Sets the current depth function to GEQUAL
  34945. */
  34946. setDepthFunctionToGreaterOrEqual(): void;
  34947. /**
  34948. * Sets the current depth function to LESS
  34949. */
  34950. setDepthFunctionToLess(): void;
  34951. /**
  34952. * Sets the current depth function to LEQUAL
  34953. */
  34954. setDepthFunctionToLessOrEqual(): void;
  34955. private _cachedStencilBuffer;
  34956. private _cachedStencilFunction;
  34957. private _cachedStencilMask;
  34958. private _cachedStencilOperationPass;
  34959. private _cachedStencilOperationFail;
  34960. private _cachedStencilOperationDepthFail;
  34961. private _cachedStencilReference;
  34962. /**
  34963. * Caches the the state of the stencil buffer
  34964. */
  34965. cacheStencilState(): void;
  34966. /**
  34967. * Restores the state of the stencil buffer
  34968. */
  34969. restoreStencilState(): void;
  34970. /**
  34971. * Directly set the WebGL Viewport
  34972. * @param x defines the x coordinate of the viewport (in screen space)
  34973. * @param y defines the y coordinate of the viewport (in screen space)
  34974. * @param width defines the width of the viewport (in screen space)
  34975. * @param height defines the height of the viewport (in screen space)
  34976. * @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
  34977. */
  34978. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34979. /**
  34980. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34981. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34982. * @param y defines the y-coordinate of the corner of the clear rectangle
  34983. * @param width defines the width of the clear rectangle
  34984. * @param height defines the height of the clear rectangle
  34985. * @param clearColor defines the clear color
  34986. */
  34987. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34988. /**
  34989. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34990. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34991. * @param y defines the y-coordinate of the corner of the clear rectangle
  34992. * @param width defines the width of the clear rectangle
  34993. * @param height defines the height of the clear rectangle
  34994. */
  34995. enableScissor(x: number, y: number, width: number, height: number): void;
  34996. /**
  34997. * Disable previously set scissor test rectangle
  34998. */
  34999. disableScissor(): void;
  35000. protected _reportDrawCall(): void;
  35001. /**
  35002. * Initializes a webVR display and starts listening to display change events
  35003. * The onVRDisplayChangedObservable will be notified upon these changes
  35004. * @returns The onVRDisplayChangedObservable
  35005. */
  35006. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35007. /** @hidden */
  35008. _prepareVRComponent(): void;
  35009. /** @hidden */
  35010. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35011. /** @hidden */
  35012. _submitVRFrame(): void;
  35013. /**
  35014. * Call this function to leave webVR mode
  35015. * Will do nothing if webVR is not supported or if there is no webVR device
  35016. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35017. */
  35018. disableVR(): void;
  35019. /**
  35020. * Gets a boolean indicating that the system is in VR mode and is presenting
  35021. * @returns true if VR mode is engaged
  35022. */
  35023. isVRPresenting(): boolean;
  35024. /** @hidden */
  35025. _requestVRFrame(): void;
  35026. /** @hidden */
  35027. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35028. /**
  35029. * Gets the source code of the vertex shader associated with a specific webGL program
  35030. * @param program defines the program to use
  35031. * @returns a string containing the source code of the vertex shader associated with the program
  35032. */
  35033. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35034. /**
  35035. * Gets the source code of the fragment shader associated with a specific webGL program
  35036. * @param program defines the program to use
  35037. * @returns a string containing the source code of the fragment shader associated with the program
  35038. */
  35039. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35040. /**
  35041. * Sets a depth stencil texture from a render target to the according uniform.
  35042. * @param channel The texture channel
  35043. * @param uniform The uniform to set
  35044. * @param texture The render target texture containing the depth stencil texture to apply
  35045. */
  35046. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35047. /**
  35048. * Sets a texture to the webGL context from a postprocess
  35049. * @param channel defines the channel to use
  35050. * @param postProcess defines the source postprocess
  35051. */
  35052. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35053. /**
  35054. * Binds the output of the passed in post process to the texture channel specified
  35055. * @param channel The channel the texture should be bound to
  35056. * @param postProcess The post process which's output should be bound
  35057. */
  35058. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35059. /** @hidden */
  35060. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  35061. protected _rebuildBuffers(): void;
  35062. /** @hidden */
  35063. _renderFrame(): void;
  35064. _renderLoop(): void;
  35065. /** @hidden */
  35066. _renderViews(): boolean;
  35067. /**
  35068. * Toggle full screen mode
  35069. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35070. */
  35071. switchFullscreen(requestPointerLock: boolean): void;
  35072. /**
  35073. * Enters full screen mode
  35074. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35075. */
  35076. enterFullscreen(requestPointerLock: boolean): void;
  35077. /**
  35078. * Exits full screen mode
  35079. */
  35080. exitFullscreen(): void;
  35081. /**
  35082. * Enters Pointerlock mode
  35083. */
  35084. enterPointerlock(): void;
  35085. /**
  35086. * Exits Pointerlock mode
  35087. */
  35088. exitPointerlock(): void;
  35089. /**
  35090. * Begin a new frame
  35091. */
  35092. beginFrame(): void;
  35093. /**
  35094. * Enf the current frame
  35095. */
  35096. endFrame(): void;
  35097. resize(): void;
  35098. /**
  35099. * Force a specific size of the canvas
  35100. * @param width defines the new canvas' width
  35101. * @param height defines the new canvas' height
  35102. */
  35103. setSize(width: number, height: number): void;
  35104. /**
  35105. * Updates a dynamic vertex buffer.
  35106. * @param vertexBuffer the vertex buffer to update
  35107. * @param data the data used to update the vertex buffer
  35108. * @param byteOffset the byte offset of the data
  35109. * @param byteLength the byte length of the data
  35110. */
  35111. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35112. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35113. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35114. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35115. _releaseTexture(texture: InternalTexture): void;
  35116. /**
  35117. * @hidden
  35118. * Rescales a texture
  35119. * @param source input texutre
  35120. * @param destination destination texture
  35121. * @param scene scene to use to render the resize
  35122. * @param internalFormat format to use when resizing
  35123. * @param onComplete callback to be called when resize has completed
  35124. */
  35125. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35126. /**
  35127. * Gets the current framerate
  35128. * @returns a number representing the framerate
  35129. */
  35130. getFps(): number;
  35131. /**
  35132. * Gets the time spent between current and previous frame
  35133. * @returns a number representing the delta time in ms
  35134. */
  35135. getDeltaTime(): number;
  35136. private _measureFps;
  35137. /** @hidden */
  35138. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35139. /**
  35140. * Update a dynamic index buffer
  35141. * @param indexBuffer defines the target index buffer
  35142. * @param indices defines the data to update
  35143. * @param offset defines the offset in the target index buffer where update should start
  35144. */
  35145. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35146. /**
  35147. * Updates the sample count of a render target texture
  35148. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35149. * @param texture defines the texture to update
  35150. * @param samples defines the sample count to set
  35151. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35152. */
  35153. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35154. /**
  35155. * Updates a depth texture Comparison Mode and Function.
  35156. * If the comparison Function is equal to 0, the mode will be set to none.
  35157. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35158. * @param texture The texture to set the comparison function for
  35159. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35160. */
  35161. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35162. /**
  35163. * Creates a webGL buffer to use with instanciation
  35164. * @param capacity defines the size of the buffer
  35165. * @returns the webGL buffer
  35166. */
  35167. createInstancesBuffer(capacity: number): DataBuffer;
  35168. /**
  35169. * Delete a webGL buffer used with instanciation
  35170. * @param buffer defines the webGL buffer to delete
  35171. */
  35172. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35173. private _clientWaitAsync;
  35174. /** @hidden */
  35175. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35176. /** @hidden */
  35177. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35178. dispose(): void;
  35179. private _disableTouchAction;
  35180. /**
  35181. * Display the loading screen
  35182. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35183. */
  35184. displayLoadingUI(): void;
  35185. /**
  35186. * Hide the loading screen
  35187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35188. */
  35189. hideLoadingUI(): void;
  35190. /**
  35191. * Gets the current loading screen object
  35192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35193. */
  35194. get loadingScreen(): ILoadingScreen;
  35195. /**
  35196. * Sets the current loading screen object
  35197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35198. */
  35199. set loadingScreen(loadingScreen: ILoadingScreen);
  35200. /**
  35201. * Sets the current loading screen text
  35202. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35203. */
  35204. set loadingUIText(text: string);
  35205. /**
  35206. * Sets the current loading screen background color
  35207. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35208. */
  35209. set loadingUIBackgroundColor(color: string);
  35210. /** Pointerlock and fullscreen */
  35211. /**
  35212. * Ask the browser to promote the current element to pointerlock mode
  35213. * @param element defines the DOM element to promote
  35214. */
  35215. static _RequestPointerlock(element: HTMLElement): void;
  35216. /**
  35217. * Asks the browser to exit pointerlock mode
  35218. */
  35219. static _ExitPointerlock(): void;
  35220. /**
  35221. * Ask the browser to promote the current element to fullscreen rendering mode
  35222. * @param element defines the DOM element to promote
  35223. */
  35224. static _RequestFullscreen(element: HTMLElement): void;
  35225. /**
  35226. * Asks the browser to exit fullscreen mode
  35227. */
  35228. static _ExitFullscreen(): void;
  35229. }
  35230. }
  35231. declare module "babylonjs/Engines/engineStore" {
  35232. import { Nullable } from "babylonjs/types";
  35233. import { Engine } from "babylonjs/Engines/engine";
  35234. import { Scene } from "babylonjs/scene";
  35235. /**
  35236. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35237. * during the life time of the application.
  35238. */
  35239. export class EngineStore {
  35240. /** Gets the list of created engines */
  35241. static Instances: import("babylonjs/Engines/engine").Engine[];
  35242. /** @hidden */
  35243. static _LastCreatedScene: Nullable<Scene>;
  35244. /**
  35245. * Gets the latest created engine
  35246. */
  35247. static get LastCreatedEngine(): Nullable<Engine>;
  35248. /**
  35249. * Gets the latest created scene
  35250. */
  35251. static get LastCreatedScene(): Nullable<Scene>;
  35252. /**
  35253. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35254. * @ignorenaming
  35255. */
  35256. static UseFallbackTexture: boolean;
  35257. /**
  35258. * Texture content used if a texture cannot loaded
  35259. * @ignorenaming
  35260. */
  35261. static FallbackTexture: string;
  35262. }
  35263. }
  35264. declare module "babylonjs/Misc/promise" {
  35265. /**
  35266. * Helper class that provides a small promise polyfill
  35267. */
  35268. export class PromisePolyfill {
  35269. /**
  35270. * Static function used to check if the polyfill is required
  35271. * If this is the case then the function will inject the polyfill to window.Promise
  35272. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35273. */
  35274. static Apply(force?: boolean): void;
  35275. }
  35276. }
  35277. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35278. /**
  35279. * Interface for screenshot methods with describe argument called `size` as object with options
  35280. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35281. */
  35282. export interface IScreenshotSize {
  35283. /**
  35284. * number in pixels for canvas height
  35285. */
  35286. height?: number;
  35287. /**
  35288. * multiplier allowing render at a higher or lower resolution
  35289. * If value is defined then height and width will be ignored and taken from camera
  35290. */
  35291. precision?: number;
  35292. /**
  35293. * number in pixels for canvas width
  35294. */
  35295. width?: number;
  35296. }
  35297. }
  35298. declare module "babylonjs/Misc/tools" {
  35299. import { Nullable, float } from "babylonjs/types";
  35300. import { DomManagement } from "babylonjs/Misc/domManagement";
  35301. import { WebRequest } from "babylonjs/Misc/webRequest";
  35302. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35303. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35304. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35305. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35306. import { Camera } from "babylonjs/Cameras/camera";
  35307. import { Engine } from "babylonjs/Engines/engine";
  35308. interface IColor4Like {
  35309. r: float;
  35310. g: float;
  35311. b: float;
  35312. a: float;
  35313. }
  35314. /**
  35315. * Class containing a set of static utilities functions
  35316. */
  35317. export class Tools {
  35318. /**
  35319. * Gets or sets the base URL to use to load assets
  35320. */
  35321. static get BaseUrl(): string;
  35322. static set BaseUrl(value: string);
  35323. /**
  35324. * Enable/Disable Custom HTTP Request Headers globally.
  35325. * default = false
  35326. * @see CustomRequestHeaders
  35327. */
  35328. static UseCustomRequestHeaders: boolean;
  35329. /**
  35330. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35331. * i.e. when loading files, where the server/service expects an Authorization header
  35332. */
  35333. static CustomRequestHeaders: {
  35334. [key: string]: string;
  35335. };
  35336. /**
  35337. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35338. */
  35339. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35340. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35341. /**
  35342. * Default behaviour for cors in the application.
  35343. * It can be a string if the expected behavior is identical in the entire app.
  35344. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35345. */
  35346. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35347. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35348. /**
  35349. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35350. * @ignorenaming
  35351. */
  35352. static get UseFallbackTexture(): boolean;
  35353. static set UseFallbackTexture(value: boolean);
  35354. /**
  35355. * Use this object to register external classes like custom textures or material
  35356. * to allow the laoders to instantiate them
  35357. */
  35358. static get RegisteredExternalClasses(): {
  35359. [key: string]: Object;
  35360. };
  35361. static set RegisteredExternalClasses(classes: {
  35362. [key: string]: Object;
  35363. });
  35364. /**
  35365. * Texture content used if a texture cannot loaded
  35366. * @ignorenaming
  35367. */
  35368. static get fallbackTexture(): string;
  35369. static set fallbackTexture(value: string);
  35370. /**
  35371. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35372. * @param u defines the coordinate on X axis
  35373. * @param v defines the coordinate on Y axis
  35374. * @param width defines the width of the source data
  35375. * @param height defines the height of the source data
  35376. * @param pixels defines the source byte array
  35377. * @param color defines the output color
  35378. */
  35379. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35380. /**
  35381. * Interpolates between a and b via alpha
  35382. * @param a The lower value (returned when alpha = 0)
  35383. * @param b The upper value (returned when alpha = 1)
  35384. * @param alpha The interpolation-factor
  35385. * @return The mixed value
  35386. */
  35387. static Mix(a: number, b: number, alpha: number): number;
  35388. /**
  35389. * Tries to instantiate a new object from a given class name
  35390. * @param className defines the class name to instantiate
  35391. * @returns the new object or null if the system was not able to do the instantiation
  35392. */
  35393. static Instantiate(className: string): any;
  35394. /**
  35395. * Provides a slice function that will work even on IE
  35396. * @param data defines the array to slice
  35397. * @param start defines the start of the data (optional)
  35398. * @param end defines the end of the data (optional)
  35399. * @returns the new sliced array
  35400. */
  35401. static Slice<T>(data: T, start?: number, end?: number): T;
  35402. /**
  35403. * Polyfill for setImmediate
  35404. * @param action defines the action to execute after the current execution block
  35405. */
  35406. static SetImmediate(action: () => void): void;
  35407. /**
  35408. * Function indicating if a number is an exponent of 2
  35409. * @param value defines the value to test
  35410. * @returns true if the value is an exponent of 2
  35411. */
  35412. static IsExponentOfTwo(value: number): boolean;
  35413. private static _tmpFloatArray;
  35414. /**
  35415. * Returns the nearest 32-bit single precision float representation of a Number
  35416. * @param value A Number. If the parameter is of a different type, it will get converted
  35417. * to a number or to NaN if it cannot be converted
  35418. * @returns number
  35419. */
  35420. static FloatRound(value: number): number;
  35421. /**
  35422. * Extracts the filename from a path
  35423. * @param path defines the path to use
  35424. * @returns the filename
  35425. */
  35426. static GetFilename(path: string): string;
  35427. /**
  35428. * Extracts the "folder" part of a path (everything before the filename).
  35429. * @param uri The URI to extract the info from
  35430. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35431. * @returns The "folder" part of the path
  35432. */
  35433. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35434. /**
  35435. * Extracts text content from a DOM element hierarchy
  35436. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35437. */
  35438. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35439. /**
  35440. * Convert an angle in radians to degrees
  35441. * @param angle defines the angle to convert
  35442. * @returns the angle in degrees
  35443. */
  35444. static ToDegrees(angle: number): number;
  35445. /**
  35446. * Convert an angle in degrees to radians
  35447. * @param angle defines the angle to convert
  35448. * @returns the angle in radians
  35449. */
  35450. static ToRadians(angle: number): number;
  35451. /**
  35452. * Returns an array if obj is not an array
  35453. * @param obj defines the object to evaluate as an array
  35454. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35455. * @returns either obj directly if obj is an array or a new array containing obj
  35456. */
  35457. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35458. /**
  35459. * Gets the pointer prefix to use
  35460. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35461. */
  35462. static GetPointerPrefix(): string;
  35463. /**
  35464. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35465. * @param url define the url we are trying
  35466. * @param element define the dom element where to configure the cors policy
  35467. */
  35468. static SetCorsBehavior(url: string | string[], element: {
  35469. crossOrigin: string | null;
  35470. }): void;
  35471. /**
  35472. * Removes unwanted characters from an url
  35473. * @param url defines the url to clean
  35474. * @returns the cleaned url
  35475. */
  35476. static CleanUrl(url: string): string;
  35477. /**
  35478. * Gets or sets a function used to pre-process url before using them to load assets
  35479. */
  35480. static get PreprocessUrl(): (url: string) => string;
  35481. static set PreprocessUrl(processor: (url: string) => string);
  35482. /**
  35483. * Loads an image as an HTMLImageElement.
  35484. * @param input url string, ArrayBuffer, or Blob to load
  35485. * @param onLoad callback called when the image successfully loads
  35486. * @param onError callback called when the image fails to load
  35487. * @param offlineProvider offline provider for caching
  35488. * @param mimeType optional mime type
  35489. * @returns the HTMLImageElement of the loaded image
  35490. */
  35491. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35492. /**
  35493. * Loads a file from a url
  35494. * @param url url string, ArrayBuffer, or Blob to load
  35495. * @param onSuccess callback called when the file successfully loads
  35496. * @param onProgress callback called while file is loading (if the server supports this mode)
  35497. * @param offlineProvider defines the offline provider for caching
  35498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35499. * @param onError callback called when the file fails to load
  35500. * @returns a file request object
  35501. */
  35502. 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;
  35503. /**
  35504. * Loads a file from a url
  35505. * @param url the file url to load
  35506. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35507. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35508. */
  35509. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35510. /**
  35511. * Load a script (identified by an url). When the url returns, the
  35512. * content of this file is added into a new script element, attached to the DOM (body element)
  35513. * @param scriptUrl defines the url of the script to laod
  35514. * @param onSuccess defines the callback called when the script is loaded
  35515. * @param onError defines the callback to call if an error occurs
  35516. * @param scriptId defines the id of the script element
  35517. */
  35518. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35519. /**
  35520. * Load an asynchronous script (identified by an url). When the url returns, the
  35521. * content of this file is added into a new script element, attached to the DOM (body element)
  35522. * @param scriptUrl defines the url of the script to laod
  35523. * @param scriptId defines the id of the script element
  35524. * @returns a promise request object
  35525. */
  35526. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35527. /**
  35528. * Loads a file from a blob
  35529. * @param fileToLoad defines the blob to use
  35530. * @param callback defines the callback to call when data is loaded
  35531. * @param progressCallback defines the callback to call during loading process
  35532. * @returns a file request object
  35533. */
  35534. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35535. /**
  35536. * Reads a file from a File object
  35537. * @param file defines the file to load
  35538. * @param onSuccess defines the callback to call when data is loaded
  35539. * @param onProgress defines the callback to call during loading process
  35540. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35541. * @param onError defines the callback to call when an error occurs
  35542. * @returns a file request object
  35543. */
  35544. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35545. /**
  35546. * Creates a data url from a given string content
  35547. * @param content defines the content to convert
  35548. * @returns the new data url link
  35549. */
  35550. static FileAsURL(content: string): string;
  35551. /**
  35552. * Format the given number to a specific decimal format
  35553. * @param value defines the number to format
  35554. * @param decimals defines the number of decimals to use
  35555. * @returns the formatted string
  35556. */
  35557. static Format(value: number, decimals?: number): string;
  35558. /**
  35559. * Tries to copy an object by duplicating every property
  35560. * @param source defines the source object
  35561. * @param destination defines the target object
  35562. * @param doNotCopyList defines a list of properties to avoid
  35563. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35564. */
  35565. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35566. /**
  35567. * Gets a boolean indicating if the given object has no own property
  35568. * @param obj defines the object to test
  35569. * @returns true if object has no own property
  35570. */
  35571. static IsEmpty(obj: any): boolean;
  35572. /**
  35573. * Function used to register events at window level
  35574. * @param windowElement defines the Window object to use
  35575. * @param events defines the events to register
  35576. */
  35577. static RegisterTopRootEvents(windowElement: Window, events: {
  35578. name: string;
  35579. handler: Nullable<(e: FocusEvent) => any>;
  35580. }[]): void;
  35581. /**
  35582. * Function used to unregister events from window level
  35583. * @param windowElement defines the Window object to use
  35584. * @param events defines the events to unregister
  35585. */
  35586. static UnregisterTopRootEvents(windowElement: Window, events: {
  35587. name: string;
  35588. handler: Nullable<(e: FocusEvent) => any>;
  35589. }[]): void;
  35590. /**
  35591. * @ignore
  35592. */
  35593. static _ScreenshotCanvas: HTMLCanvasElement;
  35594. /**
  35595. * Dumps the current bound framebuffer
  35596. * @param width defines the rendering width
  35597. * @param height defines the rendering height
  35598. * @param engine defines the hosting engine
  35599. * @param successCallback defines the callback triggered once the data are available
  35600. * @param mimeType defines the mime type of the result
  35601. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35602. */
  35603. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35604. /**
  35605. * Converts the canvas data to blob.
  35606. * This acts as a polyfill for browsers not supporting the to blob function.
  35607. * @param canvas Defines the canvas to extract the data from
  35608. * @param successCallback Defines the callback triggered once the data are available
  35609. * @param mimeType Defines the mime type of the result
  35610. */
  35611. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35612. /**
  35613. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35614. * @param successCallback defines the callback triggered once the data are available
  35615. * @param mimeType defines the mime type of the result
  35616. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35617. */
  35618. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35619. /**
  35620. * Downloads a blob in the browser
  35621. * @param blob defines the blob to download
  35622. * @param fileName defines the name of the downloaded file
  35623. */
  35624. static Download(blob: Blob, fileName: string): void;
  35625. /**
  35626. * Captures a screenshot of the current rendering
  35627. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35628. * @param engine defines the rendering engine
  35629. * @param camera defines the source camera
  35630. * @param size This parameter can be set to a single number or to an object with the
  35631. * following (optional) properties: precision, width, height. If a single number is passed,
  35632. * it will be used for both width and height. If an object is passed, the screenshot size
  35633. * will be derived from the parameters. The precision property is a multiplier allowing
  35634. * rendering at a higher or lower resolution
  35635. * @param successCallback defines the callback receives a single parameter which contains the
  35636. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35637. * src parameter of an <img> to display it
  35638. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35639. * Check your browser for supported MIME types
  35640. */
  35641. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35642. /**
  35643. * Captures a screenshot of the current rendering
  35644. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35645. * @param engine defines the rendering engine
  35646. * @param camera defines the source camera
  35647. * @param size This parameter can be set to a single number or to an object with the
  35648. * following (optional) properties: precision, width, height. If a single number is passed,
  35649. * it will be used for both width and height. If an object is passed, the screenshot size
  35650. * will be derived from the parameters. The precision property is a multiplier allowing
  35651. * rendering at a higher or lower resolution
  35652. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35653. * Check your browser for supported MIME types
  35654. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35655. * to the src parameter of an <img> to display it
  35656. */
  35657. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35658. /**
  35659. * Generates an image screenshot from the specified camera.
  35660. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35661. * @param engine The engine to use for rendering
  35662. * @param camera The camera to use for rendering
  35663. * @param size This parameter can be set to a single number or to an object with the
  35664. * following (optional) properties: precision, width, height. If a single number is passed,
  35665. * it will be used for both width and height. If an object is passed, the screenshot size
  35666. * will be derived from the parameters. The precision property is a multiplier allowing
  35667. * rendering at a higher or lower resolution
  35668. * @param successCallback The callback receives a single parameter which contains the
  35669. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35670. * src parameter of an <img> to display it
  35671. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35672. * Check your browser for supported MIME types
  35673. * @param samples Texture samples (default: 1)
  35674. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35675. * @param fileName A name for for the downloaded file.
  35676. */
  35677. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35678. /**
  35679. * Generates an image screenshot from the specified camera.
  35680. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35681. * @param engine The engine to use for rendering
  35682. * @param camera The camera to use for rendering
  35683. * @param size This parameter can be set to a single number or to an object with the
  35684. * following (optional) properties: precision, width, height. If a single number is passed,
  35685. * it will be used for both width and height. If an object is passed, the screenshot size
  35686. * will be derived from the parameters. The precision property is a multiplier allowing
  35687. * rendering at a higher or lower resolution
  35688. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35689. * Check your browser for supported MIME types
  35690. * @param samples Texture samples (default: 1)
  35691. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35692. * @param fileName A name for for the downloaded file.
  35693. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35694. * to the src parameter of an <img> to display it
  35695. */
  35696. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35697. /**
  35698. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35699. * Be aware Math.random() could cause collisions, but:
  35700. * "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"
  35701. * @returns a pseudo random id
  35702. */
  35703. static RandomId(): string;
  35704. /**
  35705. * Test if the given uri is a base64 string
  35706. * @param uri The uri to test
  35707. * @return True if the uri is a base64 string or false otherwise
  35708. */
  35709. static IsBase64(uri: string): boolean;
  35710. /**
  35711. * Decode the given base64 uri.
  35712. * @param uri The uri to decode
  35713. * @return The decoded base64 data.
  35714. */
  35715. static DecodeBase64(uri: string): ArrayBuffer;
  35716. /**
  35717. * Gets the absolute url.
  35718. * @param url the input url
  35719. * @return the absolute url
  35720. */
  35721. static GetAbsoluteUrl(url: string): string;
  35722. /**
  35723. * No log
  35724. */
  35725. static readonly NoneLogLevel: number;
  35726. /**
  35727. * Only message logs
  35728. */
  35729. static readonly MessageLogLevel: number;
  35730. /**
  35731. * Only warning logs
  35732. */
  35733. static readonly WarningLogLevel: number;
  35734. /**
  35735. * Only error logs
  35736. */
  35737. static readonly ErrorLogLevel: number;
  35738. /**
  35739. * All logs
  35740. */
  35741. static readonly AllLogLevel: number;
  35742. /**
  35743. * Gets a value indicating the number of loading errors
  35744. * @ignorenaming
  35745. */
  35746. static get errorsCount(): number;
  35747. /**
  35748. * Callback called when a new log is added
  35749. */
  35750. static OnNewCacheEntry: (entry: string) => void;
  35751. /**
  35752. * Log a message to the console
  35753. * @param message defines the message to log
  35754. */
  35755. static Log(message: string): void;
  35756. /**
  35757. * Write a warning message to the console
  35758. * @param message defines the message to log
  35759. */
  35760. static Warn(message: string): void;
  35761. /**
  35762. * Write an error message to the console
  35763. * @param message defines the message to log
  35764. */
  35765. static Error(message: string): void;
  35766. /**
  35767. * Gets current log cache (list of logs)
  35768. */
  35769. static get LogCache(): string;
  35770. /**
  35771. * Clears the log cache
  35772. */
  35773. static ClearLogCache(): void;
  35774. /**
  35775. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35776. */
  35777. static set LogLevels(level: number);
  35778. /**
  35779. * Checks if the window object exists
  35780. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35781. */
  35782. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35783. /**
  35784. * No performance log
  35785. */
  35786. static readonly PerformanceNoneLogLevel: number;
  35787. /**
  35788. * Use user marks to log performance
  35789. */
  35790. static readonly PerformanceUserMarkLogLevel: number;
  35791. /**
  35792. * Log performance to the console
  35793. */
  35794. static readonly PerformanceConsoleLogLevel: number;
  35795. private static _performance;
  35796. /**
  35797. * Sets the current performance log level
  35798. */
  35799. static set PerformanceLogLevel(level: number);
  35800. private static _StartPerformanceCounterDisabled;
  35801. private static _EndPerformanceCounterDisabled;
  35802. private static _StartUserMark;
  35803. private static _EndUserMark;
  35804. private static _StartPerformanceConsole;
  35805. private static _EndPerformanceConsole;
  35806. /**
  35807. * Starts a performance counter
  35808. */
  35809. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35810. /**
  35811. * Ends a specific performance coutner
  35812. */
  35813. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35814. /**
  35815. * Gets either window.performance.now() if supported or Date.now() else
  35816. */
  35817. static get Now(): number;
  35818. /**
  35819. * This method will return the name of the class used to create the instance of the given object.
  35820. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35821. * @param object the object to get the class name from
  35822. * @param isType defines if the object is actually a type
  35823. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35824. */
  35825. static GetClassName(object: any, isType?: boolean): string;
  35826. /**
  35827. * Gets the first element of an array satisfying a given predicate
  35828. * @param array defines the array to browse
  35829. * @param predicate defines the predicate to use
  35830. * @returns null if not found or the element
  35831. */
  35832. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35833. /**
  35834. * This method will return the name of the full name of the class, including its owning module (if any).
  35835. * 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).
  35836. * @param object the object to get the class name from
  35837. * @param isType defines if the object is actually a type
  35838. * @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.
  35839. * @ignorenaming
  35840. */
  35841. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35842. /**
  35843. * Returns a promise that resolves after the given amount of time.
  35844. * @param delay Number of milliseconds to delay
  35845. * @returns Promise that resolves after the given amount of time
  35846. */
  35847. static DelayAsync(delay: number): Promise<void>;
  35848. /**
  35849. * Utility function to detect if the current user agent is Safari
  35850. * @returns whether or not the current user agent is safari
  35851. */
  35852. static IsSafari(): boolean;
  35853. }
  35854. /**
  35855. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35856. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35857. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35858. * @param name The name of the class, case should be preserved
  35859. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35860. */
  35861. export function className(name: string, module?: string): (target: Object) => void;
  35862. /**
  35863. * An implementation of a loop for asynchronous functions.
  35864. */
  35865. export class AsyncLoop {
  35866. /**
  35867. * Defines the number of iterations for the loop
  35868. */
  35869. iterations: number;
  35870. /**
  35871. * Defines the current index of the loop.
  35872. */
  35873. index: number;
  35874. private _done;
  35875. private _fn;
  35876. private _successCallback;
  35877. /**
  35878. * Constructor.
  35879. * @param iterations the number of iterations.
  35880. * @param func the function to run each iteration
  35881. * @param successCallback the callback that will be called upon succesful execution
  35882. * @param offset starting offset.
  35883. */
  35884. constructor(
  35885. /**
  35886. * Defines the number of iterations for the loop
  35887. */
  35888. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35889. /**
  35890. * Execute the next iteration. Must be called after the last iteration was finished.
  35891. */
  35892. executeNext(): void;
  35893. /**
  35894. * Break the loop and run the success callback.
  35895. */
  35896. breakLoop(): void;
  35897. /**
  35898. * Create and run an async loop.
  35899. * @param iterations the number of iterations.
  35900. * @param fn the function to run each iteration
  35901. * @param successCallback the callback that will be called upon succesful execution
  35902. * @param offset starting offset.
  35903. * @returns the created async loop object
  35904. */
  35905. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35906. /**
  35907. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35908. * @param iterations total number of iterations
  35909. * @param syncedIterations number of synchronous iterations in each async iteration.
  35910. * @param fn the function to call each iteration.
  35911. * @param callback a success call back that will be called when iterating stops.
  35912. * @param breakFunction a break condition (optional)
  35913. * @param timeout timeout settings for the setTimeout function. default - 0.
  35914. * @returns the created async loop object
  35915. */
  35916. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35917. }
  35918. }
  35919. declare module "babylonjs/Misc/stringDictionary" {
  35920. import { Nullable } from "babylonjs/types";
  35921. /**
  35922. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35923. * The underlying implementation relies on an associative array to ensure the best performances.
  35924. * The value can be anything including 'null' but except 'undefined'
  35925. */
  35926. export class StringDictionary<T> {
  35927. /**
  35928. * This will clear this dictionary and copy the content from the 'source' one.
  35929. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35930. * @param source the dictionary to take the content from and copy to this dictionary
  35931. */
  35932. copyFrom(source: StringDictionary<T>): void;
  35933. /**
  35934. * Get a value based from its key
  35935. * @param key the given key to get the matching value from
  35936. * @return the value if found, otherwise undefined is returned
  35937. */
  35938. get(key: string): T | undefined;
  35939. /**
  35940. * Get a value from its key or add it if it doesn't exist.
  35941. * This method will ensure you that a given key/data will be present in the dictionary.
  35942. * @param key the given key to get the matching value from
  35943. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35944. * The factory will only be invoked if there's no data for the given key.
  35945. * @return the value corresponding to the key.
  35946. */
  35947. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35948. /**
  35949. * Get a value from its key if present in the dictionary otherwise add it
  35950. * @param key the key to get the value from
  35951. * @param val if there's no such key/value pair in the dictionary add it with this value
  35952. * @return the value corresponding to the key
  35953. */
  35954. getOrAdd(key: string, val: T): T;
  35955. /**
  35956. * Check if there's a given key in the dictionary
  35957. * @param key the key to check for
  35958. * @return true if the key is present, false otherwise
  35959. */
  35960. contains(key: string): boolean;
  35961. /**
  35962. * Add a new key and its corresponding value
  35963. * @param key the key to add
  35964. * @param value the value corresponding to the key
  35965. * @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
  35966. */
  35967. add(key: string, value: T): boolean;
  35968. /**
  35969. * Update a specific value associated to a key
  35970. * @param key defines the key to use
  35971. * @param value defines the value to store
  35972. * @returns true if the value was updated (or false if the key was not found)
  35973. */
  35974. set(key: string, value: T): boolean;
  35975. /**
  35976. * Get the element of the given key and remove it from the dictionary
  35977. * @param key defines the key to search
  35978. * @returns the value associated with the key or null if not found
  35979. */
  35980. getAndRemove(key: string): Nullable<T>;
  35981. /**
  35982. * Remove a key/value from the dictionary.
  35983. * @param key the key to remove
  35984. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35985. */
  35986. remove(key: string): boolean;
  35987. /**
  35988. * Clear the whole content of the dictionary
  35989. */
  35990. clear(): void;
  35991. /**
  35992. * Gets the current count
  35993. */
  35994. get count(): number;
  35995. /**
  35996. * Execute a callback on each key/val of the dictionary.
  35997. * Note that you can remove any element in this dictionary in the callback implementation
  35998. * @param callback the callback to execute on a given key/value pair
  35999. */
  36000. forEach(callback: (key: string, val: T) => void): void;
  36001. /**
  36002. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36003. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36004. * Note that you can remove any element in this dictionary in the callback implementation
  36005. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36006. * @returns the first item
  36007. */
  36008. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36009. private _count;
  36010. private _data;
  36011. }
  36012. }
  36013. declare module "babylonjs/Collisions/collisionCoordinator" {
  36014. import { Nullable } from "babylonjs/types";
  36015. import { Scene } from "babylonjs/scene";
  36016. import { Vector3 } from "babylonjs/Maths/math.vector";
  36017. import { Collider } from "babylonjs/Collisions/collider";
  36018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36019. /** @hidden */
  36020. export interface ICollisionCoordinator {
  36021. createCollider(): Collider;
  36022. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36023. init(scene: Scene): void;
  36024. }
  36025. /** @hidden */
  36026. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36027. private _scene;
  36028. private _scaledPosition;
  36029. private _scaledVelocity;
  36030. private _finalPosition;
  36031. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36032. createCollider(): Collider;
  36033. init(scene: Scene): void;
  36034. private _collideWithWorld;
  36035. }
  36036. }
  36037. declare module "babylonjs/Inputs/scene.inputManager" {
  36038. import { Nullable } from "babylonjs/types";
  36039. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36040. import { Vector2 } from "babylonjs/Maths/math.vector";
  36041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36042. import { Scene } from "babylonjs/scene";
  36043. /**
  36044. * Class used to manage all inputs for the scene.
  36045. */
  36046. export class InputManager {
  36047. /** The distance in pixel that you have to move to prevent some events */
  36048. static DragMovementThreshold: number;
  36049. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36050. static LongPressDelay: number;
  36051. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36052. static DoubleClickDelay: number;
  36053. /** If you need to check double click without raising a single click at first click, enable this flag */
  36054. static ExclusiveDoubleClickMode: boolean;
  36055. private _wheelEventName;
  36056. private _onPointerMove;
  36057. private _onPointerDown;
  36058. private _onPointerUp;
  36059. private _initClickEvent;
  36060. private _initActionManager;
  36061. private _delayedSimpleClick;
  36062. private _delayedSimpleClickTimeout;
  36063. private _previousDelayedSimpleClickTimeout;
  36064. private _meshPickProceed;
  36065. private _previousButtonPressed;
  36066. private _currentPickResult;
  36067. private _previousPickResult;
  36068. private _totalPointersPressed;
  36069. private _doubleClickOccured;
  36070. private _pointerOverMesh;
  36071. private _pickedDownMesh;
  36072. private _pickedUpMesh;
  36073. private _pointerX;
  36074. private _pointerY;
  36075. private _unTranslatedPointerX;
  36076. private _unTranslatedPointerY;
  36077. private _startingPointerPosition;
  36078. private _previousStartingPointerPosition;
  36079. private _startingPointerTime;
  36080. private _previousStartingPointerTime;
  36081. private _pointerCaptures;
  36082. private _onKeyDown;
  36083. private _onKeyUp;
  36084. private _onCanvasFocusObserver;
  36085. private _onCanvasBlurObserver;
  36086. private _scene;
  36087. /**
  36088. * Creates a new InputManager
  36089. * @param scene defines the hosting scene
  36090. */
  36091. constructor(scene: Scene);
  36092. /**
  36093. * Gets the mesh that is currently under the pointer
  36094. */
  36095. get meshUnderPointer(): Nullable<AbstractMesh>;
  36096. /**
  36097. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36098. */
  36099. get unTranslatedPointer(): Vector2;
  36100. /**
  36101. * Gets or sets the current on-screen X position of the pointer
  36102. */
  36103. get pointerX(): number;
  36104. set pointerX(value: number);
  36105. /**
  36106. * Gets or sets the current on-screen Y position of the pointer
  36107. */
  36108. get pointerY(): number;
  36109. set pointerY(value: number);
  36110. private _updatePointerPosition;
  36111. private _processPointerMove;
  36112. private _setRayOnPointerInfo;
  36113. private _checkPrePointerObservable;
  36114. /**
  36115. * Use this method to simulate a pointer move on a mesh
  36116. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36117. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36118. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36119. */
  36120. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36121. /**
  36122. * Use this method to simulate a pointer down on a mesh
  36123. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36124. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36125. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36126. */
  36127. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36128. private _processPointerDown;
  36129. /** @hidden */
  36130. _isPointerSwiping(): boolean;
  36131. /**
  36132. * Use this method to simulate a pointer up on a mesh
  36133. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36134. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36135. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36136. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36137. */
  36138. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36139. private _processPointerUp;
  36140. /**
  36141. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36142. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36143. * @returns true if the pointer was captured
  36144. */
  36145. isPointerCaptured(pointerId?: number): boolean;
  36146. /**
  36147. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36148. * @param attachUp defines if you want to attach events to pointerup
  36149. * @param attachDown defines if you want to attach events to pointerdown
  36150. * @param attachMove defines if you want to attach events to pointermove
  36151. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36152. */
  36153. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36154. /**
  36155. * Detaches all event handlers
  36156. */
  36157. detachControl(): void;
  36158. /**
  36159. * Force the value of meshUnderPointer
  36160. * @param mesh defines the mesh to use
  36161. */
  36162. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36163. /**
  36164. * Gets the mesh under the pointer
  36165. * @returns a Mesh or null if no mesh is under the pointer
  36166. */
  36167. getPointerOverMesh(): Nullable<AbstractMesh>;
  36168. }
  36169. }
  36170. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36171. /**
  36172. * Helper class used to generate session unique ID
  36173. */
  36174. export class UniqueIdGenerator {
  36175. private static _UniqueIdCounter;
  36176. /**
  36177. * Gets an unique (relatively to the current scene) Id
  36178. */
  36179. static get UniqueId(): number;
  36180. }
  36181. }
  36182. declare module "babylonjs/Animations/animationGroup" {
  36183. import { Animatable } from "babylonjs/Animations/animatable";
  36184. import { Animation } from "babylonjs/Animations/animation";
  36185. import { Scene, IDisposable } from "babylonjs/scene";
  36186. import { Observable } from "babylonjs/Misc/observable";
  36187. import { Nullable } from "babylonjs/types";
  36188. import "babylonjs/Animations/animatable";
  36189. /**
  36190. * This class defines the direct association between an animation and a target
  36191. */
  36192. export class TargetedAnimation {
  36193. /**
  36194. * Animation to perform
  36195. */
  36196. animation: Animation;
  36197. /**
  36198. * Target to animate
  36199. */
  36200. target: any;
  36201. /**
  36202. * Serialize the object
  36203. * @returns the JSON object representing the current entity
  36204. */
  36205. serialize(): any;
  36206. }
  36207. /**
  36208. * Use this class to create coordinated animations on multiple targets
  36209. */
  36210. export class AnimationGroup implements IDisposable {
  36211. /** The name of the animation group */
  36212. name: string;
  36213. private _scene;
  36214. private _targetedAnimations;
  36215. private _animatables;
  36216. private _from;
  36217. private _to;
  36218. private _isStarted;
  36219. private _isPaused;
  36220. private _speedRatio;
  36221. private _loopAnimation;
  36222. private _isAdditive;
  36223. /**
  36224. * Gets or sets the unique id of the node
  36225. */
  36226. uniqueId: number;
  36227. /**
  36228. * This observable will notify when one animation have ended
  36229. */
  36230. onAnimationEndObservable: Observable<TargetedAnimation>;
  36231. /**
  36232. * Observer raised when one animation loops
  36233. */
  36234. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36235. /**
  36236. * Observer raised when all animations have looped
  36237. */
  36238. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36239. /**
  36240. * This observable will notify when all animations have ended.
  36241. */
  36242. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36243. /**
  36244. * This observable will notify when all animations have paused.
  36245. */
  36246. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36247. /**
  36248. * This observable will notify when all animations are playing.
  36249. */
  36250. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36251. /**
  36252. * Gets the first frame
  36253. */
  36254. get from(): number;
  36255. /**
  36256. * Gets the last frame
  36257. */
  36258. get to(): number;
  36259. /**
  36260. * Define if the animations are started
  36261. */
  36262. get isStarted(): boolean;
  36263. /**
  36264. * Gets a value indicating that the current group is playing
  36265. */
  36266. get isPlaying(): boolean;
  36267. /**
  36268. * Gets or sets the speed ratio to use for all animations
  36269. */
  36270. get speedRatio(): number;
  36271. /**
  36272. * Gets or sets the speed ratio to use for all animations
  36273. */
  36274. set speedRatio(value: number);
  36275. /**
  36276. * Gets or sets if all animations should loop or not
  36277. */
  36278. get loopAnimation(): boolean;
  36279. set loopAnimation(value: boolean);
  36280. /**
  36281. * Gets or sets if all animations should be evaluated additively
  36282. */
  36283. get isAdditive(): boolean;
  36284. set isAdditive(value: boolean);
  36285. /**
  36286. * Gets the targeted animations for this animation group
  36287. */
  36288. get targetedAnimations(): Array<TargetedAnimation>;
  36289. /**
  36290. * returning the list of animatables controlled by this animation group.
  36291. */
  36292. get animatables(): Array<Animatable>;
  36293. /**
  36294. * Instantiates a new Animation Group.
  36295. * This helps managing several animations at once.
  36296. * @see http://doc.babylonjs.com/how_to/group
  36297. * @param name Defines the name of the group
  36298. * @param scene Defines the scene the group belongs to
  36299. */
  36300. constructor(
  36301. /** The name of the animation group */
  36302. name: string, scene?: Nullable<Scene>);
  36303. /**
  36304. * Add an animation (with its target) in the group
  36305. * @param animation defines the animation we want to add
  36306. * @param target defines the target of the animation
  36307. * @returns the TargetedAnimation object
  36308. */
  36309. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36310. /**
  36311. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36312. * It can add constant keys at begin or end
  36313. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36314. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36315. * @returns the animation group
  36316. */
  36317. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36318. private _animationLoopCount;
  36319. private _animationLoopFlags;
  36320. private _processLoop;
  36321. /**
  36322. * Start all animations on given targets
  36323. * @param loop defines if animations must loop
  36324. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36325. * @param from defines the from key (optional)
  36326. * @param to defines the to key (optional)
  36327. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36328. * @returns the current animation group
  36329. */
  36330. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36331. /**
  36332. * Pause all animations
  36333. * @returns the animation group
  36334. */
  36335. pause(): AnimationGroup;
  36336. /**
  36337. * Play all animations to initial state
  36338. * This function will start() the animations if they were not started or will restart() them if they were paused
  36339. * @param loop defines if animations must loop
  36340. * @returns the animation group
  36341. */
  36342. play(loop?: boolean): AnimationGroup;
  36343. /**
  36344. * Reset all animations to initial state
  36345. * @returns the animation group
  36346. */
  36347. reset(): AnimationGroup;
  36348. /**
  36349. * Restart animations from key 0
  36350. * @returns the animation group
  36351. */
  36352. restart(): AnimationGroup;
  36353. /**
  36354. * Stop all animations
  36355. * @returns the animation group
  36356. */
  36357. stop(): AnimationGroup;
  36358. /**
  36359. * Set animation weight for all animatables
  36360. * @param weight defines the weight to use
  36361. * @return the animationGroup
  36362. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36363. */
  36364. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36365. /**
  36366. * Synchronize and normalize all animatables with a source animatable
  36367. * @param root defines the root animatable to synchronize with
  36368. * @return the animationGroup
  36369. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36370. */
  36371. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36372. /**
  36373. * Goes to a specific frame in this animation group
  36374. * @param frame the frame number to go to
  36375. * @return the animationGroup
  36376. */
  36377. goToFrame(frame: number): AnimationGroup;
  36378. /**
  36379. * Dispose all associated resources
  36380. */
  36381. dispose(): void;
  36382. private _checkAnimationGroupEnded;
  36383. /**
  36384. * Clone the current animation group and returns a copy
  36385. * @param newName defines the name of the new group
  36386. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36387. * @returns the new aniamtion group
  36388. */
  36389. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36390. /**
  36391. * Serializes the animationGroup to an object
  36392. * @returns Serialized object
  36393. */
  36394. serialize(): any;
  36395. /**
  36396. * Returns a new AnimationGroup object parsed from the source provided.
  36397. * @param parsedAnimationGroup defines the source
  36398. * @param scene defines the scene that will receive the animationGroup
  36399. * @returns a new AnimationGroup
  36400. */
  36401. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36402. /**
  36403. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36404. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36405. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36406. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36407. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36408. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36409. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36410. */
  36411. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36412. /**
  36413. * Returns the string "AnimationGroup"
  36414. * @returns "AnimationGroup"
  36415. */
  36416. getClassName(): string;
  36417. /**
  36418. * Creates a detailled string about the object
  36419. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36420. * @returns a string representing the object
  36421. */
  36422. toString(fullDetails?: boolean): string;
  36423. }
  36424. }
  36425. declare module "babylonjs/scene" {
  36426. import { Nullable } from "babylonjs/types";
  36427. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36428. import { Observable } from "babylonjs/Misc/observable";
  36429. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36430. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36431. import { Geometry } from "babylonjs/Meshes/geometry";
  36432. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36435. import { Mesh } from "babylonjs/Meshes/mesh";
  36436. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36437. import { Bone } from "babylonjs/Bones/bone";
  36438. import { Skeleton } from "babylonjs/Bones/skeleton";
  36439. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36440. import { Camera } from "babylonjs/Cameras/camera";
  36441. import { AbstractScene } from "babylonjs/abstractScene";
  36442. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36443. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36444. import { Material } from "babylonjs/Materials/material";
  36445. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36446. import { Effect } from "babylonjs/Materials/effect";
  36447. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36448. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36449. import { Light } from "babylonjs/Lights/light";
  36450. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36451. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36452. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36453. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36454. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36455. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36456. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36457. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36458. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36459. import { Engine } from "babylonjs/Engines/engine";
  36460. import { Node } from "babylonjs/node";
  36461. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36462. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36463. import { WebRequest } from "babylonjs/Misc/webRequest";
  36464. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36465. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36466. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36467. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36468. import { Plane } from "babylonjs/Maths/math.plane";
  36469. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36470. import { Ray } from "babylonjs/Culling/ray";
  36471. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36472. import { Animation } from "babylonjs/Animations/animation";
  36473. import { Animatable } from "babylonjs/Animations/animatable";
  36474. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36475. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36476. import { Collider } from "babylonjs/Collisions/collider";
  36477. /**
  36478. * Define an interface for all classes that will hold resources
  36479. */
  36480. export interface IDisposable {
  36481. /**
  36482. * Releases all held resources
  36483. */
  36484. dispose(): void;
  36485. }
  36486. /** Interface defining initialization parameters for Scene class */
  36487. export interface SceneOptions {
  36488. /**
  36489. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36490. * It will improve performance when the number of geometries becomes important.
  36491. */
  36492. useGeometryUniqueIdsMap?: boolean;
  36493. /**
  36494. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36495. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36496. */
  36497. useMaterialMeshMap?: boolean;
  36498. /**
  36499. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36500. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36501. */
  36502. useClonedMeshMap?: boolean;
  36503. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36504. virtual?: boolean;
  36505. }
  36506. /**
  36507. * Represents a scene to be rendered by the engine.
  36508. * @see http://doc.babylonjs.com/features/scene
  36509. */
  36510. export class Scene extends AbstractScene implements IAnimatable {
  36511. /** The fog is deactivated */
  36512. static readonly FOGMODE_NONE: number;
  36513. /** The fog density is following an exponential function */
  36514. static readonly FOGMODE_EXP: number;
  36515. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36516. static readonly FOGMODE_EXP2: number;
  36517. /** The fog density is following a linear function. */
  36518. static readonly FOGMODE_LINEAR: number;
  36519. /**
  36520. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36521. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36522. */
  36523. static MinDeltaTime: number;
  36524. /**
  36525. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36526. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36527. */
  36528. static MaxDeltaTime: number;
  36529. /**
  36530. * Factory used to create the default material.
  36531. * @param name The name of the material to create
  36532. * @param scene The scene to create the material for
  36533. * @returns The default material
  36534. */
  36535. static DefaultMaterialFactory(scene: Scene): Material;
  36536. /**
  36537. * Factory used to create the a collision coordinator.
  36538. * @returns The collision coordinator
  36539. */
  36540. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36541. /** @hidden */
  36542. _inputManager: InputManager;
  36543. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36544. cameraToUseForPointers: Nullable<Camera>;
  36545. /** @hidden */
  36546. readonly _isScene: boolean;
  36547. /** @hidden */
  36548. _blockEntityCollection: boolean;
  36549. /**
  36550. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36551. */
  36552. autoClear: boolean;
  36553. /**
  36554. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36555. */
  36556. autoClearDepthAndStencil: boolean;
  36557. /**
  36558. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36559. */
  36560. clearColor: Color4;
  36561. /**
  36562. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36563. */
  36564. ambientColor: Color3;
  36565. /**
  36566. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36567. * It should only be one of the following (if not the default embedded one):
  36568. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36569. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36570. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36571. * The material properties need to be setup according to the type of texture in use.
  36572. */
  36573. environmentBRDFTexture: BaseTexture;
  36574. /** @hidden */
  36575. protected _environmentTexture: Nullable<BaseTexture>;
  36576. /**
  36577. * Texture used in all pbr material as the reflection texture.
  36578. * As in the majority of the scene they are the same (exception for multi room and so on),
  36579. * this is easier to reference from here than from all the materials.
  36580. */
  36581. get environmentTexture(): Nullable<BaseTexture>;
  36582. /**
  36583. * Texture used in all pbr material as the reflection texture.
  36584. * As in the majority of the scene they are the same (exception for multi room and so on),
  36585. * this is easier to set here than in all the materials.
  36586. */
  36587. set environmentTexture(value: Nullable<BaseTexture>);
  36588. /** @hidden */
  36589. protected _environmentIntensity: number;
  36590. /**
  36591. * Intensity of the environment in all pbr material.
  36592. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36593. * As in the majority of the scene they are the same (exception for multi room and so on),
  36594. * this is easier to reference from here than from all the materials.
  36595. */
  36596. get environmentIntensity(): number;
  36597. /**
  36598. * Intensity of the environment in all pbr material.
  36599. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36600. * As in the majority of the scene they are the same (exception for multi room and so on),
  36601. * this is easier to set here than in all the materials.
  36602. */
  36603. set environmentIntensity(value: number);
  36604. /** @hidden */
  36605. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36606. /**
  36607. * Default image processing configuration used either in the rendering
  36608. * Forward main pass or through the imageProcessingPostProcess if present.
  36609. * As in the majority of the scene they are the same (exception for multi camera),
  36610. * this is easier to reference from here than from all the materials and post process.
  36611. *
  36612. * No setter as we it is a shared configuration, you can set the values instead.
  36613. */
  36614. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36615. private _forceWireframe;
  36616. /**
  36617. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36618. */
  36619. set forceWireframe(value: boolean);
  36620. get forceWireframe(): boolean;
  36621. private _skipFrustumClipping;
  36622. /**
  36623. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36624. */
  36625. set skipFrustumClipping(value: boolean);
  36626. get skipFrustumClipping(): boolean;
  36627. private _forcePointsCloud;
  36628. /**
  36629. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36630. */
  36631. set forcePointsCloud(value: boolean);
  36632. get forcePointsCloud(): boolean;
  36633. /**
  36634. * Gets or sets the active clipplane 1
  36635. */
  36636. clipPlane: Nullable<Plane>;
  36637. /**
  36638. * Gets or sets the active clipplane 2
  36639. */
  36640. clipPlane2: Nullable<Plane>;
  36641. /**
  36642. * Gets or sets the active clipplane 3
  36643. */
  36644. clipPlane3: Nullable<Plane>;
  36645. /**
  36646. * Gets or sets the active clipplane 4
  36647. */
  36648. clipPlane4: Nullable<Plane>;
  36649. /**
  36650. * Gets or sets the active clipplane 5
  36651. */
  36652. clipPlane5: Nullable<Plane>;
  36653. /**
  36654. * Gets or sets the active clipplane 6
  36655. */
  36656. clipPlane6: Nullable<Plane>;
  36657. /**
  36658. * Gets or sets a boolean indicating if animations are enabled
  36659. */
  36660. animationsEnabled: boolean;
  36661. private _animationPropertiesOverride;
  36662. /**
  36663. * Gets or sets the animation properties override
  36664. */
  36665. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36666. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36667. /**
  36668. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36669. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36670. */
  36671. useConstantAnimationDeltaTime: boolean;
  36672. /**
  36673. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36674. * Please note that it requires to run a ray cast through the scene on every frame
  36675. */
  36676. constantlyUpdateMeshUnderPointer: boolean;
  36677. /**
  36678. * Defines the HTML cursor to use when hovering over interactive elements
  36679. */
  36680. hoverCursor: string;
  36681. /**
  36682. * Defines the HTML default cursor to use (empty by default)
  36683. */
  36684. defaultCursor: string;
  36685. /**
  36686. * Defines whether cursors are handled by the scene.
  36687. */
  36688. doNotHandleCursors: boolean;
  36689. /**
  36690. * This is used to call preventDefault() on pointer down
  36691. * in order to block unwanted artifacts like system double clicks
  36692. */
  36693. preventDefaultOnPointerDown: boolean;
  36694. /**
  36695. * This is used to call preventDefault() on pointer up
  36696. * in order to block unwanted artifacts like system double clicks
  36697. */
  36698. preventDefaultOnPointerUp: boolean;
  36699. /**
  36700. * Gets or sets user defined metadata
  36701. */
  36702. metadata: any;
  36703. /**
  36704. * For internal use only. Please do not use.
  36705. */
  36706. reservedDataStore: any;
  36707. /**
  36708. * Gets the name of the plugin used to load this scene (null by default)
  36709. */
  36710. loadingPluginName: string;
  36711. /**
  36712. * Use this array to add regular expressions used to disable offline support for specific urls
  36713. */
  36714. disableOfflineSupportExceptionRules: RegExp[];
  36715. /**
  36716. * An event triggered when the scene is disposed.
  36717. */
  36718. onDisposeObservable: Observable<Scene>;
  36719. private _onDisposeObserver;
  36720. /** Sets a function to be executed when this scene is disposed. */
  36721. set onDispose(callback: () => void);
  36722. /**
  36723. * An event triggered before rendering the scene (right after animations and physics)
  36724. */
  36725. onBeforeRenderObservable: Observable<Scene>;
  36726. private _onBeforeRenderObserver;
  36727. /** Sets a function to be executed before rendering this scene */
  36728. set beforeRender(callback: Nullable<() => void>);
  36729. /**
  36730. * An event triggered after rendering the scene
  36731. */
  36732. onAfterRenderObservable: Observable<Scene>;
  36733. /**
  36734. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36735. */
  36736. onAfterRenderCameraObservable: Observable<Camera>;
  36737. private _onAfterRenderObserver;
  36738. /** Sets a function to be executed after rendering this scene */
  36739. set afterRender(callback: Nullable<() => void>);
  36740. /**
  36741. * An event triggered before animating the scene
  36742. */
  36743. onBeforeAnimationsObservable: Observable<Scene>;
  36744. /**
  36745. * An event triggered after animations processing
  36746. */
  36747. onAfterAnimationsObservable: Observable<Scene>;
  36748. /**
  36749. * An event triggered before draw calls are ready to be sent
  36750. */
  36751. onBeforeDrawPhaseObservable: Observable<Scene>;
  36752. /**
  36753. * An event triggered after draw calls have been sent
  36754. */
  36755. onAfterDrawPhaseObservable: Observable<Scene>;
  36756. /**
  36757. * An event triggered when the scene is ready
  36758. */
  36759. onReadyObservable: Observable<Scene>;
  36760. /**
  36761. * An event triggered before rendering a camera
  36762. */
  36763. onBeforeCameraRenderObservable: Observable<Camera>;
  36764. private _onBeforeCameraRenderObserver;
  36765. /** Sets a function to be executed before rendering a camera*/
  36766. set beforeCameraRender(callback: () => void);
  36767. /**
  36768. * An event triggered after rendering a camera
  36769. */
  36770. onAfterCameraRenderObservable: Observable<Camera>;
  36771. private _onAfterCameraRenderObserver;
  36772. /** Sets a function to be executed after rendering a camera*/
  36773. set afterCameraRender(callback: () => void);
  36774. /**
  36775. * An event triggered when active meshes evaluation is about to start
  36776. */
  36777. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36778. /**
  36779. * An event triggered when active meshes evaluation is done
  36780. */
  36781. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36782. /**
  36783. * An event triggered when particles rendering is about to start
  36784. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36785. */
  36786. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36787. /**
  36788. * An event triggered when particles rendering is done
  36789. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36790. */
  36791. onAfterParticlesRenderingObservable: Observable<Scene>;
  36792. /**
  36793. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36794. */
  36795. onDataLoadedObservable: Observable<Scene>;
  36796. /**
  36797. * An event triggered when a camera is created
  36798. */
  36799. onNewCameraAddedObservable: Observable<Camera>;
  36800. /**
  36801. * An event triggered when a camera is removed
  36802. */
  36803. onCameraRemovedObservable: Observable<Camera>;
  36804. /**
  36805. * An event triggered when a light is created
  36806. */
  36807. onNewLightAddedObservable: Observable<Light>;
  36808. /**
  36809. * An event triggered when a light is removed
  36810. */
  36811. onLightRemovedObservable: Observable<Light>;
  36812. /**
  36813. * An event triggered when a geometry is created
  36814. */
  36815. onNewGeometryAddedObservable: Observable<Geometry>;
  36816. /**
  36817. * An event triggered when a geometry is removed
  36818. */
  36819. onGeometryRemovedObservable: Observable<Geometry>;
  36820. /**
  36821. * An event triggered when a transform node is created
  36822. */
  36823. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36824. /**
  36825. * An event triggered when a transform node is removed
  36826. */
  36827. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36828. /**
  36829. * An event triggered when a mesh is created
  36830. */
  36831. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36832. /**
  36833. * An event triggered when a mesh is removed
  36834. */
  36835. onMeshRemovedObservable: Observable<AbstractMesh>;
  36836. /**
  36837. * An event triggered when a skeleton is created
  36838. */
  36839. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36840. /**
  36841. * An event triggered when a skeleton is removed
  36842. */
  36843. onSkeletonRemovedObservable: Observable<Skeleton>;
  36844. /**
  36845. * An event triggered when a material is created
  36846. */
  36847. onNewMaterialAddedObservable: Observable<Material>;
  36848. /**
  36849. * An event triggered when a material is removed
  36850. */
  36851. onMaterialRemovedObservable: Observable<Material>;
  36852. /**
  36853. * An event triggered when a texture is created
  36854. */
  36855. onNewTextureAddedObservable: Observable<BaseTexture>;
  36856. /**
  36857. * An event triggered when a texture is removed
  36858. */
  36859. onTextureRemovedObservable: Observable<BaseTexture>;
  36860. /**
  36861. * An event triggered when render targets are about to be rendered
  36862. * Can happen multiple times per frame.
  36863. */
  36864. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36865. /**
  36866. * An event triggered when render targets were rendered.
  36867. * Can happen multiple times per frame.
  36868. */
  36869. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36870. /**
  36871. * An event triggered before calculating deterministic simulation step
  36872. */
  36873. onBeforeStepObservable: Observable<Scene>;
  36874. /**
  36875. * An event triggered after calculating deterministic simulation step
  36876. */
  36877. onAfterStepObservable: Observable<Scene>;
  36878. /**
  36879. * An event triggered when the activeCamera property is updated
  36880. */
  36881. onActiveCameraChanged: Observable<Scene>;
  36882. /**
  36883. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36884. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36885. * 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)
  36886. */
  36887. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36888. /**
  36889. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36890. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36891. * 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)
  36892. */
  36893. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36894. /**
  36895. * This Observable will when a mesh has been imported into the scene.
  36896. */
  36897. onMeshImportedObservable: Observable<AbstractMesh>;
  36898. /**
  36899. * This Observable will when an animation file has been imported into the scene.
  36900. */
  36901. onAnimationFileImportedObservable: Observable<Scene>;
  36902. /**
  36903. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36904. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36905. */
  36906. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36907. /** @hidden */
  36908. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36909. /**
  36910. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36911. */
  36912. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36913. /**
  36914. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36915. */
  36916. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36917. /**
  36918. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36919. */
  36920. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36921. /** Callback called when a pointer move is detected */
  36922. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36923. /** Callback called when a pointer down is detected */
  36924. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36925. /** Callback called when a pointer up is detected */
  36926. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36927. /** Callback called when a pointer pick is detected */
  36928. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36929. /**
  36930. * 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).
  36931. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36932. */
  36933. onPrePointerObservable: Observable<PointerInfoPre>;
  36934. /**
  36935. * Observable event triggered each time an input event is received from the rendering canvas
  36936. */
  36937. onPointerObservable: Observable<PointerInfo>;
  36938. /**
  36939. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36940. */
  36941. get unTranslatedPointer(): Vector2;
  36942. /**
  36943. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36944. */
  36945. static get DragMovementThreshold(): number;
  36946. static set DragMovementThreshold(value: number);
  36947. /**
  36948. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36949. */
  36950. static get LongPressDelay(): number;
  36951. static set LongPressDelay(value: number);
  36952. /**
  36953. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36954. */
  36955. static get DoubleClickDelay(): number;
  36956. static set DoubleClickDelay(value: number);
  36957. /** If you need to check double click without raising a single click at first click, enable this flag */
  36958. static get ExclusiveDoubleClickMode(): boolean;
  36959. static set ExclusiveDoubleClickMode(value: boolean);
  36960. /** @hidden */
  36961. _mirroredCameraPosition: Nullable<Vector3>;
  36962. /**
  36963. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36964. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36965. */
  36966. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36967. /**
  36968. * Observable event triggered each time an keyboard event is received from the hosting window
  36969. */
  36970. onKeyboardObservable: Observable<KeyboardInfo>;
  36971. private _useRightHandedSystem;
  36972. /**
  36973. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36974. */
  36975. set useRightHandedSystem(value: boolean);
  36976. get useRightHandedSystem(): boolean;
  36977. private _timeAccumulator;
  36978. private _currentStepId;
  36979. private _currentInternalStep;
  36980. /**
  36981. * Sets the step Id used by deterministic lock step
  36982. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36983. * @param newStepId defines the step Id
  36984. */
  36985. setStepId(newStepId: number): void;
  36986. /**
  36987. * Gets the step Id used by deterministic lock step
  36988. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36989. * @returns the step Id
  36990. */
  36991. getStepId(): number;
  36992. /**
  36993. * Gets the internal step used by deterministic lock step
  36994. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36995. * @returns the internal step
  36996. */
  36997. getInternalStep(): number;
  36998. private _fogEnabled;
  36999. /**
  37000. * Gets or sets a boolean indicating if fog is enabled on this scene
  37001. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37002. * (Default is true)
  37003. */
  37004. set fogEnabled(value: boolean);
  37005. get fogEnabled(): boolean;
  37006. private _fogMode;
  37007. /**
  37008. * Gets or sets the fog mode to use
  37009. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37010. * | mode | value |
  37011. * | --- | --- |
  37012. * | FOGMODE_NONE | 0 |
  37013. * | FOGMODE_EXP | 1 |
  37014. * | FOGMODE_EXP2 | 2 |
  37015. * | FOGMODE_LINEAR | 3 |
  37016. */
  37017. set fogMode(value: number);
  37018. get fogMode(): number;
  37019. /**
  37020. * Gets or sets the fog color to use
  37021. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37022. * (Default is Color3(0.2, 0.2, 0.3))
  37023. */
  37024. fogColor: Color3;
  37025. /**
  37026. * Gets or sets the fog density to use
  37027. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37028. * (Default is 0.1)
  37029. */
  37030. fogDensity: number;
  37031. /**
  37032. * Gets or sets the fog start distance to use
  37033. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37034. * (Default is 0)
  37035. */
  37036. fogStart: number;
  37037. /**
  37038. * Gets or sets the fog end distance to use
  37039. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37040. * (Default is 1000)
  37041. */
  37042. fogEnd: number;
  37043. private _shadowsEnabled;
  37044. /**
  37045. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37046. */
  37047. set shadowsEnabled(value: boolean);
  37048. get shadowsEnabled(): boolean;
  37049. private _lightsEnabled;
  37050. /**
  37051. * Gets or sets a boolean indicating if lights are enabled on this scene
  37052. */
  37053. set lightsEnabled(value: boolean);
  37054. get lightsEnabled(): boolean;
  37055. /** All of the active cameras added to this scene. */
  37056. activeCameras: Camera[];
  37057. /** @hidden */
  37058. _activeCamera: Nullable<Camera>;
  37059. /** Gets or sets the current active camera */
  37060. get activeCamera(): Nullable<Camera>;
  37061. set activeCamera(value: Nullable<Camera>);
  37062. private _defaultMaterial;
  37063. /** The default material used on meshes when no material is affected */
  37064. get defaultMaterial(): Material;
  37065. /** The default material used on meshes when no material is affected */
  37066. set defaultMaterial(value: Material);
  37067. private _texturesEnabled;
  37068. /**
  37069. * Gets or sets a boolean indicating if textures are enabled on this scene
  37070. */
  37071. set texturesEnabled(value: boolean);
  37072. get texturesEnabled(): boolean;
  37073. /**
  37074. * Gets or sets a boolean indicating if particles are enabled on this scene
  37075. */
  37076. particlesEnabled: boolean;
  37077. /**
  37078. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37079. */
  37080. spritesEnabled: boolean;
  37081. private _skeletonsEnabled;
  37082. /**
  37083. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37084. */
  37085. set skeletonsEnabled(value: boolean);
  37086. get skeletonsEnabled(): boolean;
  37087. /**
  37088. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37089. */
  37090. lensFlaresEnabled: boolean;
  37091. /**
  37092. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37093. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37094. */
  37095. collisionsEnabled: boolean;
  37096. private _collisionCoordinator;
  37097. /** @hidden */
  37098. get collisionCoordinator(): ICollisionCoordinator;
  37099. /**
  37100. * Defines the gravity applied to this scene (used only for collisions)
  37101. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37102. */
  37103. gravity: Vector3;
  37104. /**
  37105. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37106. */
  37107. postProcessesEnabled: boolean;
  37108. /**
  37109. * The list of postprocesses added to the scene
  37110. */
  37111. postProcesses: PostProcess[];
  37112. /**
  37113. * Gets the current postprocess manager
  37114. */
  37115. postProcessManager: PostProcessManager;
  37116. /**
  37117. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37118. */
  37119. renderTargetsEnabled: boolean;
  37120. /**
  37121. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37122. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37123. */
  37124. dumpNextRenderTargets: boolean;
  37125. /**
  37126. * The list of user defined render targets added to the scene
  37127. */
  37128. customRenderTargets: RenderTargetTexture[];
  37129. /**
  37130. * Defines if texture loading must be delayed
  37131. * If true, textures will only be loaded when they need to be rendered
  37132. */
  37133. useDelayedTextureLoading: boolean;
  37134. /**
  37135. * Gets the list of meshes imported to the scene through SceneLoader
  37136. */
  37137. importedMeshesFiles: String[];
  37138. /**
  37139. * Gets or sets a boolean indicating if probes are enabled on this scene
  37140. */
  37141. probesEnabled: boolean;
  37142. /**
  37143. * Gets or sets the current offline provider to use to store scene data
  37144. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37145. */
  37146. offlineProvider: IOfflineProvider;
  37147. /**
  37148. * Gets or sets the action manager associated with the scene
  37149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37150. */
  37151. actionManager: AbstractActionManager;
  37152. private _meshesForIntersections;
  37153. /**
  37154. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37155. */
  37156. proceduralTexturesEnabled: boolean;
  37157. private _engine;
  37158. private _totalVertices;
  37159. /** @hidden */
  37160. _activeIndices: PerfCounter;
  37161. /** @hidden */
  37162. _activeParticles: PerfCounter;
  37163. /** @hidden */
  37164. _activeBones: PerfCounter;
  37165. private _animationRatio;
  37166. /** @hidden */
  37167. _animationTimeLast: number;
  37168. /** @hidden */
  37169. _animationTime: number;
  37170. /**
  37171. * Gets or sets a general scale for animation speed
  37172. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37173. */
  37174. animationTimeScale: number;
  37175. /** @hidden */
  37176. _cachedMaterial: Nullable<Material>;
  37177. /** @hidden */
  37178. _cachedEffect: Nullable<Effect>;
  37179. /** @hidden */
  37180. _cachedVisibility: Nullable<number>;
  37181. private _renderId;
  37182. private _frameId;
  37183. private _executeWhenReadyTimeoutId;
  37184. private _intermediateRendering;
  37185. private _viewUpdateFlag;
  37186. private _projectionUpdateFlag;
  37187. /** @hidden */
  37188. _toBeDisposed: Nullable<IDisposable>[];
  37189. private _activeRequests;
  37190. /** @hidden */
  37191. _pendingData: any[];
  37192. private _isDisposed;
  37193. /**
  37194. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37195. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37196. */
  37197. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37198. private _activeMeshes;
  37199. private _processedMaterials;
  37200. private _renderTargets;
  37201. /** @hidden */
  37202. _activeParticleSystems: SmartArray<IParticleSystem>;
  37203. private _activeSkeletons;
  37204. private _softwareSkinnedMeshes;
  37205. private _renderingManager;
  37206. /** @hidden */
  37207. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37208. private _transformMatrix;
  37209. private _sceneUbo;
  37210. /** @hidden */
  37211. _viewMatrix: Matrix;
  37212. private _projectionMatrix;
  37213. /** @hidden */
  37214. _forcedViewPosition: Nullable<Vector3>;
  37215. /** @hidden */
  37216. _frustumPlanes: Plane[];
  37217. /**
  37218. * Gets the list of frustum planes (built from the active camera)
  37219. */
  37220. get frustumPlanes(): Plane[];
  37221. /**
  37222. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37223. * This is useful if there are more lights that the maximum simulteanous authorized
  37224. */
  37225. requireLightSorting: boolean;
  37226. /** @hidden */
  37227. readonly useMaterialMeshMap: boolean;
  37228. /** @hidden */
  37229. readonly useClonedMeshMap: boolean;
  37230. private _externalData;
  37231. private _uid;
  37232. /**
  37233. * @hidden
  37234. * Backing store of defined scene components.
  37235. */
  37236. _components: ISceneComponent[];
  37237. /**
  37238. * @hidden
  37239. * Backing store of defined scene components.
  37240. */
  37241. _serializableComponents: ISceneSerializableComponent[];
  37242. /**
  37243. * List of components to register on the next registration step.
  37244. */
  37245. private _transientComponents;
  37246. /**
  37247. * Registers the transient components if needed.
  37248. */
  37249. private _registerTransientComponents;
  37250. /**
  37251. * @hidden
  37252. * Add a component to the scene.
  37253. * Note that the ccomponent could be registered on th next frame if this is called after
  37254. * the register component stage.
  37255. * @param component Defines the component to add to the scene
  37256. */
  37257. _addComponent(component: ISceneComponent): void;
  37258. /**
  37259. * @hidden
  37260. * Gets a component from the scene.
  37261. * @param name defines the name of the component to retrieve
  37262. * @returns the component or null if not present
  37263. */
  37264. _getComponent(name: string): Nullable<ISceneComponent>;
  37265. /**
  37266. * @hidden
  37267. * Defines the actions happening before camera updates.
  37268. */
  37269. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37270. /**
  37271. * @hidden
  37272. * Defines the actions happening before clear the canvas.
  37273. */
  37274. _beforeClearStage: Stage<SimpleStageAction>;
  37275. /**
  37276. * @hidden
  37277. * Defines the actions when collecting render targets for the frame.
  37278. */
  37279. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37280. /**
  37281. * @hidden
  37282. * Defines the actions happening for one camera in the frame.
  37283. */
  37284. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37285. /**
  37286. * @hidden
  37287. * Defines the actions happening during the per mesh ready checks.
  37288. */
  37289. _isReadyForMeshStage: Stage<MeshStageAction>;
  37290. /**
  37291. * @hidden
  37292. * Defines the actions happening before evaluate active mesh checks.
  37293. */
  37294. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37295. /**
  37296. * @hidden
  37297. * Defines the actions happening during the evaluate sub mesh checks.
  37298. */
  37299. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37300. /**
  37301. * @hidden
  37302. * Defines the actions happening during the active mesh stage.
  37303. */
  37304. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37305. /**
  37306. * @hidden
  37307. * Defines the actions happening during the per camera render target step.
  37308. */
  37309. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37310. /**
  37311. * @hidden
  37312. * Defines the actions happening just before the active camera is drawing.
  37313. */
  37314. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37315. /**
  37316. * @hidden
  37317. * Defines the actions happening just before a render target is drawing.
  37318. */
  37319. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37320. /**
  37321. * @hidden
  37322. * Defines the actions happening just before a rendering group is drawing.
  37323. */
  37324. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37325. /**
  37326. * @hidden
  37327. * Defines the actions happening just before a mesh is drawing.
  37328. */
  37329. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37330. /**
  37331. * @hidden
  37332. * Defines the actions happening just after a mesh has been drawn.
  37333. */
  37334. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37335. /**
  37336. * @hidden
  37337. * Defines the actions happening just after a rendering group has been drawn.
  37338. */
  37339. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37340. /**
  37341. * @hidden
  37342. * Defines the actions happening just after the active camera has been drawn.
  37343. */
  37344. _afterCameraDrawStage: Stage<CameraStageAction>;
  37345. /**
  37346. * @hidden
  37347. * Defines the actions happening just after a render target has been drawn.
  37348. */
  37349. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37350. /**
  37351. * @hidden
  37352. * Defines the actions happening just after rendering all cameras and computing intersections.
  37353. */
  37354. _afterRenderStage: Stage<SimpleStageAction>;
  37355. /**
  37356. * @hidden
  37357. * Defines the actions happening when a pointer move event happens.
  37358. */
  37359. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37360. /**
  37361. * @hidden
  37362. * Defines the actions happening when a pointer down event happens.
  37363. */
  37364. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37365. /**
  37366. * @hidden
  37367. * Defines the actions happening when a pointer up event happens.
  37368. */
  37369. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37370. /**
  37371. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37372. */
  37373. private geometriesByUniqueId;
  37374. /**
  37375. * Creates a new Scene
  37376. * @param engine defines the engine to use to render this scene
  37377. * @param options defines the scene options
  37378. */
  37379. constructor(engine: Engine, options?: SceneOptions);
  37380. /**
  37381. * Gets a string idenfifying the name of the class
  37382. * @returns "Scene" string
  37383. */
  37384. getClassName(): string;
  37385. private _defaultMeshCandidates;
  37386. /**
  37387. * @hidden
  37388. */
  37389. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37390. private _defaultSubMeshCandidates;
  37391. /**
  37392. * @hidden
  37393. */
  37394. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37395. /**
  37396. * Sets the default candidate providers for the scene.
  37397. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37398. * and getCollidingSubMeshCandidates to their default function
  37399. */
  37400. setDefaultCandidateProviders(): void;
  37401. /**
  37402. * Gets the mesh that is currently under the pointer
  37403. */
  37404. get meshUnderPointer(): Nullable<AbstractMesh>;
  37405. /**
  37406. * Gets or sets the current on-screen X position of the pointer
  37407. */
  37408. get pointerX(): number;
  37409. set pointerX(value: number);
  37410. /**
  37411. * Gets or sets the current on-screen Y position of the pointer
  37412. */
  37413. get pointerY(): number;
  37414. set pointerY(value: number);
  37415. /**
  37416. * Gets the cached material (ie. the latest rendered one)
  37417. * @returns the cached material
  37418. */
  37419. getCachedMaterial(): Nullable<Material>;
  37420. /**
  37421. * Gets the cached effect (ie. the latest rendered one)
  37422. * @returns the cached effect
  37423. */
  37424. getCachedEffect(): Nullable<Effect>;
  37425. /**
  37426. * Gets the cached visibility state (ie. the latest rendered one)
  37427. * @returns the cached visibility state
  37428. */
  37429. getCachedVisibility(): Nullable<number>;
  37430. /**
  37431. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37432. * @param material defines the current material
  37433. * @param effect defines the current effect
  37434. * @param visibility defines the current visibility state
  37435. * @returns true if one parameter is not cached
  37436. */
  37437. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37438. /**
  37439. * Gets the engine associated with the scene
  37440. * @returns an Engine
  37441. */
  37442. getEngine(): Engine;
  37443. /**
  37444. * Gets the total number of vertices rendered per frame
  37445. * @returns the total number of vertices rendered per frame
  37446. */
  37447. getTotalVertices(): number;
  37448. /**
  37449. * Gets the performance counter for total vertices
  37450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37451. */
  37452. get totalVerticesPerfCounter(): PerfCounter;
  37453. /**
  37454. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37455. * @returns the total number of active indices rendered per frame
  37456. */
  37457. getActiveIndices(): number;
  37458. /**
  37459. * Gets the performance counter for active indices
  37460. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37461. */
  37462. get totalActiveIndicesPerfCounter(): PerfCounter;
  37463. /**
  37464. * Gets the total number of active particles rendered per frame
  37465. * @returns the total number of active particles rendered per frame
  37466. */
  37467. getActiveParticles(): number;
  37468. /**
  37469. * Gets the performance counter for active particles
  37470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37471. */
  37472. get activeParticlesPerfCounter(): PerfCounter;
  37473. /**
  37474. * Gets the total number of active bones rendered per frame
  37475. * @returns the total number of active bones rendered per frame
  37476. */
  37477. getActiveBones(): number;
  37478. /**
  37479. * Gets the performance counter for active bones
  37480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37481. */
  37482. get activeBonesPerfCounter(): PerfCounter;
  37483. /**
  37484. * Gets the array of active meshes
  37485. * @returns an array of AbstractMesh
  37486. */
  37487. getActiveMeshes(): SmartArray<AbstractMesh>;
  37488. /**
  37489. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37490. * @returns a number
  37491. */
  37492. getAnimationRatio(): number;
  37493. /**
  37494. * Gets an unique Id for the current render phase
  37495. * @returns a number
  37496. */
  37497. getRenderId(): number;
  37498. /**
  37499. * Gets an unique Id for the current frame
  37500. * @returns a number
  37501. */
  37502. getFrameId(): number;
  37503. /** Call this function if you want to manually increment the render Id*/
  37504. incrementRenderId(): void;
  37505. private _createUbo;
  37506. /**
  37507. * Use this method to simulate a pointer move on a mesh
  37508. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37509. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37510. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37511. * @returns the current scene
  37512. */
  37513. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37514. /**
  37515. * Use this method to simulate a pointer down on a mesh
  37516. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37517. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37518. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37519. * @returns the current scene
  37520. */
  37521. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37522. /**
  37523. * Use this method to simulate a pointer up on a mesh
  37524. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37525. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37526. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37527. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37528. * @returns the current scene
  37529. */
  37530. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37531. /**
  37532. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37533. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37534. * @returns true if the pointer was captured
  37535. */
  37536. isPointerCaptured(pointerId?: number): boolean;
  37537. /**
  37538. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37539. * @param attachUp defines if you want to attach events to pointerup
  37540. * @param attachDown defines if you want to attach events to pointerdown
  37541. * @param attachMove defines if you want to attach events to pointermove
  37542. */
  37543. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37544. /** Detaches all event handlers*/
  37545. detachControl(): void;
  37546. /**
  37547. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37548. * Delay loaded resources are not taking in account
  37549. * @return true if all required resources are ready
  37550. */
  37551. isReady(): boolean;
  37552. /** Resets all cached information relative to material (including effect and visibility) */
  37553. resetCachedMaterial(): void;
  37554. /**
  37555. * Registers a function to be called before every frame render
  37556. * @param func defines the function to register
  37557. */
  37558. registerBeforeRender(func: () => void): void;
  37559. /**
  37560. * Unregisters a function called before every frame render
  37561. * @param func defines the function to unregister
  37562. */
  37563. unregisterBeforeRender(func: () => void): void;
  37564. /**
  37565. * Registers a function to be called after every frame render
  37566. * @param func defines the function to register
  37567. */
  37568. registerAfterRender(func: () => void): void;
  37569. /**
  37570. * Unregisters a function called after every frame render
  37571. * @param func defines the function to unregister
  37572. */
  37573. unregisterAfterRender(func: () => void): void;
  37574. private _executeOnceBeforeRender;
  37575. /**
  37576. * The provided function will run before render once and will be disposed afterwards.
  37577. * A timeout delay can be provided so that the function will be executed in N ms.
  37578. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37579. * @param func The function to be executed.
  37580. * @param timeout optional delay in ms
  37581. */
  37582. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37583. /** @hidden */
  37584. _addPendingData(data: any): void;
  37585. /** @hidden */
  37586. _removePendingData(data: any): void;
  37587. /**
  37588. * Returns the number of items waiting to be loaded
  37589. * @returns the number of items waiting to be loaded
  37590. */
  37591. getWaitingItemsCount(): number;
  37592. /**
  37593. * Returns a boolean indicating if the scene is still loading data
  37594. */
  37595. get isLoading(): boolean;
  37596. /**
  37597. * Registers a function to be executed when the scene is ready
  37598. * @param {Function} func - the function to be executed
  37599. */
  37600. executeWhenReady(func: () => void): void;
  37601. /**
  37602. * Returns a promise that resolves when the scene is ready
  37603. * @returns A promise that resolves when the scene is ready
  37604. */
  37605. whenReadyAsync(): Promise<void>;
  37606. /** @hidden */
  37607. _checkIsReady(): void;
  37608. /**
  37609. * Gets all animatable attached to the scene
  37610. */
  37611. get animatables(): Animatable[];
  37612. /**
  37613. * Resets the last animation time frame.
  37614. * Useful to override when animations start running when loading a scene for the first time.
  37615. */
  37616. resetLastAnimationTimeFrame(): void;
  37617. /**
  37618. * Gets the current view matrix
  37619. * @returns a Matrix
  37620. */
  37621. getViewMatrix(): Matrix;
  37622. /**
  37623. * Gets the current projection matrix
  37624. * @returns a Matrix
  37625. */
  37626. getProjectionMatrix(): Matrix;
  37627. /**
  37628. * Gets the current transform matrix
  37629. * @returns a Matrix made of View * Projection
  37630. */
  37631. getTransformMatrix(): Matrix;
  37632. /**
  37633. * Sets the current transform matrix
  37634. * @param viewL defines the View matrix to use
  37635. * @param projectionL defines the Projection matrix to use
  37636. * @param viewR defines the right View matrix to use (if provided)
  37637. * @param projectionR defines the right Projection matrix to use (if provided)
  37638. */
  37639. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37640. /**
  37641. * Gets the uniform buffer used to store scene data
  37642. * @returns a UniformBuffer
  37643. */
  37644. getSceneUniformBuffer(): UniformBuffer;
  37645. /**
  37646. * Gets an unique (relatively to the current scene) Id
  37647. * @returns an unique number for the scene
  37648. */
  37649. getUniqueId(): number;
  37650. /**
  37651. * Add a mesh to the list of scene's meshes
  37652. * @param newMesh defines the mesh to add
  37653. * @param recursive if all child meshes should also be added to the scene
  37654. */
  37655. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37656. /**
  37657. * Remove a mesh for the list of scene's meshes
  37658. * @param toRemove defines the mesh to remove
  37659. * @param recursive if all child meshes should also be removed from the scene
  37660. * @returns the index where the mesh was in the mesh list
  37661. */
  37662. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37663. /**
  37664. * Add a transform node to the list of scene's transform nodes
  37665. * @param newTransformNode defines the transform node to add
  37666. */
  37667. addTransformNode(newTransformNode: TransformNode): void;
  37668. /**
  37669. * Remove a transform node for the list of scene's transform nodes
  37670. * @param toRemove defines the transform node to remove
  37671. * @returns the index where the transform node was in the transform node list
  37672. */
  37673. removeTransformNode(toRemove: TransformNode): number;
  37674. /**
  37675. * Remove a skeleton for the list of scene's skeletons
  37676. * @param toRemove defines the skeleton to remove
  37677. * @returns the index where the skeleton was in the skeleton list
  37678. */
  37679. removeSkeleton(toRemove: Skeleton): number;
  37680. /**
  37681. * Remove a morph target for the list of scene's morph targets
  37682. * @param toRemove defines the morph target to remove
  37683. * @returns the index where the morph target was in the morph target list
  37684. */
  37685. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37686. /**
  37687. * Remove a light for the list of scene's lights
  37688. * @param toRemove defines the light to remove
  37689. * @returns the index where the light was in the light list
  37690. */
  37691. removeLight(toRemove: Light): number;
  37692. /**
  37693. * Remove a camera for the list of scene's cameras
  37694. * @param toRemove defines the camera to remove
  37695. * @returns the index where the camera was in the camera list
  37696. */
  37697. removeCamera(toRemove: Camera): number;
  37698. /**
  37699. * Remove a particle system for the list of scene's particle systems
  37700. * @param toRemove defines the particle system to remove
  37701. * @returns the index where the particle system was in the particle system list
  37702. */
  37703. removeParticleSystem(toRemove: IParticleSystem): number;
  37704. /**
  37705. * Remove a animation for the list of scene's animations
  37706. * @param toRemove defines the animation to remove
  37707. * @returns the index where the animation was in the animation list
  37708. */
  37709. removeAnimation(toRemove: Animation): number;
  37710. /**
  37711. * Will stop the animation of the given target
  37712. * @param target - the target
  37713. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37714. * @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)
  37715. */
  37716. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37717. /**
  37718. * Removes the given animation group from this scene.
  37719. * @param toRemove The animation group to remove
  37720. * @returns The index of the removed animation group
  37721. */
  37722. removeAnimationGroup(toRemove: AnimationGroup): number;
  37723. /**
  37724. * Removes the given multi-material from this scene.
  37725. * @param toRemove The multi-material to remove
  37726. * @returns The index of the removed multi-material
  37727. */
  37728. removeMultiMaterial(toRemove: MultiMaterial): number;
  37729. /**
  37730. * Removes the given material from this scene.
  37731. * @param toRemove The material to remove
  37732. * @returns The index of the removed material
  37733. */
  37734. removeMaterial(toRemove: Material): number;
  37735. /**
  37736. * Removes the given action manager from this scene.
  37737. * @param toRemove The action manager to remove
  37738. * @returns The index of the removed action manager
  37739. */
  37740. removeActionManager(toRemove: AbstractActionManager): number;
  37741. /**
  37742. * Removes the given texture from this scene.
  37743. * @param toRemove The texture to remove
  37744. * @returns The index of the removed texture
  37745. */
  37746. removeTexture(toRemove: BaseTexture): number;
  37747. /**
  37748. * Adds the given light to this scene
  37749. * @param newLight The light to add
  37750. */
  37751. addLight(newLight: Light): void;
  37752. /**
  37753. * Sorts the list list based on light priorities
  37754. */
  37755. sortLightsByPriority(): void;
  37756. /**
  37757. * Adds the given camera to this scene
  37758. * @param newCamera The camera to add
  37759. */
  37760. addCamera(newCamera: Camera): void;
  37761. /**
  37762. * Adds the given skeleton to this scene
  37763. * @param newSkeleton The skeleton to add
  37764. */
  37765. addSkeleton(newSkeleton: Skeleton): void;
  37766. /**
  37767. * Adds the given particle system to this scene
  37768. * @param newParticleSystem The particle system to add
  37769. */
  37770. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37771. /**
  37772. * Adds the given animation to this scene
  37773. * @param newAnimation The animation to add
  37774. */
  37775. addAnimation(newAnimation: Animation): void;
  37776. /**
  37777. * Adds the given animation group to this scene.
  37778. * @param newAnimationGroup The animation group to add
  37779. */
  37780. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37781. /**
  37782. * Adds the given multi-material to this scene
  37783. * @param newMultiMaterial The multi-material to add
  37784. */
  37785. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37786. /**
  37787. * Adds the given material to this scene
  37788. * @param newMaterial The material to add
  37789. */
  37790. addMaterial(newMaterial: Material): void;
  37791. /**
  37792. * Adds the given morph target to this scene
  37793. * @param newMorphTargetManager The morph target to add
  37794. */
  37795. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37796. /**
  37797. * Adds the given geometry to this scene
  37798. * @param newGeometry The geometry to add
  37799. */
  37800. addGeometry(newGeometry: Geometry): void;
  37801. /**
  37802. * Adds the given action manager to this scene
  37803. * @param newActionManager The action manager to add
  37804. */
  37805. addActionManager(newActionManager: AbstractActionManager): void;
  37806. /**
  37807. * Adds the given texture to this scene.
  37808. * @param newTexture The texture to add
  37809. */
  37810. addTexture(newTexture: BaseTexture): void;
  37811. /**
  37812. * Switch active camera
  37813. * @param newCamera defines the new active camera
  37814. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37815. */
  37816. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37817. /**
  37818. * sets the active camera of the scene using its ID
  37819. * @param id defines the camera's ID
  37820. * @return the new active camera or null if none found.
  37821. */
  37822. setActiveCameraByID(id: string): Nullable<Camera>;
  37823. /**
  37824. * sets the active camera of the scene using its name
  37825. * @param name defines the camera's name
  37826. * @returns the new active camera or null if none found.
  37827. */
  37828. setActiveCameraByName(name: string): Nullable<Camera>;
  37829. /**
  37830. * get an animation group using its name
  37831. * @param name defines the material's name
  37832. * @return the animation group or null if none found.
  37833. */
  37834. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37835. /**
  37836. * Get a material using its unique id
  37837. * @param uniqueId defines the material's unique id
  37838. * @return the material or null if none found.
  37839. */
  37840. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37841. /**
  37842. * get a material using its id
  37843. * @param id defines the material's ID
  37844. * @return the material or null if none found.
  37845. */
  37846. getMaterialByID(id: string): Nullable<Material>;
  37847. /**
  37848. * Gets a the last added material using a given id
  37849. * @param id defines the material's ID
  37850. * @return the last material with the given id or null if none found.
  37851. */
  37852. getLastMaterialByID(id: string): Nullable<Material>;
  37853. /**
  37854. * Gets a material using its name
  37855. * @param name defines the material's name
  37856. * @return the material or null if none found.
  37857. */
  37858. getMaterialByName(name: string): Nullable<Material>;
  37859. /**
  37860. * Get a texture using its unique id
  37861. * @param uniqueId defines the texture's unique id
  37862. * @return the texture or null if none found.
  37863. */
  37864. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37865. /**
  37866. * Gets a camera using its id
  37867. * @param id defines the id to look for
  37868. * @returns the camera or null if not found
  37869. */
  37870. getCameraByID(id: string): Nullable<Camera>;
  37871. /**
  37872. * Gets a camera using its unique id
  37873. * @param uniqueId defines the unique id to look for
  37874. * @returns the camera or null if not found
  37875. */
  37876. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37877. /**
  37878. * Gets a camera using its name
  37879. * @param name defines the camera's name
  37880. * @return the camera or null if none found.
  37881. */
  37882. getCameraByName(name: string): Nullable<Camera>;
  37883. /**
  37884. * Gets a bone using its id
  37885. * @param id defines the bone's id
  37886. * @return the bone or null if not found
  37887. */
  37888. getBoneByID(id: string): Nullable<Bone>;
  37889. /**
  37890. * Gets a bone using its id
  37891. * @param name defines the bone's name
  37892. * @return the bone or null if not found
  37893. */
  37894. getBoneByName(name: string): Nullable<Bone>;
  37895. /**
  37896. * Gets a light node using its name
  37897. * @param name defines the the light's name
  37898. * @return the light or null if none found.
  37899. */
  37900. getLightByName(name: string): Nullable<Light>;
  37901. /**
  37902. * Gets a light node using its id
  37903. * @param id defines the light's id
  37904. * @return the light or null if none found.
  37905. */
  37906. getLightByID(id: string): Nullable<Light>;
  37907. /**
  37908. * Gets a light node using its scene-generated unique ID
  37909. * @param uniqueId defines the light's unique id
  37910. * @return the light or null if none found.
  37911. */
  37912. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37913. /**
  37914. * Gets a particle system by id
  37915. * @param id defines the particle system id
  37916. * @return the corresponding system or null if none found
  37917. */
  37918. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37919. /**
  37920. * Gets a geometry using its ID
  37921. * @param id defines the geometry's id
  37922. * @return the geometry or null if none found.
  37923. */
  37924. getGeometryByID(id: string): Nullable<Geometry>;
  37925. private _getGeometryByUniqueID;
  37926. /**
  37927. * Add a new geometry to this scene
  37928. * @param geometry defines the geometry to be added to the scene.
  37929. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37930. * @return a boolean defining if the geometry was added or not
  37931. */
  37932. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37933. /**
  37934. * Removes an existing geometry
  37935. * @param geometry defines the geometry to be removed from the scene
  37936. * @return a boolean defining if the geometry was removed or not
  37937. */
  37938. removeGeometry(geometry: Geometry): boolean;
  37939. /**
  37940. * Gets the list of geometries attached to the scene
  37941. * @returns an array of Geometry
  37942. */
  37943. getGeometries(): Geometry[];
  37944. /**
  37945. * Gets the first added mesh found of a given ID
  37946. * @param id defines the id to search for
  37947. * @return the mesh found or null if not found at all
  37948. */
  37949. getMeshByID(id: string): Nullable<AbstractMesh>;
  37950. /**
  37951. * Gets a list of meshes using their id
  37952. * @param id defines the id to search for
  37953. * @returns a list of meshes
  37954. */
  37955. getMeshesByID(id: string): Array<AbstractMesh>;
  37956. /**
  37957. * Gets the first added transform node found of a given ID
  37958. * @param id defines the id to search for
  37959. * @return the found transform node or null if not found at all.
  37960. */
  37961. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37962. /**
  37963. * Gets a transform node with its auto-generated unique id
  37964. * @param uniqueId efines the unique id to search for
  37965. * @return the found transform node or null if not found at all.
  37966. */
  37967. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37968. /**
  37969. * Gets a list of transform nodes using their id
  37970. * @param id defines the id to search for
  37971. * @returns a list of transform nodes
  37972. */
  37973. getTransformNodesByID(id: string): Array<TransformNode>;
  37974. /**
  37975. * Gets a mesh with its auto-generated unique id
  37976. * @param uniqueId defines the unique id to search for
  37977. * @return the found mesh or null if not found at all.
  37978. */
  37979. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37980. /**
  37981. * Gets a the last added mesh using a given id
  37982. * @param id defines the id to search for
  37983. * @return the found mesh or null if not found at all.
  37984. */
  37985. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37986. /**
  37987. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37988. * @param id defines the id to search for
  37989. * @return the found node or null if not found at all
  37990. */
  37991. getLastEntryByID(id: string): Nullable<Node>;
  37992. /**
  37993. * Gets a node (Mesh, Camera, Light) using a given id
  37994. * @param id defines the id to search for
  37995. * @return the found node or null if not found at all
  37996. */
  37997. getNodeByID(id: string): Nullable<Node>;
  37998. /**
  37999. * Gets a node (Mesh, Camera, Light) using a given name
  38000. * @param name defines the name to search for
  38001. * @return the found node or null if not found at all.
  38002. */
  38003. getNodeByName(name: string): Nullable<Node>;
  38004. /**
  38005. * Gets a mesh using a given name
  38006. * @param name defines the name to search for
  38007. * @return the found mesh or null if not found at all.
  38008. */
  38009. getMeshByName(name: string): Nullable<AbstractMesh>;
  38010. /**
  38011. * Gets a transform node using a given name
  38012. * @param name defines the name to search for
  38013. * @return the found transform node or null if not found at all.
  38014. */
  38015. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38016. /**
  38017. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38018. * @param id defines the id to search for
  38019. * @return the found skeleton or null if not found at all.
  38020. */
  38021. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38022. /**
  38023. * Gets a skeleton using a given auto generated unique id
  38024. * @param uniqueId defines the unique id to search for
  38025. * @return the found skeleton or null if not found at all.
  38026. */
  38027. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38028. /**
  38029. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38030. * @param id defines the id to search for
  38031. * @return the found skeleton or null if not found at all.
  38032. */
  38033. getSkeletonById(id: string): Nullable<Skeleton>;
  38034. /**
  38035. * Gets a skeleton using a given name
  38036. * @param name defines the name to search for
  38037. * @return the found skeleton or null if not found at all.
  38038. */
  38039. getSkeletonByName(name: string): Nullable<Skeleton>;
  38040. /**
  38041. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38042. * @param id defines the id to search for
  38043. * @return the found morph target manager or null if not found at all.
  38044. */
  38045. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38046. /**
  38047. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38048. * @param id defines the id to search for
  38049. * @return the found morph target or null if not found at all.
  38050. */
  38051. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38052. /**
  38053. * Gets a boolean indicating if the given mesh is active
  38054. * @param mesh defines the mesh to look for
  38055. * @returns true if the mesh is in the active list
  38056. */
  38057. isActiveMesh(mesh: AbstractMesh): boolean;
  38058. /**
  38059. * Return a unique id as a string which can serve as an identifier for the scene
  38060. */
  38061. get uid(): string;
  38062. /**
  38063. * Add an externaly attached data from its key.
  38064. * This method call will fail and return false, if such key already exists.
  38065. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38066. * @param key the unique key that identifies the data
  38067. * @param data the data object to associate to the key for this Engine instance
  38068. * @return true if no such key were already present and the data was added successfully, false otherwise
  38069. */
  38070. addExternalData<T>(key: string, data: T): boolean;
  38071. /**
  38072. * Get an externaly attached data from its key
  38073. * @param key the unique key that identifies the data
  38074. * @return the associated data, if present (can be null), or undefined if not present
  38075. */
  38076. getExternalData<T>(key: string): Nullable<T>;
  38077. /**
  38078. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38079. * @param key the unique key that identifies the data
  38080. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38081. * @return the associated data, can be null if the factory returned null.
  38082. */
  38083. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38084. /**
  38085. * Remove an externaly attached data from the Engine instance
  38086. * @param key the unique key that identifies the data
  38087. * @return true if the data was successfully removed, false if it doesn't exist
  38088. */
  38089. removeExternalData(key: string): boolean;
  38090. private _evaluateSubMesh;
  38091. /**
  38092. * Clear the processed materials smart array preventing retention point in material dispose.
  38093. */
  38094. freeProcessedMaterials(): void;
  38095. private _preventFreeActiveMeshesAndRenderingGroups;
  38096. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38097. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38098. * when disposing several meshes in a row or a hierarchy of meshes.
  38099. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38100. */
  38101. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38102. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38103. /**
  38104. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38105. */
  38106. freeActiveMeshes(): void;
  38107. /**
  38108. * Clear the info related to rendering groups preventing retention points during dispose.
  38109. */
  38110. freeRenderingGroups(): void;
  38111. /** @hidden */
  38112. _isInIntermediateRendering(): boolean;
  38113. /**
  38114. * Lambda returning the list of potentially active meshes.
  38115. */
  38116. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38117. /**
  38118. * Lambda returning the list of potentially active sub meshes.
  38119. */
  38120. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38121. /**
  38122. * Lambda returning the list of potentially intersecting sub meshes.
  38123. */
  38124. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38125. /**
  38126. * Lambda returning the list of potentially colliding sub meshes.
  38127. */
  38128. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38129. private _activeMeshesFrozen;
  38130. private _skipEvaluateActiveMeshesCompletely;
  38131. /**
  38132. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38133. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38134. * @returns the current scene
  38135. */
  38136. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38137. /**
  38138. * Use this function to restart evaluating active meshes on every frame
  38139. * @returns the current scene
  38140. */
  38141. unfreezeActiveMeshes(): Scene;
  38142. private _evaluateActiveMeshes;
  38143. private _activeMesh;
  38144. /**
  38145. * Update the transform matrix to update from the current active camera
  38146. * @param force defines a boolean used to force the update even if cache is up to date
  38147. */
  38148. updateTransformMatrix(force?: boolean): void;
  38149. private _bindFrameBuffer;
  38150. /** @hidden */
  38151. _allowPostProcessClearColor: boolean;
  38152. /** @hidden */
  38153. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38154. private _processSubCameras;
  38155. private _checkIntersections;
  38156. /** @hidden */
  38157. _advancePhysicsEngineStep(step: number): void;
  38158. /**
  38159. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38160. */
  38161. getDeterministicFrameTime: () => number;
  38162. /** @hidden */
  38163. _animate(): void;
  38164. /** Execute all animations (for a frame) */
  38165. animate(): void;
  38166. /**
  38167. * Render the scene
  38168. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38169. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38170. */
  38171. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38172. /**
  38173. * Freeze all materials
  38174. * A frozen material will not be updatable but should be faster to render
  38175. */
  38176. freezeMaterials(): void;
  38177. /**
  38178. * Unfreeze all materials
  38179. * A frozen material will not be updatable but should be faster to render
  38180. */
  38181. unfreezeMaterials(): void;
  38182. /**
  38183. * Releases all held ressources
  38184. */
  38185. dispose(): void;
  38186. /**
  38187. * Gets if the scene is already disposed
  38188. */
  38189. get isDisposed(): boolean;
  38190. /**
  38191. * Call this function to reduce memory footprint of the scene.
  38192. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38193. */
  38194. clearCachedVertexData(): void;
  38195. /**
  38196. * This function will remove the local cached buffer data from texture.
  38197. * It will save memory but will prevent the texture from being rebuilt
  38198. */
  38199. cleanCachedTextureBuffer(): void;
  38200. /**
  38201. * Get the world extend vectors with an optional filter
  38202. *
  38203. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38204. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38205. */
  38206. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38207. min: Vector3;
  38208. max: Vector3;
  38209. };
  38210. /**
  38211. * Creates a ray that can be used to pick in the scene
  38212. * @param x defines the x coordinate of the origin (on-screen)
  38213. * @param y defines the y coordinate of the origin (on-screen)
  38214. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38215. * @param camera defines the camera to use for the picking
  38216. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38217. * @returns a Ray
  38218. */
  38219. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38220. /**
  38221. * Creates a ray that can be used to pick in the scene
  38222. * @param x defines the x coordinate of the origin (on-screen)
  38223. * @param y defines the y coordinate of the origin (on-screen)
  38224. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38225. * @param result defines the ray where to store the picking ray
  38226. * @param camera defines the camera to use for the picking
  38227. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38228. * @returns the current scene
  38229. */
  38230. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38231. /**
  38232. * Creates a ray that can be used to pick in the scene
  38233. * @param x defines the x coordinate of the origin (on-screen)
  38234. * @param y defines the y coordinate of the origin (on-screen)
  38235. * @param camera defines the camera to use for the picking
  38236. * @returns a Ray
  38237. */
  38238. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38239. /**
  38240. * Creates a ray that can be used to pick in the scene
  38241. * @param x defines the x coordinate of the origin (on-screen)
  38242. * @param y defines the y coordinate of the origin (on-screen)
  38243. * @param result defines the ray where to store the picking ray
  38244. * @param camera defines the camera to use for the picking
  38245. * @returns the current scene
  38246. */
  38247. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38248. /** Launch a ray to try to pick a mesh in the scene
  38249. * @param x position on screen
  38250. * @param y position on screen
  38251. * @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
  38252. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  38253. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38254. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38255. * @returns a PickingInfo
  38256. */
  38257. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38258. /** Use the given ray to pick a mesh in the scene
  38259. * @param ray The ray to use to pick meshes
  38260. * @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
  38261. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  38262. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38263. * @returns a PickingInfo
  38264. */
  38265. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38266. /**
  38267. * Launch a ray to try to pick a mesh in the scene
  38268. * @param x X position on screen
  38269. * @param y Y position on screen
  38270. * @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
  38271. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38272. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38273. * @returns an array of PickingInfo
  38274. */
  38275. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38276. /**
  38277. * Launch a ray to try to pick a mesh in the scene
  38278. * @param ray Ray to use
  38279. * @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
  38280. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38281. * @returns an array of PickingInfo
  38282. */
  38283. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38284. /**
  38285. * Force the value of meshUnderPointer
  38286. * @param mesh defines the mesh to use
  38287. */
  38288. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38289. /**
  38290. * Gets the mesh under the pointer
  38291. * @returns a Mesh or null if no mesh is under the pointer
  38292. */
  38293. getPointerOverMesh(): Nullable<AbstractMesh>;
  38294. /** @hidden */
  38295. _rebuildGeometries(): void;
  38296. /** @hidden */
  38297. _rebuildTextures(): void;
  38298. private _getByTags;
  38299. /**
  38300. * Get a list of meshes by tags
  38301. * @param tagsQuery defines the tags query to use
  38302. * @param forEach defines a predicate used to filter results
  38303. * @returns an array of Mesh
  38304. */
  38305. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38306. /**
  38307. * Get a list of cameras by tags
  38308. * @param tagsQuery defines the tags query to use
  38309. * @param forEach defines a predicate used to filter results
  38310. * @returns an array of Camera
  38311. */
  38312. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38313. /**
  38314. * Get a list of lights by tags
  38315. * @param tagsQuery defines the tags query to use
  38316. * @param forEach defines a predicate used to filter results
  38317. * @returns an array of Light
  38318. */
  38319. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38320. /**
  38321. * Get a list of materials by tags
  38322. * @param tagsQuery defines the tags query to use
  38323. * @param forEach defines a predicate used to filter results
  38324. * @returns an array of Material
  38325. */
  38326. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38327. /**
  38328. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38329. * This allowed control for front to back rendering or reversly depending of the special needs.
  38330. *
  38331. * @param renderingGroupId The rendering group id corresponding to its index
  38332. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38333. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38334. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38335. */
  38336. 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;
  38337. /**
  38338. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38339. *
  38340. * @param renderingGroupId The rendering group id corresponding to its index
  38341. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38342. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38343. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38344. */
  38345. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38346. /**
  38347. * Gets the current auto clear configuration for one rendering group of the rendering
  38348. * manager.
  38349. * @param index the rendering group index to get the information for
  38350. * @returns The auto clear setup for the requested rendering group
  38351. */
  38352. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38353. private _blockMaterialDirtyMechanism;
  38354. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38355. get blockMaterialDirtyMechanism(): boolean;
  38356. set blockMaterialDirtyMechanism(value: boolean);
  38357. /**
  38358. * Will flag all materials as dirty to trigger new shader compilation
  38359. * @param flag defines the flag used to specify which material part must be marked as dirty
  38360. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38361. */
  38362. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38363. /** @hidden */
  38364. _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;
  38365. /** @hidden */
  38366. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38367. /** @hidden */
  38368. _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;
  38369. /** @hidden */
  38370. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38371. /** @hidden */
  38372. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38373. /** @hidden */
  38374. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38375. }
  38376. }
  38377. declare module "babylonjs/assetContainer" {
  38378. import { AbstractScene } from "babylonjs/abstractScene";
  38379. import { Scene } from "babylonjs/scene";
  38380. import { Mesh } from "babylonjs/Meshes/mesh";
  38381. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38382. import { Skeleton } from "babylonjs/Bones/skeleton";
  38383. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38384. import { Animatable } from "babylonjs/Animations/animatable";
  38385. import { Nullable } from "babylonjs/types";
  38386. import { Node } from "babylonjs/node";
  38387. /**
  38388. * Set of assets to keep when moving a scene into an asset container.
  38389. */
  38390. export class KeepAssets extends AbstractScene {
  38391. }
  38392. /**
  38393. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38394. */
  38395. export class InstantiatedEntries {
  38396. /**
  38397. * List of new root nodes (eg. nodes with no parent)
  38398. */
  38399. rootNodes: TransformNode[];
  38400. /**
  38401. * List of new skeletons
  38402. */
  38403. skeletons: Skeleton[];
  38404. /**
  38405. * List of new animation groups
  38406. */
  38407. animationGroups: AnimationGroup[];
  38408. }
  38409. /**
  38410. * Container with a set of assets that can be added or removed from a scene.
  38411. */
  38412. export class AssetContainer extends AbstractScene {
  38413. private _wasAddedToScene;
  38414. /**
  38415. * The scene the AssetContainer belongs to.
  38416. */
  38417. scene: Scene;
  38418. /**
  38419. * Instantiates an AssetContainer.
  38420. * @param scene The scene the AssetContainer belongs to.
  38421. */
  38422. constructor(scene: Scene);
  38423. /**
  38424. * Instantiate or clone all meshes and add the new ones to the scene.
  38425. * Skeletons and animation groups will all be cloned
  38426. * @param nameFunction defines an optional function used to get new names for clones
  38427. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38428. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38429. */
  38430. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38431. /**
  38432. * Adds all the assets from the container to the scene.
  38433. */
  38434. addAllToScene(): void;
  38435. /**
  38436. * Removes all the assets in the container from the scene
  38437. */
  38438. removeAllFromScene(): void;
  38439. /**
  38440. * Disposes all the assets in the container
  38441. */
  38442. dispose(): void;
  38443. private _moveAssets;
  38444. /**
  38445. * Removes all the assets contained in the scene and adds them to the container.
  38446. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38447. */
  38448. moveAllFromScene(keepAssets?: KeepAssets): void;
  38449. /**
  38450. * 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.
  38451. * @returns the root mesh
  38452. */
  38453. createRootMesh(): Mesh;
  38454. /**
  38455. * Merge animations from this asset container into a scene
  38456. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38457. * @param animatables set of animatables to retarget to a node from the scene
  38458. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38459. */
  38460. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38461. }
  38462. }
  38463. declare module "babylonjs/abstractScene" {
  38464. import { Scene } from "babylonjs/scene";
  38465. import { Nullable } from "babylonjs/types";
  38466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38467. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38468. import { Geometry } from "babylonjs/Meshes/geometry";
  38469. import { Skeleton } from "babylonjs/Bones/skeleton";
  38470. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38471. import { AssetContainer } from "babylonjs/assetContainer";
  38472. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38473. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38475. import { Material } from "babylonjs/Materials/material";
  38476. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38477. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38478. import { Camera } from "babylonjs/Cameras/camera";
  38479. import { Light } from "babylonjs/Lights/light";
  38480. import { Node } from "babylonjs/node";
  38481. import { Animation } from "babylonjs/Animations/animation";
  38482. /**
  38483. * Defines how the parser contract is defined.
  38484. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38485. */
  38486. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38487. /**
  38488. * Defines how the individual parser contract is defined.
  38489. * These parser can parse an individual asset
  38490. */
  38491. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38492. /**
  38493. * Base class of the scene acting as a container for the different elements composing a scene.
  38494. * This class is dynamically extended by the different components of the scene increasing
  38495. * flexibility and reducing coupling
  38496. */
  38497. export abstract class AbstractScene {
  38498. /**
  38499. * Stores the list of available parsers in the application.
  38500. */
  38501. private static _BabylonFileParsers;
  38502. /**
  38503. * Stores the list of available individual parsers in the application.
  38504. */
  38505. private static _IndividualBabylonFileParsers;
  38506. /**
  38507. * Adds a parser in the list of available ones
  38508. * @param name Defines the name of the parser
  38509. * @param parser Defines the parser to add
  38510. */
  38511. static AddParser(name: string, parser: BabylonFileParser): void;
  38512. /**
  38513. * Gets a general parser from the list of avaialble ones
  38514. * @param name Defines the name of the parser
  38515. * @returns the requested parser or null
  38516. */
  38517. static GetParser(name: string): Nullable<BabylonFileParser>;
  38518. /**
  38519. * Adds n individual parser in the list of available ones
  38520. * @param name Defines the name of the parser
  38521. * @param parser Defines the parser to add
  38522. */
  38523. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38524. /**
  38525. * Gets an individual parser from the list of avaialble ones
  38526. * @param name Defines the name of the parser
  38527. * @returns the requested parser or null
  38528. */
  38529. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38530. /**
  38531. * Parser json data and populate both a scene and its associated container object
  38532. * @param jsonData Defines the data to parse
  38533. * @param scene Defines the scene to parse the data for
  38534. * @param container Defines the container attached to the parsing sequence
  38535. * @param rootUrl Defines the root url of the data
  38536. */
  38537. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38538. /**
  38539. * Gets the list of root nodes (ie. nodes with no parent)
  38540. */
  38541. rootNodes: Node[];
  38542. /** All of the cameras added to this scene
  38543. * @see http://doc.babylonjs.com/babylon101/cameras
  38544. */
  38545. cameras: Camera[];
  38546. /**
  38547. * All of the lights added to this scene
  38548. * @see http://doc.babylonjs.com/babylon101/lights
  38549. */
  38550. lights: Light[];
  38551. /**
  38552. * All of the (abstract) meshes added to this scene
  38553. */
  38554. meshes: AbstractMesh[];
  38555. /**
  38556. * The list of skeletons added to the scene
  38557. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38558. */
  38559. skeletons: Skeleton[];
  38560. /**
  38561. * All of the particle systems added to this scene
  38562. * @see http://doc.babylonjs.com/babylon101/particles
  38563. */
  38564. particleSystems: IParticleSystem[];
  38565. /**
  38566. * Gets a list of Animations associated with the scene
  38567. */
  38568. animations: Animation[];
  38569. /**
  38570. * All of the animation groups added to this scene
  38571. * @see http://doc.babylonjs.com/how_to/group
  38572. */
  38573. animationGroups: AnimationGroup[];
  38574. /**
  38575. * All of the multi-materials added to this scene
  38576. * @see http://doc.babylonjs.com/how_to/multi_materials
  38577. */
  38578. multiMaterials: MultiMaterial[];
  38579. /**
  38580. * All of the materials added to this scene
  38581. * In the context of a Scene, it is not supposed to be modified manually.
  38582. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38583. * Note also that the order of the Material within the array is not significant and might change.
  38584. * @see http://doc.babylonjs.com/babylon101/materials
  38585. */
  38586. materials: Material[];
  38587. /**
  38588. * The list of morph target managers added to the scene
  38589. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38590. */
  38591. morphTargetManagers: MorphTargetManager[];
  38592. /**
  38593. * The list of geometries used in the scene.
  38594. */
  38595. geometries: Geometry[];
  38596. /**
  38597. * All of the tranform nodes added to this scene
  38598. * In the context of a Scene, it is not supposed to be modified manually.
  38599. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38600. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38601. * @see http://doc.babylonjs.com/how_to/transformnode
  38602. */
  38603. transformNodes: TransformNode[];
  38604. /**
  38605. * ActionManagers available on the scene.
  38606. */
  38607. actionManagers: AbstractActionManager[];
  38608. /**
  38609. * Textures to keep.
  38610. */
  38611. textures: BaseTexture[];
  38612. /**
  38613. * Environment texture for the scene
  38614. */
  38615. environmentTexture: Nullable<BaseTexture>;
  38616. /**
  38617. * @returns all meshes, lights, cameras, transformNodes and bones
  38618. */
  38619. getNodes(): Array<Node>;
  38620. }
  38621. }
  38622. declare module "babylonjs/Audio/sound" {
  38623. import { Observable } from "babylonjs/Misc/observable";
  38624. import { Vector3 } from "babylonjs/Maths/math.vector";
  38625. import { Nullable } from "babylonjs/types";
  38626. import { Scene } from "babylonjs/scene";
  38627. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38628. /**
  38629. * Interface used to define options for Sound class
  38630. */
  38631. export interface ISoundOptions {
  38632. /**
  38633. * Does the sound autoplay once loaded.
  38634. */
  38635. autoplay?: boolean;
  38636. /**
  38637. * Does the sound loop after it finishes playing once.
  38638. */
  38639. loop?: boolean;
  38640. /**
  38641. * Sound's volume
  38642. */
  38643. volume?: number;
  38644. /**
  38645. * Is it a spatial sound?
  38646. */
  38647. spatialSound?: boolean;
  38648. /**
  38649. * Maximum distance to hear that sound
  38650. */
  38651. maxDistance?: number;
  38652. /**
  38653. * Uses user defined attenuation function
  38654. */
  38655. useCustomAttenuation?: boolean;
  38656. /**
  38657. * Define the roll off factor of spatial sounds.
  38658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38659. */
  38660. rolloffFactor?: number;
  38661. /**
  38662. * Define the reference distance the sound should be heard perfectly.
  38663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38664. */
  38665. refDistance?: number;
  38666. /**
  38667. * Define the distance attenuation model the sound will follow.
  38668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38669. */
  38670. distanceModel?: string;
  38671. /**
  38672. * Defines the playback speed (1 by default)
  38673. */
  38674. playbackRate?: number;
  38675. /**
  38676. * Defines if the sound is from a streaming source
  38677. */
  38678. streaming?: boolean;
  38679. /**
  38680. * Defines an optional length (in seconds) inside the sound file
  38681. */
  38682. length?: number;
  38683. /**
  38684. * Defines an optional offset (in seconds) inside the sound file
  38685. */
  38686. offset?: number;
  38687. /**
  38688. * If true, URLs will not be required to state the audio file codec to use.
  38689. */
  38690. skipCodecCheck?: boolean;
  38691. }
  38692. /**
  38693. * Defines a sound that can be played in the application.
  38694. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38696. */
  38697. export class Sound {
  38698. /**
  38699. * The name of the sound in the scene.
  38700. */
  38701. name: string;
  38702. /**
  38703. * Does the sound autoplay once loaded.
  38704. */
  38705. autoplay: boolean;
  38706. /**
  38707. * Does the sound loop after it finishes playing once.
  38708. */
  38709. loop: boolean;
  38710. /**
  38711. * Does the sound use a custom attenuation curve to simulate the falloff
  38712. * happening when the source gets further away from the camera.
  38713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38714. */
  38715. useCustomAttenuation: boolean;
  38716. /**
  38717. * The sound track id this sound belongs to.
  38718. */
  38719. soundTrackId: number;
  38720. /**
  38721. * Is this sound currently played.
  38722. */
  38723. isPlaying: boolean;
  38724. /**
  38725. * Is this sound currently paused.
  38726. */
  38727. isPaused: boolean;
  38728. /**
  38729. * Does this sound enables spatial sound.
  38730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38731. */
  38732. spatialSound: boolean;
  38733. /**
  38734. * Define the reference distance the sound should be heard perfectly.
  38735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38736. */
  38737. refDistance: number;
  38738. /**
  38739. * Define the roll off factor of spatial sounds.
  38740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38741. */
  38742. rolloffFactor: number;
  38743. /**
  38744. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38746. */
  38747. maxDistance: number;
  38748. /**
  38749. * Define the distance attenuation model the sound will follow.
  38750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38751. */
  38752. distanceModel: string;
  38753. /**
  38754. * @hidden
  38755. * Back Compat
  38756. **/
  38757. onended: () => any;
  38758. /**
  38759. * Observable event when the current playing sound finishes.
  38760. */
  38761. onEndedObservable: Observable<Sound>;
  38762. private _panningModel;
  38763. private _playbackRate;
  38764. private _streaming;
  38765. private _startTime;
  38766. private _startOffset;
  38767. private _position;
  38768. /** @hidden */
  38769. _positionInEmitterSpace: boolean;
  38770. private _localDirection;
  38771. private _volume;
  38772. private _isReadyToPlay;
  38773. private _isDirectional;
  38774. private _readyToPlayCallback;
  38775. private _audioBuffer;
  38776. private _soundSource;
  38777. private _streamingSource;
  38778. private _soundPanner;
  38779. private _soundGain;
  38780. private _inputAudioNode;
  38781. private _outputAudioNode;
  38782. private _coneInnerAngle;
  38783. private _coneOuterAngle;
  38784. private _coneOuterGain;
  38785. private _scene;
  38786. private _connectedTransformNode;
  38787. private _customAttenuationFunction;
  38788. private _registerFunc;
  38789. private _isOutputConnected;
  38790. private _htmlAudioElement;
  38791. private _urlType;
  38792. private _length?;
  38793. private _offset?;
  38794. /** @hidden */
  38795. static _SceneComponentInitialization: (scene: Scene) => void;
  38796. /**
  38797. * Create a sound and attach it to a scene
  38798. * @param name Name of your sound
  38799. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38800. * @param scene defines the scene the sound belongs to
  38801. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38802. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38803. */
  38804. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38805. /**
  38806. * Release the sound and its associated resources
  38807. */
  38808. dispose(): void;
  38809. /**
  38810. * Gets if the sounds is ready to be played or not.
  38811. * @returns true if ready, otherwise false
  38812. */
  38813. isReady(): boolean;
  38814. private _soundLoaded;
  38815. /**
  38816. * Sets the data of the sound from an audiobuffer
  38817. * @param audioBuffer The audioBuffer containing the data
  38818. */
  38819. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38820. /**
  38821. * Updates the current sounds options such as maxdistance, loop...
  38822. * @param options A JSON object containing values named as the object properties
  38823. */
  38824. updateOptions(options: ISoundOptions): void;
  38825. private _createSpatialParameters;
  38826. private _updateSpatialParameters;
  38827. /**
  38828. * Switch the panning model to HRTF:
  38829. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38831. */
  38832. switchPanningModelToHRTF(): void;
  38833. /**
  38834. * Switch the panning model to Equal Power:
  38835. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38837. */
  38838. switchPanningModelToEqualPower(): void;
  38839. private _switchPanningModel;
  38840. /**
  38841. * Connect this sound to a sound track audio node like gain...
  38842. * @param soundTrackAudioNode the sound track audio node to connect to
  38843. */
  38844. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38845. /**
  38846. * Transform this sound into a directional source
  38847. * @param coneInnerAngle Size of the inner cone in degree
  38848. * @param coneOuterAngle Size of the outer cone in degree
  38849. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38850. */
  38851. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38852. /**
  38853. * Gets or sets the inner angle for the directional cone.
  38854. */
  38855. get directionalConeInnerAngle(): number;
  38856. /**
  38857. * Gets or sets the inner angle for the directional cone.
  38858. */
  38859. set directionalConeInnerAngle(value: number);
  38860. /**
  38861. * Gets or sets the outer angle for the directional cone.
  38862. */
  38863. get directionalConeOuterAngle(): number;
  38864. /**
  38865. * Gets or sets the outer angle for the directional cone.
  38866. */
  38867. set directionalConeOuterAngle(value: number);
  38868. /**
  38869. * Sets the position of the emitter if spatial sound is enabled
  38870. * @param newPosition Defines the new posisiton
  38871. */
  38872. setPosition(newPosition: Vector3): void;
  38873. /**
  38874. * Sets the local direction of the emitter if spatial sound is enabled
  38875. * @param newLocalDirection Defines the new local direction
  38876. */
  38877. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38878. private _updateDirection;
  38879. /** @hidden */
  38880. updateDistanceFromListener(): void;
  38881. /**
  38882. * Sets a new custom attenuation function for the sound.
  38883. * @param callback Defines the function used for the attenuation
  38884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38885. */
  38886. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38887. /**
  38888. * Play the sound
  38889. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38890. * @param offset (optional) Start the sound at a specific time in seconds
  38891. * @param length (optional) Sound duration (in seconds)
  38892. */
  38893. play(time?: number, offset?: number, length?: number): void;
  38894. private _onended;
  38895. /**
  38896. * Stop the sound
  38897. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38898. */
  38899. stop(time?: number): void;
  38900. /**
  38901. * Put the sound in pause
  38902. */
  38903. pause(): void;
  38904. /**
  38905. * Sets a dedicated volume for this sounds
  38906. * @param newVolume Define the new volume of the sound
  38907. * @param time Define time for gradual change to new volume
  38908. */
  38909. setVolume(newVolume: number, time?: number): void;
  38910. /**
  38911. * Set the sound play back rate
  38912. * @param newPlaybackRate Define the playback rate the sound should be played at
  38913. */
  38914. setPlaybackRate(newPlaybackRate: number): void;
  38915. /**
  38916. * Gets the volume of the sound.
  38917. * @returns the volume of the sound
  38918. */
  38919. getVolume(): number;
  38920. /**
  38921. * Attach the sound to a dedicated mesh
  38922. * @param transformNode The transform node to connect the sound with
  38923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38924. */
  38925. attachToMesh(transformNode: TransformNode): void;
  38926. /**
  38927. * Detach the sound from the previously attached mesh
  38928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38929. */
  38930. detachFromMesh(): void;
  38931. private _onRegisterAfterWorldMatrixUpdate;
  38932. /**
  38933. * Clone the current sound in the scene.
  38934. * @returns the new sound clone
  38935. */
  38936. clone(): Nullable<Sound>;
  38937. /**
  38938. * Gets the current underlying audio buffer containing the data
  38939. * @returns the audio buffer
  38940. */
  38941. getAudioBuffer(): Nullable<AudioBuffer>;
  38942. /**
  38943. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38944. * @returns the source node
  38945. */
  38946. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38947. /**
  38948. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38949. * @returns the gain node
  38950. */
  38951. getSoundGain(): Nullable<GainNode>;
  38952. /**
  38953. * Serializes the Sound in a JSON representation
  38954. * @returns the JSON representation of the sound
  38955. */
  38956. serialize(): any;
  38957. /**
  38958. * Parse a JSON representation of a sound to innstantiate in a given scene
  38959. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38960. * @param scene Define the scene the new parsed sound should be created in
  38961. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38962. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38963. * @returns the newly parsed sound
  38964. */
  38965. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38966. }
  38967. }
  38968. declare module "babylonjs/Actions/directAudioActions" {
  38969. import { Action } from "babylonjs/Actions/action";
  38970. import { Condition } from "babylonjs/Actions/condition";
  38971. import { Sound } from "babylonjs/Audio/sound";
  38972. /**
  38973. * This defines an action helpful to play a defined sound on a triggered action.
  38974. */
  38975. export class PlaySoundAction extends Action {
  38976. private _sound;
  38977. /**
  38978. * Instantiate the action
  38979. * @param triggerOptions defines the trigger options
  38980. * @param sound defines the sound to play
  38981. * @param condition defines the trigger related conditions
  38982. */
  38983. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38984. /** @hidden */
  38985. _prepare(): void;
  38986. /**
  38987. * Execute the action and play the sound.
  38988. */
  38989. execute(): void;
  38990. /**
  38991. * Serializes the actions and its related information.
  38992. * @param parent defines the object to serialize in
  38993. * @returns the serialized object
  38994. */
  38995. serialize(parent: any): any;
  38996. }
  38997. /**
  38998. * This defines an action helpful to stop a defined sound on a triggered action.
  38999. */
  39000. export class StopSoundAction extends Action {
  39001. private _sound;
  39002. /**
  39003. * Instantiate the action
  39004. * @param triggerOptions defines the trigger options
  39005. * @param sound defines the sound to stop
  39006. * @param condition defines the trigger related conditions
  39007. */
  39008. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39009. /** @hidden */
  39010. _prepare(): void;
  39011. /**
  39012. * Execute the action and stop the sound.
  39013. */
  39014. execute(): void;
  39015. /**
  39016. * Serializes the actions and its related information.
  39017. * @param parent defines the object to serialize in
  39018. * @returns the serialized object
  39019. */
  39020. serialize(parent: any): any;
  39021. }
  39022. }
  39023. declare module "babylonjs/Actions/interpolateValueAction" {
  39024. import { Action } from "babylonjs/Actions/action";
  39025. import { Condition } from "babylonjs/Actions/condition";
  39026. import { Observable } from "babylonjs/Misc/observable";
  39027. /**
  39028. * This defines an action responsible to change the value of a property
  39029. * by interpolating between its current value and the newly set one once triggered.
  39030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39031. */
  39032. export class InterpolateValueAction extends Action {
  39033. /**
  39034. * Defines the path of the property where the value should be interpolated
  39035. */
  39036. propertyPath: string;
  39037. /**
  39038. * Defines the target value at the end of the interpolation.
  39039. */
  39040. value: any;
  39041. /**
  39042. * Defines the time it will take for the property to interpolate to the value.
  39043. */
  39044. duration: number;
  39045. /**
  39046. * Defines if the other scene animations should be stopped when the action has been triggered
  39047. */
  39048. stopOtherAnimations?: boolean;
  39049. /**
  39050. * Defines a callback raised once the interpolation animation has been done.
  39051. */
  39052. onInterpolationDone?: () => void;
  39053. /**
  39054. * Observable triggered once the interpolation animation has been done.
  39055. */
  39056. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39057. private _target;
  39058. private _effectiveTarget;
  39059. private _property;
  39060. /**
  39061. * Instantiate the action
  39062. * @param triggerOptions defines the trigger options
  39063. * @param target defines the object containing the value to interpolate
  39064. * @param propertyPath defines the path to the property in the target object
  39065. * @param value defines the target value at the end of the interpolation
  39066. * @param duration deines the time it will take for the property to interpolate to the value.
  39067. * @param condition defines the trigger related conditions
  39068. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39069. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39070. */
  39071. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39072. /** @hidden */
  39073. _prepare(): void;
  39074. /**
  39075. * Execute the action starts the value interpolation.
  39076. */
  39077. execute(): void;
  39078. /**
  39079. * Serializes the actions and its related information.
  39080. * @param parent defines the object to serialize in
  39081. * @returns the serialized object
  39082. */
  39083. serialize(parent: any): any;
  39084. }
  39085. }
  39086. declare module "babylonjs/Actions/index" {
  39087. export * from "babylonjs/Actions/abstractActionManager";
  39088. export * from "babylonjs/Actions/action";
  39089. export * from "babylonjs/Actions/actionEvent";
  39090. export * from "babylonjs/Actions/actionManager";
  39091. export * from "babylonjs/Actions/condition";
  39092. export * from "babylonjs/Actions/directActions";
  39093. export * from "babylonjs/Actions/directAudioActions";
  39094. export * from "babylonjs/Actions/interpolateValueAction";
  39095. }
  39096. declare module "babylonjs/Animations/index" {
  39097. export * from "babylonjs/Animations/animatable";
  39098. export * from "babylonjs/Animations/animation";
  39099. export * from "babylonjs/Animations/animationGroup";
  39100. export * from "babylonjs/Animations/animationPropertiesOverride";
  39101. export * from "babylonjs/Animations/easing";
  39102. export * from "babylonjs/Animations/runtimeAnimation";
  39103. export * from "babylonjs/Animations/animationEvent";
  39104. export * from "babylonjs/Animations/animationGroup";
  39105. export * from "babylonjs/Animations/animationKey";
  39106. export * from "babylonjs/Animations/animationRange";
  39107. export * from "babylonjs/Animations/animatable.interface";
  39108. }
  39109. declare module "babylonjs/Audio/soundTrack" {
  39110. import { Sound } from "babylonjs/Audio/sound";
  39111. import { Analyser } from "babylonjs/Audio/analyser";
  39112. import { Scene } from "babylonjs/scene";
  39113. /**
  39114. * Options allowed during the creation of a sound track.
  39115. */
  39116. export interface ISoundTrackOptions {
  39117. /**
  39118. * The volume the sound track should take during creation
  39119. */
  39120. volume?: number;
  39121. /**
  39122. * Define if the sound track is the main sound track of the scene
  39123. */
  39124. mainTrack?: boolean;
  39125. }
  39126. /**
  39127. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39128. * It will be also used in a future release to apply effects on a specific track.
  39129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39130. */
  39131. export class SoundTrack {
  39132. /**
  39133. * The unique identifier of the sound track in the scene.
  39134. */
  39135. id: number;
  39136. /**
  39137. * The list of sounds included in the sound track.
  39138. */
  39139. soundCollection: Array<Sound>;
  39140. private _outputAudioNode;
  39141. private _scene;
  39142. private _connectedAnalyser;
  39143. private _options;
  39144. private _isInitialized;
  39145. /**
  39146. * Creates a new sound track.
  39147. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39148. * @param scene Define the scene the sound track belongs to
  39149. * @param options
  39150. */
  39151. constructor(scene: Scene, options?: ISoundTrackOptions);
  39152. private _initializeSoundTrackAudioGraph;
  39153. /**
  39154. * Release the sound track and its associated resources
  39155. */
  39156. dispose(): void;
  39157. /**
  39158. * Adds a sound to this sound track
  39159. * @param sound define the cound to add
  39160. * @ignoreNaming
  39161. */
  39162. AddSound(sound: Sound): void;
  39163. /**
  39164. * Removes a sound to this sound track
  39165. * @param sound define the cound to remove
  39166. * @ignoreNaming
  39167. */
  39168. RemoveSound(sound: Sound): void;
  39169. /**
  39170. * Set a global volume for the full sound track.
  39171. * @param newVolume Define the new volume of the sound track
  39172. */
  39173. setVolume(newVolume: number): void;
  39174. /**
  39175. * Switch the panning model to HRTF:
  39176. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39178. */
  39179. switchPanningModelToHRTF(): void;
  39180. /**
  39181. * Switch the panning model to Equal Power:
  39182. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39183. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39184. */
  39185. switchPanningModelToEqualPower(): void;
  39186. /**
  39187. * Connect the sound track to an audio analyser allowing some amazing
  39188. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39190. * @param analyser The analyser to connect to the engine
  39191. */
  39192. connectToAnalyser(analyser: Analyser): void;
  39193. }
  39194. }
  39195. declare module "babylonjs/Audio/audioSceneComponent" {
  39196. import { Sound } from "babylonjs/Audio/sound";
  39197. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39198. import { Nullable } from "babylonjs/types";
  39199. import { Vector3 } from "babylonjs/Maths/math.vector";
  39200. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39201. import { Scene } from "babylonjs/scene";
  39202. import { AbstractScene } from "babylonjs/abstractScene";
  39203. import "babylonjs/Audio/audioEngine";
  39204. module "babylonjs/abstractScene" {
  39205. interface AbstractScene {
  39206. /**
  39207. * The list of sounds used in the scene.
  39208. */
  39209. sounds: Nullable<Array<Sound>>;
  39210. }
  39211. }
  39212. module "babylonjs/scene" {
  39213. interface Scene {
  39214. /**
  39215. * @hidden
  39216. * Backing field
  39217. */
  39218. _mainSoundTrack: SoundTrack;
  39219. /**
  39220. * The main sound track played by the scene.
  39221. * It cotains your primary collection of sounds.
  39222. */
  39223. mainSoundTrack: SoundTrack;
  39224. /**
  39225. * The list of sound tracks added to the scene
  39226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39227. */
  39228. soundTracks: Nullable<Array<SoundTrack>>;
  39229. /**
  39230. * Gets a sound using a given name
  39231. * @param name defines the name to search for
  39232. * @return the found sound or null if not found at all.
  39233. */
  39234. getSoundByName(name: string): Nullable<Sound>;
  39235. /**
  39236. * Gets or sets if audio support is enabled
  39237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39238. */
  39239. audioEnabled: boolean;
  39240. /**
  39241. * Gets or sets if audio will be output to headphones
  39242. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39243. */
  39244. headphone: boolean;
  39245. /**
  39246. * Gets or sets custom audio listener position provider
  39247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39248. */
  39249. audioListenerPositionProvider: Nullable<() => Vector3>;
  39250. /**
  39251. * Gets or sets a refresh rate when using 3D audio positioning
  39252. */
  39253. audioPositioningRefreshRate: number;
  39254. }
  39255. }
  39256. /**
  39257. * Defines the sound scene component responsible to manage any sounds
  39258. * in a given scene.
  39259. */
  39260. export class AudioSceneComponent implements ISceneSerializableComponent {
  39261. /**
  39262. * The component name helpfull to identify the component in the list of scene components.
  39263. */
  39264. readonly name: string;
  39265. /**
  39266. * The scene the component belongs to.
  39267. */
  39268. scene: Scene;
  39269. private _audioEnabled;
  39270. /**
  39271. * Gets whether audio is enabled or not.
  39272. * Please use related enable/disable method to switch state.
  39273. */
  39274. get audioEnabled(): boolean;
  39275. private _headphone;
  39276. /**
  39277. * Gets whether audio is outputing to headphone or not.
  39278. * Please use the according Switch methods to change output.
  39279. */
  39280. get headphone(): boolean;
  39281. /**
  39282. * Gets or sets a refresh rate when using 3D audio positioning
  39283. */
  39284. audioPositioningRefreshRate: number;
  39285. private _audioListenerPositionProvider;
  39286. /**
  39287. * Gets the current audio listener position provider
  39288. */
  39289. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39290. /**
  39291. * Sets a custom listener position for all sounds in the scene
  39292. * By default, this is the position of the first active camera
  39293. */
  39294. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39295. /**
  39296. * Creates a new instance of the component for the given scene
  39297. * @param scene Defines the scene to register the component in
  39298. */
  39299. constructor(scene: Scene);
  39300. /**
  39301. * Registers the component in a given scene
  39302. */
  39303. register(): void;
  39304. /**
  39305. * Rebuilds the elements related to this component in case of
  39306. * context lost for instance.
  39307. */
  39308. rebuild(): void;
  39309. /**
  39310. * Serializes the component data to the specified json object
  39311. * @param serializationObject The object to serialize to
  39312. */
  39313. serialize(serializationObject: any): void;
  39314. /**
  39315. * Adds all the elements from the container to the scene
  39316. * @param container the container holding the elements
  39317. */
  39318. addFromContainer(container: AbstractScene): void;
  39319. /**
  39320. * Removes all the elements in the container from the scene
  39321. * @param container contains the elements to remove
  39322. * @param dispose if the removed element should be disposed (default: false)
  39323. */
  39324. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39325. /**
  39326. * Disposes the component and the associated ressources.
  39327. */
  39328. dispose(): void;
  39329. /**
  39330. * Disables audio in the associated scene.
  39331. */
  39332. disableAudio(): void;
  39333. /**
  39334. * Enables audio in the associated scene.
  39335. */
  39336. enableAudio(): void;
  39337. /**
  39338. * Switch audio to headphone output.
  39339. */
  39340. switchAudioModeForHeadphones(): void;
  39341. /**
  39342. * Switch audio to normal speakers.
  39343. */
  39344. switchAudioModeForNormalSpeakers(): void;
  39345. private _cachedCameraDirection;
  39346. private _cachedCameraPosition;
  39347. private _lastCheck;
  39348. private _afterRender;
  39349. }
  39350. }
  39351. declare module "babylonjs/Audio/weightedsound" {
  39352. import { Sound } from "babylonjs/Audio/sound";
  39353. /**
  39354. * Wraps one or more Sound objects and selects one with random weight for playback.
  39355. */
  39356. export class WeightedSound {
  39357. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39358. loop: boolean;
  39359. private _coneInnerAngle;
  39360. private _coneOuterAngle;
  39361. private _volume;
  39362. /** A Sound is currently playing. */
  39363. isPlaying: boolean;
  39364. /** A Sound is currently paused. */
  39365. isPaused: boolean;
  39366. private _sounds;
  39367. private _weights;
  39368. private _currentIndex?;
  39369. /**
  39370. * Creates a new WeightedSound from the list of sounds given.
  39371. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39372. * @param sounds Array of Sounds that will be selected from.
  39373. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39374. */
  39375. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39376. /**
  39377. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39378. */
  39379. get directionalConeInnerAngle(): number;
  39380. /**
  39381. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39382. */
  39383. set directionalConeInnerAngle(value: number);
  39384. /**
  39385. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39386. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39387. */
  39388. get directionalConeOuterAngle(): number;
  39389. /**
  39390. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39391. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39392. */
  39393. set directionalConeOuterAngle(value: number);
  39394. /**
  39395. * Playback volume.
  39396. */
  39397. get volume(): number;
  39398. /**
  39399. * Playback volume.
  39400. */
  39401. set volume(value: number);
  39402. private _onended;
  39403. /**
  39404. * Suspend playback
  39405. */
  39406. pause(): void;
  39407. /**
  39408. * Stop playback
  39409. */
  39410. stop(): void;
  39411. /**
  39412. * Start playback.
  39413. * @param startOffset Position the clip head at a specific time in seconds.
  39414. */
  39415. play(startOffset?: number): void;
  39416. }
  39417. }
  39418. declare module "babylonjs/Audio/index" {
  39419. export * from "babylonjs/Audio/analyser";
  39420. export * from "babylonjs/Audio/audioEngine";
  39421. export * from "babylonjs/Audio/audioSceneComponent";
  39422. export * from "babylonjs/Audio/sound";
  39423. export * from "babylonjs/Audio/soundTrack";
  39424. export * from "babylonjs/Audio/weightedsound";
  39425. }
  39426. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39427. import { Behavior } from "babylonjs/Behaviors/behavior";
  39428. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39429. import { BackEase } from "babylonjs/Animations/easing";
  39430. /**
  39431. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39432. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39433. */
  39434. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39435. /**
  39436. * Gets the name of the behavior.
  39437. */
  39438. get name(): string;
  39439. /**
  39440. * The easing function used by animations
  39441. */
  39442. static EasingFunction: BackEase;
  39443. /**
  39444. * The easing mode used by animations
  39445. */
  39446. static EasingMode: number;
  39447. /**
  39448. * The duration of the animation, in milliseconds
  39449. */
  39450. transitionDuration: number;
  39451. /**
  39452. * Length of the distance animated by the transition when lower radius is reached
  39453. */
  39454. lowerRadiusTransitionRange: number;
  39455. /**
  39456. * Length of the distance animated by the transition when upper radius is reached
  39457. */
  39458. upperRadiusTransitionRange: number;
  39459. private _autoTransitionRange;
  39460. /**
  39461. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39462. */
  39463. get autoTransitionRange(): boolean;
  39464. /**
  39465. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39466. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39467. */
  39468. set autoTransitionRange(value: boolean);
  39469. private _attachedCamera;
  39470. private _onAfterCheckInputsObserver;
  39471. private _onMeshTargetChangedObserver;
  39472. /**
  39473. * Initializes the behavior.
  39474. */
  39475. init(): void;
  39476. /**
  39477. * Attaches the behavior to its arc rotate camera.
  39478. * @param camera Defines the camera to attach the behavior to
  39479. */
  39480. attach(camera: ArcRotateCamera): void;
  39481. /**
  39482. * Detaches the behavior from its current arc rotate camera.
  39483. */
  39484. detach(): void;
  39485. private _radiusIsAnimating;
  39486. private _radiusBounceTransition;
  39487. private _animatables;
  39488. private _cachedWheelPrecision;
  39489. /**
  39490. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39491. * @param radiusLimit The limit to check against.
  39492. * @return Bool to indicate if at limit.
  39493. */
  39494. private _isRadiusAtLimit;
  39495. /**
  39496. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39497. * @param radiusDelta The delta by which to animate to. Can be negative.
  39498. */
  39499. private _applyBoundRadiusAnimation;
  39500. /**
  39501. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39502. */
  39503. protected _clearAnimationLocks(): void;
  39504. /**
  39505. * Stops and removes all animations that have been applied to the camera
  39506. */
  39507. stopAllAnimations(): void;
  39508. }
  39509. }
  39510. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39511. import { Behavior } from "babylonjs/Behaviors/behavior";
  39512. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39513. import { ExponentialEase } from "babylonjs/Animations/easing";
  39514. import { Nullable } from "babylonjs/types";
  39515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39516. import { Vector3 } from "babylonjs/Maths/math.vector";
  39517. /**
  39518. * 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.
  39519. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39520. */
  39521. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39522. /**
  39523. * Gets the name of the behavior.
  39524. */
  39525. get name(): string;
  39526. private _mode;
  39527. private _radiusScale;
  39528. private _positionScale;
  39529. private _defaultElevation;
  39530. private _elevationReturnTime;
  39531. private _elevationReturnWaitTime;
  39532. private _zoomStopsAnimation;
  39533. private _framingTime;
  39534. /**
  39535. * The easing function used by animations
  39536. */
  39537. static EasingFunction: ExponentialEase;
  39538. /**
  39539. * The easing mode used by animations
  39540. */
  39541. static EasingMode: number;
  39542. /**
  39543. * Sets the current mode used by the behavior
  39544. */
  39545. set mode(mode: number);
  39546. /**
  39547. * Gets current mode used by the behavior.
  39548. */
  39549. get mode(): number;
  39550. /**
  39551. * Sets the scale applied to the radius (1 by default)
  39552. */
  39553. set radiusScale(radius: number);
  39554. /**
  39555. * Gets the scale applied to the radius
  39556. */
  39557. get radiusScale(): number;
  39558. /**
  39559. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39560. */
  39561. set positionScale(scale: number);
  39562. /**
  39563. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39564. */
  39565. get positionScale(): number;
  39566. /**
  39567. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39568. * behaviour is triggered, in radians.
  39569. */
  39570. set defaultElevation(elevation: number);
  39571. /**
  39572. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39573. * behaviour is triggered, in radians.
  39574. */
  39575. get defaultElevation(): number;
  39576. /**
  39577. * Sets the time (in milliseconds) taken to return to the default beta position.
  39578. * Negative value indicates camera should not return to default.
  39579. */
  39580. set elevationReturnTime(speed: number);
  39581. /**
  39582. * Gets the time (in milliseconds) taken to return to the default beta position.
  39583. * Negative value indicates camera should not return to default.
  39584. */
  39585. get elevationReturnTime(): number;
  39586. /**
  39587. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39588. */
  39589. set elevationReturnWaitTime(time: number);
  39590. /**
  39591. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39592. */
  39593. get elevationReturnWaitTime(): number;
  39594. /**
  39595. * Sets the flag that indicates if user zooming should stop animation.
  39596. */
  39597. set zoomStopsAnimation(flag: boolean);
  39598. /**
  39599. * Gets the flag that indicates if user zooming should stop animation.
  39600. */
  39601. get zoomStopsAnimation(): boolean;
  39602. /**
  39603. * Sets the transition time when framing the mesh, in milliseconds
  39604. */
  39605. set framingTime(time: number);
  39606. /**
  39607. * Gets the transition time when framing the mesh, in milliseconds
  39608. */
  39609. get framingTime(): number;
  39610. /**
  39611. * Define if the behavior should automatically change the configured
  39612. * camera limits and sensibilities.
  39613. */
  39614. autoCorrectCameraLimitsAndSensibility: boolean;
  39615. private _onPrePointerObservableObserver;
  39616. private _onAfterCheckInputsObserver;
  39617. private _onMeshTargetChangedObserver;
  39618. private _attachedCamera;
  39619. private _isPointerDown;
  39620. private _lastInteractionTime;
  39621. /**
  39622. * Initializes the behavior.
  39623. */
  39624. init(): void;
  39625. /**
  39626. * Attaches the behavior to its arc rotate camera.
  39627. * @param camera Defines the camera to attach the behavior to
  39628. */
  39629. attach(camera: ArcRotateCamera): void;
  39630. /**
  39631. * Detaches the behavior from its current arc rotate camera.
  39632. */
  39633. detach(): void;
  39634. private _animatables;
  39635. private _betaIsAnimating;
  39636. private _betaTransition;
  39637. private _radiusTransition;
  39638. private _vectorTransition;
  39639. /**
  39640. * Targets the given mesh and updates zoom level accordingly.
  39641. * @param mesh The mesh to target.
  39642. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39643. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39644. */
  39645. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39646. /**
  39647. * Targets the given mesh with its children and updates zoom level accordingly.
  39648. * @param mesh The mesh to target.
  39649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39651. */
  39652. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39653. /**
  39654. * Targets the given meshes with their children and updates zoom level accordingly.
  39655. * @param meshes The mesh to target.
  39656. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39657. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39658. */
  39659. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39660. /**
  39661. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39662. * @param minimumWorld Determines the smaller position of the bounding box extend
  39663. * @param maximumWorld Determines the bigger position of the bounding box extend
  39664. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39665. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39666. */
  39667. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39668. /**
  39669. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39670. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39671. * frustum width.
  39672. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39673. * to fully enclose the mesh in the viewing frustum.
  39674. */
  39675. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39676. /**
  39677. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39678. * is automatically returned to its default position (expected to be above ground plane).
  39679. */
  39680. private _maintainCameraAboveGround;
  39681. /**
  39682. * Returns the frustum slope based on the canvas ratio and camera FOV
  39683. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39684. */
  39685. private _getFrustumSlope;
  39686. /**
  39687. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39688. */
  39689. private _clearAnimationLocks;
  39690. /**
  39691. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39692. */
  39693. private _applyUserInteraction;
  39694. /**
  39695. * Stops and removes all animations that have been applied to the camera
  39696. */
  39697. stopAllAnimations(): void;
  39698. /**
  39699. * Gets a value indicating if the user is moving the camera
  39700. */
  39701. get isUserIsMoving(): boolean;
  39702. /**
  39703. * The camera can move all the way towards the mesh.
  39704. */
  39705. static IgnoreBoundsSizeMode: number;
  39706. /**
  39707. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39708. */
  39709. static FitFrustumSidesMode: number;
  39710. }
  39711. }
  39712. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39713. import { Nullable } from "babylonjs/types";
  39714. import { Camera } from "babylonjs/Cameras/camera";
  39715. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39716. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39717. /**
  39718. * Base class for Camera Pointer Inputs.
  39719. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39720. * for example usage.
  39721. */
  39722. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39723. /**
  39724. * Defines the camera the input is attached to.
  39725. */
  39726. abstract camera: Camera;
  39727. /**
  39728. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39729. */
  39730. protected _altKey: boolean;
  39731. protected _ctrlKey: boolean;
  39732. protected _metaKey: boolean;
  39733. protected _shiftKey: boolean;
  39734. /**
  39735. * Which mouse buttons were pressed at time of last mouse event.
  39736. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39737. */
  39738. protected _buttonsPressed: number;
  39739. /**
  39740. * Defines the buttons associated with the input to handle camera move.
  39741. */
  39742. buttons: number[];
  39743. /**
  39744. * Attach the input controls to a specific dom element to get the input from.
  39745. * @param element Defines the element the controls should be listened from
  39746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39747. */
  39748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39749. /**
  39750. * Detach the current controls from the specified dom element.
  39751. * @param element Defines the element to stop listening the inputs from
  39752. */
  39753. detachControl(element: Nullable<HTMLElement>): void;
  39754. /**
  39755. * Gets the class name of the current input.
  39756. * @returns the class name
  39757. */
  39758. getClassName(): string;
  39759. /**
  39760. * Get the friendly name associated with the input class.
  39761. * @returns the input friendly name
  39762. */
  39763. getSimpleName(): string;
  39764. /**
  39765. * Called on pointer POINTERDOUBLETAP event.
  39766. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39767. */
  39768. protected onDoubleTap(type: string): void;
  39769. /**
  39770. * Called on pointer POINTERMOVE event if only a single touch is active.
  39771. * Override this method to provide functionality.
  39772. */
  39773. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39774. /**
  39775. * Called on pointer POINTERMOVE event if multiple touches are active.
  39776. * Override this method to provide functionality.
  39777. */
  39778. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39779. /**
  39780. * Called on JS contextmenu event.
  39781. * Override this method to provide functionality.
  39782. */
  39783. protected onContextMenu(evt: PointerEvent): void;
  39784. /**
  39785. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39786. * press.
  39787. * Override this method to provide functionality.
  39788. */
  39789. protected onButtonDown(evt: PointerEvent): void;
  39790. /**
  39791. * Called each time a new POINTERUP event occurs. Ie, for each button
  39792. * release.
  39793. * Override this method to provide functionality.
  39794. */
  39795. protected onButtonUp(evt: PointerEvent): void;
  39796. /**
  39797. * Called when window becomes inactive.
  39798. * Override this method to provide functionality.
  39799. */
  39800. protected onLostFocus(): void;
  39801. private _pointerInput;
  39802. private _observer;
  39803. private _onLostFocus;
  39804. private pointA;
  39805. private pointB;
  39806. }
  39807. }
  39808. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39809. import { Nullable } from "babylonjs/types";
  39810. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39811. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39812. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39813. /**
  39814. * Manage the pointers inputs to control an arc rotate camera.
  39815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39816. */
  39817. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39818. /**
  39819. * Defines the camera the input is attached to.
  39820. */
  39821. camera: ArcRotateCamera;
  39822. /**
  39823. * Gets the class name of the current input.
  39824. * @returns the class name
  39825. */
  39826. getClassName(): string;
  39827. /**
  39828. * Defines the buttons associated with the input to handle camera move.
  39829. */
  39830. buttons: number[];
  39831. /**
  39832. * Defines the pointer angular sensibility along the X axis or how fast is
  39833. * the camera rotating.
  39834. */
  39835. angularSensibilityX: number;
  39836. /**
  39837. * Defines the pointer angular sensibility along the Y axis or how fast is
  39838. * the camera rotating.
  39839. */
  39840. angularSensibilityY: number;
  39841. /**
  39842. * Defines the pointer pinch precision or how fast is the camera zooming.
  39843. */
  39844. pinchPrecision: number;
  39845. /**
  39846. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39847. * from 0.
  39848. * It defines the percentage of current camera.radius to use as delta when
  39849. * pinch zoom is used.
  39850. */
  39851. pinchDeltaPercentage: number;
  39852. /**
  39853. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39854. * that any object in the plane at the camera's target point will scale
  39855. * perfectly with finger motion.
  39856. * Overrides pinchDeltaPercentage and pinchPrecision.
  39857. */
  39858. useNaturalPinchZoom: boolean;
  39859. /**
  39860. * Defines the pointer panning sensibility or how fast is the camera moving.
  39861. */
  39862. panningSensibility: number;
  39863. /**
  39864. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39865. */
  39866. multiTouchPanning: boolean;
  39867. /**
  39868. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39869. * zoom (pinch) through multitouch.
  39870. */
  39871. multiTouchPanAndZoom: boolean;
  39872. /**
  39873. * Revers pinch action direction.
  39874. */
  39875. pinchInwards: boolean;
  39876. private _isPanClick;
  39877. private _twoFingerActivityCount;
  39878. private _isPinching;
  39879. /**
  39880. * Called on pointer POINTERMOVE event if only a single touch is active.
  39881. */
  39882. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39883. /**
  39884. * Called on pointer POINTERDOUBLETAP event.
  39885. */
  39886. protected onDoubleTap(type: string): void;
  39887. /**
  39888. * Called on pointer POINTERMOVE event if multiple touches are active.
  39889. */
  39890. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39891. /**
  39892. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39893. * press.
  39894. */
  39895. protected onButtonDown(evt: PointerEvent): void;
  39896. /**
  39897. * Called each time a new POINTERUP event occurs. Ie, for each button
  39898. * release.
  39899. */
  39900. protected onButtonUp(evt: PointerEvent): void;
  39901. /**
  39902. * Called when window becomes inactive.
  39903. */
  39904. protected onLostFocus(): void;
  39905. }
  39906. }
  39907. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39908. import { Nullable } from "babylonjs/types";
  39909. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39910. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39911. /**
  39912. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39914. */
  39915. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39916. /**
  39917. * Defines the camera the input is attached to.
  39918. */
  39919. camera: ArcRotateCamera;
  39920. /**
  39921. * Defines the list of key codes associated with the up action (increase alpha)
  39922. */
  39923. keysUp: number[];
  39924. /**
  39925. * Defines the list of key codes associated with the down action (decrease alpha)
  39926. */
  39927. keysDown: number[];
  39928. /**
  39929. * Defines the list of key codes associated with the left action (increase beta)
  39930. */
  39931. keysLeft: number[];
  39932. /**
  39933. * Defines the list of key codes associated with the right action (decrease beta)
  39934. */
  39935. keysRight: number[];
  39936. /**
  39937. * Defines the list of key codes associated with the reset action.
  39938. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39939. */
  39940. keysReset: number[];
  39941. /**
  39942. * Defines the panning sensibility of the inputs.
  39943. * (How fast is the camera panning)
  39944. */
  39945. panningSensibility: number;
  39946. /**
  39947. * Defines the zooming sensibility of the inputs.
  39948. * (How fast is the camera zooming)
  39949. */
  39950. zoomingSensibility: number;
  39951. /**
  39952. * Defines whether maintaining the alt key down switch the movement mode from
  39953. * orientation to zoom.
  39954. */
  39955. useAltToZoom: boolean;
  39956. /**
  39957. * Rotation speed of the camera
  39958. */
  39959. angularSpeed: number;
  39960. private _keys;
  39961. private _ctrlPressed;
  39962. private _altPressed;
  39963. private _onCanvasBlurObserver;
  39964. private _onKeyboardObserver;
  39965. private _engine;
  39966. private _scene;
  39967. /**
  39968. * Attach the input controls to a specific dom element to get the input from.
  39969. * @param element Defines the element the controls should be listened from
  39970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39971. */
  39972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39973. /**
  39974. * Detach the current controls from the specified dom element.
  39975. * @param element Defines the element to stop listening the inputs from
  39976. */
  39977. detachControl(element: Nullable<HTMLElement>): void;
  39978. /**
  39979. * Update the current camera state depending on the inputs that have been used this frame.
  39980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39981. */
  39982. checkInputs(): void;
  39983. /**
  39984. * Gets the class name of the current intput.
  39985. * @returns the class name
  39986. */
  39987. getClassName(): string;
  39988. /**
  39989. * Get the friendly name associated with the input class.
  39990. * @returns the input friendly name
  39991. */
  39992. getSimpleName(): string;
  39993. }
  39994. }
  39995. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39996. import { Nullable } from "babylonjs/types";
  39997. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39998. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39999. /**
  40000. * Manage the mouse wheel inputs to control an arc rotate camera.
  40001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40002. */
  40003. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40004. /**
  40005. * Defines the camera the input is attached to.
  40006. */
  40007. camera: ArcRotateCamera;
  40008. /**
  40009. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40010. */
  40011. wheelPrecision: number;
  40012. /**
  40013. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40014. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40015. */
  40016. wheelDeltaPercentage: number;
  40017. private _wheel;
  40018. private _observer;
  40019. private computeDeltaFromMouseWheelLegacyEvent;
  40020. /**
  40021. * Attach the input controls to a specific dom element to get the input from.
  40022. * @param element Defines the element the controls should be listened from
  40023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40024. */
  40025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40026. /**
  40027. * Detach the current controls from the specified dom element.
  40028. * @param element Defines the element to stop listening the inputs from
  40029. */
  40030. detachControl(element: Nullable<HTMLElement>): void;
  40031. /**
  40032. * Gets the class name of the current intput.
  40033. * @returns the class name
  40034. */
  40035. getClassName(): string;
  40036. /**
  40037. * Get the friendly name associated with the input class.
  40038. * @returns the input friendly name
  40039. */
  40040. getSimpleName(): string;
  40041. }
  40042. }
  40043. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40044. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40045. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40046. /**
  40047. * Default Inputs manager for the ArcRotateCamera.
  40048. * It groups all the default supported inputs for ease of use.
  40049. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40050. */
  40051. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40052. /**
  40053. * Instantiates a new ArcRotateCameraInputsManager.
  40054. * @param camera Defines the camera the inputs belong to
  40055. */
  40056. constructor(camera: ArcRotateCamera);
  40057. /**
  40058. * Add mouse wheel input support to the input manager.
  40059. * @returns the current input manager
  40060. */
  40061. addMouseWheel(): ArcRotateCameraInputsManager;
  40062. /**
  40063. * Add pointers input support to the input manager.
  40064. * @returns the current input manager
  40065. */
  40066. addPointers(): ArcRotateCameraInputsManager;
  40067. /**
  40068. * Add keyboard input support to the input manager.
  40069. * @returns the current input manager
  40070. */
  40071. addKeyboard(): ArcRotateCameraInputsManager;
  40072. }
  40073. }
  40074. declare module "babylonjs/Cameras/arcRotateCamera" {
  40075. import { Observable } from "babylonjs/Misc/observable";
  40076. import { Nullable } from "babylonjs/types";
  40077. import { Scene } from "babylonjs/scene";
  40078. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40080. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40081. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40082. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40083. import { Camera } from "babylonjs/Cameras/camera";
  40084. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40085. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40086. import { Collider } from "babylonjs/Collisions/collider";
  40087. /**
  40088. * This represents an orbital type of camera.
  40089. *
  40090. * 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.
  40091. * 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.
  40092. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40093. */
  40094. export class ArcRotateCamera extends TargetCamera {
  40095. /**
  40096. * Defines the rotation angle of the camera along the longitudinal axis.
  40097. */
  40098. alpha: number;
  40099. /**
  40100. * Defines the rotation angle of the camera along the latitudinal axis.
  40101. */
  40102. beta: number;
  40103. /**
  40104. * Defines the radius of the camera from it s target point.
  40105. */
  40106. radius: number;
  40107. protected _target: Vector3;
  40108. protected _targetHost: Nullable<AbstractMesh>;
  40109. /**
  40110. * Defines the target point of the camera.
  40111. * The camera looks towards it form the radius distance.
  40112. */
  40113. get target(): Vector3;
  40114. set target(value: Vector3);
  40115. /**
  40116. * Define the current local position of the camera in the scene
  40117. */
  40118. get position(): Vector3;
  40119. set position(newPosition: Vector3);
  40120. protected _upVector: Vector3;
  40121. protected _upToYMatrix: Matrix;
  40122. protected _YToUpMatrix: Matrix;
  40123. /**
  40124. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40125. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40126. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40127. */
  40128. set upVector(vec: Vector3);
  40129. get upVector(): Vector3;
  40130. /**
  40131. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40132. */
  40133. setMatUp(): void;
  40134. /**
  40135. * Current inertia value on the longitudinal axis.
  40136. * The bigger this number the longer it will take for the camera to stop.
  40137. */
  40138. inertialAlphaOffset: number;
  40139. /**
  40140. * Current inertia value on the latitudinal axis.
  40141. * The bigger this number the longer it will take for the camera to stop.
  40142. */
  40143. inertialBetaOffset: number;
  40144. /**
  40145. * Current inertia value on the radius axis.
  40146. * The bigger this number the longer it will take for the camera to stop.
  40147. */
  40148. inertialRadiusOffset: number;
  40149. /**
  40150. * Minimum allowed angle on the longitudinal axis.
  40151. * This can help limiting how the Camera is able to move in the scene.
  40152. */
  40153. lowerAlphaLimit: Nullable<number>;
  40154. /**
  40155. * Maximum allowed angle on the longitudinal axis.
  40156. * This can help limiting how the Camera is able to move in the scene.
  40157. */
  40158. upperAlphaLimit: Nullable<number>;
  40159. /**
  40160. * Minimum allowed angle on the latitudinal axis.
  40161. * This can help limiting how the Camera is able to move in the scene.
  40162. */
  40163. lowerBetaLimit: number;
  40164. /**
  40165. * Maximum allowed angle on the latitudinal axis.
  40166. * This can help limiting how the Camera is able to move in the scene.
  40167. */
  40168. upperBetaLimit: number;
  40169. /**
  40170. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40171. * This can help limiting how the Camera is able to move in the scene.
  40172. */
  40173. lowerRadiusLimit: Nullable<number>;
  40174. /**
  40175. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40176. * This can help limiting how the Camera is able to move in the scene.
  40177. */
  40178. upperRadiusLimit: Nullable<number>;
  40179. /**
  40180. * Defines the current inertia value used during panning of the camera along the X axis.
  40181. */
  40182. inertialPanningX: number;
  40183. /**
  40184. * Defines the current inertia value used during panning of the camera along the Y axis.
  40185. */
  40186. inertialPanningY: number;
  40187. /**
  40188. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40189. * Basically if your fingers moves away from more than this distance you will be considered
  40190. * in pinch mode.
  40191. */
  40192. pinchToPanMaxDistance: number;
  40193. /**
  40194. * Defines the maximum distance the camera can pan.
  40195. * This could help keeping the cammera always in your scene.
  40196. */
  40197. panningDistanceLimit: Nullable<number>;
  40198. /**
  40199. * Defines the target of the camera before paning.
  40200. */
  40201. panningOriginTarget: Vector3;
  40202. /**
  40203. * Defines the value of the inertia used during panning.
  40204. * 0 would mean stop inertia and one would mean no decelleration at all.
  40205. */
  40206. panningInertia: number;
  40207. /**
  40208. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40209. */
  40210. get angularSensibilityX(): number;
  40211. set angularSensibilityX(value: number);
  40212. /**
  40213. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40214. */
  40215. get angularSensibilityY(): number;
  40216. set angularSensibilityY(value: number);
  40217. /**
  40218. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40219. */
  40220. get pinchPrecision(): number;
  40221. set pinchPrecision(value: number);
  40222. /**
  40223. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40224. * It will be used instead of pinchDeltaPrecision if different from 0.
  40225. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40226. */
  40227. get pinchDeltaPercentage(): number;
  40228. set pinchDeltaPercentage(value: number);
  40229. /**
  40230. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40231. * and pinch delta percentage.
  40232. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40233. * that any object in the plane at the camera's target point will scale
  40234. * perfectly with finger motion.
  40235. */
  40236. get useNaturalPinchZoom(): boolean;
  40237. set useNaturalPinchZoom(value: boolean);
  40238. /**
  40239. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40240. */
  40241. get panningSensibility(): number;
  40242. set panningSensibility(value: number);
  40243. /**
  40244. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40245. */
  40246. get keysUp(): number[];
  40247. set keysUp(value: number[]);
  40248. /**
  40249. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40250. */
  40251. get keysDown(): number[];
  40252. set keysDown(value: number[]);
  40253. /**
  40254. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40255. */
  40256. get keysLeft(): number[];
  40257. set keysLeft(value: number[]);
  40258. /**
  40259. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40260. */
  40261. get keysRight(): number[];
  40262. set keysRight(value: number[]);
  40263. /**
  40264. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40265. */
  40266. get wheelPrecision(): number;
  40267. set wheelPrecision(value: number);
  40268. /**
  40269. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40270. * It will be used instead of pinchDeltaPrecision if different from 0.
  40271. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40272. */
  40273. get wheelDeltaPercentage(): number;
  40274. set wheelDeltaPercentage(value: number);
  40275. /**
  40276. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40277. */
  40278. zoomOnFactor: number;
  40279. /**
  40280. * Defines a screen offset for the camera position.
  40281. */
  40282. targetScreenOffset: Vector2;
  40283. /**
  40284. * Allows the camera to be completely reversed.
  40285. * If false the camera can not arrive upside down.
  40286. */
  40287. allowUpsideDown: boolean;
  40288. /**
  40289. * Define if double tap/click is used to restore the previously saved state of the camera.
  40290. */
  40291. useInputToRestoreState: boolean;
  40292. /** @hidden */
  40293. _viewMatrix: Matrix;
  40294. /** @hidden */
  40295. _useCtrlForPanning: boolean;
  40296. /** @hidden */
  40297. _panningMouseButton: number;
  40298. /**
  40299. * Defines the input associated to the camera.
  40300. */
  40301. inputs: ArcRotateCameraInputsManager;
  40302. /** @hidden */
  40303. _reset: () => void;
  40304. /**
  40305. * Defines the allowed panning axis.
  40306. */
  40307. panningAxis: Vector3;
  40308. protected _localDirection: Vector3;
  40309. protected _transformedDirection: Vector3;
  40310. private _bouncingBehavior;
  40311. /**
  40312. * Gets the bouncing behavior of the camera if it has been enabled.
  40313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40314. */
  40315. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40316. /**
  40317. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40318. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40319. */
  40320. get useBouncingBehavior(): boolean;
  40321. set useBouncingBehavior(value: boolean);
  40322. private _framingBehavior;
  40323. /**
  40324. * Gets the framing behavior of the camera if it has been enabled.
  40325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40326. */
  40327. get framingBehavior(): Nullable<FramingBehavior>;
  40328. /**
  40329. * Defines if the framing behavior of the camera is enabled on the camera.
  40330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40331. */
  40332. get useFramingBehavior(): boolean;
  40333. set useFramingBehavior(value: boolean);
  40334. private _autoRotationBehavior;
  40335. /**
  40336. * Gets the auto rotation behavior of the camera if it has been enabled.
  40337. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40338. */
  40339. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40340. /**
  40341. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40342. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40343. */
  40344. get useAutoRotationBehavior(): boolean;
  40345. set useAutoRotationBehavior(value: boolean);
  40346. /**
  40347. * Observable triggered when the mesh target has been changed on the camera.
  40348. */
  40349. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40350. /**
  40351. * Event raised when the camera is colliding with a mesh.
  40352. */
  40353. onCollide: (collidedMesh: AbstractMesh) => void;
  40354. /**
  40355. * Defines whether the camera should check collision with the objects oh the scene.
  40356. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40357. */
  40358. checkCollisions: boolean;
  40359. /**
  40360. * Defines the collision radius of the camera.
  40361. * This simulates a sphere around the camera.
  40362. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40363. */
  40364. collisionRadius: Vector3;
  40365. protected _collider: Collider;
  40366. protected _previousPosition: Vector3;
  40367. protected _collisionVelocity: Vector3;
  40368. protected _newPosition: Vector3;
  40369. protected _previousAlpha: number;
  40370. protected _previousBeta: number;
  40371. protected _previousRadius: number;
  40372. protected _collisionTriggered: boolean;
  40373. protected _targetBoundingCenter: Nullable<Vector3>;
  40374. private _computationVector;
  40375. /**
  40376. * Instantiates a new ArcRotateCamera in a given scene
  40377. * @param name Defines the name of the camera
  40378. * @param alpha Defines the camera rotation along the logitudinal axis
  40379. * @param beta Defines the camera rotation along the latitudinal axis
  40380. * @param radius Defines the camera distance from its target
  40381. * @param target Defines the camera target
  40382. * @param scene Defines the scene the camera belongs to
  40383. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40384. */
  40385. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40386. /** @hidden */
  40387. _initCache(): void;
  40388. /** @hidden */
  40389. _updateCache(ignoreParentClass?: boolean): void;
  40390. protected _getTargetPosition(): Vector3;
  40391. private _storedAlpha;
  40392. private _storedBeta;
  40393. private _storedRadius;
  40394. private _storedTarget;
  40395. private _storedTargetScreenOffset;
  40396. /**
  40397. * Stores the current state of the camera (alpha, beta, radius and target)
  40398. * @returns the camera itself
  40399. */
  40400. storeState(): Camera;
  40401. /**
  40402. * @hidden
  40403. * Restored camera state. You must call storeState() first
  40404. */
  40405. _restoreStateValues(): boolean;
  40406. /** @hidden */
  40407. _isSynchronizedViewMatrix(): boolean;
  40408. /**
  40409. * Attached controls to the current camera.
  40410. * @param element Defines the element the controls should be listened from
  40411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40412. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40413. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40414. */
  40415. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40416. /**
  40417. * Detach the current controls from the camera.
  40418. * The camera will stop reacting to inputs.
  40419. * @param element Defines the element to stop listening the inputs from
  40420. */
  40421. detachControl(element: HTMLElement): void;
  40422. /** @hidden */
  40423. _checkInputs(): void;
  40424. protected _checkLimits(): void;
  40425. /**
  40426. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40427. */
  40428. rebuildAnglesAndRadius(): void;
  40429. /**
  40430. * Use a position to define the current camera related information like alpha, beta and radius
  40431. * @param position Defines the position to set the camera at
  40432. */
  40433. setPosition(position: Vector3): void;
  40434. /**
  40435. * Defines the target the camera should look at.
  40436. * This will automatically adapt alpha beta and radius to fit within the new target.
  40437. * @param target Defines the new target as a Vector or a mesh
  40438. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40439. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40440. */
  40441. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40442. /** @hidden */
  40443. _getViewMatrix(): Matrix;
  40444. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40445. /**
  40446. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40447. * @param meshes Defines the mesh to zoom on
  40448. * @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)
  40449. */
  40450. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40451. /**
  40452. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40453. * The target will be changed but the radius
  40454. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40455. * @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)
  40456. */
  40457. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40458. min: Vector3;
  40459. max: Vector3;
  40460. distance: number;
  40461. }, doNotUpdateMaxZ?: boolean): void;
  40462. /**
  40463. * @override
  40464. * Override Camera.createRigCamera
  40465. */
  40466. createRigCamera(name: string, cameraIndex: number): Camera;
  40467. /**
  40468. * @hidden
  40469. * @override
  40470. * Override Camera._updateRigCameras
  40471. */
  40472. _updateRigCameras(): void;
  40473. /**
  40474. * Destroy the camera and release the current resources hold by it.
  40475. */
  40476. dispose(): void;
  40477. /**
  40478. * Gets the current object class name.
  40479. * @return the class name
  40480. */
  40481. getClassName(): string;
  40482. }
  40483. }
  40484. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40485. import { Behavior } from "babylonjs/Behaviors/behavior";
  40486. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40487. /**
  40488. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40489. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40490. */
  40491. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40492. /**
  40493. * Gets the name of the behavior.
  40494. */
  40495. get name(): string;
  40496. private _zoomStopsAnimation;
  40497. private _idleRotationSpeed;
  40498. private _idleRotationWaitTime;
  40499. private _idleRotationSpinupTime;
  40500. /**
  40501. * Sets the flag that indicates if user zooming should stop animation.
  40502. */
  40503. set zoomStopsAnimation(flag: boolean);
  40504. /**
  40505. * Gets the flag that indicates if user zooming should stop animation.
  40506. */
  40507. get zoomStopsAnimation(): boolean;
  40508. /**
  40509. * Sets the default speed at which the camera rotates around the model.
  40510. */
  40511. set idleRotationSpeed(speed: number);
  40512. /**
  40513. * Gets the default speed at which the camera rotates around the model.
  40514. */
  40515. get idleRotationSpeed(): number;
  40516. /**
  40517. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40518. */
  40519. set idleRotationWaitTime(time: number);
  40520. /**
  40521. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40522. */
  40523. get idleRotationWaitTime(): number;
  40524. /**
  40525. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40526. */
  40527. set idleRotationSpinupTime(time: number);
  40528. /**
  40529. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40530. */
  40531. get idleRotationSpinupTime(): number;
  40532. /**
  40533. * Gets a value indicating if the camera is currently rotating because of this behavior
  40534. */
  40535. get rotationInProgress(): boolean;
  40536. private _onPrePointerObservableObserver;
  40537. private _onAfterCheckInputsObserver;
  40538. private _attachedCamera;
  40539. private _isPointerDown;
  40540. private _lastFrameTime;
  40541. private _lastInteractionTime;
  40542. private _cameraRotationSpeed;
  40543. /**
  40544. * Initializes the behavior.
  40545. */
  40546. init(): void;
  40547. /**
  40548. * Attaches the behavior to its arc rotate camera.
  40549. * @param camera Defines the camera to attach the behavior to
  40550. */
  40551. attach(camera: ArcRotateCamera): void;
  40552. /**
  40553. * Detaches the behavior from its current arc rotate camera.
  40554. */
  40555. detach(): void;
  40556. /**
  40557. * Returns true if user is scrolling.
  40558. * @return true if user is scrolling.
  40559. */
  40560. private _userIsZooming;
  40561. private _lastFrameRadius;
  40562. private _shouldAnimationStopForInteraction;
  40563. /**
  40564. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40565. */
  40566. private _applyUserInteraction;
  40567. private _userIsMoving;
  40568. }
  40569. }
  40570. declare module "babylonjs/Behaviors/Cameras/index" {
  40571. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40572. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40573. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40574. }
  40575. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40576. import { Mesh } from "babylonjs/Meshes/mesh";
  40577. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40578. import { Behavior } from "babylonjs/Behaviors/behavior";
  40579. /**
  40580. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40581. */
  40582. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40583. private ui;
  40584. /**
  40585. * The name of the behavior
  40586. */
  40587. name: string;
  40588. /**
  40589. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40590. */
  40591. distanceAwayFromFace: number;
  40592. /**
  40593. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40594. */
  40595. distanceAwayFromBottomOfFace: number;
  40596. private _faceVectors;
  40597. private _target;
  40598. private _scene;
  40599. private _onRenderObserver;
  40600. private _tmpMatrix;
  40601. private _tmpVector;
  40602. /**
  40603. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40604. * @param ui The transform node that should be attched to the mesh
  40605. */
  40606. constructor(ui: TransformNode);
  40607. /**
  40608. * Initializes the behavior
  40609. */
  40610. init(): void;
  40611. private _closestFace;
  40612. private _zeroVector;
  40613. private _lookAtTmpMatrix;
  40614. private _lookAtToRef;
  40615. /**
  40616. * Attaches the AttachToBoxBehavior to the passed in mesh
  40617. * @param target The mesh that the specified node will be attached to
  40618. */
  40619. attach(target: Mesh): void;
  40620. /**
  40621. * Detaches the behavior from the mesh
  40622. */
  40623. detach(): void;
  40624. }
  40625. }
  40626. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40627. import { Behavior } from "babylonjs/Behaviors/behavior";
  40628. import { Mesh } from "babylonjs/Meshes/mesh";
  40629. /**
  40630. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40631. */
  40632. export class FadeInOutBehavior implements Behavior<Mesh> {
  40633. /**
  40634. * Time in milliseconds to delay before fading in (Default: 0)
  40635. */
  40636. delay: number;
  40637. /**
  40638. * Time in milliseconds for the mesh to fade in (Default: 300)
  40639. */
  40640. fadeInTime: number;
  40641. private _millisecondsPerFrame;
  40642. private _hovered;
  40643. private _hoverValue;
  40644. private _ownerNode;
  40645. /**
  40646. * Instatiates the FadeInOutBehavior
  40647. */
  40648. constructor();
  40649. /**
  40650. * The name of the behavior
  40651. */
  40652. get name(): string;
  40653. /**
  40654. * Initializes the behavior
  40655. */
  40656. init(): void;
  40657. /**
  40658. * Attaches the fade behavior on the passed in mesh
  40659. * @param ownerNode The mesh that will be faded in/out once attached
  40660. */
  40661. attach(ownerNode: Mesh): void;
  40662. /**
  40663. * Detaches the behavior from the mesh
  40664. */
  40665. detach(): void;
  40666. /**
  40667. * Triggers the mesh to begin fading in or out
  40668. * @param value if the object should fade in or out (true to fade in)
  40669. */
  40670. fadeIn(value: boolean): void;
  40671. private _update;
  40672. private _setAllVisibility;
  40673. }
  40674. }
  40675. declare module "babylonjs/Misc/pivotTools" {
  40676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40677. /**
  40678. * Class containing a set of static utilities functions for managing Pivots
  40679. * @hidden
  40680. */
  40681. export class PivotTools {
  40682. private static _PivotCached;
  40683. private static _OldPivotPoint;
  40684. private static _PivotTranslation;
  40685. private static _PivotTmpVector;
  40686. /** @hidden */
  40687. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40688. /** @hidden */
  40689. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40690. }
  40691. }
  40692. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40693. import { Scene } from "babylonjs/scene";
  40694. import { Vector4 } from "babylonjs/Maths/math.vector";
  40695. import { Mesh } from "babylonjs/Meshes/mesh";
  40696. import { Nullable } from "babylonjs/types";
  40697. import { Plane } from "babylonjs/Maths/math.plane";
  40698. /**
  40699. * Class containing static functions to help procedurally build meshes
  40700. */
  40701. export class PlaneBuilder {
  40702. /**
  40703. * Creates a plane mesh
  40704. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40705. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40706. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40710. * @param name defines the name of the mesh
  40711. * @param options defines the options used to create the mesh
  40712. * @param scene defines the hosting scene
  40713. * @returns the plane mesh
  40714. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40715. */
  40716. static CreatePlane(name: string, options: {
  40717. size?: number;
  40718. width?: number;
  40719. height?: number;
  40720. sideOrientation?: number;
  40721. frontUVs?: Vector4;
  40722. backUVs?: Vector4;
  40723. updatable?: boolean;
  40724. sourcePlane?: Plane;
  40725. }, scene?: Nullable<Scene>): Mesh;
  40726. }
  40727. }
  40728. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40729. import { Behavior } from "babylonjs/Behaviors/behavior";
  40730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40731. import { Observable } from "babylonjs/Misc/observable";
  40732. import { Vector3 } from "babylonjs/Maths/math.vector";
  40733. import { Ray } from "babylonjs/Culling/ray";
  40734. import "babylonjs/Meshes/Builders/planeBuilder";
  40735. /**
  40736. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40737. */
  40738. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40739. private static _AnyMouseID;
  40740. /**
  40741. * Abstract mesh the behavior is set on
  40742. */
  40743. attachedNode: AbstractMesh;
  40744. private _dragPlane;
  40745. private _scene;
  40746. private _pointerObserver;
  40747. private _beforeRenderObserver;
  40748. private static _planeScene;
  40749. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40750. /**
  40751. * 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)
  40752. */
  40753. maxDragAngle: number;
  40754. /**
  40755. * @hidden
  40756. */
  40757. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40758. /**
  40759. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40760. */
  40761. currentDraggingPointerID: number;
  40762. /**
  40763. * The last position where the pointer hit the drag plane in world space
  40764. */
  40765. lastDragPosition: Vector3;
  40766. /**
  40767. * If the behavior is currently in a dragging state
  40768. */
  40769. dragging: boolean;
  40770. /**
  40771. * 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)
  40772. */
  40773. dragDeltaRatio: number;
  40774. /**
  40775. * If the drag plane orientation should be updated during the dragging (Default: true)
  40776. */
  40777. updateDragPlane: boolean;
  40778. private _debugMode;
  40779. private _moving;
  40780. /**
  40781. * Fires each time the attached mesh is dragged with the pointer
  40782. * * delta between last drag position and current drag position in world space
  40783. * * dragDistance along the drag axis
  40784. * * dragPlaneNormal normal of the current drag plane used during the drag
  40785. * * dragPlanePoint in world space where the drag intersects the drag plane
  40786. */
  40787. onDragObservable: Observable<{
  40788. delta: Vector3;
  40789. dragPlanePoint: Vector3;
  40790. dragPlaneNormal: Vector3;
  40791. dragDistance: number;
  40792. pointerId: number;
  40793. }>;
  40794. /**
  40795. * Fires each time a drag begins (eg. mouse down on mesh)
  40796. */
  40797. onDragStartObservable: Observable<{
  40798. dragPlanePoint: Vector3;
  40799. pointerId: number;
  40800. }>;
  40801. /**
  40802. * Fires each time a drag ends (eg. mouse release after drag)
  40803. */
  40804. onDragEndObservable: Observable<{
  40805. dragPlanePoint: Vector3;
  40806. pointerId: number;
  40807. }>;
  40808. /**
  40809. * If the attached mesh should be moved when dragged
  40810. */
  40811. moveAttached: boolean;
  40812. /**
  40813. * If the drag behavior will react to drag events (Default: true)
  40814. */
  40815. enabled: boolean;
  40816. /**
  40817. * If pointer events should start and release the drag (Default: true)
  40818. */
  40819. startAndReleaseDragOnPointerEvents: boolean;
  40820. /**
  40821. * If camera controls should be detached during the drag
  40822. */
  40823. detachCameraControls: boolean;
  40824. /**
  40825. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40826. */
  40827. useObjectOrientationForDragging: boolean;
  40828. private _options;
  40829. /**
  40830. * Gets the options used by the behavior
  40831. */
  40832. get options(): {
  40833. dragAxis?: Vector3;
  40834. dragPlaneNormal?: Vector3;
  40835. };
  40836. /**
  40837. * Sets the options used by the behavior
  40838. */
  40839. set options(options: {
  40840. dragAxis?: Vector3;
  40841. dragPlaneNormal?: Vector3;
  40842. });
  40843. /**
  40844. * Creates a pointer drag behavior that can be attached to a mesh
  40845. * @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)
  40846. */
  40847. constructor(options?: {
  40848. dragAxis?: Vector3;
  40849. dragPlaneNormal?: Vector3;
  40850. });
  40851. /**
  40852. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40853. */
  40854. validateDrag: (targetPosition: Vector3) => boolean;
  40855. /**
  40856. * The name of the behavior
  40857. */
  40858. get name(): string;
  40859. /**
  40860. * Initializes the behavior
  40861. */
  40862. init(): void;
  40863. private _tmpVector;
  40864. private _alternatePickedPoint;
  40865. private _worldDragAxis;
  40866. private _targetPosition;
  40867. private _attachedElement;
  40868. /**
  40869. * Attaches the drag behavior the passed in mesh
  40870. * @param ownerNode The mesh that will be dragged around once attached
  40871. * @param predicate Predicate to use for pick filtering
  40872. */
  40873. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40874. /**
  40875. * Force relase the drag action by code.
  40876. */
  40877. releaseDrag(): void;
  40878. private _startDragRay;
  40879. private _lastPointerRay;
  40880. /**
  40881. * Simulates the start of a pointer drag event on the behavior
  40882. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40883. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40884. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40885. */
  40886. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40887. private _startDrag;
  40888. private _dragDelta;
  40889. private _moveDrag;
  40890. private _pickWithRayOnDragPlane;
  40891. private _pointA;
  40892. private _pointB;
  40893. private _pointC;
  40894. private _lineA;
  40895. private _lineB;
  40896. private _localAxis;
  40897. private _lookAt;
  40898. private _updateDragPlanePosition;
  40899. /**
  40900. * Detaches the behavior from the mesh
  40901. */
  40902. detach(): void;
  40903. }
  40904. }
  40905. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40906. import { Mesh } from "babylonjs/Meshes/mesh";
  40907. import { Behavior } from "babylonjs/Behaviors/behavior";
  40908. /**
  40909. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40910. */
  40911. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40912. private _dragBehaviorA;
  40913. private _dragBehaviorB;
  40914. private _startDistance;
  40915. private _initialScale;
  40916. private _targetScale;
  40917. private _ownerNode;
  40918. private _sceneRenderObserver;
  40919. /**
  40920. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40921. */
  40922. constructor();
  40923. /**
  40924. * The name of the behavior
  40925. */
  40926. get name(): string;
  40927. /**
  40928. * Initializes the behavior
  40929. */
  40930. init(): void;
  40931. private _getCurrentDistance;
  40932. /**
  40933. * Attaches the scale behavior the passed in mesh
  40934. * @param ownerNode The mesh that will be scaled around once attached
  40935. */
  40936. attach(ownerNode: Mesh): void;
  40937. /**
  40938. * Detaches the behavior from the mesh
  40939. */
  40940. detach(): void;
  40941. }
  40942. }
  40943. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40944. import { Behavior } from "babylonjs/Behaviors/behavior";
  40945. import { Mesh } from "babylonjs/Meshes/mesh";
  40946. import { Observable } from "babylonjs/Misc/observable";
  40947. /**
  40948. * 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
  40949. */
  40950. export class SixDofDragBehavior implements Behavior<Mesh> {
  40951. private static _virtualScene;
  40952. private _ownerNode;
  40953. private _sceneRenderObserver;
  40954. private _scene;
  40955. private _targetPosition;
  40956. private _virtualOriginMesh;
  40957. private _virtualDragMesh;
  40958. private _pointerObserver;
  40959. private _moving;
  40960. private _startingOrientation;
  40961. private _attachedElement;
  40962. /**
  40963. * 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)
  40964. */
  40965. private zDragFactor;
  40966. /**
  40967. * If the object should rotate to face the drag origin
  40968. */
  40969. rotateDraggedObject: boolean;
  40970. /**
  40971. * If the behavior is currently in a dragging state
  40972. */
  40973. dragging: boolean;
  40974. /**
  40975. * 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)
  40976. */
  40977. dragDeltaRatio: number;
  40978. /**
  40979. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40980. */
  40981. currentDraggingPointerID: number;
  40982. /**
  40983. * If camera controls should be detached during the drag
  40984. */
  40985. detachCameraControls: boolean;
  40986. /**
  40987. * Fires each time a drag starts
  40988. */
  40989. onDragStartObservable: Observable<{}>;
  40990. /**
  40991. * Fires each time a drag ends (eg. mouse release after drag)
  40992. */
  40993. onDragEndObservable: Observable<{}>;
  40994. /**
  40995. * 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
  40996. */
  40997. constructor();
  40998. /**
  40999. * The name of the behavior
  41000. */
  41001. get name(): string;
  41002. /**
  41003. * Initializes the behavior
  41004. */
  41005. init(): void;
  41006. /**
  41007. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41008. */
  41009. private get _pointerCamera();
  41010. /**
  41011. * Attaches the scale behavior the passed in mesh
  41012. * @param ownerNode The mesh that will be scaled around once attached
  41013. */
  41014. attach(ownerNode: Mesh): void;
  41015. /**
  41016. * Detaches the behavior from the mesh
  41017. */
  41018. detach(): void;
  41019. }
  41020. }
  41021. declare module "babylonjs/Behaviors/Meshes/index" {
  41022. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41023. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41024. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41025. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41026. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41027. }
  41028. declare module "babylonjs/Behaviors/index" {
  41029. export * from "babylonjs/Behaviors/behavior";
  41030. export * from "babylonjs/Behaviors/Cameras/index";
  41031. export * from "babylonjs/Behaviors/Meshes/index";
  41032. }
  41033. declare module "babylonjs/Bones/boneIKController" {
  41034. import { Bone } from "babylonjs/Bones/bone";
  41035. import { Vector3 } from "babylonjs/Maths/math.vector";
  41036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41037. import { Nullable } from "babylonjs/types";
  41038. /**
  41039. * Class used to apply inverse kinematics to bones
  41040. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41041. */
  41042. export class BoneIKController {
  41043. private static _tmpVecs;
  41044. private static _tmpQuat;
  41045. private static _tmpMats;
  41046. /**
  41047. * Gets or sets the target mesh
  41048. */
  41049. targetMesh: AbstractMesh;
  41050. /** Gets or sets the mesh used as pole */
  41051. poleTargetMesh: AbstractMesh;
  41052. /**
  41053. * Gets or sets the bone used as pole
  41054. */
  41055. poleTargetBone: Nullable<Bone>;
  41056. /**
  41057. * Gets or sets the target position
  41058. */
  41059. targetPosition: Vector3;
  41060. /**
  41061. * Gets or sets the pole target position
  41062. */
  41063. poleTargetPosition: Vector3;
  41064. /**
  41065. * Gets or sets the pole target local offset
  41066. */
  41067. poleTargetLocalOffset: Vector3;
  41068. /**
  41069. * Gets or sets the pole angle
  41070. */
  41071. poleAngle: number;
  41072. /**
  41073. * Gets or sets the mesh associated with the controller
  41074. */
  41075. mesh: AbstractMesh;
  41076. /**
  41077. * 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)
  41078. */
  41079. slerpAmount: number;
  41080. private _bone1Quat;
  41081. private _bone1Mat;
  41082. private _bone2Ang;
  41083. private _bone1;
  41084. private _bone2;
  41085. private _bone1Length;
  41086. private _bone2Length;
  41087. private _maxAngle;
  41088. private _maxReach;
  41089. private _rightHandedSystem;
  41090. private _bendAxis;
  41091. private _slerping;
  41092. private _adjustRoll;
  41093. /**
  41094. * Gets or sets maximum allowed angle
  41095. */
  41096. get maxAngle(): number;
  41097. set maxAngle(value: number);
  41098. /**
  41099. * Creates a new BoneIKController
  41100. * @param mesh defines the mesh to control
  41101. * @param bone defines the bone to control
  41102. * @param options defines options to set up the controller
  41103. */
  41104. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41105. targetMesh?: AbstractMesh;
  41106. poleTargetMesh?: AbstractMesh;
  41107. poleTargetBone?: Bone;
  41108. poleTargetLocalOffset?: Vector3;
  41109. poleAngle?: number;
  41110. bendAxis?: Vector3;
  41111. maxAngle?: number;
  41112. slerpAmount?: number;
  41113. });
  41114. private _setMaxAngle;
  41115. /**
  41116. * Force the controller to update the bones
  41117. */
  41118. update(): void;
  41119. }
  41120. }
  41121. declare module "babylonjs/Bones/boneLookController" {
  41122. import { Vector3 } from "babylonjs/Maths/math.vector";
  41123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41124. import { Bone } from "babylonjs/Bones/bone";
  41125. import { Space } from "babylonjs/Maths/math.axis";
  41126. /**
  41127. * Class used to make a bone look toward a point in space
  41128. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41129. */
  41130. export class BoneLookController {
  41131. private static _tmpVecs;
  41132. private static _tmpQuat;
  41133. private static _tmpMats;
  41134. /**
  41135. * The target Vector3 that the bone will look at
  41136. */
  41137. target: Vector3;
  41138. /**
  41139. * The mesh that the bone is attached to
  41140. */
  41141. mesh: AbstractMesh;
  41142. /**
  41143. * The bone that will be looking to the target
  41144. */
  41145. bone: Bone;
  41146. /**
  41147. * The up axis of the coordinate system that is used when the bone is rotated
  41148. */
  41149. upAxis: Vector3;
  41150. /**
  41151. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41152. */
  41153. upAxisSpace: Space;
  41154. /**
  41155. * Used to make an adjustment to the yaw of the bone
  41156. */
  41157. adjustYaw: number;
  41158. /**
  41159. * Used to make an adjustment to the pitch of the bone
  41160. */
  41161. adjustPitch: number;
  41162. /**
  41163. * Used to make an adjustment to the roll of the bone
  41164. */
  41165. adjustRoll: number;
  41166. /**
  41167. * 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)
  41168. */
  41169. slerpAmount: number;
  41170. private _minYaw;
  41171. private _maxYaw;
  41172. private _minPitch;
  41173. private _maxPitch;
  41174. private _minYawSin;
  41175. private _minYawCos;
  41176. private _maxYawSin;
  41177. private _maxYawCos;
  41178. private _midYawConstraint;
  41179. private _minPitchTan;
  41180. private _maxPitchTan;
  41181. private _boneQuat;
  41182. private _slerping;
  41183. private _transformYawPitch;
  41184. private _transformYawPitchInv;
  41185. private _firstFrameSkipped;
  41186. private _yawRange;
  41187. private _fowardAxis;
  41188. /**
  41189. * Gets or sets the minimum yaw angle that the bone can look to
  41190. */
  41191. get minYaw(): number;
  41192. set minYaw(value: number);
  41193. /**
  41194. * Gets or sets the maximum yaw angle that the bone can look to
  41195. */
  41196. get maxYaw(): number;
  41197. set maxYaw(value: number);
  41198. /**
  41199. * Gets or sets the minimum pitch angle that the bone can look to
  41200. */
  41201. get minPitch(): number;
  41202. set minPitch(value: number);
  41203. /**
  41204. * Gets or sets the maximum pitch angle that the bone can look to
  41205. */
  41206. get maxPitch(): number;
  41207. set maxPitch(value: number);
  41208. /**
  41209. * Create a BoneLookController
  41210. * @param mesh the mesh that the bone belongs to
  41211. * @param bone the bone that will be looking to the target
  41212. * @param target the target Vector3 to look at
  41213. * @param options optional settings:
  41214. * * maxYaw: the maximum angle the bone will yaw to
  41215. * * minYaw: the minimum angle the bone will yaw to
  41216. * * maxPitch: the maximum angle the bone will pitch to
  41217. * * minPitch: the minimum angle the bone will yaw to
  41218. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41219. * * upAxis: the up axis of the coordinate system
  41220. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41221. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41222. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41223. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41224. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41225. * * adjustRoll: used to make an adjustment to the roll of the bone
  41226. **/
  41227. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41228. maxYaw?: number;
  41229. minYaw?: number;
  41230. maxPitch?: number;
  41231. minPitch?: number;
  41232. slerpAmount?: number;
  41233. upAxis?: Vector3;
  41234. upAxisSpace?: Space;
  41235. yawAxis?: Vector3;
  41236. pitchAxis?: Vector3;
  41237. adjustYaw?: number;
  41238. adjustPitch?: number;
  41239. adjustRoll?: number;
  41240. });
  41241. /**
  41242. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41243. */
  41244. update(): void;
  41245. private _getAngleDiff;
  41246. private _getAngleBetween;
  41247. private _isAngleBetween;
  41248. }
  41249. }
  41250. declare module "babylonjs/Bones/index" {
  41251. export * from "babylonjs/Bones/bone";
  41252. export * from "babylonjs/Bones/boneIKController";
  41253. export * from "babylonjs/Bones/boneLookController";
  41254. export * from "babylonjs/Bones/skeleton";
  41255. }
  41256. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41257. import { Nullable } from "babylonjs/types";
  41258. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41259. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41260. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41261. /**
  41262. * Manage the gamepad inputs to control an arc rotate camera.
  41263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41264. */
  41265. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41266. /**
  41267. * Defines the camera the input is attached to.
  41268. */
  41269. camera: ArcRotateCamera;
  41270. /**
  41271. * Defines the gamepad the input is gathering event from.
  41272. */
  41273. gamepad: Nullable<Gamepad>;
  41274. /**
  41275. * Defines the gamepad rotation sensiblity.
  41276. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41277. */
  41278. gamepadRotationSensibility: number;
  41279. /**
  41280. * Defines the gamepad move sensiblity.
  41281. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41282. */
  41283. gamepadMoveSensibility: number;
  41284. private _yAxisScale;
  41285. /**
  41286. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41287. */
  41288. get invertYAxis(): boolean;
  41289. set invertYAxis(value: boolean);
  41290. private _onGamepadConnectedObserver;
  41291. private _onGamepadDisconnectedObserver;
  41292. /**
  41293. * Attach the input controls to a specific dom element to get the input from.
  41294. * @param element Defines the element the controls should be listened from
  41295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41296. */
  41297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41298. /**
  41299. * Detach the current controls from the specified dom element.
  41300. * @param element Defines the element to stop listening the inputs from
  41301. */
  41302. detachControl(element: Nullable<HTMLElement>): void;
  41303. /**
  41304. * Update the current camera state depending on the inputs that have been used this frame.
  41305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41306. */
  41307. checkInputs(): void;
  41308. /**
  41309. * Gets the class name of the current intput.
  41310. * @returns the class name
  41311. */
  41312. getClassName(): string;
  41313. /**
  41314. * Get the friendly name associated with the input class.
  41315. * @returns the input friendly name
  41316. */
  41317. getSimpleName(): string;
  41318. }
  41319. }
  41320. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41321. import { Nullable } from "babylonjs/types";
  41322. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41323. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41324. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41325. interface ArcRotateCameraInputsManager {
  41326. /**
  41327. * Add orientation input support to the input manager.
  41328. * @returns the current input manager
  41329. */
  41330. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41331. }
  41332. }
  41333. /**
  41334. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41336. */
  41337. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41338. /**
  41339. * Defines the camera the input is attached to.
  41340. */
  41341. camera: ArcRotateCamera;
  41342. /**
  41343. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41344. */
  41345. alphaCorrection: number;
  41346. /**
  41347. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41348. */
  41349. gammaCorrection: number;
  41350. private _alpha;
  41351. private _gamma;
  41352. private _dirty;
  41353. private _deviceOrientationHandler;
  41354. /**
  41355. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41356. */
  41357. constructor();
  41358. /**
  41359. * Attach the input controls to a specific dom element to get the input from.
  41360. * @param element Defines the element the controls should be listened from
  41361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41362. */
  41363. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41364. /** @hidden */
  41365. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41366. /**
  41367. * Update the current camera state depending on the inputs that have been used this frame.
  41368. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41369. */
  41370. checkInputs(): void;
  41371. /**
  41372. * Detach the current controls from the specified dom element.
  41373. * @param element Defines the element to stop listening the inputs from
  41374. */
  41375. detachControl(element: Nullable<HTMLElement>): void;
  41376. /**
  41377. * Gets the class name of the current intput.
  41378. * @returns the class name
  41379. */
  41380. getClassName(): string;
  41381. /**
  41382. * Get the friendly name associated with the input class.
  41383. * @returns the input friendly name
  41384. */
  41385. getSimpleName(): string;
  41386. }
  41387. }
  41388. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41389. import { Nullable } from "babylonjs/types";
  41390. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41391. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41392. /**
  41393. * Listen to mouse events to control the camera.
  41394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41395. */
  41396. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41397. /**
  41398. * Defines the camera the input is attached to.
  41399. */
  41400. camera: FlyCamera;
  41401. /**
  41402. * Defines if touch is enabled. (Default is true.)
  41403. */
  41404. touchEnabled: boolean;
  41405. /**
  41406. * Defines the buttons associated with the input to handle camera rotation.
  41407. */
  41408. buttons: number[];
  41409. /**
  41410. * Assign buttons for Yaw control.
  41411. */
  41412. buttonsYaw: number[];
  41413. /**
  41414. * Assign buttons for Pitch control.
  41415. */
  41416. buttonsPitch: number[];
  41417. /**
  41418. * Assign buttons for Roll control.
  41419. */
  41420. buttonsRoll: number[];
  41421. /**
  41422. * Detect if any button is being pressed while mouse is moved.
  41423. * -1 = Mouse locked.
  41424. * 0 = Left button.
  41425. * 1 = Middle Button.
  41426. * 2 = Right Button.
  41427. */
  41428. activeButton: number;
  41429. /**
  41430. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41431. * Higher values reduce its sensitivity.
  41432. */
  41433. angularSensibility: number;
  41434. private _mousemoveCallback;
  41435. private _observer;
  41436. private _rollObserver;
  41437. private previousPosition;
  41438. private noPreventDefault;
  41439. private element;
  41440. /**
  41441. * Listen to mouse events to control the camera.
  41442. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41444. */
  41445. constructor(touchEnabled?: boolean);
  41446. /**
  41447. * Attach the mouse control to the HTML DOM element.
  41448. * @param element Defines the element that listens to the input events.
  41449. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41450. */
  41451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41452. /**
  41453. * Detach the current controls from the specified dom element.
  41454. * @param element Defines the element to stop listening the inputs from
  41455. */
  41456. detachControl(element: Nullable<HTMLElement>): void;
  41457. /**
  41458. * Gets the class name of the current input.
  41459. * @returns the class name.
  41460. */
  41461. getClassName(): string;
  41462. /**
  41463. * Get the friendly name associated with the input class.
  41464. * @returns the input's friendly name.
  41465. */
  41466. getSimpleName(): string;
  41467. private _pointerInput;
  41468. private _onMouseMove;
  41469. /**
  41470. * Rotate camera by mouse offset.
  41471. */
  41472. private rotateCamera;
  41473. }
  41474. }
  41475. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41476. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41477. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41478. /**
  41479. * Default Inputs manager for the FlyCamera.
  41480. * It groups all the default supported inputs for ease of use.
  41481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41482. */
  41483. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41484. /**
  41485. * Instantiates a new FlyCameraInputsManager.
  41486. * @param camera Defines the camera the inputs belong to.
  41487. */
  41488. constructor(camera: FlyCamera);
  41489. /**
  41490. * Add keyboard input support to the input manager.
  41491. * @returns the new FlyCameraKeyboardMoveInput().
  41492. */
  41493. addKeyboard(): FlyCameraInputsManager;
  41494. /**
  41495. * Add mouse input support to the input manager.
  41496. * @param touchEnabled Enable touch screen support.
  41497. * @returns the new FlyCameraMouseInput().
  41498. */
  41499. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41500. }
  41501. }
  41502. declare module "babylonjs/Cameras/flyCamera" {
  41503. import { Scene } from "babylonjs/scene";
  41504. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41506. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41507. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41508. /**
  41509. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41510. * such as in a 3D Space Shooter or a Flight Simulator.
  41511. */
  41512. export class FlyCamera extends TargetCamera {
  41513. /**
  41514. * Define the collision ellipsoid of the camera.
  41515. * This is helpful for simulating a camera body, like a player's body.
  41516. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41517. */
  41518. ellipsoid: Vector3;
  41519. /**
  41520. * Define an offset for the position of the ellipsoid around the camera.
  41521. * This can be helpful if the camera is attached away from the player's body center,
  41522. * such as at its head.
  41523. */
  41524. ellipsoidOffset: Vector3;
  41525. /**
  41526. * Enable or disable collisions of the camera with the rest of the scene objects.
  41527. */
  41528. checkCollisions: boolean;
  41529. /**
  41530. * Enable or disable gravity on the camera.
  41531. */
  41532. applyGravity: boolean;
  41533. /**
  41534. * Define the current direction the camera is moving to.
  41535. */
  41536. cameraDirection: Vector3;
  41537. /**
  41538. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41539. * This overrides and empties cameraRotation.
  41540. */
  41541. rotationQuaternion: Quaternion;
  41542. /**
  41543. * Track Roll to maintain the wanted Rolling when looking around.
  41544. */
  41545. _trackRoll: number;
  41546. /**
  41547. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41548. */
  41549. rollCorrect: number;
  41550. /**
  41551. * Mimic a banked turn, Rolling the camera when Yawing.
  41552. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41553. */
  41554. bankedTurn: boolean;
  41555. /**
  41556. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41557. */
  41558. bankedTurnLimit: number;
  41559. /**
  41560. * Value of 0 disables the banked Roll.
  41561. * Value of 1 is equal to the Yaw angle in radians.
  41562. */
  41563. bankedTurnMultiplier: number;
  41564. /**
  41565. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41566. */
  41567. inputs: FlyCameraInputsManager;
  41568. /**
  41569. * Gets the input sensibility for mouse input.
  41570. * Higher values reduce sensitivity.
  41571. */
  41572. get angularSensibility(): number;
  41573. /**
  41574. * Sets the input sensibility for a mouse input.
  41575. * Higher values reduce sensitivity.
  41576. */
  41577. set angularSensibility(value: number);
  41578. /**
  41579. * Get the keys for camera movement forward.
  41580. */
  41581. get keysForward(): number[];
  41582. /**
  41583. * Set the keys for camera movement forward.
  41584. */
  41585. set keysForward(value: number[]);
  41586. /**
  41587. * Get the keys for camera movement backward.
  41588. */
  41589. get keysBackward(): number[];
  41590. set keysBackward(value: number[]);
  41591. /**
  41592. * Get the keys for camera movement up.
  41593. */
  41594. get keysUp(): number[];
  41595. /**
  41596. * Set the keys for camera movement up.
  41597. */
  41598. set keysUp(value: number[]);
  41599. /**
  41600. * Get the keys for camera movement down.
  41601. */
  41602. get keysDown(): number[];
  41603. /**
  41604. * Set the keys for camera movement down.
  41605. */
  41606. set keysDown(value: number[]);
  41607. /**
  41608. * Get the keys for camera movement left.
  41609. */
  41610. get keysLeft(): number[];
  41611. /**
  41612. * Set the keys for camera movement left.
  41613. */
  41614. set keysLeft(value: number[]);
  41615. /**
  41616. * Set the keys for camera movement right.
  41617. */
  41618. get keysRight(): number[];
  41619. /**
  41620. * Set the keys for camera movement right.
  41621. */
  41622. set keysRight(value: number[]);
  41623. /**
  41624. * Event raised when the camera collides with a mesh in the scene.
  41625. */
  41626. onCollide: (collidedMesh: AbstractMesh) => void;
  41627. private _collider;
  41628. private _needMoveForGravity;
  41629. private _oldPosition;
  41630. private _diffPosition;
  41631. private _newPosition;
  41632. /** @hidden */
  41633. _localDirection: Vector3;
  41634. /** @hidden */
  41635. _transformedDirection: Vector3;
  41636. /**
  41637. * Instantiates a FlyCamera.
  41638. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41639. * such as in a 3D Space Shooter or a Flight Simulator.
  41640. * @param name Define the name of the camera in the scene.
  41641. * @param position Define the starting position of the camera in the scene.
  41642. * @param scene Define the scene the camera belongs to.
  41643. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41644. */
  41645. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41646. /**
  41647. * Attach a control to the HTML DOM element.
  41648. * @param element Defines the element that listens to the input events.
  41649. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41650. */
  41651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41652. /**
  41653. * Detach a control from the HTML DOM element.
  41654. * The camera will stop reacting to that input.
  41655. * @param element Defines the element that listens to the input events.
  41656. */
  41657. detachControl(element: HTMLElement): void;
  41658. private _collisionMask;
  41659. /**
  41660. * Get the mask that the camera ignores in collision events.
  41661. */
  41662. get collisionMask(): number;
  41663. /**
  41664. * Set the mask that the camera ignores in collision events.
  41665. */
  41666. set collisionMask(mask: number);
  41667. /** @hidden */
  41668. _collideWithWorld(displacement: Vector3): void;
  41669. /** @hidden */
  41670. private _onCollisionPositionChange;
  41671. /** @hidden */
  41672. _checkInputs(): void;
  41673. /** @hidden */
  41674. _decideIfNeedsToMove(): boolean;
  41675. /** @hidden */
  41676. _updatePosition(): void;
  41677. /**
  41678. * Restore the Roll to its target value at the rate specified.
  41679. * @param rate - Higher means slower restoring.
  41680. * @hidden
  41681. */
  41682. restoreRoll(rate: number): void;
  41683. /**
  41684. * Destroy the camera and release the current resources held by it.
  41685. */
  41686. dispose(): void;
  41687. /**
  41688. * Get the current object class name.
  41689. * @returns the class name.
  41690. */
  41691. getClassName(): string;
  41692. }
  41693. }
  41694. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41695. import { Nullable } from "babylonjs/types";
  41696. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41697. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41698. /**
  41699. * Listen to keyboard events to control the camera.
  41700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41701. */
  41702. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41703. /**
  41704. * Defines the camera the input is attached to.
  41705. */
  41706. camera: FlyCamera;
  41707. /**
  41708. * The list of keyboard keys used to control the forward move of the camera.
  41709. */
  41710. keysForward: number[];
  41711. /**
  41712. * The list of keyboard keys used to control the backward move of the camera.
  41713. */
  41714. keysBackward: number[];
  41715. /**
  41716. * The list of keyboard keys used to control the forward move of the camera.
  41717. */
  41718. keysUp: number[];
  41719. /**
  41720. * The list of keyboard keys used to control the backward move of the camera.
  41721. */
  41722. keysDown: number[];
  41723. /**
  41724. * The list of keyboard keys used to control the right strafe move of the camera.
  41725. */
  41726. keysRight: number[];
  41727. /**
  41728. * The list of keyboard keys used to control the left strafe move of the camera.
  41729. */
  41730. keysLeft: number[];
  41731. private _keys;
  41732. private _onCanvasBlurObserver;
  41733. private _onKeyboardObserver;
  41734. private _engine;
  41735. private _scene;
  41736. /**
  41737. * Attach the input controls to a specific dom element to get the input from.
  41738. * @param element Defines the element the controls should be listened from
  41739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41740. */
  41741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41742. /**
  41743. * Detach the current controls from the specified dom element.
  41744. * @param element Defines the element to stop listening the inputs from
  41745. */
  41746. detachControl(element: Nullable<HTMLElement>): void;
  41747. /**
  41748. * Gets the class name of the current intput.
  41749. * @returns the class name
  41750. */
  41751. getClassName(): string;
  41752. /** @hidden */
  41753. _onLostFocus(e: FocusEvent): void;
  41754. /**
  41755. * Get the friendly name associated with the input class.
  41756. * @returns the input friendly name
  41757. */
  41758. getSimpleName(): string;
  41759. /**
  41760. * Update the current camera state depending on the inputs that have been used this frame.
  41761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41762. */
  41763. checkInputs(): void;
  41764. }
  41765. }
  41766. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41767. import { Nullable } from "babylonjs/types";
  41768. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41769. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41770. /**
  41771. * Manage the mouse wheel inputs to control a follow camera.
  41772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41773. */
  41774. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41775. /**
  41776. * Defines the camera the input is attached to.
  41777. */
  41778. camera: FollowCamera;
  41779. /**
  41780. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41781. */
  41782. axisControlRadius: boolean;
  41783. /**
  41784. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41785. */
  41786. axisControlHeight: boolean;
  41787. /**
  41788. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41789. */
  41790. axisControlRotation: boolean;
  41791. /**
  41792. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41793. * relation to mouseWheel events.
  41794. */
  41795. wheelPrecision: number;
  41796. /**
  41797. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41798. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41799. */
  41800. wheelDeltaPercentage: number;
  41801. private _wheel;
  41802. private _observer;
  41803. /**
  41804. * Attach the input controls to a specific dom element to get the input from.
  41805. * @param element Defines the element the controls should be listened from
  41806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41807. */
  41808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41809. /**
  41810. * Detach the current controls from the specified dom element.
  41811. * @param element Defines the element to stop listening the inputs from
  41812. */
  41813. detachControl(element: Nullable<HTMLElement>): void;
  41814. /**
  41815. * Gets the class name of the current intput.
  41816. * @returns the class name
  41817. */
  41818. getClassName(): string;
  41819. /**
  41820. * Get the friendly name associated with the input class.
  41821. * @returns the input friendly name
  41822. */
  41823. getSimpleName(): string;
  41824. }
  41825. }
  41826. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41827. import { Nullable } from "babylonjs/types";
  41828. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41829. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41830. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41831. /**
  41832. * Manage the pointers inputs to control an follow camera.
  41833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41834. */
  41835. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41836. /**
  41837. * Defines the camera the input is attached to.
  41838. */
  41839. camera: FollowCamera;
  41840. /**
  41841. * Gets the class name of the current input.
  41842. * @returns the class name
  41843. */
  41844. getClassName(): string;
  41845. /**
  41846. * Defines the pointer angular sensibility along the X axis or how fast is
  41847. * the camera rotating.
  41848. * A negative number will reverse the axis direction.
  41849. */
  41850. angularSensibilityX: number;
  41851. /**
  41852. * Defines the pointer angular sensibility along the Y axis or how fast is
  41853. * the camera rotating.
  41854. * A negative number will reverse the axis direction.
  41855. */
  41856. angularSensibilityY: number;
  41857. /**
  41858. * Defines the pointer pinch precision or how fast is the camera zooming.
  41859. * A negative number will reverse the axis direction.
  41860. */
  41861. pinchPrecision: number;
  41862. /**
  41863. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41864. * from 0.
  41865. * It defines the percentage of current camera.radius to use as delta when
  41866. * pinch zoom is used.
  41867. */
  41868. pinchDeltaPercentage: number;
  41869. /**
  41870. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41871. */
  41872. axisXControlRadius: boolean;
  41873. /**
  41874. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41875. */
  41876. axisXControlHeight: boolean;
  41877. /**
  41878. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41879. */
  41880. axisXControlRotation: boolean;
  41881. /**
  41882. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41883. */
  41884. axisYControlRadius: boolean;
  41885. /**
  41886. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41887. */
  41888. axisYControlHeight: boolean;
  41889. /**
  41890. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41891. */
  41892. axisYControlRotation: boolean;
  41893. /**
  41894. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41895. */
  41896. axisPinchControlRadius: boolean;
  41897. /**
  41898. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41899. */
  41900. axisPinchControlHeight: boolean;
  41901. /**
  41902. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41903. */
  41904. axisPinchControlRotation: boolean;
  41905. /**
  41906. * Log error messages if basic misconfiguration has occurred.
  41907. */
  41908. warningEnable: boolean;
  41909. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41910. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41911. private _warningCounter;
  41912. private _warning;
  41913. }
  41914. }
  41915. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41916. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41917. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41918. /**
  41919. * Default Inputs manager for the FollowCamera.
  41920. * It groups all the default supported inputs for ease of use.
  41921. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41922. */
  41923. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41924. /**
  41925. * Instantiates a new FollowCameraInputsManager.
  41926. * @param camera Defines the camera the inputs belong to
  41927. */
  41928. constructor(camera: FollowCamera);
  41929. /**
  41930. * Add keyboard input support to the input manager.
  41931. * @returns the current input manager
  41932. */
  41933. addKeyboard(): FollowCameraInputsManager;
  41934. /**
  41935. * Add mouse wheel input support to the input manager.
  41936. * @returns the current input manager
  41937. */
  41938. addMouseWheel(): FollowCameraInputsManager;
  41939. /**
  41940. * Add pointers input support to the input manager.
  41941. * @returns the current input manager
  41942. */
  41943. addPointers(): FollowCameraInputsManager;
  41944. /**
  41945. * Add orientation input support to the input manager.
  41946. * @returns the current input manager
  41947. */
  41948. addVRDeviceOrientation(): FollowCameraInputsManager;
  41949. }
  41950. }
  41951. declare module "babylonjs/Cameras/followCamera" {
  41952. import { Nullable } from "babylonjs/types";
  41953. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41954. import { Scene } from "babylonjs/scene";
  41955. import { Vector3 } from "babylonjs/Maths/math.vector";
  41956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41957. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41958. /**
  41959. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41960. * an arc rotate version arcFollowCamera are available.
  41961. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41962. */
  41963. export class FollowCamera extends TargetCamera {
  41964. /**
  41965. * Distance the follow camera should follow an object at
  41966. */
  41967. radius: number;
  41968. /**
  41969. * Minimum allowed distance of the camera to the axis of rotation
  41970. * (The camera can not get closer).
  41971. * This can help limiting how the Camera is able to move in the scene.
  41972. */
  41973. lowerRadiusLimit: Nullable<number>;
  41974. /**
  41975. * Maximum allowed distance of the camera to the axis of rotation
  41976. * (The camera can not get further).
  41977. * This can help limiting how the Camera is able to move in the scene.
  41978. */
  41979. upperRadiusLimit: Nullable<number>;
  41980. /**
  41981. * Define a rotation offset between the camera and the object it follows
  41982. */
  41983. rotationOffset: number;
  41984. /**
  41985. * Minimum allowed angle to camera position relative to target object.
  41986. * This can help limiting how the Camera is able to move in the scene.
  41987. */
  41988. lowerRotationOffsetLimit: Nullable<number>;
  41989. /**
  41990. * Maximum allowed angle to camera position relative to target object.
  41991. * This can help limiting how the Camera is able to move in the scene.
  41992. */
  41993. upperRotationOffsetLimit: Nullable<number>;
  41994. /**
  41995. * Define a height offset between the camera and the object it follows.
  41996. * It can help following an object from the top (like a car chaing a plane)
  41997. */
  41998. heightOffset: number;
  41999. /**
  42000. * Minimum allowed height of camera position relative to target object.
  42001. * This can help limiting how the Camera is able to move in the scene.
  42002. */
  42003. lowerHeightOffsetLimit: Nullable<number>;
  42004. /**
  42005. * Maximum allowed height of camera position relative to target object.
  42006. * This can help limiting how the Camera is able to move in the scene.
  42007. */
  42008. upperHeightOffsetLimit: Nullable<number>;
  42009. /**
  42010. * Define how fast the camera can accelerate to follow it s target.
  42011. */
  42012. cameraAcceleration: number;
  42013. /**
  42014. * Define the speed limit of the camera following an object.
  42015. */
  42016. maxCameraSpeed: number;
  42017. /**
  42018. * Define the target of the camera.
  42019. */
  42020. lockedTarget: Nullable<AbstractMesh>;
  42021. /**
  42022. * Defines the input associated with the camera.
  42023. */
  42024. inputs: FollowCameraInputsManager;
  42025. /**
  42026. * Instantiates the follow camera.
  42027. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42028. * @param name Define the name of the camera in the scene
  42029. * @param position Define the position of the camera
  42030. * @param scene Define the scene the camera belong to
  42031. * @param lockedTarget Define the target of the camera
  42032. */
  42033. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42034. private _follow;
  42035. /**
  42036. * Attached controls to the current camera.
  42037. * @param element Defines the element the controls should be listened from
  42038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42039. */
  42040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42041. /**
  42042. * Detach the current controls from the camera.
  42043. * The camera will stop reacting to inputs.
  42044. * @param element Defines the element to stop listening the inputs from
  42045. */
  42046. detachControl(element: HTMLElement): void;
  42047. /** @hidden */
  42048. _checkInputs(): void;
  42049. private _checkLimits;
  42050. /**
  42051. * Gets the camera class name.
  42052. * @returns the class name
  42053. */
  42054. getClassName(): string;
  42055. }
  42056. /**
  42057. * Arc Rotate version of the follow camera.
  42058. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42059. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42060. */
  42061. export class ArcFollowCamera extends TargetCamera {
  42062. /** The longitudinal angle of the camera */
  42063. alpha: number;
  42064. /** The latitudinal angle of the camera */
  42065. beta: number;
  42066. /** The radius of the camera from its target */
  42067. radius: number;
  42068. /** Define the camera target (the messh it should follow) */
  42069. target: Nullable<AbstractMesh>;
  42070. private _cartesianCoordinates;
  42071. /**
  42072. * Instantiates a new ArcFollowCamera
  42073. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42074. * @param name Define the name of the camera
  42075. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42076. * @param beta Define the rotation angle of the camera around the elevation axis
  42077. * @param radius Define the radius of the camera from its target point
  42078. * @param target Define the target of the camera
  42079. * @param scene Define the scene the camera belongs to
  42080. */
  42081. constructor(name: string,
  42082. /** The longitudinal angle of the camera */
  42083. alpha: number,
  42084. /** The latitudinal angle of the camera */
  42085. beta: number,
  42086. /** The radius of the camera from its target */
  42087. radius: number,
  42088. /** Define the camera target (the messh it should follow) */
  42089. target: Nullable<AbstractMesh>, scene: Scene);
  42090. private _follow;
  42091. /** @hidden */
  42092. _checkInputs(): void;
  42093. /**
  42094. * Returns the class name of the object.
  42095. * It is mostly used internally for serialization purposes.
  42096. */
  42097. getClassName(): string;
  42098. }
  42099. }
  42100. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42101. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42102. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42103. import { Nullable } from "babylonjs/types";
  42104. /**
  42105. * Manage the keyboard inputs to control the movement of a follow camera.
  42106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42107. */
  42108. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42109. /**
  42110. * Defines the camera the input is attached to.
  42111. */
  42112. camera: FollowCamera;
  42113. /**
  42114. * Defines the list of key codes associated with the up action (increase heightOffset)
  42115. */
  42116. keysHeightOffsetIncr: number[];
  42117. /**
  42118. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42119. */
  42120. keysHeightOffsetDecr: number[];
  42121. /**
  42122. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42123. */
  42124. keysHeightOffsetModifierAlt: boolean;
  42125. /**
  42126. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42127. */
  42128. keysHeightOffsetModifierCtrl: boolean;
  42129. /**
  42130. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42131. */
  42132. keysHeightOffsetModifierShift: boolean;
  42133. /**
  42134. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42135. */
  42136. keysRotationOffsetIncr: number[];
  42137. /**
  42138. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42139. */
  42140. keysRotationOffsetDecr: number[];
  42141. /**
  42142. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42143. */
  42144. keysRotationOffsetModifierAlt: boolean;
  42145. /**
  42146. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42147. */
  42148. keysRotationOffsetModifierCtrl: boolean;
  42149. /**
  42150. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42151. */
  42152. keysRotationOffsetModifierShift: boolean;
  42153. /**
  42154. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42155. */
  42156. keysRadiusIncr: number[];
  42157. /**
  42158. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42159. */
  42160. keysRadiusDecr: number[];
  42161. /**
  42162. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42163. */
  42164. keysRadiusModifierAlt: boolean;
  42165. /**
  42166. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42167. */
  42168. keysRadiusModifierCtrl: boolean;
  42169. /**
  42170. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42171. */
  42172. keysRadiusModifierShift: boolean;
  42173. /**
  42174. * Defines the rate of change of heightOffset.
  42175. */
  42176. heightSensibility: number;
  42177. /**
  42178. * Defines the rate of change of rotationOffset.
  42179. */
  42180. rotationSensibility: number;
  42181. /**
  42182. * Defines the rate of change of radius.
  42183. */
  42184. radiusSensibility: number;
  42185. private _keys;
  42186. private _ctrlPressed;
  42187. private _altPressed;
  42188. private _shiftPressed;
  42189. private _onCanvasBlurObserver;
  42190. private _onKeyboardObserver;
  42191. private _engine;
  42192. private _scene;
  42193. /**
  42194. * Attach the input controls to a specific dom element to get the input from.
  42195. * @param element Defines the element the controls should be listened from
  42196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42197. */
  42198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42199. /**
  42200. * Detach the current controls from the specified dom element.
  42201. * @param element Defines the element to stop listening the inputs from
  42202. */
  42203. detachControl(element: Nullable<HTMLElement>): void;
  42204. /**
  42205. * Update the current camera state depending on the inputs that have been used this frame.
  42206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42207. */
  42208. checkInputs(): void;
  42209. /**
  42210. * Gets the class name of the current input.
  42211. * @returns the class name
  42212. */
  42213. getClassName(): string;
  42214. /**
  42215. * Get the friendly name associated with the input class.
  42216. * @returns the input friendly name
  42217. */
  42218. getSimpleName(): string;
  42219. /**
  42220. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42221. * allow modification of the heightOffset value.
  42222. */
  42223. private _modifierHeightOffset;
  42224. /**
  42225. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42226. * allow modification of the rotationOffset value.
  42227. */
  42228. private _modifierRotationOffset;
  42229. /**
  42230. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42231. * allow modification of the radius value.
  42232. */
  42233. private _modifierRadius;
  42234. }
  42235. }
  42236. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42237. import { Nullable } from "babylonjs/types";
  42238. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42239. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42240. import { Observable } from "babylonjs/Misc/observable";
  42241. module "babylonjs/Cameras/freeCameraInputsManager" {
  42242. interface FreeCameraInputsManager {
  42243. /**
  42244. * @hidden
  42245. */
  42246. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42247. /**
  42248. * Add orientation input support to the input manager.
  42249. * @returns the current input manager
  42250. */
  42251. addDeviceOrientation(): FreeCameraInputsManager;
  42252. }
  42253. }
  42254. /**
  42255. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42256. * Screen rotation is taken into account.
  42257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42258. */
  42259. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42260. private _camera;
  42261. private _screenOrientationAngle;
  42262. private _constantTranform;
  42263. private _screenQuaternion;
  42264. private _alpha;
  42265. private _beta;
  42266. private _gamma;
  42267. /**
  42268. * Can be used to detect if a device orientation sensor is available on a device
  42269. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42270. * @returns a promise that will resolve on orientation change
  42271. */
  42272. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42273. /**
  42274. * @hidden
  42275. */
  42276. _onDeviceOrientationChangedObservable: Observable<void>;
  42277. /**
  42278. * Instantiates a new input
  42279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42280. */
  42281. constructor();
  42282. /**
  42283. * Define the camera controlled by the input.
  42284. */
  42285. get camera(): FreeCamera;
  42286. set camera(camera: FreeCamera);
  42287. /**
  42288. * Attach the input controls to a specific dom element to get the input from.
  42289. * @param element Defines the element the controls should be listened from
  42290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42291. */
  42292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42293. private _orientationChanged;
  42294. private _deviceOrientation;
  42295. /**
  42296. * Detach the current controls from the specified dom element.
  42297. * @param element Defines the element to stop listening the inputs from
  42298. */
  42299. detachControl(element: Nullable<HTMLElement>): void;
  42300. /**
  42301. * Update the current camera state depending on the inputs that have been used this frame.
  42302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42303. */
  42304. checkInputs(): void;
  42305. /**
  42306. * Gets the class name of the current intput.
  42307. * @returns the class name
  42308. */
  42309. getClassName(): string;
  42310. /**
  42311. * Get the friendly name associated with the input class.
  42312. * @returns the input friendly name
  42313. */
  42314. getSimpleName(): string;
  42315. }
  42316. }
  42317. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42318. import { Nullable } from "babylonjs/types";
  42319. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42320. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42321. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42322. /**
  42323. * Manage the gamepad inputs to control a free camera.
  42324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42325. */
  42326. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42327. /**
  42328. * Define the camera the input is attached to.
  42329. */
  42330. camera: FreeCamera;
  42331. /**
  42332. * Define the Gamepad controlling the input
  42333. */
  42334. gamepad: Nullable<Gamepad>;
  42335. /**
  42336. * Defines the gamepad rotation sensiblity.
  42337. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42338. */
  42339. gamepadAngularSensibility: number;
  42340. /**
  42341. * Defines the gamepad move sensiblity.
  42342. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42343. */
  42344. gamepadMoveSensibility: number;
  42345. private _yAxisScale;
  42346. /**
  42347. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42348. */
  42349. get invertYAxis(): boolean;
  42350. set invertYAxis(value: boolean);
  42351. private _onGamepadConnectedObserver;
  42352. private _onGamepadDisconnectedObserver;
  42353. private _cameraTransform;
  42354. private _deltaTransform;
  42355. private _vector3;
  42356. private _vector2;
  42357. /**
  42358. * Attach the input controls to a specific dom element to get the input from.
  42359. * @param element Defines the element the controls should be listened from
  42360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42361. */
  42362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42363. /**
  42364. * Detach the current controls from the specified dom element.
  42365. * @param element Defines the element to stop listening the inputs from
  42366. */
  42367. detachControl(element: Nullable<HTMLElement>): void;
  42368. /**
  42369. * Update the current camera state depending on the inputs that have been used this frame.
  42370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42371. */
  42372. checkInputs(): void;
  42373. /**
  42374. * Gets the class name of the current intput.
  42375. * @returns the class name
  42376. */
  42377. getClassName(): string;
  42378. /**
  42379. * Get the friendly name associated with the input class.
  42380. * @returns the input friendly name
  42381. */
  42382. getSimpleName(): string;
  42383. }
  42384. }
  42385. declare module "babylonjs/Misc/virtualJoystick" {
  42386. import { Nullable } from "babylonjs/types";
  42387. import { Vector3 } from "babylonjs/Maths/math.vector";
  42388. /**
  42389. * Defines the potential axis of a Joystick
  42390. */
  42391. export enum JoystickAxis {
  42392. /** X axis */
  42393. X = 0,
  42394. /** Y axis */
  42395. Y = 1,
  42396. /** Z axis */
  42397. Z = 2
  42398. }
  42399. /**
  42400. * Class used to define virtual joystick (used in touch mode)
  42401. */
  42402. export class VirtualJoystick {
  42403. /**
  42404. * Gets or sets a boolean indicating that left and right values must be inverted
  42405. */
  42406. reverseLeftRight: boolean;
  42407. /**
  42408. * Gets or sets a boolean indicating that up and down values must be inverted
  42409. */
  42410. reverseUpDown: boolean;
  42411. /**
  42412. * Gets the offset value for the position (ie. the change of the position value)
  42413. */
  42414. deltaPosition: Vector3;
  42415. /**
  42416. * Gets a boolean indicating if the virtual joystick was pressed
  42417. */
  42418. pressed: boolean;
  42419. /**
  42420. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42421. */
  42422. static Canvas: Nullable<HTMLCanvasElement>;
  42423. private static _globalJoystickIndex;
  42424. private static vjCanvasContext;
  42425. private static vjCanvasWidth;
  42426. private static vjCanvasHeight;
  42427. private static halfWidth;
  42428. private _action;
  42429. private _axisTargetedByLeftAndRight;
  42430. private _axisTargetedByUpAndDown;
  42431. private _joystickSensibility;
  42432. private _inversedSensibility;
  42433. private _joystickPointerID;
  42434. private _joystickColor;
  42435. private _joystickPointerPos;
  42436. private _joystickPreviousPointerPos;
  42437. private _joystickPointerStartPos;
  42438. private _deltaJoystickVector;
  42439. private _leftJoystick;
  42440. private _touches;
  42441. private _onPointerDownHandlerRef;
  42442. private _onPointerMoveHandlerRef;
  42443. private _onPointerUpHandlerRef;
  42444. private _onResize;
  42445. /**
  42446. * Creates a new virtual joystick
  42447. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42448. */
  42449. constructor(leftJoystick?: boolean);
  42450. /**
  42451. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42452. * @param newJoystickSensibility defines the new sensibility
  42453. */
  42454. setJoystickSensibility(newJoystickSensibility: number): void;
  42455. private _onPointerDown;
  42456. private _onPointerMove;
  42457. private _onPointerUp;
  42458. /**
  42459. * Change the color of the virtual joystick
  42460. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42461. */
  42462. setJoystickColor(newColor: string): void;
  42463. /**
  42464. * Defines a callback to call when the joystick is touched
  42465. * @param action defines the callback
  42466. */
  42467. setActionOnTouch(action: () => any): void;
  42468. /**
  42469. * Defines which axis you'd like to control for left & right
  42470. * @param axis defines the axis to use
  42471. */
  42472. setAxisForLeftRight(axis: JoystickAxis): void;
  42473. /**
  42474. * Defines which axis you'd like to control for up & down
  42475. * @param axis defines the axis to use
  42476. */
  42477. setAxisForUpDown(axis: JoystickAxis): void;
  42478. private _drawVirtualJoystick;
  42479. /**
  42480. * Release internal HTML canvas
  42481. */
  42482. releaseCanvas(): void;
  42483. }
  42484. }
  42485. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42486. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42487. import { Nullable } from "babylonjs/types";
  42488. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42489. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42490. module "babylonjs/Cameras/freeCameraInputsManager" {
  42491. interface FreeCameraInputsManager {
  42492. /**
  42493. * Add virtual joystick input support to the input manager.
  42494. * @returns the current input manager
  42495. */
  42496. addVirtualJoystick(): FreeCameraInputsManager;
  42497. }
  42498. }
  42499. /**
  42500. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42502. */
  42503. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42504. /**
  42505. * Defines the camera the input is attached to.
  42506. */
  42507. camera: FreeCamera;
  42508. private _leftjoystick;
  42509. private _rightjoystick;
  42510. /**
  42511. * Gets the left stick of the virtual joystick.
  42512. * @returns The virtual Joystick
  42513. */
  42514. getLeftJoystick(): VirtualJoystick;
  42515. /**
  42516. * Gets the right stick of the virtual joystick.
  42517. * @returns The virtual Joystick
  42518. */
  42519. getRightJoystick(): VirtualJoystick;
  42520. /**
  42521. * Update the current camera state depending on the inputs that have been used this frame.
  42522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42523. */
  42524. checkInputs(): void;
  42525. /**
  42526. * Attach the input controls to a specific dom element to get the input from.
  42527. * @param element Defines the element the controls should be listened from
  42528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42529. */
  42530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42531. /**
  42532. * Detach the current controls from the specified dom element.
  42533. * @param element Defines the element to stop listening the inputs from
  42534. */
  42535. detachControl(element: Nullable<HTMLElement>): void;
  42536. /**
  42537. * Gets the class name of the current intput.
  42538. * @returns the class name
  42539. */
  42540. getClassName(): string;
  42541. /**
  42542. * Get the friendly name associated with the input class.
  42543. * @returns the input friendly name
  42544. */
  42545. getSimpleName(): string;
  42546. }
  42547. }
  42548. declare module "babylonjs/Cameras/Inputs/index" {
  42549. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42550. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42551. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42552. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42553. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42554. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42555. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42556. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42557. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42558. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42559. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42560. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42561. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42562. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42563. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42564. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42565. }
  42566. declare module "babylonjs/Cameras/touchCamera" {
  42567. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42568. import { Scene } from "babylonjs/scene";
  42569. import { Vector3 } from "babylonjs/Maths/math.vector";
  42570. /**
  42571. * This represents a FPS type of camera controlled by touch.
  42572. * This is like a universal camera minus the Gamepad controls.
  42573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42574. */
  42575. export class TouchCamera extends FreeCamera {
  42576. /**
  42577. * Defines the touch sensibility for rotation.
  42578. * The higher the faster.
  42579. */
  42580. get touchAngularSensibility(): number;
  42581. set touchAngularSensibility(value: number);
  42582. /**
  42583. * Defines the touch sensibility for move.
  42584. * The higher the faster.
  42585. */
  42586. get touchMoveSensibility(): number;
  42587. set touchMoveSensibility(value: number);
  42588. /**
  42589. * Instantiates a new touch camera.
  42590. * This represents a FPS type of camera controlled by touch.
  42591. * This is like a universal camera minus the Gamepad controls.
  42592. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42593. * @param name Define the name of the camera in the scene
  42594. * @param position Define the start position of the camera in the scene
  42595. * @param scene Define the scene the camera belongs to
  42596. */
  42597. constructor(name: string, position: Vector3, scene: Scene);
  42598. /**
  42599. * Gets the current object class name.
  42600. * @return the class name
  42601. */
  42602. getClassName(): string;
  42603. /** @hidden */
  42604. _setupInputs(): void;
  42605. }
  42606. }
  42607. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42608. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42609. import { Scene } from "babylonjs/scene";
  42610. import { Vector3 } from "babylonjs/Maths/math.vector";
  42611. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42612. import { Axis } from "babylonjs/Maths/math.axis";
  42613. /**
  42614. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42615. * being tilted forward or back and left or right.
  42616. */
  42617. export class DeviceOrientationCamera extends FreeCamera {
  42618. private _initialQuaternion;
  42619. private _quaternionCache;
  42620. private _tmpDragQuaternion;
  42621. private _disablePointerInputWhenUsingDeviceOrientation;
  42622. /**
  42623. * Creates a new device orientation camera
  42624. * @param name The name of the camera
  42625. * @param position The start position camera
  42626. * @param scene The scene the camera belongs to
  42627. */
  42628. constructor(name: string, position: Vector3, scene: Scene);
  42629. /**
  42630. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42631. */
  42632. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42633. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42634. private _dragFactor;
  42635. /**
  42636. * Enabled turning on the y axis when the orientation sensor is active
  42637. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42638. */
  42639. enableHorizontalDragging(dragFactor?: number): void;
  42640. /**
  42641. * Gets the current instance class name ("DeviceOrientationCamera").
  42642. * This helps avoiding instanceof at run time.
  42643. * @returns the class name
  42644. */
  42645. getClassName(): string;
  42646. /**
  42647. * @hidden
  42648. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42649. */
  42650. _checkInputs(): void;
  42651. /**
  42652. * Reset the camera to its default orientation on the specified axis only.
  42653. * @param axis The axis to reset
  42654. */
  42655. resetToCurrentRotation(axis?: Axis): void;
  42656. }
  42657. }
  42658. declare module "babylonjs/Gamepads/xboxGamepad" {
  42659. import { Observable } from "babylonjs/Misc/observable";
  42660. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42661. /**
  42662. * Defines supported buttons for XBox360 compatible gamepads
  42663. */
  42664. export enum Xbox360Button {
  42665. /** A */
  42666. A = 0,
  42667. /** B */
  42668. B = 1,
  42669. /** X */
  42670. X = 2,
  42671. /** Y */
  42672. Y = 3,
  42673. /** Left button */
  42674. LB = 4,
  42675. /** Right button */
  42676. RB = 5,
  42677. /** Back */
  42678. Back = 8,
  42679. /** Start */
  42680. Start = 9,
  42681. /** Left stick */
  42682. LeftStick = 10,
  42683. /** Right stick */
  42684. RightStick = 11
  42685. }
  42686. /** Defines values for XBox360 DPad */
  42687. export enum Xbox360Dpad {
  42688. /** Up */
  42689. Up = 12,
  42690. /** Down */
  42691. Down = 13,
  42692. /** Left */
  42693. Left = 14,
  42694. /** Right */
  42695. Right = 15
  42696. }
  42697. /**
  42698. * Defines a XBox360 gamepad
  42699. */
  42700. export class Xbox360Pad extends Gamepad {
  42701. private _leftTrigger;
  42702. private _rightTrigger;
  42703. private _onlefttriggerchanged;
  42704. private _onrighttriggerchanged;
  42705. private _onbuttondown;
  42706. private _onbuttonup;
  42707. private _ondpaddown;
  42708. private _ondpadup;
  42709. /** Observable raised when a button is pressed */
  42710. onButtonDownObservable: Observable<Xbox360Button>;
  42711. /** Observable raised when a button is released */
  42712. onButtonUpObservable: Observable<Xbox360Button>;
  42713. /** Observable raised when a pad is pressed */
  42714. onPadDownObservable: Observable<Xbox360Dpad>;
  42715. /** Observable raised when a pad is released */
  42716. onPadUpObservable: Observable<Xbox360Dpad>;
  42717. private _buttonA;
  42718. private _buttonB;
  42719. private _buttonX;
  42720. private _buttonY;
  42721. private _buttonBack;
  42722. private _buttonStart;
  42723. private _buttonLB;
  42724. private _buttonRB;
  42725. private _buttonLeftStick;
  42726. private _buttonRightStick;
  42727. private _dPadUp;
  42728. private _dPadDown;
  42729. private _dPadLeft;
  42730. private _dPadRight;
  42731. private _isXboxOnePad;
  42732. /**
  42733. * Creates a new XBox360 gamepad object
  42734. * @param id defines the id of this gamepad
  42735. * @param index defines its index
  42736. * @param gamepad defines the internal HTML gamepad object
  42737. * @param xboxOne defines if it is a XBox One gamepad
  42738. */
  42739. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42740. /**
  42741. * Defines the callback to call when left trigger is pressed
  42742. * @param callback defines the callback to use
  42743. */
  42744. onlefttriggerchanged(callback: (value: number) => void): void;
  42745. /**
  42746. * Defines the callback to call when right trigger is pressed
  42747. * @param callback defines the callback to use
  42748. */
  42749. onrighttriggerchanged(callback: (value: number) => void): void;
  42750. /**
  42751. * Gets the left trigger value
  42752. */
  42753. get leftTrigger(): number;
  42754. /**
  42755. * Sets the left trigger value
  42756. */
  42757. set leftTrigger(newValue: number);
  42758. /**
  42759. * Gets the right trigger value
  42760. */
  42761. get rightTrigger(): number;
  42762. /**
  42763. * Sets the right trigger value
  42764. */
  42765. set rightTrigger(newValue: number);
  42766. /**
  42767. * Defines the callback to call when a button is pressed
  42768. * @param callback defines the callback to use
  42769. */
  42770. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42771. /**
  42772. * Defines the callback to call when a button is released
  42773. * @param callback defines the callback to use
  42774. */
  42775. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42776. /**
  42777. * Defines the callback to call when a pad is pressed
  42778. * @param callback defines the callback to use
  42779. */
  42780. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42781. /**
  42782. * Defines the callback to call when a pad is released
  42783. * @param callback defines the callback to use
  42784. */
  42785. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42786. private _setButtonValue;
  42787. private _setDPadValue;
  42788. /**
  42789. * Gets the value of the `A` button
  42790. */
  42791. get buttonA(): number;
  42792. /**
  42793. * Sets the value of the `A` button
  42794. */
  42795. set buttonA(value: number);
  42796. /**
  42797. * Gets the value of the `B` button
  42798. */
  42799. get buttonB(): number;
  42800. /**
  42801. * Sets the value of the `B` button
  42802. */
  42803. set buttonB(value: number);
  42804. /**
  42805. * Gets the value of the `X` button
  42806. */
  42807. get buttonX(): number;
  42808. /**
  42809. * Sets the value of the `X` button
  42810. */
  42811. set buttonX(value: number);
  42812. /**
  42813. * Gets the value of the `Y` button
  42814. */
  42815. get buttonY(): number;
  42816. /**
  42817. * Sets the value of the `Y` button
  42818. */
  42819. set buttonY(value: number);
  42820. /**
  42821. * Gets the value of the `Start` button
  42822. */
  42823. get buttonStart(): number;
  42824. /**
  42825. * Sets the value of the `Start` button
  42826. */
  42827. set buttonStart(value: number);
  42828. /**
  42829. * Gets the value of the `Back` button
  42830. */
  42831. get buttonBack(): number;
  42832. /**
  42833. * Sets the value of the `Back` button
  42834. */
  42835. set buttonBack(value: number);
  42836. /**
  42837. * Gets the value of the `Left` button
  42838. */
  42839. get buttonLB(): number;
  42840. /**
  42841. * Sets the value of the `Left` button
  42842. */
  42843. set buttonLB(value: number);
  42844. /**
  42845. * Gets the value of the `Right` button
  42846. */
  42847. get buttonRB(): number;
  42848. /**
  42849. * Sets the value of the `Right` button
  42850. */
  42851. set buttonRB(value: number);
  42852. /**
  42853. * Gets the value of the Left joystick
  42854. */
  42855. get buttonLeftStick(): number;
  42856. /**
  42857. * Sets the value of the Left joystick
  42858. */
  42859. set buttonLeftStick(value: number);
  42860. /**
  42861. * Gets the value of the Right joystick
  42862. */
  42863. get buttonRightStick(): number;
  42864. /**
  42865. * Sets the value of the Right joystick
  42866. */
  42867. set buttonRightStick(value: number);
  42868. /**
  42869. * Gets the value of D-pad up
  42870. */
  42871. get dPadUp(): number;
  42872. /**
  42873. * Sets the value of D-pad up
  42874. */
  42875. set dPadUp(value: number);
  42876. /**
  42877. * Gets the value of D-pad down
  42878. */
  42879. get dPadDown(): number;
  42880. /**
  42881. * Sets the value of D-pad down
  42882. */
  42883. set dPadDown(value: number);
  42884. /**
  42885. * Gets the value of D-pad left
  42886. */
  42887. get dPadLeft(): number;
  42888. /**
  42889. * Sets the value of D-pad left
  42890. */
  42891. set dPadLeft(value: number);
  42892. /**
  42893. * Gets the value of D-pad right
  42894. */
  42895. get dPadRight(): number;
  42896. /**
  42897. * Sets the value of D-pad right
  42898. */
  42899. set dPadRight(value: number);
  42900. /**
  42901. * Force the gamepad to synchronize with device values
  42902. */
  42903. update(): void;
  42904. /**
  42905. * Disposes the gamepad
  42906. */
  42907. dispose(): void;
  42908. }
  42909. }
  42910. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42911. import { Observable } from "babylonjs/Misc/observable";
  42912. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42913. /**
  42914. * Defines supported buttons for DualShock compatible gamepads
  42915. */
  42916. export enum DualShockButton {
  42917. /** Cross */
  42918. Cross = 0,
  42919. /** Circle */
  42920. Circle = 1,
  42921. /** Square */
  42922. Square = 2,
  42923. /** Triangle */
  42924. Triangle = 3,
  42925. /** L1 */
  42926. L1 = 4,
  42927. /** R1 */
  42928. R1 = 5,
  42929. /** Share */
  42930. Share = 8,
  42931. /** Options */
  42932. Options = 9,
  42933. /** Left stick */
  42934. LeftStick = 10,
  42935. /** Right stick */
  42936. RightStick = 11
  42937. }
  42938. /** Defines values for DualShock DPad */
  42939. export enum DualShockDpad {
  42940. /** Up */
  42941. Up = 12,
  42942. /** Down */
  42943. Down = 13,
  42944. /** Left */
  42945. Left = 14,
  42946. /** Right */
  42947. Right = 15
  42948. }
  42949. /**
  42950. * Defines a DualShock gamepad
  42951. */
  42952. export class DualShockPad extends Gamepad {
  42953. private _leftTrigger;
  42954. private _rightTrigger;
  42955. private _onlefttriggerchanged;
  42956. private _onrighttriggerchanged;
  42957. private _onbuttondown;
  42958. private _onbuttonup;
  42959. private _ondpaddown;
  42960. private _ondpadup;
  42961. /** Observable raised when a button is pressed */
  42962. onButtonDownObservable: Observable<DualShockButton>;
  42963. /** Observable raised when a button is released */
  42964. onButtonUpObservable: Observable<DualShockButton>;
  42965. /** Observable raised when a pad is pressed */
  42966. onPadDownObservable: Observable<DualShockDpad>;
  42967. /** Observable raised when a pad is released */
  42968. onPadUpObservable: Observable<DualShockDpad>;
  42969. private _buttonCross;
  42970. private _buttonCircle;
  42971. private _buttonSquare;
  42972. private _buttonTriangle;
  42973. private _buttonShare;
  42974. private _buttonOptions;
  42975. private _buttonL1;
  42976. private _buttonR1;
  42977. private _buttonLeftStick;
  42978. private _buttonRightStick;
  42979. private _dPadUp;
  42980. private _dPadDown;
  42981. private _dPadLeft;
  42982. private _dPadRight;
  42983. /**
  42984. * Creates a new DualShock gamepad object
  42985. * @param id defines the id of this gamepad
  42986. * @param index defines its index
  42987. * @param gamepad defines the internal HTML gamepad object
  42988. */
  42989. constructor(id: string, index: number, gamepad: any);
  42990. /**
  42991. * Defines the callback to call when left trigger is pressed
  42992. * @param callback defines the callback to use
  42993. */
  42994. onlefttriggerchanged(callback: (value: number) => void): void;
  42995. /**
  42996. * Defines the callback to call when right trigger is pressed
  42997. * @param callback defines the callback to use
  42998. */
  42999. onrighttriggerchanged(callback: (value: number) => void): void;
  43000. /**
  43001. * Gets the left trigger value
  43002. */
  43003. get leftTrigger(): number;
  43004. /**
  43005. * Sets the left trigger value
  43006. */
  43007. set leftTrigger(newValue: number);
  43008. /**
  43009. * Gets the right trigger value
  43010. */
  43011. get rightTrigger(): number;
  43012. /**
  43013. * Sets the right trigger value
  43014. */
  43015. set rightTrigger(newValue: number);
  43016. /**
  43017. * Defines the callback to call when a button is pressed
  43018. * @param callback defines the callback to use
  43019. */
  43020. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43021. /**
  43022. * Defines the callback to call when a button is released
  43023. * @param callback defines the callback to use
  43024. */
  43025. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43026. /**
  43027. * Defines the callback to call when a pad is pressed
  43028. * @param callback defines the callback to use
  43029. */
  43030. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43031. /**
  43032. * Defines the callback to call when a pad is released
  43033. * @param callback defines the callback to use
  43034. */
  43035. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43036. private _setButtonValue;
  43037. private _setDPadValue;
  43038. /**
  43039. * Gets the value of the `Cross` button
  43040. */
  43041. get buttonCross(): number;
  43042. /**
  43043. * Sets the value of the `Cross` button
  43044. */
  43045. set buttonCross(value: number);
  43046. /**
  43047. * Gets the value of the `Circle` button
  43048. */
  43049. get buttonCircle(): number;
  43050. /**
  43051. * Sets the value of the `Circle` button
  43052. */
  43053. set buttonCircle(value: number);
  43054. /**
  43055. * Gets the value of the `Square` button
  43056. */
  43057. get buttonSquare(): number;
  43058. /**
  43059. * Sets the value of the `Square` button
  43060. */
  43061. set buttonSquare(value: number);
  43062. /**
  43063. * Gets the value of the `Triangle` button
  43064. */
  43065. get buttonTriangle(): number;
  43066. /**
  43067. * Sets the value of the `Triangle` button
  43068. */
  43069. set buttonTriangle(value: number);
  43070. /**
  43071. * Gets the value of the `Options` button
  43072. */
  43073. get buttonOptions(): number;
  43074. /**
  43075. * Sets the value of the `Options` button
  43076. */
  43077. set buttonOptions(value: number);
  43078. /**
  43079. * Gets the value of the `Share` button
  43080. */
  43081. get buttonShare(): number;
  43082. /**
  43083. * Sets the value of the `Share` button
  43084. */
  43085. set buttonShare(value: number);
  43086. /**
  43087. * Gets the value of the `L1` button
  43088. */
  43089. get buttonL1(): number;
  43090. /**
  43091. * Sets the value of the `L1` button
  43092. */
  43093. set buttonL1(value: number);
  43094. /**
  43095. * Gets the value of the `R1` button
  43096. */
  43097. get buttonR1(): number;
  43098. /**
  43099. * Sets the value of the `R1` button
  43100. */
  43101. set buttonR1(value: number);
  43102. /**
  43103. * Gets the value of the Left joystick
  43104. */
  43105. get buttonLeftStick(): number;
  43106. /**
  43107. * Sets the value of the Left joystick
  43108. */
  43109. set buttonLeftStick(value: number);
  43110. /**
  43111. * Gets the value of the Right joystick
  43112. */
  43113. get buttonRightStick(): number;
  43114. /**
  43115. * Sets the value of the Right joystick
  43116. */
  43117. set buttonRightStick(value: number);
  43118. /**
  43119. * Gets the value of D-pad up
  43120. */
  43121. get dPadUp(): number;
  43122. /**
  43123. * Sets the value of D-pad up
  43124. */
  43125. set dPadUp(value: number);
  43126. /**
  43127. * Gets the value of D-pad down
  43128. */
  43129. get dPadDown(): number;
  43130. /**
  43131. * Sets the value of D-pad down
  43132. */
  43133. set dPadDown(value: number);
  43134. /**
  43135. * Gets the value of D-pad left
  43136. */
  43137. get dPadLeft(): number;
  43138. /**
  43139. * Sets the value of D-pad left
  43140. */
  43141. set dPadLeft(value: number);
  43142. /**
  43143. * Gets the value of D-pad right
  43144. */
  43145. get dPadRight(): number;
  43146. /**
  43147. * Sets the value of D-pad right
  43148. */
  43149. set dPadRight(value: number);
  43150. /**
  43151. * Force the gamepad to synchronize with device values
  43152. */
  43153. update(): void;
  43154. /**
  43155. * Disposes the gamepad
  43156. */
  43157. dispose(): void;
  43158. }
  43159. }
  43160. declare module "babylonjs/Gamepads/gamepadManager" {
  43161. import { Observable } from "babylonjs/Misc/observable";
  43162. import { Nullable } from "babylonjs/types";
  43163. import { Scene } from "babylonjs/scene";
  43164. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43165. /**
  43166. * Manager for handling gamepads
  43167. */
  43168. export class GamepadManager {
  43169. private _scene?;
  43170. private _babylonGamepads;
  43171. private _oneGamepadConnected;
  43172. /** @hidden */
  43173. _isMonitoring: boolean;
  43174. private _gamepadEventSupported;
  43175. private _gamepadSupport?;
  43176. /**
  43177. * observable to be triggered when the gamepad controller has been connected
  43178. */
  43179. onGamepadConnectedObservable: Observable<Gamepad>;
  43180. /**
  43181. * observable to be triggered when the gamepad controller has been disconnected
  43182. */
  43183. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43184. private _onGamepadConnectedEvent;
  43185. private _onGamepadDisconnectedEvent;
  43186. /**
  43187. * Initializes the gamepad manager
  43188. * @param _scene BabylonJS scene
  43189. */
  43190. constructor(_scene?: Scene | undefined);
  43191. /**
  43192. * The gamepads in the game pad manager
  43193. */
  43194. get gamepads(): Gamepad[];
  43195. /**
  43196. * Get the gamepad controllers based on type
  43197. * @param type The type of gamepad controller
  43198. * @returns Nullable gamepad
  43199. */
  43200. getGamepadByType(type?: number): Nullable<Gamepad>;
  43201. /**
  43202. * Disposes the gamepad manager
  43203. */
  43204. dispose(): void;
  43205. private _addNewGamepad;
  43206. private _startMonitoringGamepads;
  43207. private _stopMonitoringGamepads;
  43208. /** @hidden */
  43209. _checkGamepadsStatus(): void;
  43210. private _updateGamepadObjects;
  43211. }
  43212. }
  43213. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43214. import { Nullable } from "babylonjs/types";
  43215. import { Scene } from "babylonjs/scene";
  43216. import { ISceneComponent } from "babylonjs/sceneComponent";
  43217. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43218. module "babylonjs/scene" {
  43219. interface Scene {
  43220. /** @hidden */
  43221. _gamepadManager: Nullable<GamepadManager>;
  43222. /**
  43223. * Gets the gamepad manager associated with the scene
  43224. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43225. */
  43226. gamepadManager: GamepadManager;
  43227. }
  43228. }
  43229. module "babylonjs/Cameras/freeCameraInputsManager" {
  43230. /**
  43231. * Interface representing a free camera inputs manager
  43232. */
  43233. interface FreeCameraInputsManager {
  43234. /**
  43235. * Adds gamepad input support to the FreeCameraInputsManager.
  43236. * @returns the FreeCameraInputsManager
  43237. */
  43238. addGamepad(): FreeCameraInputsManager;
  43239. }
  43240. }
  43241. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43242. /**
  43243. * Interface representing an arc rotate camera inputs manager
  43244. */
  43245. interface ArcRotateCameraInputsManager {
  43246. /**
  43247. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43248. * @returns the camera inputs manager
  43249. */
  43250. addGamepad(): ArcRotateCameraInputsManager;
  43251. }
  43252. }
  43253. /**
  43254. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43255. */
  43256. export class GamepadSystemSceneComponent implements ISceneComponent {
  43257. /**
  43258. * The component name helpfull to identify the component in the list of scene components.
  43259. */
  43260. readonly name: string;
  43261. /**
  43262. * The scene the component belongs to.
  43263. */
  43264. scene: Scene;
  43265. /**
  43266. * Creates a new instance of the component for the given scene
  43267. * @param scene Defines the scene to register the component in
  43268. */
  43269. constructor(scene: Scene);
  43270. /**
  43271. * Registers the component in a given scene
  43272. */
  43273. register(): void;
  43274. /**
  43275. * Rebuilds the elements related to this component in case of
  43276. * context lost for instance.
  43277. */
  43278. rebuild(): void;
  43279. /**
  43280. * Disposes the component and the associated ressources
  43281. */
  43282. dispose(): void;
  43283. private _beforeCameraUpdate;
  43284. }
  43285. }
  43286. declare module "babylonjs/Cameras/universalCamera" {
  43287. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43288. import { Scene } from "babylonjs/scene";
  43289. import { Vector3 } from "babylonjs/Maths/math.vector";
  43290. import "babylonjs/Gamepads/gamepadSceneComponent";
  43291. /**
  43292. * 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,
  43293. * which still works and will still be found in many Playgrounds.
  43294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43295. */
  43296. export class UniversalCamera extends TouchCamera {
  43297. /**
  43298. * Defines the gamepad rotation sensiblity.
  43299. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43300. */
  43301. get gamepadAngularSensibility(): number;
  43302. set gamepadAngularSensibility(value: number);
  43303. /**
  43304. * Defines the gamepad move sensiblity.
  43305. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43306. */
  43307. get gamepadMoveSensibility(): number;
  43308. set gamepadMoveSensibility(value: number);
  43309. /**
  43310. * 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,
  43311. * which still works and will still be found in many Playgrounds.
  43312. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43313. * @param name Define the name of the camera in the scene
  43314. * @param position Define the start position of the camera in the scene
  43315. * @param scene Define the scene the camera belongs to
  43316. */
  43317. constructor(name: string, position: Vector3, scene: Scene);
  43318. /**
  43319. * Gets the current object class name.
  43320. * @return the class name
  43321. */
  43322. getClassName(): string;
  43323. }
  43324. }
  43325. declare module "babylonjs/Cameras/gamepadCamera" {
  43326. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43327. import { Scene } from "babylonjs/scene";
  43328. import { Vector3 } from "babylonjs/Maths/math.vector";
  43329. /**
  43330. * This represents a FPS type of camera. This is only here for back compat purpose.
  43331. * Please use the UniversalCamera instead as both are identical.
  43332. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43333. */
  43334. export class GamepadCamera extends UniversalCamera {
  43335. /**
  43336. * Instantiates a new Gamepad Camera
  43337. * This represents a FPS type of camera. This is only here for back compat purpose.
  43338. * Please use the UniversalCamera instead as both are identical.
  43339. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43340. * @param name Define the name of the camera in the scene
  43341. * @param position Define the start position of the camera in the scene
  43342. * @param scene Define the scene the camera belongs to
  43343. */
  43344. constructor(name: string, position: Vector3, scene: Scene);
  43345. /**
  43346. * Gets the current object class name.
  43347. * @return the class name
  43348. */
  43349. getClassName(): string;
  43350. }
  43351. }
  43352. declare module "babylonjs/Shaders/pass.fragment" {
  43353. /** @hidden */
  43354. export var passPixelShader: {
  43355. name: string;
  43356. shader: string;
  43357. };
  43358. }
  43359. declare module "babylonjs/Shaders/passCube.fragment" {
  43360. /** @hidden */
  43361. export var passCubePixelShader: {
  43362. name: string;
  43363. shader: string;
  43364. };
  43365. }
  43366. declare module "babylonjs/PostProcesses/passPostProcess" {
  43367. import { Nullable } from "babylonjs/types";
  43368. import { Camera } from "babylonjs/Cameras/camera";
  43369. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43370. import { Engine } from "babylonjs/Engines/engine";
  43371. import "babylonjs/Shaders/pass.fragment";
  43372. import "babylonjs/Shaders/passCube.fragment";
  43373. /**
  43374. * PassPostProcess which produces an output the same as it's input
  43375. */
  43376. export class PassPostProcess extends PostProcess {
  43377. /**
  43378. * Creates the PassPostProcess
  43379. * @param name The name of the effect.
  43380. * @param options The required width/height ratio to downsize to before computing the render pass.
  43381. * @param camera The camera to apply the render pass to.
  43382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43383. * @param engine The engine which the post process will be applied. (default: current engine)
  43384. * @param reusable If the post process can be reused on the same frame. (default: false)
  43385. * @param textureType The type of texture to be used when performing the post processing.
  43386. * @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)
  43387. */
  43388. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43389. }
  43390. /**
  43391. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43392. */
  43393. export class PassCubePostProcess extends PostProcess {
  43394. private _face;
  43395. /**
  43396. * Gets or sets the cube face to display.
  43397. * * 0 is +X
  43398. * * 1 is -X
  43399. * * 2 is +Y
  43400. * * 3 is -Y
  43401. * * 4 is +Z
  43402. * * 5 is -Z
  43403. */
  43404. get face(): number;
  43405. set face(value: number);
  43406. /**
  43407. * Creates the PassCubePostProcess
  43408. * @param name The name of the effect.
  43409. * @param options The required width/height ratio to downsize to before computing the render pass.
  43410. * @param camera The camera to apply the render pass to.
  43411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43412. * @param engine The engine which the post process will be applied. (default: current engine)
  43413. * @param reusable If the post process can be reused on the same frame. (default: false)
  43414. * @param textureType The type of texture to be used when performing the post processing.
  43415. * @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)
  43416. */
  43417. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43418. }
  43419. }
  43420. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43421. /** @hidden */
  43422. export var anaglyphPixelShader: {
  43423. name: string;
  43424. shader: string;
  43425. };
  43426. }
  43427. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43428. import { Engine } from "babylonjs/Engines/engine";
  43429. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43430. import { Camera } from "babylonjs/Cameras/camera";
  43431. import "babylonjs/Shaders/anaglyph.fragment";
  43432. /**
  43433. * Postprocess used to generate anaglyphic rendering
  43434. */
  43435. export class AnaglyphPostProcess extends PostProcess {
  43436. private _passedProcess;
  43437. /**
  43438. * Creates a new AnaglyphPostProcess
  43439. * @param name defines postprocess name
  43440. * @param options defines creation options or target ratio scale
  43441. * @param rigCameras defines cameras using this postprocess
  43442. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43443. * @param engine defines hosting engine
  43444. * @param reusable defines if the postprocess will be reused multiple times per frame
  43445. */
  43446. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43447. }
  43448. }
  43449. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43450. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43451. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43452. import { Scene } from "babylonjs/scene";
  43453. import { Vector3 } from "babylonjs/Maths/math.vector";
  43454. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43455. /**
  43456. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43457. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43458. */
  43459. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43460. /**
  43461. * Creates a new AnaglyphArcRotateCamera
  43462. * @param name defines camera name
  43463. * @param alpha defines alpha angle (in radians)
  43464. * @param beta defines beta angle (in radians)
  43465. * @param radius defines radius
  43466. * @param target defines camera target
  43467. * @param interaxialDistance defines distance between each color axis
  43468. * @param scene defines the hosting scene
  43469. */
  43470. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43471. /**
  43472. * Gets camera class name
  43473. * @returns AnaglyphArcRotateCamera
  43474. */
  43475. getClassName(): string;
  43476. }
  43477. }
  43478. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43479. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43480. import { Scene } from "babylonjs/scene";
  43481. import { Vector3 } from "babylonjs/Maths/math.vector";
  43482. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43483. /**
  43484. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43485. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43486. */
  43487. export class AnaglyphFreeCamera extends FreeCamera {
  43488. /**
  43489. * Creates a new AnaglyphFreeCamera
  43490. * @param name defines camera name
  43491. * @param position defines initial position
  43492. * @param interaxialDistance defines distance between each color axis
  43493. * @param scene defines the hosting scene
  43494. */
  43495. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43496. /**
  43497. * Gets camera class name
  43498. * @returns AnaglyphFreeCamera
  43499. */
  43500. getClassName(): string;
  43501. }
  43502. }
  43503. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43504. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43505. import { Scene } from "babylonjs/scene";
  43506. import { Vector3 } from "babylonjs/Maths/math.vector";
  43507. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43508. /**
  43509. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43510. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43511. */
  43512. export class AnaglyphGamepadCamera extends GamepadCamera {
  43513. /**
  43514. * Creates a new AnaglyphGamepadCamera
  43515. * @param name defines camera name
  43516. * @param position defines initial position
  43517. * @param interaxialDistance defines distance between each color axis
  43518. * @param scene defines the hosting scene
  43519. */
  43520. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43521. /**
  43522. * Gets camera class name
  43523. * @returns AnaglyphGamepadCamera
  43524. */
  43525. getClassName(): string;
  43526. }
  43527. }
  43528. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43529. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43530. import { Scene } from "babylonjs/scene";
  43531. import { Vector3 } from "babylonjs/Maths/math.vector";
  43532. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43533. /**
  43534. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43535. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43536. */
  43537. export class AnaglyphUniversalCamera extends UniversalCamera {
  43538. /**
  43539. * Creates a new AnaglyphUniversalCamera
  43540. * @param name defines camera name
  43541. * @param position defines initial position
  43542. * @param interaxialDistance defines distance between each color axis
  43543. * @param scene defines the hosting scene
  43544. */
  43545. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43546. /**
  43547. * Gets camera class name
  43548. * @returns AnaglyphUniversalCamera
  43549. */
  43550. getClassName(): string;
  43551. }
  43552. }
  43553. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43554. /** @hidden */
  43555. export var stereoscopicInterlacePixelShader: {
  43556. name: string;
  43557. shader: string;
  43558. };
  43559. }
  43560. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43561. import { Camera } from "babylonjs/Cameras/camera";
  43562. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43563. import { Engine } from "babylonjs/Engines/engine";
  43564. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43565. /**
  43566. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43567. */
  43568. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43569. private _stepSize;
  43570. private _passedProcess;
  43571. /**
  43572. * Initializes a StereoscopicInterlacePostProcessI
  43573. * @param name The name of the effect.
  43574. * @param rigCameras The rig cameras to be appled to the post process
  43575. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43576. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43578. * @param engine The engine which the post process will be applied. (default: current engine)
  43579. * @param reusable If the post process can be reused on the same frame. (default: false)
  43580. */
  43581. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43582. }
  43583. /**
  43584. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43585. */
  43586. export class StereoscopicInterlacePostProcess extends PostProcess {
  43587. private _stepSize;
  43588. private _passedProcess;
  43589. /**
  43590. * Initializes a StereoscopicInterlacePostProcess
  43591. * @param name The name of the effect.
  43592. * @param rigCameras The rig cameras to be appled to the post process
  43593. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43595. * @param engine The engine which the post process will be applied. (default: current engine)
  43596. * @param reusable If the post process can be reused on the same frame. (default: false)
  43597. */
  43598. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43599. }
  43600. }
  43601. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43602. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43603. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43604. import { Scene } from "babylonjs/scene";
  43605. import { Vector3 } from "babylonjs/Maths/math.vector";
  43606. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43607. /**
  43608. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43609. * @see http://doc.babylonjs.com/features/cameras
  43610. */
  43611. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43612. /**
  43613. * Creates a new StereoscopicArcRotateCamera
  43614. * @param name defines camera name
  43615. * @param alpha defines alpha angle (in radians)
  43616. * @param beta defines beta angle (in radians)
  43617. * @param radius defines radius
  43618. * @param target defines camera target
  43619. * @param interaxialDistance defines distance between each color axis
  43620. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43621. * @param scene defines the hosting scene
  43622. */
  43623. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43624. /**
  43625. * Gets camera class name
  43626. * @returns StereoscopicArcRotateCamera
  43627. */
  43628. getClassName(): string;
  43629. }
  43630. }
  43631. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43632. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43633. import { Scene } from "babylonjs/scene";
  43634. import { Vector3 } from "babylonjs/Maths/math.vector";
  43635. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43636. /**
  43637. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43638. * @see http://doc.babylonjs.com/features/cameras
  43639. */
  43640. export class StereoscopicFreeCamera extends FreeCamera {
  43641. /**
  43642. * Creates a new StereoscopicFreeCamera
  43643. * @param name defines camera name
  43644. * @param position defines initial position
  43645. * @param interaxialDistance defines distance between each color axis
  43646. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43647. * @param scene defines the hosting scene
  43648. */
  43649. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43650. /**
  43651. * Gets camera class name
  43652. * @returns StereoscopicFreeCamera
  43653. */
  43654. getClassName(): string;
  43655. }
  43656. }
  43657. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43658. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43659. import { Scene } from "babylonjs/scene";
  43660. import { Vector3 } from "babylonjs/Maths/math.vector";
  43661. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43662. /**
  43663. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43664. * @see http://doc.babylonjs.com/features/cameras
  43665. */
  43666. export class StereoscopicGamepadCamera extends GamepadCamera {
  43667. /**
  43668. * Creates a new StereoscopicGamepadCamera
  43669. * @param name defines camera name
  43670. * @param position defines initial position
  43671. * @param interaxialDistance defines distance between each color axis
  43672. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43673. * @param scene defines the hosting scene
  43674. */
  43675. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43676. /**
  43677. * Gets camera class name
  43678. * @returns StereoscopicGamepadCamera
  43679. */
  43680. getClassName(): string;
  43681. }
  43682. }
  43683. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43684. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43685. import { Scene } from "babylonjs/scene";
  43686. import { Vector3 } from "babylonjs/Maths/math.vector";
  43687. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43688. /**
  43689. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43690. * @see http://doc.babylonjs.com/features/cameras
  43691. */
  43692. export class StereoscopicUniversalCamera extends UniversalCamera {
  43693. /**
  43694. * Creates a new StereoscopicUniversalCamera
  43695. * @param name defines camera name
  43696. * @param position defines initial position
  43697. * @param interaxialDistance defines distance between each color axis
  43698. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43699. * @param scene defines the hosting scene
  43700. */
  43701. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43702. /**
  43703. * Gets camera class name
  43704. * @returns StereoscopicUniversalCamera
  43705. */
  43706. getClassName(): string;
  43707. }
  43708. }
  43709. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43710. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43711. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43712. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43713. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43714. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43715. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43716. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43717. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43718. }
  43719. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43720. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43721. import { Scene } from "babylonjs/scene";
  43722. import { Vector3 } from "babylonjs/Maths/math.vector";
  43723. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43724. /**
  43725. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43726. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43727. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43728. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43729. */
  43730. export class VirtualJoysticksCamera extends FreeCamera {
  43731. /**
  43732. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43733. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43734. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43735. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43736. * @param name Define the name of the camera in the scene
  43737. * @param position Define the start position of the camera in the scene
  43738. * @param scene Define the scene the camera belongs to
  43739. */
  43740. constructor(name: string, position: Vector3, scene: Scene);
  43741. /**
  43742. * Gets the current object class name.
  43743. * @return the class name
  43744. */
  43745. getClassName(): string;
  43746. }
  43747. }
  43748. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43749. import { Matrix } from "babylonjs/Maths/math.vector";
  43750. /**
  43751. * This represents all the required metrics to create a VR camera.
  43752. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43753. */
  43754. export class VRCameraMetrics {
  43755. /**
  43756. * Define the horizontal resolution off the screen.
  43757. */
  43758. hResolution: number;
  43759. /**
  43760. * Define the vertical resolution off the screen.
  43761. */
  43762. vResolution: number;
  43763. /**
  43764. * Define the horizontal screen size.
  43765. */
  43766. hScreenSize: number;
  43767. /**
  43768. * Define the vertical screen size.
  43769. */
  43770. vScreenSize: number;
  43771. /**
  43772. * Define the vertical screen center position.
  43773. */
  43774. vScreenCenter: number;
  43775. /**
  43776. * Define the distance of the eyes to the screen.
  43777. */
  43778. eyeToScreenDistance: number;
  43779. /**
  43780. * Define the distance between both lenses
  43781. */
  43782. lensSeparationDistance: number;
  43783. /**
  43784. * Define the distance between both viewer's eyes.
  43785. */
  43786. interpupillaryDistance: number;
  43787. /**
  43788. * Define the distortion factor of the VR postprocess.
  43789. * Please, touch with care.
  43790. */
  43791. distortionK: number[];
  43792. /**
  43793. * Define the chromatic aberration correction factors for the VR post process.
  43794. */
  43795. chromaAbCorrection: number[];
  43796. /**
  43797. * Define the scale factor of the post process.
  43798. * The smaller the better but the slower.
  43799. */
  43800. postProcessScaleFactor: number;
  43801. /**
  43802. * Define an offset for the lens center.
  43803. */
  43804. lensCenterOffset: number;
  43805. /**
  43806. * Define if the current vr camera should compensate the distortion of the lense or not.
  43807. */
  43808. compensateDistortion: boolean;
  43809. /**
  43810. * Defines if multiview should be enabled when rendering (Default: false)
  43811. */
  43812. multiviewEnabled: boolean;
  43813. /**
  43814. * Gets the rendering aspect ratio based on the provided resolutions.
  43815. */
  43816. get aspectRatio(): number;
  43817. /**
  43818. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43819. */
  43820. get aspectRatioFov(): number;
  43821. /**
  43822. * @hidden
  43823. */
  43824. get leftHMatrix(): Matrix;
  43825. /**
  43826. * @hidden
  43827. */
  43828. get rightHMatrix(): Matrix;
  43829. /**
  43830. * @hidden
  43831. */
  43832. get leftPreViewMatrix(): Matrix;
  43833. /**
  43834. * @hidden
  43835. */
  43836. get rightPreViewMatrix(): Matrix;
  43837. /**
  43838. * Get the default VRMetrics based on the most generic setup.
  43839. * @returns the default vr metrics
  43840. */
  43841. static GetDefault(): VRCameraMetrics;
  43842. }
  43843. }
  43844. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43845. /** @hidden */
  43846. export var vrDistortionCorrectionPixelShader: {
  43847. name: string;
  43848. shader: string;
  43849. };
  43850. }
  43851. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43852. import { Camera } from "babylonjs/Cameras/camera";
  43853. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43854. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43855. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43856. /**
  43857. * VRDistortionCorrectionPostProcess used for mobile VR
  43858. */
  43859. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43860. private _isRightEye;
  43861. private _distortionFactors;
  43862. private _postProcessScaleFactor;
  43863. private _lensCenterOffset;
  43864. private _scaleIn;
  43865. private _scaleFactor;
  43866. private _lensCenter;
  43867. /**
  43868. * Initializes the VRDistortionCorrectionPostProcess
  43869. * @param name The name of the effect.
  43870. * @param camera The camera to apply the render pass to.
  43871. * @param isRightEye If this is for the right eye distortion
  43872. * @param vrMetrics All the required metrics for the VR camera
  43873. */
  43874. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43875. }
  43876. }
  43877. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43878. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43879. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43880. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43881. import { Scene } from "babylonjs/scene";
  43882. import { Vector3 } from "babylonjs/Maths/math.vector";
  43883. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43884. import "babylonjs/Cameras/RigModes/vrRigMode";
  43885. /**
  43886. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43887. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43888. */
  43889. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43890. /**
  43891. * Creates a new VRDeviceOrientationArcRotateCamera
  43892. * @param name defines camera name
  43893. * @param alpha defines the camera rotation along the logitudinal axis
  43894. * @param beta defines the camera rotation along the latitudinal axis
  43895. * @param radius defines the camera distance from its target
  43896. * @param target defines the camera target
  43897. * @param scene defines the scene the camera belongs to
  43898. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43899. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43900. */
  43901. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43902. /**
  43903. * Gets camera class name
  43904. * @returns VRDeviceOrientationArcRotateCamera
  43905. */
  43906. getClassName(): string;
  43907. }
  43908. }
  43909. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43910. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43911. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43912. import { Scene } from "babylonjs/scene";
  43913. import { Vector3 } from "babylonjs/Maths/math.vector";
  43914. import "babylonjs/Cameras/RigModes/vrRigMode";
  43915. /**
  43916. * Camera used to simulate VR rendering (based on FreeCamera)
  43917. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43918. */
  43919. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43920. /**
  43921. * Creates a new VRDeviceOrientationFreeCamera
  43922. * @param name defines camera name
  43923. * @param position defines the start position of the camera
  43924. * @param scene defines the scene the camera belongs to
  43925. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43926. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43927. */
  43928. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43929. /**
  43930. * Gets camera class name
  43931. * @returns VRDeviceOrientationFreeCamera
  43932. */
  43933. getClassName(): string;
  43934. }
  43935. }
  43936. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43937. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43938. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43939. import { Scene } from "babylonjs/scene";
  43940. import { Vector3 } from "babylonjs/Maths/math.vector";
  43941. import "babylonjs/Gamepads/gamepadSceneComponent";
  43942. /**
  43943. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43944. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43945. */
  43946. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43947. /**
  43948. * Creates a new VRDeviceOrientationGamepadCamera
  43949. * @param name defines camera name
  43950. * @param position defines the start position of the camera
  43951. * @param scene defines the scene the camera belongs to
  43952. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43953. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43954. */
  43955. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43956. /**
  43957. * Gets camera class name
  43958. * @returns VRDeviceOrientationGamepadCamera
  43959. */
  43960. getClassName(): string;
  43961. }
  43962. }
  43963. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43964. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43965. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43966. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43967. /** @hidden */
  43968. export var imageProcessingPixelShader: {
  43969. name: string;
  43970. shader: string;
  43971. };
  43972. }
  43973. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43974. import { Nullable } from "babylonjs/types";
  43975. import { Color4 } from "babylonjs/Maths/math.color";
  43976. import { Camera } from "babylonjs/Cameras/camera";
  43977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43978. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43979. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43981. import { Engine } from "babylonjs/Engines/engine";
  43982. import "babylonjs/Shaders/imageProcessing.fragment";
  43983. import "babylonjs/Shaders/postprocess.vertex";
  43984. /**
  43985. * ImageProcessingPostProcess
  43986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43987. */
  43988. export class ImageProcessingPostProcess extends PostProcess {
  43989. /**
  43990. * Default configuration related to image processing available in the PBR Material.
  43991. */
  43992. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43993. /**
  43994. * Gets the image processing configuration used either in this material.
  43995. */
  43996. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43997. /**
  43998. * Sets the Default image processing configuration used either in the this material.
  43999. *
  44000. * If sets to null, the scene one is in use.
  44001. */
  44002. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44003. /**
  44004. * Keep track of the image processing observer to allow dispose and replace.
  44005. */
  44006. private _imageProcessingObserver;
  44007. /**
  44008. * Attaches a new image processing configuration to the PBR Material.
  44009. * @param configuration
  44010. */
  44011. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44012. /**
  44013. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44014. */
  44015. get colorCurves(): Nullable<ColorCurves>;
  44016. /**
  44017. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44018. */
  44019. set colorCurves(value: Nullable<ColorCurves>);
  44020. /**
  44021. * Gets wether the color curves effect is enabled.
  44022. */
  44023. get colorCurvesEnabled(): boolean;
  44024. /**
  44025. * Sets wether the color curves effect is enabled.
  44026. */
  44027. set colorCurvesEnabled(value: boolean);
  44028. /**
  44029. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44030. */
  44031. get colorGradingTexture(): Nullable<BaseTexture>;
  44032. /**
  44033. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44034. */
  44035. set colorGradingTexture(value: Nullable<BaseTexture>);
  44036. /**
  44037. * Gets wether the color grading effect is enabled.
  44038. */
  44039. get colorGradingEnabled(): boolean;
  44040. /**
  44041. * Gets wether the color grading effect is enabled.
  44042. */
  44043. set colorGradingEnabled(value: boolean);
  44044. /**
  44045. * Gets exposure used in the effect.
  44046. */
  44047. get exposure(): number;
  44048. /**
  44049. * Sets exposure used in the effect.
  44050. */
  44051. set exposure(value: number);
  44052. /**
  44053. * Gets wether tonemapping is enabled or not.
  44054. */
  44055. get toneMappingEnabled(): boolean;
  44056. /**
  44057. * Sets wether tonemapping is enabled or not
  44058. */
  44059. set toneMappingEnabled(value: boolean);
  44060. /**
  44061. * Gets the type of tone mapping effect.
  44062. */
  44063. get toneMappingType(): number;
  44064. /**
  44065. * Sets the type of tone mapping effect.
  44066. */
  44067. set toneMappingType(value: number);
  44068. /**
  44069. * Gets contrast used in the effect.
  44070. */
  44071. get contrast(): number;
  44072. /**
  44073. * Sets contrast used in the effect.
  44074. */
  44075. set contrast(value: number);
  44076. /**
  44077. * Gets Vignette stretch size.
  44078. */
  44079. get vignetteStretch(): number;
  44080. /**
  44081. * Sets Vignette stretch size.
  44082. */
  44083. set vignetteStretch(value: number);
  44084. /**
  44085. * Gets Vignette centre X Offset.
  44086. */
  44087. get vignetteCentreX(): number;
  44088. /**
  44089. * Sets Vignette centre X Offset.
  44090. */
  44091. set vignetteCentreX(value: number);
  44092. /**
  44093. * Gets Vignette centre Y Offset.
  44094. */
  44095. get vignetteCentreY(): number;
  44096. /**
  44097. * Sets Vignette centre Y Offset.
  44098. */
  44099. set vignetteCentreY(value: number);
  44100. /**
  44101. * Gets Vignette weight or intensity of the vignette effect.
  44102. */
  44103. get vignetteWeight(): number;
  44104. /**
  44105. * Sets Vignette weight or intensity of the vignette effect.
  44106. */
  44107. set vignetteWeight(value: number);
  44108. /**
  44109. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44110. * if vignetteEnabled is set to true.
  44111. */
  44112. get vignetteColor(): Color4;
  44113. /**
  44114. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44115. * if vignetteEnabled is set to true.
  44116. */
  44117. set vignetteColor(value: Color4);
  44118. /**
  44119. * Gets Camera field of view used by the Vignette effect.
  44120. */
  44121. get vignetteCameraFov(): number;
  44122. /**
  44123. * Sets Camera field of view used by the Vignette effect.
  44124. */
  44125. set vignetteCameraFov(value: number);
  44126. /**
  44127. * Gets the vignette blend mode allowing different kind of effect.
  44128. */
  44129. get vignetteBlendMode(): number;
  44130. /**
  44131. * Sets the vignette blend mode allowing different kind of effect.
  44132. */
  44133. set vignetteBlendMode(value: number);
  44134. /**
  44135. * Gets wether the vignette effect is enabled.
  44136. */
  44137. get vignetteEnabled(): boolean;
  44138. /**
  44139. * Sets wether the vignette effect is enabled.
  44140. */
  44141. set vignetteEnabled(value: boolean);
  44142. private _fromLinearSpace;
  44143. /**
  44144. * Gets wether the input of the processing is in Gamma or Linear Space.
  44145. */
  44146. get fromLinearSpace(): boolean;
  44147. /**
  44148. * Sets wether the input of the processing is in Gamma or Linear Space.
  44149. */
  44150. set fromLinearSpace(value: boolean);
  44151. /**
  44152. * Defines cache preventing GC.
  44153. */
  44154. private _defines;
  44155. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44156. /**
  44157. * "ImageProcessingPostProcess"
  44158. * @returns "ImageProcessingPostProcess"
  44159. */
  44160. getClassName(): string;
  44161. protected _updateParameters(): void;
  44162. dispose(camera?: Camera): void;
  44163. }
  44164. }
  44165. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44166. import { Scene } from "babylonjs/scene";
  44167. import { Color3 } from "babylonjs/Maths/math.color";
  44168. import { Mesh } from "babylonjs/Meshes/mesh";
  44169. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44170. import { Nullable } from "babylonjs/types";
  44171. /**
  44172. * Class containing static functions to help procedurally build meshes
  44173. */
  44174. export class GroundBuilder {
  44175. /**
  44176. * Creates a ground mesh
  44177. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44178. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44180. * @param name defines the name of the mesh
  44181. * @param options defines the options used to create the mesh
  44182. * @param scene defines the hosting scene
  44183. * @returns the ground mesh
  44184. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44185. */
  44186. static CreateGround(name: string, options: {
  44187. width?: number;
  44188. height?: number;
  44189. subdivisions?: number;
  44190. subdivisionsX?: number;
  44191. subdivisionsY?: number;
  44192. updatable?: boolean;
  44193. }, scene: any): Mesh;
  44194. /**
  44195. * Creates a tiled ground mesh
  44196. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44197. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44198. * * 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
  44199. * * 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
  44200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44201. * @param name defines the name of the mesh
  44202. * @param options defines the options used to create the mesh
  44203. * @param scene defines the hosting scene
  44204. * @returns the tiled ground mesh
  44205. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44206. */
  44207. static CreateTiledGround(name: string, options: {
  44208. xmin: number;
  44209. zmin: number;
  44210. xmax: number;
  44211. zmax: number;
  44212. subdivisions?: {
  44213. w: number;
  44214. h: number;
  44215. };
  44216. precision?: {
  44217. w: number;
  44218. h: number;
  44219. };
  44220. updatable?: boolean;
  44221. }, scene?: Nullable<Scene>): Mesh;
  44222. /**
  44223. * Creates a ground mesh from a height map
  44224. * * The parameter `url` sets the URL of the height map image resource.
  44225. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44226. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44227. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44228. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44229. * * 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.
  44230. * * 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).
  44231. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44233. * @param name defines the name of the mesh
  44234. * @param url defines the url to the height map
  44235. * @param options defines the options used to create the mesh
  44236. * @param scene defines the hosting scene
  44237. * @returns the ground mesh
  44238. * @see https://doc.babylonjs.com/babylon101/height_map
  44239. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44240. */
  44241. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44242. width?: number;
  44243. height?: number;
  44244. subdivisions?: number;
  44245. minHeight?: number;
  44246. maxHeight?: number;
  44247. colorFilter?: Color3;
  44248. alphaFilter?: number;
  44249. updatable?: boolean;
  44250. onReady?: (mesh: GroundMesh) => void;
  44251. }, scene?: Nullable<Scene>): GroundMesh;
  44252. }
  44253. }
  44254. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44255. import { Vector4 } from "babylonjs/Maths/math.vector";
  44256. import { Mesh } from "babylonjs/Meshes/mesh";
  44257. /**
  44258. * Class containing static functions to help procedurally build meshes
  44259. */
  44260. export class TorusBuilder {
  44261. /**
  44262. * Creates a torus mesh
  44263. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44264. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44265. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44269. * @param name defines the name of the mesh
  44270. * @param options defines the options used to create the mesh
  44271. * @param scene defines the hosting scene
  44272. * @returns the torus mesh
  44273. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44274. */
  44275. static CreateTorus(name: string, options: {
  44276. diameter?: number;
  44277. thickness?: number;
  44278. tessellation?: number;
  44279. updatable?: boolean;
  44280. sideOrientation?: number;
  44281. frontUVs?: Vector4;
  44282. backUVs?: Vector4;
  44283. }, scene: any): Mesh;
  44284. }
  44285. }
  44286. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44287. import { Vector4 } from "babylonjs/Maths/math.vector";
  44288. import { Color4 } from "babylonjs/Maths/math.color";
  44289. import { Mesh } from "babylonjs/Meshes/mesh";
  44290. /**
  44291. * Class containing static functions to help procedurally build meshes
  44292. */
  44293. export class CylinderBuilder {
  44294. /**
  44295. * Creates a cylinder or a cone mesh
  44296. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44297. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44298. * * 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.
  44299. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44300. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44301. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44302. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44303. * * 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).
  44304. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44305. * * 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).
  44306. * * 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
  44307. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44308. * * 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
  44309. * * 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.
  44310. * * If `enclose` is false, a ring surface is one element.
  44311. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44312. * * 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
  44313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44316. * @param name defines the name of the mesh
  44317. * @param options defines the options used to create the mesh
  44318. * @param scene defines the hosting scene
  44319. * @returns the cylinder mesh
  44320. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44321. */
  44322. static CreateCylinder(name: string, options: {
  44323. height?: number;
  44324. diameterTop?: number;
  44325. diameterBottom?: number;
  44326. diameter?: number;
  44327. tessellation?: number;
  44328. subdivisions?: number;
  44329. arc?: number;
  44330. faceColors?: Color4[];
  44331. faceUV?: Vector4[];
  44332. updatable?: boolean;
  44333. hasRings?: boolean;
  44334. enclose?: boolean;
  44335. cap?: number;
  44336. sideOrientation?: number;
  44337. frontUVs?: Vector4;
  44338. backUVs?: Vector4;
  44339. }, scene: any): Mesh;
  44340. }
  44341. }
  44342. declare module "babylonjs/XR/webXRTypes" {
  44343. import { Nullable } from "babylonjs/types";
  44344. import { IDisposable } from "babylonjs/scene";
  44345. /**
  44346. * States of the webXR experience
  44347. */
  44348. export enum WebXRState {
  44349. /**
  44350. * Transitioning to being in XR mode
  44351. */
  44352. ENTERING_XR = 0,
  44353. /**
  44354. * Transitioning to non XR mode
  44355. */
  44356. EXITING_XR = 1,
  44357. /**
  44358. * In XR mode and presenting
  44359. */
  44360. IN_XR = 2,
  44361. /**
  44362. * Not entered XR mode
  44363. */
  44364. NOT_IN_XR = 3
  44365. }
  44366. /**
  44367. * Abstraction of the XR render target
  44368. */
  44369. export interface WebXRRenderTarget extends IDisposable {
  44370. /**
  44371. * xrpresent context of the canvas which can be used to display/mirror xr content
  44372. */
  44373. canvasContext: WebGLRenderingContext;
  44374. /**
  44375. * xr layer for the canvas
  44376. */
  44377. xrLayer: Nullable<XRWebGLLayer>;
  44378. /**
  44379. * Initializes the xr layer for the session
  44380. * @param xrSession xr session
  44381. * @returns a promise that will resolve once the XR Layer has been created
  44382. */
  44383. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44384. }
  44385. }
  44386. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44387. import { Nullable } from "babylonjs/types";
  44388. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44389. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44390. /**
  44391. * COnfiguration object for WebXR output canvas
  44392. */
  44393. export class WebXRManagedOutputCanvasOptions {
  44394. /**
  44395. * An optional canvas in case you wish to create it yourself and provide it here.
  44396. * If not provided, a new canvas will be created
  44397. */
  44398. canvasElement?: HTMLCanvasElement;
  44399. /**
  44400. * Options for this XR Layer output
  44401. */
  44402. canvasOptions?: XRWebGLLayerOptions;
  44403. /**
  44404. * CSS styling for a newly created canvas (if not provided)
  44405. */
  44406. newCanvasCssStyle?: string;
  44407. /**
  44408. * Get the default values of the configuration object
  44409. * @returns default values of this configuration object
  44410. */
  44411. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44412. }
  44413. /**
  44414. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44415. */
  44416. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44417. private _options;
  44418. private _canvas;
  44419. private _engine;
  44420. /**
  44421. * Rendering context of the canvas which can be used to display/mirror xr content
  44422. */
  44423. canvasContext: WebGLRenderingContext;
  44424. /**
  44425. * xr layer for the canvas
  44426. */
  44427. xrLayer: Nullable<XRWebGLLayer>;
  44428. /**
  44429. * Initializes the canvas to be added/removed upon entering/exiting xr
  44430. * @param _xrSessionManager The XR Session manager
  44431. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44432. */
  44433. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44434. /**
  44435. * Disposes of the object
  44436. */
  44437. dispose(): void;
  44438. /**
  44439. * Initializes the xr layer for the session
  44440. * @param xrSession xr session
  44441. * @returns a promise that will resolve once the XR Layer has been created
  44442. */
  44443. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44444. private _addCanvas;
  44445. private _removeCanvas;
  44446. private _setManagedOutputCanvas;
  44447. }
  44448. }
  44449. declare module "babylonjs/XR/webXRSessionManager" {
  44450. import { Observable } from "babylonjs/Misc/observable";
  44451. import { Nullable } from "babylonjs/types";
  44452. import { IDisposable, Scene } from "babylonjs/scene";
  44453. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44454. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44455. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44456. /**
  44457. * Manages an XRSession to work with Babylon's engine
  44458. * @see https://doc.babylonjs.com/how_to/webxr
  44459. */
  44460. export class WebXRSessionManager implements IDisposable {
  44461. /** The scene which the session should be created for */
  44462. scene: Scene;
  44463. private _referenceSpace;
  44464. private _rttProvider;
  44465. private _sessionEnded;
  44466. private _xrNavigator;
  44467. private baseLayer;
  44468. /**
  44469. * The base reference space from which the session started. good if you want to reset your
  44470. * reference space
  44471. */
  44472. baseReferenceSpace: XRReferenceSpace;
  44473. /**
  44474. * Current XR frame
  44475. */
  44476. currentFrame: Nullable<XRFrame>;
  44477. /** WebXR timestamp updated every frame */
  44478. currentTimestamp: number;
  44479. /**
  44480. * Used just in case of a failure to initialize an immersive session.
  44481. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44482. */
  44483. defaultHeightCompensation: number;
  44484. /**
  44485. * Fires every time a new xrFrame arrives which can be used to update the camera
  44486. */
  44487. onXRFrameObservable: Observable<XRFrame>;
  44488. /**
  44489. * Fires when the reference space changed
  44490. */
  44491. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44492. /**
  44493. * Fires when the xr session is ended either by the device or manually done
  44494. */
  44495. onXRSessionEnded: Observable<any>;
  44496. /**
  44497. * Fires when the xr session is ended either by the device or manually done
  44498. */
  44499. onXRSessionInit: Observable<XRSession>;
  44500. /**
  44501. * Underlying xr session
  44502. */
  44503. session: XRSession;
  44504. /**
  44505. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44506. * or get the offset the player is currently at.
  44507. */
  44508. viewerReferenceSpace: XRReferenceSpace;
  44509. /**
  44510. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44511. * @param scene The scene which the session should be created for
  44512. */
  44513. constructor(
  44514. /** The scene which the session should be created for */
  44515. scene: Scene);
  44516. /**
  44517. * The current reference space used in this session. This reference space can constantly change!
  44518. * It is mainly used to offset the camera's position.
  44519. */
  44520. get referenceSpace(): XRReferenceSpace;
  44521. /**
  44522. * Set a new reference space and triggers the observable
  44523. */
  44524. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44525. /**
  44526. * Disposes of the session manager
  44527. */
  44528. dispose(): void;
  44529. /**
  44530. * Stops the xrSession and restores the render loop
  44531. * @returns Promise which resolves after it exits XR
  44532. */
  44533. exitXRAsync(): Promise<void>;
  44534. /**
  44535. * Gets the correct render target texture to be rendered this frame for this eye
  44536. * @param eye the eye for which to get the render target
  44537. * @returns the render target for the specified eye
  44538. */
  44539. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44540. /**
  44541. * Creates a WebXRRenderTarget object for the XR session
  44542. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44543. * @param options optional options to provide when creating a new render target
  44544. * @returns a WebXR render target to which the session can render
  44545. */
  44546. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44547. /**
  44548. * Initializes the manager
  44549. * After initialization enterXR can be called to start an XR session
  44550. * @returns Promise which resolves after it is initialized
  44551. */
  44552. initializeAsync(): Promise<void>;
  44553. /**
  44554. * Initializes an xr session
  44555. * @param xrSessionMode mode to initialize
  44556. * @param xrSessionInit defines optional and required values to pass to the session builder
  44557. * @returns a promise which will resolve once the session has been initialized
  44558. */
  44559. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44560. /**
  44561. * Checks if a session would be supported for the creation options specified
  44562. * @param sessionMode session mode to check if supported eg. immersive-vr
  44563. * @returns A Promise that resolves to true if supported and false if not
  44564. */
  44565. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44566. /**
  44567. * Resets the reference space to the one started the session
  44568. */
  44569. resetReferenceSpace(): void;
  44570. /**
  44571. * Starts rendering to the xr layer
  44572. */
  44573. runXRRenderLoop(): void;
  44574. /**
  44575. * Sets the reference space on the xr session
  44576. * @param referenceSpaceType space to set
  44577. * @returns a promise that will resolve once the reference space has been set
  44578. */
  44579. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44580. /**
  44581. * Updates the render state of the session
  44582. * @param state state to set
  44583. * @returns a promise that resolves once the render state has been updated
  44584. */
  44585. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44586. /**
  44587. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44588. * @param sessionMode defines the session to test
  44589. * @returns a promise with boolean as final value
  44590. */
  44591. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44592. private _createRenderTargetTexture;
  44593. }
  44594. }
  44595. declare module "babylonjs/XR/webXRCamera" {
  44596. import { Scene } from "babylonjs/scene";
  44597. import { Camera } from "babylonjs/Cameras/camera";
  44598. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44599. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44600. /**
  44601. * WebXR Camera which holds the views for the xrSession
  44602. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44603. */
  44604. export class WebXRCamera extends FreeCamera {
  44605. private _xrSessionManager;
  44606. private _firstFrame;
  44607. private _referenceQuaternion;
  44608. private _referencedPosition;
  44609. private _xrInvPositionCache;
  44610. private _xrInvQuaternionCache;
  44611. /**
  44612. * Should position compensation execute on first frame.
  44613. * This is used when copying the position from a native (non XR) camera
  44614. */
  44615. compensateOnFirstFrame: boolean;
  44616. /**
  44617. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44618. * @param name the name of the camera
  44619. * @param scene the scene to add the camera to
  44620. * @param _xrSessionManager a constructed xr session manager
  44621. */
  44622. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44623. /**
  44624. * Return the user's height, unrelated to the current ground.
  44625. * This will be the y position of this camera, when ground level is 0.
  44626. */
  44627. get realWorldHeight(): number;
  44628. /** @hidden */
  44629. _updateForDualEyeDebugging(): void;
  44630. /**
  44631. * Sets this camera's transformation based on a non-vr camera
  44632. * @param otherCamera the non-vr camera to copy the transformation from
  44633. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44634. */
  44635. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44636. /**
  44637. * Gets the current instance class name ("WebXRCamera").
  44638. * @returns the class name
  44639. */
  44640. getClassName(): string;
  44641. private _updateFromXRSession;
  44642. private _updateNumberOfRigCameras;
  44643. private _updateReferenceSpace;
  44644. private _updateReferenceSpaceOffset;
  44645. }
  44646. }
  44647. declare module "babylonjs/XR/webXRFeaturesManager" {
  44648. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44649. import { IDisposable } from "babylonjs/scene";
  44650. /**
  44651. * Defining the interface required for a (webxr) feature
  44652. */
  44653. export interface IWebXRFeature extends IDisposable {
  44654. /**
  44655. * Is this feature attached
  44656. */
  44657. attached: boolean;
  44658. /**
  44659. * Should auto-attach be disabled?
  44660. */
  44661. disableAutoAttach: boolean;
  44662. /**
  44663. * Attach the feature to the session
  44664. * Will usually be called by the features manager
  44665. *
  44666. * @param force should attachment be forced (even when already attached)
  44667. * @returns true if successful.
  44668. */
  44669. attach(force?: boolean): boolean;
  44670. /**
  44671. * Detach the feature from the session
  44672. * Will usually be called by the features manager
  44673. *
  44674. * @returns true if successful.
  44675. */
  44676. detach(): boolean;
  44677. }
  44678. /**
  44679. * A list of the currently available features without referencing them
  44680. */
  44681. export class WebXRFeatureName {
  44682. /**
  44683. * The name of the anchor system feature
  44684. */
  44685. static ANCHOR_SYSTEM: string;
  44686. /**
  44687. * The name of the background remover feature
  44688. */
  44689. static BACKGROUND_REMOVER: string;
  44690. /**
  44691. * The name of the hit test feature
  44692. */
  44693. static HIT_TEST: string;
  44694. /**
  44695. * physics impostors for xr controllers feature
  44696. */
  44697. static PHYSICS_CONTROLLERS: string;
  44698. /**
  44699. * The name of the plane detection feature
  44700. */
  44701. static PLANE_DETECTION: string;
  44702. /**
  44703. * The name of the pointer selection feature
  44704. */
  44705. static POINTER_SELECTION: string;
  44706. /**
  44707. * The name of the teleportation feature
  44708. */
  44709. static TELEPORTATION: string;
  44710. }
  44711. /**
  44712. * Defining the constructor of a feature. Used to register the modules.
  44713. */
  44714. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44715. /**
  44716. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44717. * It is mainly used in AR sessions.
  44718. *
  44719. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44720. */
  44721. export class WebXRFeaturesManager implements IDisposable {
  44722. private _xrSessionManager;
  44723. private static readonly _AvailableFeatures;
  44724. private _features;
  44725. /**
  44726. * constructs a new features manages.
  44727. *
  44728. * @param _xrSessionManager an instance of WebXRSessionManager
  44729. */
  44730. constructor(_xrSessionManager: WebXRSessionManager);
  44731. /**
  44732. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44733. * Mainly used internally.
  44734. *
  44735. * @param featureName the name of the feature to register
  44736. * @param constructorFunction the function used to construct the module
  44737. * @param version the (babylon) version of the module
  44738. * @param stable is that a stable version of this module
  44739. */
  44740. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44741. /**
  44742. * Returns a constructor of a specific feature.
  44743. *
  44744. * @param featureName the name of the feature to construct
  44745. * @param version the version of the feature to load
  44746. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44747. * @param options optional options provided to the module.
  44748. * @returns a function that, when called, will return a new instance of this feature
  44749. */
  44750. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44751. /**
  44752. * Can be used to return the list of features currently registered
  44753. *
  44754. * @returns an Array of available features
  44755. */
  44756. static GetAvailableFeatures(): string[];
  44757. /**
  44758. * Gets the versions available for a specific feature
  44759. * @param featureName the name of the feature
  44760. * @returns an array with the available versions
  44761. */
  44762. static GetAvailableVersions(featureName: string): string[];
  44763. /**
  44764. * Return the latest unstable version of this feature
  44765. * @param featureName the name of the feature to search
  44766. * @returns the version number. if not found will return -1
  44767. */
  44768. static GetLatestVersionOfFeature(featureName: string): number;
  44769. /**
  44770. * Return the latest stable version of this feature
  44771. * @param featureName the name of the feature to search
  44772. * @returns the version number. if not found will return -1
  44773. */
  44774. static GetStableVersionOfFeature(featureName: string): number;
  44775. /**
  44776. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44777. * Can be used during a session to start a feature
  44778. * @param featureName the name of feature to attach
  44779. */
  44780. attachFeature(featureName: string): void;
  44781. /**
  44782. * Can be used inside a session or when the session ends to detach a specific feature
  44783. * @param featureName the name of the feature to detach
  44784. */
  44785. detachFeature(featureName: string): void;
  44786. /**
  44787. * Used to disable an already-enabled feature
  44788. * The feature will be disposed and will be recreated once enabled.
  44789. * @param featureName the feature to disable
  44790. * @returns true if disable was successful
  44791. */
  44792. disableFeature(featureName: string | {
  44793. Name: string;
  44794. }): boolean;
  44795. /**
  44796. * dispose this features manager
  44797. */
  44798. dispose(): void;
  44799. /**
  44800. * 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.
  44801. * 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.
  44802. *
  44803. * @param featureName the name of the feature to load or the class of the feature
  44804. * @param version optional version to load. if not provided the latest version will be enabled
  44805. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44806. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44807. * @returns a new constructed feature or throws an error if feature not found.
  44808. */
  44809. enableFeature(featureName: string | {
  44810. Name: string;
  44811. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44812. /**
  44813. * get the implementation of an enabled feature.
  44814. * @param featureName the name of the feature to load
  44815. * @returns the feature class, if found
  44816. */
  44817. getEnabledFeature(featureName: string): IWebXRFeature;
  44818. /**
  44819. * Get the list of enabled features
  44820. * @returns an array of enabled features
  44821. */
  44822. getEnabledFeatures(): string[];
  44823. }
  44824. }
  44825. declare module "babylonjs/XR/webXRExperienceHelper" {
  44826. import { Observable } from "babylonjs/Misc/observable";
  44827. import { IDisposable, Scene } from "babylonjs/scene";
  44828. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44829. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44830. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44831. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44832. /**
  44833. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44834. * @see https://doc.babylonjs.com/how_to/webxr
  44835. */
  44836. export class WebXRExperienceHelper implements IDisposable {
  44837. private scene;
  44838. private _nonVRCamera;
  44839. private _originalSceneAutoClear;
  44840. private _supported;
  44841. /**
  44842. * Camera used to render xr content
  44843. */
  44844. camera: WebXRCamera;
  44845. /** A features manager for this xr session */
  44846. featuresManager: WebXRFeaturesManager;
  44847. /**
  44848. * Observers registered here will be triggered after the camera's initial transformation is set
  44849. * This can be used to set a different ground level or an extra rotation.
  44850. *
  44851. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44852. * to the position set after this observable is done executing.
  44853. */
  44854. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44855. /**
  44856. * Fires when the state of the experience helper has changed
  44857. */
  44858. onStateChangedObservable: Observable<WebXRState>;
  44859. /** Session manager used to keep track of xr session */
  44860. sessionManager: WebXRSessionManager;
  44861. /**
  44862. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44863. */
  44864. state: WebXRState;
  44865. /**
  44866. * Creates a WebXRExperienceHelper
  44867. * @param scene The scene the helper should be created in
  44868. */
  44869. private constructor();
  44870. /**
  44871. * Creates the experience helper
  44872. * @param scene the scene to attach the experience helper to
  44873. * @returns a promise for the experience helper
  44874. */
  44875. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44876. /**
  44877. * Disposes of the experience helper
  44878. */
  44879. dispose(): void;
  44880. /**
  44881. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44882. * @param sessionMode options for the XR session
  44883. * @param referenceSpaceType frame of reference of the XR session
  44884. * @param renderTarget the output canvas that will be used to enter XR mode
  44885. * @returns promise that resolves after xr mode has entered
  44886. */
  44887. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44888. /**
  44889. * Exits XR mode and returns the scene to its original state
  44890. * @returns promise that resolves after xr mode has exited
  44891. */
  44892. exitXRAsync(): Promise<void>;
  44893. private _nonXRToXRCamera;
  44894. private _setState;
  44895. }
  44896. }
  44897. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44898. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44899. import { Observable } from "babylonjs/Misc/observable";
  44900. import { IDisposable } from "babylonjs/scene";
  44901. /**
  44902. * X-Y values for axes in WebXR
  44903. */
  44904. export interface IWebXRMotionControllerAxesValue {
  44905. /**
  44906. * The value of the x axis
  44907. */
  44908. x: number;
  44909. /**
  44910. * The value of the y-axis
  44911. */
  44912. y: number;
  44913. }
  44914. /**
  44915. * changed / previous values for the values of this component
  44916. */
  44917. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44918. /**
  44919. * current (this frame) value
  44920. */
  44921. current: T;
  44922. /**
  44923. * previous (last change) value
  44924. */
  44925. previous: T;
  44926. }
  44927. /**
  44928. * Represents changes in the component between current frame and last values recorded
  44929. */
  44930. export interface IWebXRMotionControllerComponentChanges {
  44931. /**
  44932. * will be populated with previous and current values if axes changed
  44933. */
  44934. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44935. /**
  44936. * will be populated with previous and current values if pressed changed
  44937. */
  44938. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44939. /**
  44940. * will be populated with previous and current values if touched changed
  44941. */
  44942. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44943. /**
  44944. * will be populated with previous and current values if value changed
  44945. */
  44946. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44947. }
  44948. /**
  44949. * This class represents a single component (for example button or thumbstick) of a motion controller
  44950. */
  44951. export class WebXRControllerComponent implements IDisposable {
  44952. /**
  44953. * the id of this component
  44954. */
  44955. id: string;
  44956. /**
  44957. * the type of the component
  44958. */
  44959. type: MotionControllerComponentType;
  44960. private _buttonIndex;
  44961. private _axesIndices;
  44962. private _axes;
  44963. private _changes;
  44964. private _currentValue;
  44965. private _hasChanges;
  44966. private _pressed;
  44967. private _touched;
  44968. /**
  44969. * button component type
  44970. */
  44971. static BUTTON_TYPE: MotionControllerComponentType;
  44972. /**
  44973. * squeeze component type
  44974. */
  44975. static SQUEEZE_TYPE: MotionControllerComponentType;
  44976. /**
  44977. * Thumbstick component type
  44978. */
  44979. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44980. /**
  44981. * Touchpad component type
  44982. */
  44983. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44984. /**
  44985. * trigger component type
  44986. */
  44987. static TRIGGER_TYPE: MotionControllerComponentType;
  44988. /**
  44989. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44990. * the axes data changes
  44991. */
  44992. onAxisValueChangedObservable: Observable<{
  44993. x: number;
  44994. y: number;
  44995. }>;
  44996. /**
  44997. * Observers registered here will be triggered when the state of a button changes
  44998. * State change is either pressed / touched / value
  44999. */
  45000. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45001. /**
  45002. * Creates a new component for a motion controller.
  45003. * It is created by the motion controller itself
  45004. *
  45005. * @param id the id of this component
  45006. * @param type the type of the component
  45007. * @param _buttonIndex index in the buttons array of the gamepad
  45008. * @param _axesIndices indices of the values in the axes array of the gamepad
  45009. */
  45010. constructor(
  45011. /**
  45012. * the id of this component
  45013. */
  45014. id: string,
  45015. /**
  45016. * the type of the component
  45017. */
  45018. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45019. /**
  45020. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45021. */
  45022. get axes(): IWebXRMotionControllerAxesValue;
  45023. /**
  45024. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45025. */
  45026. get changes(): IWebXRMotionControllerComponentChanges;
  45027. /**
  45028. * Return whether or not the component changed the last frame
  45029. */
  45030. get hasChanges(): boolean;
  45031. /**
  45032. * is the button currently pressed
  45033. */
  45034. get pressed(): boolean;
  45035. /**
  45036. * is the button currently touched
  45037. */
  45038. get touched(): boolean;
  45039. /**
  45040. * Get the current value of this component
  45041. */
  45042. get value(): number;
  45043. /**
  45044. * Dispose this component
  45045. */
  45046. dispose(): void;
  45047. /**
  45048. * Are there axes correlating to this component
  45049. * @return true is axes data is available
  45050. */
  45051. isAxes(): boolean;
  45052. /**
  45053. * Is this component a button (hence - pressable)
  45054. * @returns true if can be pressed
  45055. */
  45056. isButton(): boolean;
  45057. /**
  45058. * update this component using the gamepad object it is in. Called on every frame
  45059. * @param nativeController the native gamepad controller object
  45060. */
  45061. update(nativeController: IMinimalMotionControllerObject): void;
  45062. }
  45063. }
  45064. declare module "babylonjs/Loading/sceneLoader" {
  45065. import { Observable } from "babylonjs/Misc/observable";
  45066. import { Nullable } from "babylonjs/types";
  45067. import { Scene } from "babylonjs/scene";
  45068. import { Engine } from "babylonjs/Engines/engine";
  45069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45070. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45071. import { AssetContainer } from "babylonjs/assetContainer";
  45072. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45073. import { Skeleton } from "babylonjs/Bones/skeleton";
  45074. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45075. import { WebRequest } from "babylonjs/Misc/webRequest";
  45076. /**
  45077. * Class used to represent data loading progression
  45078. */
  45079. export class SceneLoaderProgressEvent {
  45080. /** defines if data length to load can be evaluated */
  45081. readonly lengthComputable: boolean;
  45082. /** defines the loaded data length */
  45083. readonly loaded: number;
  45084. /** defines the data length to load */
  45085. readonly total: number;
  45086. /**
  45087. * Create a new progress event
  45088. * @param lengthComputable defines if data length to load can be evaluated
  45089. * @param loaded defines the loaded data length
  45090. * @param total defines the data length to load
  45091. */
  45092. constructor(
  45093. /** defines if data length to load can be evaluated */
  45094. lengthComputable: boolean,
  45095. /** defines the loaded data length */
  45096. loaded: number,
  45097. /** defines the data length to load */
  45098. total: number);
  45099. /**
  45100. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45101. * @param event defines the source event
  45102. * @returns a new SceneLoaderProgressEvent
  45103. */
  45104. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45105. }
  45106. /**
  45107. * Interface used by SceneLoader plugins to define supported file extensions
  45108. */
  45109. export interface ISceneLoaderPluginExtensions {
  45110. /**
  45111. * Defines the list of supported extensions
  45112. */
  45113. [extension: string]: {
  45114. isBinary: boolean;
  45115. };
  45116. }
  45117. /**
  45118. * Interface used by SceneLoader plugin factory
  45119. */
  45120. export interface ISceneLoaderPluginFactory {
  45121. /**
  45122. * Defines the name of the factory
  45123. */
  45124. name: string;
  45125. /**
  45126. * Function called to create a new plugin
  45127. * @return the new plugin
  45128. */
  45129. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45130. /**
  45131. * The callback that returns true if the data can be directly loaded.
  45132. * @param data string containing the file data
  45133. * @returns if the data can be loaded directly
  45134. */
  45135. canDirectLoad?(data: string): boolean;
  45136. }
  45137. /**
  45138. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45139. */
  45140. export interface ISceneLoaderPluginBase {
  45141. /**
  45142. * The friendly name of this plugin.
  45143. */
  45144. name: string;
  45145. /**
  45146. * The file extensions supported by this plugin.
  45147. */
  45148. extensions: string | ISceneLoaderPluginExtensions;
  45149. /**
  45150. * The callback called when loading from a url.
  45151. * @param scene scene loading this url
  45152. * @param url url to load
  45153. * @param onSuccess callback called when the file successfully loads
  45154. * @param onProgress callback called while file is loading (if the server supports this mode)
  45155. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45156. * @param onError callback called when the file fails to load
  45157. * @returns a file request object
  45158. */
  45159. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45160. /**
  45161. * The callback called when loading from a file object.
  45162. * @param scene scene loading this file
  45163. * @param file defines the file to load
  45164. * @param onSuccess defines the callback to call when data is loaded
  45165. * @param onProgress defines the callback to call during loading process
  45166. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45167. * @param onError defines the callback to call when an error occurs
  45168. * @returns a file request object
  45169. */
  45170. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45171. /**
  45172. * The callback that returns true if the data can be directly loaded.
  45173. * @param data string containing the file data
  45174. * @returns if the data can be loaded directly
  45175. */
  45176. canDirectLoad?(data: string): boolean;
  45177. /**
  45178. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45179. * @param scene scene loading this data
  45180. * @param data string containing the data
  45181. * @returns data to pass to the plugin
  45182. */
  45183. directLoad?(scene: Scene, data: string): any;
  45184. /**
  45185. * The callback that allows custom handling of the root url based on the response url.
  45186. * @param rootUrl the original root url
  45187. * @param responseURL the response url if available
  45188. * @returns the new root url
  45189. */
  45190. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45191. }
  45192. /**
  45193. * Interface used to define a SceneLoader plugin
  45194. */
  45195. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45196. /**
  45197. * Import meshes into a scene.
  45198. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45199. * @param scene The scene to import into
  45200. * @param data The data to import
  45201. * @param rootUrl The root url for scene and resources
  45202. * @param meshes The meshes array to import into
  45203. * @param particleSystems The particle systems array to import into
  45204. * @param skeletons The skeletons array to import into
  45205. * @param onError The callback when import fails
  45206. * @returns True if successful or false otherwise
  45207. */
  45208. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45209. /**
  45210. * Load into a scene.
  45211. * @param scene The scene to load into
  45212. * @param data The data to import
  45213. * @param rootUrl The root url for scene and resources
  45214. * @param onError The callback when import fails
  45215. * @returns True if successful or false otherwise
  45216. */
  45217. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45218. /**
  45219. * Load into an asset container.
  45220. * @param scene The scene to load into
  45221. * @param data The data to import
  45222. * @param rootUrl The root url for scene and resources
  45223. * @param onError The callback when import fails
  45224. * @returns The loaded asset container
  45225. */
  45226. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45227. }
  45228. /**
  45229. * Interface used to define an async SceneLoader plugin
  45230. */
  45231. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45232. /**
  45233. * Import meshes into a scene.
  45234. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45235. * @param scene The scene to import into
  45236. * @param data The data to import
  45237. * @param rootUrl The root url for scene and resources
  45238. * @param onProgress The callback when the load progresses
  45239. * @param fileName Defines the name of the file to load
  45240. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45241. */
  45242. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45243. meshes: AbstractMesh[];
  45244. particleSystems: IParticleSystem[];
  45245. skeletons: Skeleton[];
  45246. animationGroups: AnimationGroup[];
  45247. }>;
  45248. /**
  45249. * Load into a scene.
  45250. * @param scene The scene to load into
  45251. * @param data The data to import
  45252. * @param rootUrl The root url for scene and resources
  45253. * @param onProgress The callback when the load progresses
  45254. * @param fileName Defines the name of the file to load
  45255. * @returns Nothing
  45256. */
  45257. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45258. /**
  45259. * Load into an asset container.
  45260. * @param scene The scene to load into
  45261. * @param data The data to import
  45262. * @param rootUrl The root url for scene and resources
  45263. * @param onProgress The callback when the load progresses
  45264. * @param fileName Defines the name of the file to load
  45265. * @returns The loaded asset container
  45266. */
  45267. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45268. }
  45269. /**
  45270. * Mode that determines how to handle old animation groups before loading new ones.
  45271. */
  45272. export enum SceneLoaderAnimationGroupLoadingMode {
  45273. /**
  45274. * Reset all old animations to initial state then dispose them.
  45275. */
  45276. Clean = 0,
  45277. /**
  45278. * Stop all old animations.
  45279. */
  45280. Stop = 1,
  45281. /**
  45282. * Restart old animations from first frame.
  45283. */
  45284. Sync = 2,
  45285. /**
  45286. * Old animations remains untouched.
  45287. */
  45288. NoSync = 3
  45289. }
  45290. /**
  45291. * Class used to load scene from various file formats using registered plugins
  45292. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45293. */
  45294. export class SceneLoader {
  45295. /**
  45296. * No logging while loading
  45297. */
  45298. static readonly NO_LOGGING: number;
  45299. /**
  45300. * Minimal logging while loading
  45301. */
  45302. static readonly MINIMAL_LOGGING: number;
  45303. /**
  45304. * Summary logging while loading
  45305. */
  45306. static readonly SUMMARY_LOGGING: number;
  45307. /**
  45308. * Detailled logging while loading
  45309. */
  45310. static readonly DETAILED_LOGGING: number;
  45311. /**
  45312. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45313. */
  45314. static get ForceFullSceneLoadingForIncremental(): boolean;
  45315. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45316. /**
  45317. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45318. */
  45319. static get ShowLoadingScreen(): boolean;
  45320. static set ShowLoadingScreen(value: boolean);
  45321. /**
  45322. * Defines the current logging level (while loading the scene)
  45323. * @ignorenaming
  45324. */
  45325. static get loggingLevel(): number;
  45326. static set loggingLevel(value: number);
  45327. /**
  45328. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45329. */
  45330. static get CleanBoneMatrixWeights(): boolean;
  45331. static set CleanBoneMatrixWeights(value: boolean);
  45332. /**
  45333. * Event raised when a plugin is used to load a scene
  45334. */
  45335. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45336. private static _registeredPlugins;
  45337. private static _getDefaultPlugin;
  45338. private static _getPluginForExtension;
  45339. private static _getPluginForDirectLoad;
  45340. private static _getPluginForFilename;
  45341. private static _getDirectLoad;
  45342. private static _loadData;
  45343. private static _getFileInfo;
  45344. /**
  45345. * Gets a plugin that can load the given extension
  45346. * @param extension defines the extension to load
  45347. * @returns a plugin or null if none works
  45348. */
  45349. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45350. /**
  45351. * Gets a boolean indicating that the given extension can be loaded
  45352. * @param extension defines the extension to load
  45353. * @returns true if the extension is supported
  45354. */
  45355. static IsPluginForExtensionAvailable(extension: string): boolean;
  45356. /**
  45357. * Adds a new plugin to the list of registered plugins
  45358. * @param plugin defines the plugin to add
  45359. */
  45360. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45361. /**
  45362. * Import meshes into a scene
  45363. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45364. * @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)
  45365. * @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)
  45366. * @param scene the instance of BABYLON.Scene to append to
  45367. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45368. * @param onProgress a callback with a progress event for each file being loaded
  45369. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45370. * @param pluginExtension the extension used to determine the plugin
  45371. * @returns The loaded plugin
  45372. */
  45373. 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>;
  45374. /**
  45375. * Import meshes into a scene
  45376. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45377. * @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)
  45378. * @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)
  45379. * @param scene the instance of BABYLON.Scene to append to
  45380. * @param onProgress a callback with a progress event for each file being loaded
  45381. * @param pluginExtension the extension used to determine the plugin
  45382. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45383. */
  45384. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45385. meshes: AbstractMesh[];
  45386. particleSystems: IParticleSystem[];
  45387. skeletons: Skeleton[];
  45388. animationGroups: AnimationGroup[];
  45389. }>;
  45390. /**
  45391. * Load a scene
  45392. * @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)
  45393. * @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)
  45394. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45395. * @param onSuccess a callback with the scene when import succeeds
  45396. * @param onProgress a callback with a progress event for each file being loaded
  45397. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45398. * @param pluginExtension the extension used to determine the plugin
  45399. * @returns The loaded plugin
  45400. */
  45401. 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>;
  45402. /**
  45403. * Load a scene
  45404. * @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)
  45405. * @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)
  45406. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45407. * @param onProgress a callback with a progress event for each file being loaded
  45408. * @param pluginExtension the extension used to determine the plugin
  45409. * @returns The loaded scene
  45410. */
  45411. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45412. /**
  45413. * Append a scene
  45414. * @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)
  45415. * @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)
  45416. * @param scene is the instance of BABYLON.Scene to append to
  45417. * @param onSuccess a callback with the scene when import succeeds
  45418. * @param onProgress a callback with a progress event for each file being loaded
  45419. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45420. * @param pluginExtension the extension used to determine the plugin
  45421. * @returns The loaded plugin
  45422. */
  45423. 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>;
  45424. /**
  45425. * Append a scene
  45426. * @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)
  45427. * @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)
  45428. * @param scene is the instance of BABYLON.Scene to append to
  45429. * @param onProgress a callback with a progress event for each file being loaded
  45430. * @param pluginExtension the extension used to determine the plugin
  45431. * @returns The given scene
  45432. */
  45433. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45434. /**
  45435. * Load a scene into an asset container
  45436. * @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)
  45437. * @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)
  45438. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45439. * @param onSuccess a callback with the scene when import succeeds
  45440. * @param onProgress a callback with a progress event for each file being loaded
  45441. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45442. * @param pluginExtension the extension used to determine the plugin
  45443. * @returns The loaded plugin
  45444. */
  45445. 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>;
  45446. /**
  45447. * Load a scene into an asset container
  45448. * @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)
  45449. * @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)
  45450. * @param scene is the instance of Scene to append to
  45451. * @param onProgress a callback with a progress event for each file being loaded
  45452. * @param pluginExtension the extension used to determine the plugin
  45453. * @returns The loaded asset container
  45454. */
  45455. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45456. /**
  45457. * Import animations from a file into a scene
  45458. * @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)
  45459. * @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)
  45460. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45461. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45462. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45463. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45464. * @param onSuccess a callback with the scene when import succeeds
  45465. * @param onProgress a callback with a progress event for each file being loaded
  45466. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45467. */
  45468. 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;
  45469. /**
  45470. * Import animations from a file into a scene
  45471. * @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)
  45472. * @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)
  45473. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45474. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45475. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45476. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45477. * @param onSuccess a callback with the scene when import succeeds
  45478. * @param onProgress a callback with a progress event for each file being loaded
  45479. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45480. * @returns the updated scene with imported animations
  45481. */
  45482. 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>;
  45483. }
  45484. }
  45485. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45486. import { IDisposable, Scene } from "babylonjs/scene";
  45487. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45488. import { Observable } from "babylonjs/Misc/observable";
  45489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45490. import { Nullable } from "babylonjs/types";
  45491. /**
  45492. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45493. */
  45494. export type MotionControllerHandness = "none" | "left" | "right";
  45495. /**
  45496. * The type of components available in motion controllers.
  45497. * This is not the name of the component.
  45498. */
  45499. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45500. /**
  45501. * The state of a controller component
  45502. */
  45503. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45504. /**
  45505. * The schema of motion controller layout.
  45506. * No object will be initialized using this interface
  45507. * This is used just to define the profile.
  45508. */
  45509. export interface IMotionControllerLayout {
  45510. /**
  45511. * Path to load the assets. Usually relative to the base path
  45512. */
  45513. assetPath: string;
  45514. /**
  45515. * Available components (unsorted)
  45516. */
  45517. components: {
  45518. /**
  45519. * A map of component Ids
  45520. */
  45521. [componentId: string]: {
  45522. /**
  45523. * The type of input the component outputs
  45524. */
  45525. type: MotionControllerComponentType;
  45526. /**
  45527. * The indices of this component in the gamepad object
  45528. */
  45529. gamepadIndices: {
  45530. /**
  45531. * Index of button
  45532. */
  45533. button?: number;
  45534. /**
  45535. * If available, index of x-axis
  45536. */
  45537. xAxis?: number;
  45538. /**
  45539. * If available, index of y-axis
  45540. */
  45541. yAxis?: number;
  45542. };
  45543. /**
  45544. * The mesh's root node name
  45545. */
  45546. rootNodeName: string;
  45547. /**
  45548. * Animation definitions for this model
  45549. */
  45550. visualResponses: {
  45551. [stateKey: string]: {
  45552. /**
  45553. * What property will be animated
  45554. */
  45555. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45556. /**
  45557. * What states influence this visual response
  45558. */
  45559. states: MotionControllerComponentStateType[];
  45560. /**
  45561. * Type of animation - movement or visibility
  45562. */
  45563. valueNodeProperty: "transform" | "visibility";
  45564. /**
  45565. * Base node name to move. Its position will be calculated according to the min and max nodes
  45566. */
  45567. valueNodeName?: string;
  45568. /**
  45569. * Minimum movement node
  45570. */
  45571. minNodeName?: string;
  45572. /**
  45573. * Max movement node
  45574. */
  45575. maxNodeName?: string;
  45576. };
  45577. };
  45578. /**
  45579. * If touch enabled, what is the name of node to display user feedback
  45580. */
  45581. touchPointNodeName?: string;
  45582. };
  45583. };
  45584. /**
  45585. * Is it xr standard mapping or not
  45586. */
  45587. gamepadMapping: "" | "xr-standard";
  45588. /**
  45589. * Base root node of this entire model
  45590. */
  45591. rootNodeName: string;
  45592. /**
  45593. * Defines the main button component id
  45594. */
  45595. selectComponentId: string;
  45596. }
  45597. /**
  45598. * A definition for the layout map in the input profile
  45599. */
  45600. export interface IMotionControllerLayoutMap {
  45601. /**
  45602. * Layouts with handness type as a key
  45603. */
  45604. [handness: string]: IMotionControllerLayout;
  45605. }
  45606. /**
  45607. * The XR Input profile schema
  45608. * Profiles can be found here:
  45609. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45610. */
  45611. export interface IMotionControllerProfile {
  45612. /**
  45613. * fallback profiles for this profileId
  45614. */
  45615. fallbackProfileIds: string[];
  45616. /**
  45617. * The layout map, with handness as key
  45618. */
  45619. layouts: IMotionControllerLayoutMap;
  45620. /**
  45621. * The id of this profile
  45622. * correlates to the profile(s) in the xrInput.profiles array
  45623. */
  45624. profileId: string;
  45625. }
  45626. /**
  45627. * A helper-interface for the 3 meshes needed for controller button animation
  45628. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45629. */
  45630. export interface IMotionControllerButtonMeshMap {
  45631. /**
  45632. * the mesh that defines the pressed value mesh position.
  45633. * This is used to find the max-position of this button
  45634. */
  45635. pressedMesh: AbstractMesh;
  45636. /**
  45637. * the mesh that defines the unpressed value mesh position.
  45638. * This is used to find the min (or initial) position of this button
  45639. */
  45640. unpressedMesh: AbstractMesh;
  45641. /**
  45642. * The mesh that will be changed when value changes
  45643. */
  45644. valueMesh: AbstractMesh;
  45645. }
  45646. /**
  45647. * A helper-interface for the 3 meshes needed for controller axis animation.
  45648. * This will be expanded when touchpad animations are fully supported
  45649. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45650. */
  45651. export interface IMotionControllerMeshMap {
  45652. /**
  45653. * the mesh that defines the maximum value mesh position.
  45654. */
  45655. maxMesh?: AbstractMesh;
  45656. /**
  45657. * the mesh that defines the minimum value mesh position.
  45658. */
  45659. minMesh?: AbstractMesh;
  45660. /**
  45661. * The mesh that will be changed when axis value changes
  45662. */
  45663. valueMesh: AbstractMesh;
  45664. }
  45665. /**
  45666. * The elements needed for change-detection of the gamepad objects in motion controllers
  45667. */
  45668. export interface IMinimalMotionControllerObject {
  45669. /**
  45670. * Available axes of this controller
  45671. */
  45672. axes: number[];
  45673. /**
  45674. * An array of available buttons
  45675. */
  45676. buttons: Array<{
  45677. /**
  45678. * Value of the button/trigger
  45679. */
  45680. value: number;
  45681. /**
  45682. * If the button/trigger is currently touched
  45683. */
  45684. touched: boolean;
  45685. /**
  45686. * If the button/trigger is currently pressed
  45687. */
  45688. pressed: boolean;
  45689. }>;
  45690. }
  45691. /**
  45692. * An Abstract Motion controller
  45693. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45694. * Each component has an observable to check for changes in value and state
  45695. */
  45696. export abstract class WebXRAbstractMotionController implements IDisposable {
  45697. protected scene: Scene;
  45698. protected layout: IMotionControllerLayout;
  45699. /**
  45700. * The gamepad object correlating to this controller
  45701. */
  45702. gamepadObject: IMinimalMotionControllerObject;
  45703. /**
  45704. * handness (left/right/none) of this controller
  45705. */
  45706. handness: MotionControllerHandness;
  45707. private _initComponent;
  45708. private _modelReady;
  45709. /**
  45710. * A map of components (WebXRControllerComponent) in this motion controller
  45711. * Components have a ComponentType and can also have both button and axis definitions
  45712. */
  45713. readonly components: {
  45714. [id: string]: WebXRControllerComponent;
  45715. };
  45716. /**
  45717. * Disable the model's animation. Can be set at any time.
  45718. */
  45719. disableAnimation: boolean;
  45720. /**
  45721. * Observers registered here will be triggered when the model of this controller is done loading
  45722. */
  45723. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45724. /**
  45725. * The profile id of this motion controller
  45726. */
  45727. abstract profileId: string;
  45728. /**
  45729. * The root mesh of the model. It is null if the model was not yet initialized
  45730. */
  45731. rootMesh: Nullable<AbstractMesh>;
  45732. /**
  45733. * constructs a new abstract motion controller
  45734. * @param scene the scene to which the model of the controller will be added
  45735. * @param layout The profile layout to load
  45736. * @param gamepadObject The gamepad object correlating to this controller
  45737. * @param handness handness (left/right/none) of this controller
  45738. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45739. */
  45740. constructor(scene: Scene, layout: IMotionControllerLayout,
  45741. /**
  45742. * The gamepad object correlating to this controller
  45743. */
  45744. gamepadObject: IMinimalMotionControllerObject,
  45745. /**
  45746. * handness (left/right/none) of this controller
  45747. */
  45748. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45749. /**
  45750. * Dispose this controller, the model mesh and all its components
  45751. */
  45752. dispose(): void;
  45753. /**
  45754. * Returns all components of specific type
  45755. * @param type the type to search for
  45756. * @return an array of components with this type
  45757. */
  45758. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45759. /**
  45760. * get a component based an its component id as defined in layout.components
  45761. * @param id the id of the component
  45762. * @returns the component correlates to the id or undefined if not found
  45763. */
  45764. getComponent(id: string): WebXRControllerComponent;
  45765. /**
  45766. * Get the list of components available in this motion controller
  45767. * @returns an array of strings correlating to available components
  45768. */
  45769. getComponentIds(): string[];
  45770. /**
  45771. * Get the first component of specific type
  45772. * @param type type of component to find
  45773. * @return a controller component or null if not found
  45774. */
  45775. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45776. /**
  45777. * Get the main (Select) component of this controller as defined in the layout
  45778. * @returns the main component of this controller
  45779. */
  45780. getMainComponent(): WebXRControllerComponent;
  45781. /**
  45782. * Loads the model correlating to this controller
  45783. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45784. * @returns A promise fulfilled with the result of the model loading
  45785. */
  45786. loadModel(): Promise<boolean>;
  45787. /**
  45788. * Update this model using the current XRFrame
  45789. * @param xrFrame the current xr frame to use and update the model
  45790. */
  45791. updateFromXRFrame(xrFrame: XRFrame): void;
  45792. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45793. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45794. /**
  45795. * Moves the axis on the controller mesh based on its current state
  45796. * @param axis the index of the axis
  45797. * @param axisValue the value of the axis which determines the meshes new position
  45798. * @hidden
  45799. */
  45800. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45801. /**
  45802. * Update the model itself with the current frame data
  45803. * @param xrFrame the frame to use for updating the model mesh
  45804. */
  45805. protected updateModel(xrFrame: XRFrame): void;
  45806. /**
  45807. * Get the filename and path for this controller's model
  45808. * @returns a map of filename and path
  45809. */
  45810. protected abstract _getFilenameAndPath(): {
  45811. filename: string;
  45812. path: string;
  45813. };
  45814. /**
  45815. * This function is called before the mesh is loaded. It checks for loading constraints.
  45816. * For example, this function can check if the GLB loader is available
  45817. * If this function returns false, the generic controller will be loaded instead
  45818. * @returns Is the client ready to load the mesh
  45819. */
  45820. protected abstract _getModelLoadingConstraints(): boolean;
  45821. /**
  45822. * This function will be called after the model was successfully loaded and can be used
  45823. * for mesh transformations before it is available for the user
  45824. * @param meshes the loaded meshes
  45825. */
  45826. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45827. /**
  45828. * Set the root mesh for this controller. Important for the WebXR controller class
  45829. * @param meshes the loaded meshes
  45830. */
  45831. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45832. /**
  45833. * A function executed each frame that updates the mesh (if needed)
  45834. * @param xrFrame the current xrFrame
  45835. */
  45836. protected abstract _updateModel(xrFrame: XRFrame): void;
  45837. private _getGenericFilenameAndPath;
  45838. private _getGenericParentMesh;
  45839. }
  45840. }
  45841. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45842. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45844. import { Scene } from "babylonjs/scene";
  45845. /**
  45846. * A generic trigger-only motion controller for WebXR
  45847. */
  45848. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45849. /**
  45850. * Static version of the profile id of this controller
  45851. */
  45852. static ProfileId: string;
  45853. profileId: string;
  45854. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45855. protected _getFilenameAndPath(): {
  45856. filename: string;
  45857. path: string;
  45858. };
  45859. protected _getModelLoadingConstraints(): boolean;
  45860. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45861. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45862. protected _updateModel(): void;
  45863. }
  45864. }
  45865. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45866. import { Vector4 } from "babylonjs/Maths/math.vector";
  45867. import { Mesh } from "babylonjs/Meshes/mesh";
  45868. import { Scene } from "babylonjs/scene";
  45869. import { Nullable } from "babylonjs/types";
  45870. /**
  45871. * Class containing static functions to help procedurally build meshes
  45872. */
  45873. export class SphereBuilder {
  45874. /**
  45875. * Creates a sphere mesh
  45876. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45877. * * 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`)
  45878. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45879. * * 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
  45880. * * 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)
  45881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45884. * @param name defines the name of the mesh
  45885. * @param options defines the options used to create the mesh
  45886. * @param scene defines the hosting scene
  45887. * @returns the sphere mesh
  45888. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45889. */
  45890. static CreateSphere(name: string, options: {
  45891. segments?: number;
  45892. diameter?: number;
  45893. diameterX?: number;
  45894. diameterY?: number;
  45895. diameterZ?: number;
  45896. arc?: number;
  45897. slice?: number;
  45898. sideOrientation?: number;
  45899. frontUVs?: Vector4;
  45900. backUVs?: Vector4;
  45901. updatable?: boolean;
  45902. }, scene?: Nullable<Scene>): Mesh;
  45903. }
  45904. }
  45905. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45907. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45908. import { Scene } from "babylonjs/scene";
  45909. /**
  45910. * A profiled motion controller has its profile loaded from an online repository.
  45911. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45912. */
  45913. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45914. private _repositoryUrl;
  45915. private _buttonMeshMapping;
  45916. private _touchDots;
  45917. /**
  45918. * The profile ID of this controller. Will be populated when the controller initializes.
  45919. */
  45920. profileId: string;
  45921. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45922. dispose(): void;
  45923. protected _getFilenameAndPath(): {
  45924. filename: string;
  45925. path: string;
  45926. };
  45927. protected _getModelLoadingConstraints(): boolean;
  45928. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45929. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45930. protected _updateModel(_xrFrame: XRFrame): void;
  45931. }
  45932. }
  45933. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45934. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45935. import { Scene } from "babylonjs/scene";
  45936. /**
  45937. * A construction function type to create a new controller based on an xrInput object
  45938. */
  45939. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45940. /**
  45941. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45942. *
  45943. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45944. * it should be replaced with auto-loaded controllers.
  45945. *
  45946. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45947. */
  45948. export class WebXRMotionControllerManager {
  45949. private static _AvailableControllers;
  45950. private static _Fallbacks;
  45951. private static _ProfileLoadingPromises;
  45952. private static _ProfilesList;
  45953. /**
  45954. * The base URL of the online controller repository. Can be changed at any time.
  45955. */
  45956. static BaseRepositoryUrl: string;
  45957. /**
  45958. * Which repository gets priority - local or online
  45959. */
  45960. static PrioritizeOnlineRepository: boolean;
  45961. /**
  45962. * Use the online repository, or use only locally-defined controllers
  45963. */
  45964. static UseOnlineRepository: boolean;
  45965. /**
  45966. * Clear the cache used for profile loading and reload when requested again
  45967. */
  45968. static ClearProfilesCache(): void;
  45969. /**
  45970. * Register the default fallbacks.
  45971. * This function is called automatically when this file is imported.
  45972. */
  45973. static DefaultFallbacks(): void;
  45974. /**
  45975. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45976. * @param profileId the profile to which a fallback needs to be found
  45977. * @return an array with corresponding fallback profiles
  45978. */
  45979. static FindFallbackWithProfileId(profileId: string): string[];
  45980. /**
  45981. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45982. * The order of search:
  45983. *
  45984. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45985. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45986. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45987. * 4) return the generic trigger controller if none were found
  45988. *
  45989. * @param xrInput the xrInput to which a new controller is initialized
  45990. * @param scene the scene to which the model will be added
  45991. * @param forceProfile force a certain profile for this controller
  45992. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45993. */
  45994. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45995. /**
  45996. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45997. *
  45998. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45999. *
  46000. * @param type the profile type to register
  46001. * @param constructFunction the function to be called when loading this profile
  46002. */
  46003. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46004. /**
  46005. * Register a fallback to a specific profile.
  46006. * @param profileId the profileId that will receive the fallbacks
  46007. * @param fallbacks A list of fallback profiles
  46008. */
  46009. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46010. /**
  46011. * Will update the list of profiles available in the repository
  46012. * @return a promise that resolves to a map of profiles available online
  46013. */
  46014. static UpdateProfilesList(): Promise<{
  46015. [profile: string]: string;
  46016. }>;
  46017. private static _LoadProfileFromRepository;
  46018. private static _LoadProfilesFromAvailableControllers;
  46019. }
  46020. }
  46021. declare module "babylonjs/XR/webXRInputSource" {
  46022. import { Observable } from "babylonjs/Misc/observable";
  46023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46024. import { Ray } from "babylonjs/Culling/ray";
  46025. import { Scene } from "babylonjs/scene";
  46026. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46027. /**
  46028. * Configuration options for the WebXR controller creation
  46029. */
  46030. export interface IWebXRControllerOptions {
  46031. /**
  46032. * Should the controller mesh be animated when a user interacts with it
  46033. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46034. */
  46035. disableMotionControllerAnimation?: boolean;
  46036. /**
  46037. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46038. */
  46039. doNotLoadControllerMesh?: boolean;
  46040. /**
  46041. * Force a specific controller type for this controller.
  46042. * This can be used when creating your own profile or when testing different controllers
  46043. */
  46044. forceControllerProfile?: string;
  46045. }
  46046. /**
  46047. * Represents an XR controller
  46048. */
  46049. export class WebXRInputSource {
  46050. private _scene;
  46051. /** The underlying input source for the controller */
  46052. inputSource: XRInputSource;
  46053. private _options;
  46054. private _tmpQuaternion;
  46055. private _tmpVector;
  46056. private _uniqueId;
  46057. /**
  46058. * 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
  46059. */
  46060. grip?: AbstractMesh;
  46061. /**
  46062. * If available, this is the gamepad object related to this controller.
  46063. * Using this object it is possible to get click events and trackpad changes of the
  46064. * webxr controller that is currently being used.
  46065. */
  46066. motionController?: WebXRAbstractMotionController;
  46067. /**
  46068. * Event that fires when the controller is removed/disposed.
  46069. * The object provided as event data is this controller, after associated assets were disposed.
  46070. * uniqueId is still available.
  46071. */
  46072. onDisposeObservable: Observable<WebXRInputSource>;
  46073. /**
  46074. * Will be triggered when the mesh associated with the motion controller is done loading.
  46075. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46076. * A shortened version of controller -> motion controller -> on mesh loaded.
  46077. */
  46078. onMeshLoadedObservable: Observable<AbstractMesh>;
  46079. /**
  46080. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46081. */
  46082. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46083. /**
  46084. * Pointer which can be used to select objects or attach a visible laser to
  46085. */
  46086. pointer: AbstractMesh;
  46087. /**
  46088. * Creates the controller
  46089. * @see https://doc.babylonjs.com/how_to/webxr
  46090. * @param _scene the scene which the controller should be associated to
  46091. * @param inputSource the underlying input source for the controller
  46092. * @param _options options for this controller creation
  46093. */
  46094. constructor(_scene: Scene,
  46095. /** The underlying input source for the controller */
  46096. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46097. /**
  46098. * Get this controllers unique id
  46099. */
  46100. get uniqueId(): string;
  46101. /**
  46102. * Disposes of the object
  46103. */
  46104. dispose(): void;
  46105. /**
  46106. * Gets a world space ray coming from the pointer or grip
  46107. * @param result the resulting ray
  46108. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46109. */
  46110. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46111. /**
  46112. * Updates the controller pose based on the given XRFrame
  46113. * @param xrFrame xr frame to update the pose with
  46114. * @param referenceSpace reference space to use
  46115. */
  46116. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46117. }
  46118. }
  46119. declare module "babylonjs/XR/webXRInput" {
  46120. import { Observable } from "babylonjs/Misc/observable";
  46121. import { IDisposable } from "babylonjs/scene";
  46122. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46123. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46124. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46125. /**
  46126. * The schema for initialization options of the XR Input class
  46127. */
  46128. export interface IWebXRInputOptions {
  46129. /**
  46130. * If set to true no model will be automatically loaded
  46131. */
  46132. doNotLoadControllerMeshes?: boolean;
  46133. /**
  46134. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46135. * If not found, the xr input profile data will be used.
  46136. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46137. */
  46138. forceInputProfile?: string;
  46139. /**
  46140. * Do not send a request to the controller repository to load the profile.
  46141. *
  46142. * Instead, use the controllers available in babylon itself.
  46143. */
  46144. disableOnlineControllerRepository?: boolean;
  46145. /**
  46146. * A custom URL for the controllers repository
  46147. */
  46148. customControllersRepositoryURL?: string;
  46149. /**
  46150. * Should the controller model's components not move according to the user input
  46151. */
  46152. disableControllerAnimation?: boolean;
  46153. }
  46154. /**
  46155. * XR input used to track XR inputs such as controllers/rays
  46156. */
  46157. export class WebXRInput implements IDisposable {
  46158. /**
  46159. * the xr session manager for this session
  46160. */
  46161. xrSessionManager: WebXRSessionManager;
  46162. /**
  46163. * the WebXR camera for this session. Mainly used for teleportation
  46164. */
  46165. xrCamera: WebXRCamera;
  46166. private readonly options;
  46167. /**
  46168. * XR controllers being tracked
  46169. */
  46170. controllers: Array<WebXRInputSource>;
  46171. private _frameObserver;
  46172. private _sessionEndedObserver;
  46173. private _sessionInitObserver;
  46174. /**
  46175. * Event when a controller has been connected/added
  46176. */
  46177. onControllerAddedObservable: Observable<WebXRInputSource>;
  46178. /**
  46179. * Event when a controller has been removed/disconnected
  46180. */
  46181. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46182. /**
  46183. * Initializes the WebXRInput
  46184. * @param xrSessionManager the xr session manager for this session
  46185. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46186. * @param options = initialization options for this xr input
  46187. */
  46188. constructor(
  46189. /**
  46190. * the xr session manager for this session
  46191. */
  46192. xrSessionManager: WebXRSessionManager,
  46193. /**
  46194. * the WebXR camera for this session. Mainly used for teleportation
  46195. */
  46196. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46197. private _onInputSourcesChange;
  46198. private _addAndRemoveControllers;
  46199. /**
  46200. * Disposes of the object
  46201. */
  46202. dispose(): void;
  46203. }
  46204. }
  46205. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46206. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46207. import { Observable, EventState } from "babylonjs/Misc/observable";
  46208. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46209. /**
  46210. * This is the base class for all WebXR features.
  46211. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46212. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46213. */
  46214. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46215. protected _xrSessionManager: WebXRSessionManager;
  46216. private _attached;
  46217. private _removeOnDetach;
  46218. /**
  46219. * Should auto-attach be disabled?
  46220. */
  46221. disableAutoAttach: boolean;
  46222. /**
  46223. * Construct a new (abstract) WebXR feature
  46224. * @param _xrSessionManager the xr session manager for this feature
  46225. */
  46226. constructor(_xrSessionManager: WebXRSessionManager);
  46227. /**
  46228. * Is this feature attached
  46229. */
  46230. get attached(): boolean;
  46231. /**
  46232. * attach this feature
  46233. *
  46234. * @param force should attachment be forced (even when already attached)
  46235. * @returns true if successful, false is failed or already attached
  46236. */
  46237. attach(force?: boolean): boolean;
  46238. /**
  46239. * detach this feature.
  46240. *
  46241. * @returns true if successful, false if failed or already detached
  46242. */
  46243. detach(): boolean;
  46244. /**
  46245. * Dispose this feature and all of the resources attached
  46246. */
  46247. dispose(): void;
  46248. /**
  46249. * This is used to register callbacks that will automatically be removed when detach is called.
  46250. * @param observable the observable to which the observer will be attached
  46251. * @param callback the callback to register
  46252. */
  46253. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46254. /**
  46255. * Code in this function will be executed on each xrFrame received from the browser.
  46256. * This function will not execute after the feature is detached.
  46257. * @param _xrFrame the current frame
  46258. */
  46259. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46260. }
  46261. }
  46262. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46263. import { IDisposable, Scene } from "babylonjs/scene";
  46264. import { Nullable } from "babylonjs/types";
  46265. import { Observable } from "babylonjs/Misc/observable";
  46266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46267. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46268. import { Camera } from "babylonjs/Cameras/camera";
  46269. /**
  46270. * Renders a layer on top of an existing scene
  46271. */
  46272. export class UtilityLayerRenderer implements IDisposable {
  46273. /** the original scene that will be rendered on top of */
  46274. originalScene: Scene;
  46275. private _pointerCaptures;
  46276. private _lastPointerEvents;
  46277. private static _DefaultUtilityLayer;
  46278. private static _DefaultKeepDepthUtilityLayer;
  46279. private _sharedGizmoLight;
  46280. private _renderCamera;
  46281. /**
  46282. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46283. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46284. * @returns the camera that is used when rendering the utility layer
  46285. */
  46286. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46287. /**
  46288. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46289. * @param cam the camera that should be used when rendering the utility layer
  46290. */
  46291. setRenderCamera(cam: Nullable<Camera>): void;
  46292. /**
  46293. * @hidden
  46294. * Light which used by gizmos to get light shading
  46295. */
  46296. _getSharedGizmoLight(): HemisphericLight;
  46297. /**
  46298. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46299. */
  46300. pickUtilitySceneFirst: boolean;
  46301. /**
  46302. * 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)
  46303. */
  46304. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46305. /**
  46306. * 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)
  46307. */
  46308. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46309. /**
  46310. * The scene that is rendered on top of the original scene
  46311. */
  46312. utilityLayerScene: Scene;
  46313. /**
  46314. * If the utility layer should automatically be rendered on top of existing scene
  46315. */
  46316. shouldRender: boolean;
  46317. /**
  46318. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46319. */
  46320. onlyCheckPointerDownEvents: boolean;
  46321. /**
  46322. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46323. */
  46324. processAllEvents: boolean;
  46325. /**
  46326. * Observable raised when the pointer move from the utility layer scene to the main scene
  46327. */
  46328. onPointerOutObservable: Observable<number>;
  46329. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46330. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46331. private _afterRenderObserver;
  46332. private _sceneDisposeObserver;
  46333. private _originalPointerObserver;
  46334. /**
  46335. * Instantiates a UtilityLayerRenderer
  46336. * @param originalScene the original scene that will be rendered on top of
  46337. * @param handleEvents boolean indicating if the utility layer should handle events
  46338. */
  46339. constructor(
  46340. /** the original scene that will be rendered on top of */
  46341. originalScene: Scene, handleEvents?: boolean);
  46342. private _notifyObservers;
  46343. /**
  46344. * Renders the utility layers scene on top of the original scene
  46345. */
  46346. render(): void;
  46347. /**
  46348. * Disposes of the renderer
  46349. */
  46350. dispose(): void;
  46351. private _updateCamera;
  46352. }
  46353. }
  46354. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46355. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46357. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46358. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46359. import { Scene } from "babylonjs/scene";
  46360. import { Nullable } from "babylonjs/types";
  46361. import { Color3 } from "babylonjs/Maths/math.color";
  46362. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46363. /**
  46364. * Options interface for the pointer selection module
  46365. */
  46366. export interface IWebXRControllerPointerSelectionOptions {
  46367. /**
  46368. * if provided, this scene will be used to render meshes.
  46369. */
  46370. customUtilityLayerScene?: Scene;
  46371. /**
  46372. * 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)
  46373. * If not disabled, the last picked point will be used to execute a pointer up event
  46374. * If disabled, pointer up event will be triggered right after the pointer down event.
  46375. * Used in screen and gaze target ray mode only
  46376. */
  46377. disablePointerUpOnTouchOut: boolean;
  46378. /**
  46379. * For gaze mode (time to select instead of press)
  46380. */
  46381. forceGazeMode: boolean;
  46382. /**
  46383. * 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
  46384. * to start a new countdown to the pointer down event.
  46385. * Defaults to 1.
  46386. */
  46387. gazeModePointerMovedFactor?: number;
  46388. /**
  46389. * Different button type to use instead of the main component
  46390. */
  46391. overrideButtonId?: string;
  46392. /**
  46393. * use this rendering group id for the meshes (optional)
  46394. */
  46395. renderingGroupId?: number;
  46396. /**
  46397. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46398. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46399. * 3000 means 3 seconds between pointing at something and selecting it
  46400. */
  46401. timeToSelect?: number;
  46402. /**
  46403. * Should meshes created here be added to a utility layer or the main scene
  46404. */
  46405. useUtilityLayer?: boolean;
  46406. /**
  46407. * the xr input to use with this pointer selection
  46408. */
  46409. xrInput: WebXRInput;
  46410. }
  46411. /**
  46412. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46413. */
  46414. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46415. private readonly _options;
  46416. private static _idCounter;
  46417. private _attachController;
  46418. private _controllers;
  46419. private _scene;
  46420. private _tmpVectorForPickCompare;
  46421. /**
  46422. * The module's name
  46423. */
  46424. static readonly Name: string;
  46425. /**
  46426. * The (Babylon) version of this module.
  46427. * This is an integer representing the implementation version.
  46428. * This number does not correspond to the WebXR specs version
  46429. */
  46430. static readonly Version: number;
  46431. /**
  46432. * Disable lighting on the laser pointer (so it will always be visible)
  46433. */
  46434. disablePointerLighting: boolean;
  46435. /**
  46436. * Disable lighting on the selection mesh (so it will always be visible)
  46437. */
  46438. disableSelectionMeshLighting: boolean;
  46439. /**
  46440. * Should the laser pointer be displayed
  46441. */
  46442. displayLaserPointer: boolean;
  46443. /**
  46444. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46445. */
  46446. displaySelectionMesh: boolean;
  46447. /**
  46448. * This color will be set to the laser pointer when selection is triggered
  46449. */
  46450. laserPointerPickedColor: Color3;
  46451. /**
  46452. * Default color of the laser pointer
  46453. */
  46454. lasterPointerDefaultColor: Color3;
  46455. /**
  46456. * default color of the selection ring
  46457. */
  46458. selectionMeshDefaultColor: Color3;
  46459. /**
  46460. * This color will be applied to the selection ring when selection is triggered
  46461. */
  46462. selectionMeshPickedColor: Color3;
  46463. /**
  46464. * Optional filter to be used for ray selection. This predicate shares behavior with
  46465. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46466. */
  46467. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46468. /**
  46469. * constructs a new background remover module
  46470. * @param _xrSessionManager the session manager for this module
  46471. * @param _options read-only options to be used in this module
  46472. */
  46473. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46474. /**
  46475. * attach this feature
  46476. * Will usually be called by the features manager
  46477. *
  46478. * @returns true if successful.
  46479. */
  46480. attach(): boolean;
  46481. /**
  46482. * detach this feature.
  46483. * Will usually be called by the features manager
  46484. *
  46485. * @returns true if successful.
  46486. */
  46487. detach(): boolean;
  46488. /**
  46489. * Will get the mesh under a specific pointer.
  46490. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46491. * @param controllerId the controllerId to check
  46492. * @returns The mesh under pointer or null if no mesh is under the pointer
  46493. */
  46494. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46495. /**
  46496. * Get the xr controller that correlates to the pointer id in the pointer event
  46497. *
  46498. * @param id the pointer id to search for
  46499. * @returns the controller that correlates to this id or null if not found
  46500. */
  46501. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46502. protected _onXRFrame(_xrFrame: XRFrame): void;
  46503. private _attachGazeMode;
  46504. private _attachScreenRayMode;
  46505. private _attachTrackedPointerRayMode;
  46506. private _convertNormalToDirectionOfRay;
  46507. private _detachController;
  46508. private _generateNewMeshPair;
  46509. private _pickingMoved;
  46510. private _updatePointerDistance;
  46511. }
  46512. }
  46513. declare module "babylonjs/XR/webXREnterExitUI" {
  46514. import { Nullable } from "babylonjs/types";
  46515. import { Observable } from "babylonjs/Misc/observable";
  46516. import { IDisposable, Scene } from "babylonjs/scene";
  46517. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46518. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46519. /**
  46520. * Button which can be used to enter a different mode of XR
  46521. */
  46522. export class WebXREnterExitUIButton {
  46523. /** button element */
  46524. element: HTMLElement;
  46525. /** XR initialization options for the button */
  46526. sessionMode: XRSessionMode;
  46527. /** Reference space type */
  46528. referenceSpaceType: XRReferenceSpaceType;
  46529. /**
  46530. * Creates a WebXREnterExitUIButton
  46531. * @param element button element
  46532. * @param sessionMode XR initialization session mode
  46533. * @param referenceSpaceType the type of reference space to be used
  46534. */
  46535. constructor(
  46536. /** button element */
  46537. element: HTMLElement,
  46538. /** XR initialization options for the button */
  46539. sessionMode: XRSessionMode,
  46540. /** Reference space type */
  46541. referenceSpaceType: XRReferenceSpaceType);
  46542. /**
  46543. * Extendable function which can be used to update the button's visuals when the state changes
  46544. * @param activeButton the current active button in the UI
  46545. */
  46546. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46547. }
  46548. /**
  46549. * Options to create the webXR UI
  46550. */
  46551. export class WebXREnterExitUIOptions {
  46552. /**
  46553. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46554. */
  46555. customButtons?: Array<WebXREnterExitUIButton>;
  46556. /**
  46557. * A reference space type to use when creating the default button.
  46558. * Default is local-floor
  46559. */
  46560. referenceSpaceType?: XRReferenceSpaceType;
  46561. /**
  46562. * Context to enter xr with
  46563. */
  46564. renderTarget?: Nullable<WebXRRenderTarget>;
  46565. /**
  46566. * A session mode to use when creating the default button.
  46567. * Default is immersive-vr
  46568. */
  46569. sessionMode?: XRSessionMode;
  46570. }
  46571. /**
  46572. * UI to allow the user to enter/exit XR mode
  46573. */
  46574. export class WebXREnterExitUI implements IDisposable {
  46575. private scene;
  46576. /** version of the options passed to this UI */
  46577. options: WebXREnterExitUIOptions;
  46578. private _activeButton;
  46579. private _buttons;
  46580. private _overlay;
  46581. /**
  46582. * Fired every time the active button is changed.
  46583. *
  46584. * When xr is entered via a button that launches xr that button will be the callback parameter
  46585. *
  46586. * When exiting xr the callback parameter will be null)
  46587. */
  46588. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46589. /**
  46590. *
  46591. * @param scene babylon scene object to use
  46592. * @param options (read-only) version of the options passed to this UI
  46593. */
  46594. private constructor();
  46595. /**
  46596. * Creates UI to allow the user to enter/exit XR mode
  46597. * @param scene the scene to add the ui to
  46598. * @param helper the xr experience helper to enter/exit xr with
  46599. * @param options options to configure the UI
  46600. * @returns the created ui
  46601. */
  46602. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46603. /**
  46604. * Disposes of the XR UI component
  46605. */
  46606. dispose(): void;
  46607. private _updateButtons;
  46608. }
  46609. }
  46610. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46611. import { Vector3 } from "babylonjs/Maths/math.vector";
  46612. import { Color4 } from "babylonjs/Maths/math.color";
  46613. import { Nullable } from "babylonjs/types";
  46614. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46615. import { Scene } from "babylonjs/scene";
  46616. /**
  46617. * Class containing static functions to help procedurally build meshes
  46618. */
  46619. export class LinesBuilder {
  46620. /**
  46621. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46622. * * 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
  46623. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46624. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46625. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46626. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46627. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46628. * * 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
  46629. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46632. * @param name defines the name of the new line system
  46633. * @param options defines the options used to create the line system
  46634. * @param scene defines the hosting scene
  46635. * @returns a new line system mesh
  46636. */
  46637. static CreateLineSystem(name: string, options: {
  46638. lines: Vector3[][];
  46639. updatable?: boolean;
  46640. instance?: Nullable<LinesMesh>;
  46641. colors?: Nullable<Color4[][]>;
  46642. useVertexAlpha?: boolean;
  46643. }, scene: Nullable<Scene>): LinesMesh;
  46644. /**
  46645. * Creates a line mesh
  46646. * 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
  46647. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46648. * * The parameter `points` is an array successive Vector3
  46649. * * 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
  46650. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46651. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46652. * * When updating an instance, remember that only point positions can change, not the number of points
  46653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46655. * @param name defines the name of the new line system
  46656. * @param options defines the options used to create the line system
  46657. * @param scene defines the hosting scene
  46658. * @returns a new line mesh
  46659. */
  46660. static CreateLines(name: string, options: {
  46661. points: Vector3[];
  46662. updatable?: boolean;
  46663. instance?: Nullable<LinesMesh>;
  46664. colors?: Color4[];
  46665. useVertexAlpha?: boolean;
  46666. }, scene?: Nullable<Scene>): LinesMesh;
  46667. /**
  46668. * Creates a dashed line mesh
  46669. * * 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
  46670. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46671. * * The parameter `points` is an array successive Vector3
  46672. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46673. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46674. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46675. * * 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
  46676. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46677. * * When updating an instance, remember that only point positions can change, not the number of points
  46678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46679. * @param name defines the name of the mesh
  46680. * @param options defines the options used to create the mesh
  46681. * @param scene defines the hosting scene
  46682. * @returns the dashed line mesh
  46683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46684. */
  46685. static CreateDashedLines(name: string, options: {
  46686. points: Vector3[];
  46687. dashSize?: number;
  46688. gapSize?: number;
  46689. dashNb?: number;
  46690. updatable?: boolean;
  46691. instance?: LinesMesh;
  46692. useVertexAlpha?: boolean;
  46693. }, scene?: Nullable<Scene>): LinesMesh;
  46694. }
  46695. }
  46696. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46697. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46698. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46699. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46701. import { Vector3 } from "babylonjs/Maths/math.vector";
  46702. import { Material } from "babylonjs/Materials/material";
  46703. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46704. import { Scene } from "babylonjs/scene";
  46705. /**
  46706. * The options container for the teleportation module
  46707. */
  46708. export interface IWebXRTeleportationOptions {
  46709. /**
  46710. * if provided, this scene will be used to render meshes.
  46711. */
  46712. customUtilityLayerScene?: Scene;
  46713. /**
  46714. * Values to configure the default target mesh
  46715. */
  46716. defaultTargetMeshOptions?: {
  46717. /**
  46718. * Fill color of the teleportation area
  46719. */
  46720. teleportationFillColor?: string;
  46721. /**
  46722. * Border color for the teleportation area
  46723. */
  46724. teleportationBorderColor?: string;
  46725. /**
  46726. * Disable the mesh's animation sequence
  46727. */
  46728. disableAnimation?: boolean;
  46729. /**
  46730. * Disable lighting on the material or the ring and arrow
  46731. */
  46732. disableLighting?: boolean;
  46733. /**
  46734. * Override the default material of the torus and arrow
  46735. */
  46736. torusArrowMaterial?: Material;
  46737. };
  46738. /**
  46739. * A list of meshes to use as floor meshes.
  46740. * Meshes can be added and removed after initializing the feature using the
  46741. * addFloorMesh and removeFloorMesh functions
  46742. * If empty, rotation will still work
  46743. */
  46744. floorMeshes?: AbstractMesh[];
  46745. /**
  46746. * use this rendering group id for the meshes (optional)
  46747. */
  46748. renderingGroupId?: number;
  46749. /**
  46750. * Should teleportation move only to snap points
  46751. */
  46752. snapPointsOnly?: boolean;
  46753. /**
  46754. * An array of points to which the teleportation will snap to.
  46755. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46756. */
  46757. snapPositions?: Vector3[];
  46758. /**
  46759. * How close should the teleportation ray be in order to snap to position.
  46760. * Default to 0.8 units (meters)
  46761. */
  46762. snapToPositionRadius?: number;
  46763. /**
  46764. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46765. * If you want to support rotation, make sure your mesh has a direction indicator.
  46766. *
  46767. * When left untouched, the default mesh will be initialized.
  46768. */
  46769. teleportationTargetMesh?: AbstractMesh;
  46770. /**
  46771. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46772. */
  46773. timeToTeleport?: number;
  46774. /**
  46775. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46776. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46777. */
  46778. useMainComponentOnly?: boolean;
  46779. /**
  46780. * Should meshes created here be added to a utility layer or the main scene
  46781. */
  46782. useUtilityLayer?: boolean;
  46783. /**
  46784. * Babylon XR Input class for controller
  46785. */
  46786. xrInput: WebXRInput;
  46787. }
  46788. /**
  46789. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46790. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46791. * the input of the attached controllers.
  46792. */
  46793. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46794. private _options;
  46795. private _controllers;
  46796. private _currentTeleportationControllerId;
  46797. private _floorMeshes;
  46798. private _quadraticBezierCurve;
  46799. private _selectionFeature;
  46800. private _snapToPositions;
  46801. private _snappedToPoint;
  46802. private _teleportationRingMaterial?;
  46803. private _tmpRay;
  46804. private _tmpVector;
  46805. /**
  46806. * The module's name
  46807. */
  46808. static readonly Name: string;
  46809. /**
  46810. * The (Babylon) version of this module.
  46811. * This is an integer representing the implementation version.
  46812. * This number does not correspond to the webxr specs version
  46813. */
  46814. static readonly Version: number;
  46815. /**
  46816. * Is movement backwards enabled
  46817. */
  46818. backwardsMovementEnabled: boolean;
  46819. /**
  46820. * Distance to travel when moving backwards
  46821. */
  46822. backwardsTeleportationDistance: number;
  46823. /**
  46824. * The distance from the user to the inspection point in the direction of the controller
  46825. * A higher number will allow the user to move further
  46826. * defaults to 5 (meters, in xr units)
  46827. */
  46828. parabolicCheckRadius: number;
  46829. /**
  46830. * Should the module support parabolic ray on top of direct ray
  46831. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46832. * Very helpful when moving between floors / different heights
  46833. */
  46834. parabolicRayEnabled: boolean;
  46835. /**
  46836. * How much rotation should be applied when rotating right and left
  46837. */
  46838. rotationAngle: number;
  46839. /**
  46840. * Is rotation enabled when moving forward?
  46841. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46842. */
  46843. rotationEnabled: boolean;
  46844. /**
  46845. * constructs a new anchor system
  46846. * @param _xrSessionManager an instance of WebXRSessionManager
  46847. * @param _options configuration object for this feature
  46848. */
  46849. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46850. /**
  46851. * Get the snapPointsOnly flag
  46852. */
  46853. get snapPointsOnly(): boolean;
  46854. /**
  46855. * Sets the snapPointsOnly flag
  46856. * @param snapToPoints should teleportation be exclusively to snap points
  46857. */
  46858. set snapPointsOnly(snapToPoints: boolean);
  46859. /**
  46860. * Add a new mesh to the floor meshes array
  46861. * @param mesh the mesh to use as floor mesh
  46862. */
  46863. addFloorMesh(mesh: AbstractMesh): void;
  46864. /**
  46865. * Add a new snap-to point to fix teleportation to this position
  46866. * @param newSnapPoint The new Snap-To point
  46867. */
  46868. addSnapPoint(newSnapPoint: Vector3): void;
  46869. attach(): boolean;
  46870. detach(): boolean;
  46871. dispose(): void;
  46872. /**
  46873. * Remove a mesh from the floor meshes array
  46874. * @param mesh the mesh to remove
  46875. */
  46876. removeFloorMesh(mesh: AbstractMesh): void;
  46877. /**
  46878. * Remove a mesh from the floor meshes array using its name
  46879. * @param name the mesh name to remove
  46880. */
  46881. removeFloorMeshByName(name: string): void;
  46882. /**
  46883. * 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
  46884. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46885. * @returns was the point found and removed or not
  46886. */
  46887. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46888. /**
  46889. * This function sets a selection feature that will be disabled when
  46890. * the forward ray is shown and will be reattached when hidden.
  46891. * This is used to remove the selection rays when moving.
  46892. * @param selectionFeature the feature to disable when forward movement is enabled
  46893. */
  46894. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46895. protected _onXRFrame(_xrFrame: XRFrame): void;
  46896. private _attachController;
  46897. private _createDefaultTargetMesh;
  46898. private _detachController;
  46899. private _findClosestSnapPointWithRadius;
  46900. private _setTargetMeshPosition;
  46901. private _setTargetMeshVisibility;
  46902. private _showParabolicPath;
  46903. private _teleportForward;
  46904. }
  46905. }
  46906. declare module "babylonjs/XR/webXRDefaultExperience" {
  46907. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46908. import { Scene } from "babylonjs/scene";
  46909. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46910. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46911. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46912. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46914. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46915. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46916. /**
  46917. * Options for the default xr helper
  46918. */
  46919. export class WebXRDefaultExperienceOptions {
  46920. /**
  46921. * Enable or disable default UI to enter XR
  46922. */
  46923. disableDefaultUI?: boolean;
  46924. /**
  46925. * Should teleportation not initialize. defaults to false.
  46926. */
  46927. disableTeleportation?: boolean;
  46928. /**
  46929. * Floor meshes that will be used for teleport
  46930. */
  46931. floorMeshes?: Array<AbstractMesh>;
  46932. /**
  46933. * If set to true, the first frame will not be used to reset position
  46934. * The first frame is mainly used when copying transformation from the old camera
  46935. * Mainly used in AR
  46936. */
  46937. ignoreNativeCameraTransformation?: boolean;
  46938. /**
  46939. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46940. */
  46941. inputOptions?: IWebXRInputOptions;
  46942. /**
  46943. * optional configuration for the output canvas
  46944. */
  46945. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46946. /**
  46947. * optional UI options. This can be used among other to change session mode and reference space type
  46948. */
  46949. uiOptions?: WebXREnterExitUIOptions;
  46950. /**
  46951. * When loading teleportation and pointer select, use stable versions instead of latest.
  46952. */
  46953. useStablePlugins?: boolean;
  46954. }
  46955. /**
  46956. * Default experience which provides a similar setup to the previous webVRExperience
  46957. */
  46958. export class WebXRDefaultExperience {
  46959. /**
  46960. * Base experience
  46961. */
  46962. baseExperience: WebXRExperienceHelper;
  46963. /**
  46964. * Enables ui for entering/exiting xr
  46965. */
  46966. enterExitUI: WebXREnterExitUI;
  46967. /**
  46968. * Input experience extension
  46969. */
  46970. input: WebXRInput;
  46971. /**
  46972. * Enables laser pointer and selection
  46973. */
  46974. pointerSelection: WebXRControllerPointerSelection;
  46975. /**
  46976. * Default target xr should render to
  46977. */
  46978. renderTarget: WebXRRenderTarget;
  46979. /**
  46980. * Enables teleportation
  46981. */
  46982. teleportation: WebXRMotionControllerTeleportation;
  46983. private constructor();
  46984. /**
  46985. * Creates the default xr experience
  46986. * @param scene scene
  46987. * @param options options for basic configuration
  46988. * @returns resulting WebXRDefaultExperience
  46989. */
  46990. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46991. /**
  46992. * DIsposes of the experience helper
  46993. */
  46994. dispose(): void;
  46995. }
  46996. }
  46997. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46998. import { Observable } from "babylonjs/Misc/observable";
  46999. import { Nullable } from "babylonjs/types";
  47000. import { Camera } from "babylonjs/Cameras/camera";
  47001. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47002. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47003. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47004. import { Scene } from "babylonjs/scene";
  47005. import { Vector3 } from "babylonjs/Maths/math.vector";
  47006. import { Color3 } from "babylonjs/Maths/math.color";
  47007. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47009. import { Mesh } from "babylonjs/Meshes/mesh";
  47010. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47011. import { EasingFunction } from "babylonjs/Animations/easing";
  47012. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47013. import "babylonjs/Meshes/Builders/groundBuilder";
  47014. import "babylonjs/Meshes/Builders/torusBuilder";
  47015. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47016. import "babylonjs/Gamepads/gamepadSceneComponent";
  47017. import "babylonjs/Animations/animatable";
  47018. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47019. /**
  47020. * Options to modify the vr teleportation behavior.
  47021. */
  47022. export interface VRTeleportationOptions {
  47023. /**
  47024. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47025. */
  47026. floorMeshName?: string;
  47027. /**
  47028. * A list of meshes to be used as the teleportation floor. (default: empty)
  47029. */
  47030. floorMeshes?: Mesh[];
  47031. /**
  47032. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47033. */
  47034. teleportationMode?: number;
  47035. /**
  47036. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47037. */
  47038. teleportationTime?: number;
  47039. /**
  47040. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47041. */
  47042. teleportationSpeed?: number;
  47043. /**
  47044. * The easing function used in the animation or null for Linear. (default CircleEase)
  47045. */
  47046. easingFunction?: EasingFunction;
  47047. }
  47048. /**
  47049. * Options to modify the vr experience helper's behavior.
  47050. */
  47051. export interface VRExperienceHelperOptions extends WebVROptions {
  47052. /**
  47053. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47054. */
  47055. createDeviceOrientationCamera?: boolean;
  47056. /**
  47057. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47058. */
  47059. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47060. /**
  47061. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47062. */
  47063. laserToggle?: boolean;
  47064. /**
  47065. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47066. */
  47067. floorMeshes?: Mesh[];
  47068. /**
  47069. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47070. */
  47071. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47072. /**
  47073. * Defines if WebXR should be used instead of WebVR (if available)
  47074. */
  47075. useXR?: boolean;
  47076. }
  47077. /**
  47078. * Event containing information after VR has been entered
  47079. */
  47080. export class OnAfterEnteringVRObservableEvent {
  47081. /**
  47082. * If entering vr was successful
  47083. */
  47084. success: boolean;
  47085. }
  47086. /**
  47087. * Helps to quickly add VR support to an existing scene.
  47088. * See http://doc.babylonjs.com/how_to/webvr_helper
  47089. */
  47090. export class VRExperienceHelper {
  47091. /** Options to modify the vr experience helper's behavior. */
  47092. webVROptions: VRExperienceHelperOptions;
  47093. private _scene;
  47094. private _position;
  47095. private _btnVR;
  47096. private _btnVRDisplayed;
  47097. private _webVRsupported;
  47098. private _webVRready;
  47099. private _webVRrequesting;
  47100. private _webVRpresenting;
  47101. private _hasEnteredVR;
  47102. private _fullscreenVRpresenting;
  47103. private _inputElement;
  47104. private _webVRCamera;
  47105. private _vrDeviceOrientationCamera;
  47106. private _deviceOrientationCamera;
  47107. private _existingCamera;
  47108. private _onKeyDown;
  47109. private _onVrDisplayPresentChange;
  47110. private _onVRDisplayChanged;
  47111. private _onVRRequestPresentStart;
  47112. private _onVRRequestPresentComplete;
  47113. /**
  47114. * 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)
  47115. */
  47116. enableGazeEvenWhenNoPointerLock: boolean;
  47117. /**
  47118. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47119. */
  47120. exitVROnDoubleTap: boolean;
  47121. /**
  47122. * Observable raised right before entering VR.
  47123. */
  47124. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47125. /**
  47126. * Observable raised when entering VR has completed.
  47127. */
  47128. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47129. /**
  47130. * Observable raised when exiting VR.
  47131. */
  47132. onExitingVRObservable: Observable<VRExperienceHelper>;
  47133. /**
  47134. * Observable raised when controller mesh is loaded.
  47135. */
  47136. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47137. /** Return this.onEnteringVRObservable
  47138. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47139. */
  47140. get onEnteringVR(): Observable<VRExperienceHelper>;
  47141. /** Return this.onExitingVRObservable
  47142. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47143. */
  47144. get onExitingVR(): Observable<VRExperienceHelper>;
  47145. /** Return this.onControllerMeshLoadedObservable
  47146. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47147. */
  47148. get onControllerMeshLoaded(): Observable<WebVRController>;
  47149. private _rayLength;
  47150. private _useCustomVRButton;
  47151. private _teleportationRequested;
  47152. private _teleportActive;
  47153. private _floorMeshName;
  47154. private _floorMeshesCollection;
  47155. private _teleportationMode;
  47156. private _teleportationTime;
  47157. private _teleportationSpeed;
  47158. private _teleportationEasing;
  47159. private _rotationAllowed;
  47160. private _teleportBackwardsVector;
  47161. private _teleportationTarget;
  47162. private _isDefaultTeleportationTarget;
  47163. private _postProcessMove;
  47164. private _teleportationFillColor;
  47165. private _teleportationBorderColor;
  47166. private _rotationAngle;
  47167. private _haloCenter;
  47168. private _cameraGazer;
  47169. private _padSensibilityUp;
  47170. private _padSensibilityDown;
  47171. private _leftController;
  47172. private _rightController;
  47173. private _gazeColor;
  47174. private _laserColor;
  47175. private _pickedLaserColor;
  47176. private _pickedGazeColor;
  47177. /**
  47178. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47179. */
  47180. onNewMeshSelected: Observable<AbstractMesh>;
  47181. /**
  47182. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47183. * This observable will provide the mesh and the controller used to select the mesh
  47184. */
  47185. onMeshSelectedWithController: Observable<{
  47186. mesh: AbstractMesh;
  47187. controller: WebVRController;
  47188. }>;
  47189. /**
  47190. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47191. */
  47192. onNewMeshPicked: Observable<PickingInfo>;
  47193. private _circleEase;
  47194. /**
  47195. * Observable raised before camera teleportation
  47196. */
  47197. onBeforeCameraTeleport: Observable<Vector3>;
  47198. /**
  47199. * Observable raised after camera teleportation
  47200. */
  47201. onAfterCameraTeleport: Observable<Vector3>;
  47202. /**
  47203. * Observable raised when current selected mesh gets unselected
  47204. */
  47205. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47206. private _raySelectionPredicate;
  47207. /**
  47208. * To be optionaly changed by user to define custom ray selection
  47209. */
  47210. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47211. /**
  47212. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47213. */
  47214. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47215. /**
  47216. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47217. */
  47218. teleportationEnabled: boolean;
  47219. private _defaultHeight;
  47220. private _teleportationInitialized;
  47221. private _interactionsEnabled;
  47222. private _interactionsRequested;
  47223. private _displayGaze;
  47224. private _displayLaserPointer;
  47225. /**
  47226. * The mesh used to display where the user is going to teleport.
  47227. */
  47228. get teleportationTarget(): Mesh;
  47229. /**
  47230. * Sets the mesh to be used to display where the user is going to teleport.
  47231. */
  47232. set teleportationTarget(value: Mesh);
  47233. /**
  47234. * 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
  47235. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47236. * See http://doc.babylonjs.com/resources/baking_transformations
  47237. */
  47238. get gazeTrackerMesh(): Mesh;
  47239. set gazeTrackerMesh(value: Mesh);
  47240. /**
  47241. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47242. */
  47243. updateGazeTrackerScale: boolean;
  47244. /**
  47245. * If the gaze trackers color should be updated when selecting meshes
  47246. */
  47247. updateGazeTrackerColor: boolean;
  47248. /**
  47249. * If the controller laser color should be updated when selecting meshes
  47250. */
  47251. updateControllerLaserColor: boolean;
  47252. /**
  47253. * The gaze tracking mesh corresponding to the left controller
  47254. */
  47255. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47256. /**
  47257. * The gaze tracking mesh corresponding to the right controller
  47258. */
  47259. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47260. /**
  47261. * If the ray of the gaze should be displayed.
  47262. */
  47263. get displayGaze(): boolean;
  47264. /**
  47265. * Sets if the ray of the gaze should be displayed.
  47266. */
  47267. set displayGaze(value: boolean);
  47268. /**
  47269. * If the ray of the LaserPointer should be displayed.
  47270. */
  47271. get displayLaserPointer(): boolean;
  47272. /**
  47273. * Sets if the ray of the LaserPointer should be displayed.
  47274. */
  47275. set displayLaserPointer(value: boolean);
  47276. /**
  47277. * The deviceOrientationCamera used as the camera when not in VR.
  47278. */
  47279. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47280. /**
  47281. * Based on the current WebVR support, returns the current VR camera used.
  47282. */
  47283. get currentVRCamera(): Nullable<Camera>;
  47284. /**
  47285. * The webVRCamera which is used when in VR.
  47286. */
  47287. get webVRCamera(): WebVRFreeCamera;
  47288. /**
  47289. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47290. */
  47291. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47292. /**
  47293. * The html button that is used to trigger entering into VR.
  47294. */
  47295. get vrButton(): Nullable<HTMLButtonElement>;
  47296. private get _teleportationRequestInitiated();
  47297. /**
  47298. * Defines whether or not Pointer lock should be requested when switching to
  47299. * full screen.
  47300. */
  47301. requestPointerLockOnFullScreen: boolean;
  47302. /**
  47303. * If asking to force XR, this will be populated with the default xr experience
  47304. */
  47305. xr: WebXRDefaultExperience;
  47306. /**
  47307. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47308. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47309. */
  47310. xrTestDone: boolean;
  47311. /**
  47312. * Instantiates a VRExperienceHelper.
  47313. * Helps to quickly add VR support to an existing scene.
  47314. * @param scene The scene the VRExperienceHelper belongs to.
  47315. * @param webVROptions Options to modify the vr experience helper's behavior.
  47316. */
  47317. constructor(scene: Scene,
  47318. /** Options to modify the vr experience helper's behavior. */
  47319. webVROptions?: VRExperienceHelperOptions);
  47320. private completeVRInit;
  47321. private _onDefaultMeshLoaded;
  47322. private _onResize;
  47323. private _onFullscreenChange;
  47324. /**
  47325. * Gets a value indicating if we are currently in VR mode.
  47326. */
  47327. get isInVRMode(): boolean;
  47328. private onVrDisplayPresentChange;
  47329. private onVRDisplayChanged;
  47330. private moveButtonToBottomRight;
  47331. private displayVRButton;
  47332. private updateButtonVisibility;
  47333. private _cachedAngularSensibility;
  47334. /**
  47335. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47336. * Otherwise, will use the fullscreen API.
  47337. */
  47338. enterVR(): void;
  47339. /**
  47340. * Attempt to exit VR, or fullscreen.
  47341. */
  47342. exitVR(): void;
  47343. /**
  47344. * The position of the vr experience helper.
  47345. */
  47346. get position(): Vector3;
  47347. /**
  47348. * Sets the position of the vr experience helper.
  47349. */
  47350. set position(value: Vector3);
  47351. /**
  47352. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47353. */
  47354. enableInteractions(): void;
  47355. private get _noControllerIsActive();
  47356. private beforeRender;
  47357. private _isTeleportationFloor;
  47358. /**
  47359. * Adds a floor mesh to be used for teleportation.
  47360. * @param floorMesh the mesh to be used for teleportation.
  47361. */
  47362. addFloorMesh(floorMesh: Mesh): void;
  47363. /**
  47364. * Removes a floor mesh from being used for teleportation.
  47365. * @param floorMesh the mesh to be removed.
  47366. */
  47367. removeFloorMesh(floorMesh: Mesh): void;
  47368. /**
  47369. * Enables interactions and teleportation using the VR controllers and gaze.
  47370. * @param vrTeleportationOptions options to modify teleportation behavior.
  47371. */
  47372. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47373. private _onNewGamepadConnected;
  47374. private _tryEnableInteractionOnController;
  47375. private _onNewGamepadDisconnected;
  47376. private _enableInteractionOnController;
  47377. private _checkTeleportWithRay;
  47378. private _checkRotate;
  47379. private _checkTeleportBackwards;
  47380. private _enableTeleportationOnController;
  47381. private _createTeleportationCircles;
  47382. private _displayTeleportationTarget;
  47383. private _hideTeleportationTarget;
  47384. private _rotateCamera;
  47385. private _moveTeleportationSelectorTo;
  47386. private _workingVector;
  47387. private _workingQuaternion;
  47388. private _workingMatrix;
  47389. /**
  47390. * Time Constant Teleportation Mode
  47391. */
  47392. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47393. /**
  47394. * Speed Constant Teleportation Mode
  47395. */
  47396. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47397. /**
  47398. * Teleports the users feet to the desired location
  47399. * @param location The location where the user's feet should be placed
  47400. */
  47401. teleportCamera(location: Vector3): void;
  47402. private _convertNormalToDirectionOfRay;
  47403. private _castRayAndSelectObject;
  47404. private _notifySelectedMeshUnselected;
  47405. /**
  47406. * Permanently set new colors for the laser pointer
  47407. * @param color the new laser color
  47408. * @param pickedColor the new laser color when picked mesh detected
  47409. */
  47410. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47411. /**
  47412. * Set lighting enabled / disabled on the laser pointer of both controllers
  47413. * @param enabled should the lighting be enabled on the laser pointer
  47414. */
  47415. setLaserLightingState(enabled?: boolean): void;
  47416. /**
  47417. * Permanently set new colors for the gaze pointer
  47418. * @param color the new gaze color
  47419. * @param pickedColor the new gaze color when picked mesh detected
  47420. */
  47421. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47422. /**
  47423. * Sets the color of the laser ray from the vr controllers.
  47424. * @param color new color for the ray.
  47425. */
  47426. changeLaserColor(color: Color3): void;
  47427. /**
  47428. * Sets the color of the ray from the vr headsets gaze.
  47429. * @param color new color for the ray.
  47430. */
  47431. changeGazeColor(color: Color3): void;
  47432. /**
  47433. * Exits VR and disposes of the vr experience helper
  47434. */
  47435. dispose(): void;
  47436. /**
  47437. * Gets the name of the VRExperienceHelper class
  47438. * @returns "VRExperienceHelper"
  47439. */
  47440. getClassName(): string;
  47441. }
  47442. }
  47443. declare module "babylonjs/Cameras/VR/index" {
  47444. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47445. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47446. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47447. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47448. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47449. export * from "babylonjs/Cameras/VR/webVRCamera";
  47450. }
  47451. declare module "babylonjs/Cameras/RigModes/index" {
  47452. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47453. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47454. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47455. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47456. }
  47457. declare module "babylonjs/Cameras/index" {
  47458. export * from "babylonjs/Cameras/Inputs/index";
  47459. export * from "babylonjs/Cameras/cameraInputsManager";
  47460. export * from "babylonjs/Cameras/camera";
  47461. export * from "babylonjs/Cameras/targetCamera";
  47462. export * from "babylonjs/Cameras/freeCamera";
  47463. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47464. export * from "babylonjs/Cameras/touchCamera";
  47465. export * from "babylonjs/Cameras/arcRotateCamera";
  47466. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47467. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47468. export * from "babylonjs/Cameras/flyCamera";
  47469. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47470. export * from "babylonjs/Cameras/followCamera";
  47471. export * from "babylonjs/Cameras/followCameraInputsManager";
  47472. export * from "babylonjs/Cameras/gamepadCamera";
  47473. export * from "babylonjs/Cameras/Stereoscopic/index";
  47474. export * from "babylonjs/Cameras/universalCamera";
  47475. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47476. export * from "babylonjs/Cameras/VR/index";
  47477. export * from "babylonjs/Cameras/RigModes/index";
  47478. }
  47479. declare module "babylonjs/Collisions/index" {
  47480. export * from "babylonjs/Collisions/collider";
  47481. export * from "babylonjs/Collisions/collisionCoordinator";
  47482. export * from "babylonjs/Collisions/pickingInfo";
  47483. export * from "babylonjs/Collisions/intersectionInfo";
  47484. export * from "babylonjs/Collisions/meshCollisionData";
  47485. }
  47486. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47487. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47488. import { Vector3 } from "babylonjs/Maths/math.vector";
  47489. import { Ray } from "babylonjs/Culling/ray";
  47490. import { Plane } from "babylonjs/Maths/math.plane";
  47491. /**
  47492. * Contains an array of blocks representing the octree
  47493. */
  47494. export interface IOctreeContainer<T> {
  47495. /**
  47496. * Blocks within the octree
  47497. */
  47498. blocks: Array<OctreeBlock<T>>;
  47499. }
  47500. /**
  47501. * Class used to store a cell in an octree
  47502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47503. */
  47504. export class OctreeBlock<T> {
  47505. /**
  47506. * Gets the content of the current block
  47507. */
  47508. entries: T[];
  47509. /**
  47510. * Gets the list of block children
  47511. */
  47512. blocks: Array<OctreeBlock<T>>;
  47513. private _depth;
  47514. private _maxDepth;
  47515. private _capacity;
  47516. private _minPoint;
  47517. private _maxPoint;
  47518. private _boundingVectors;
  47519. private _creationFunc;
  47520. /**
  47521. * Creates a new block
  47522. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47523. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47524. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47525. * @param depth defines the current depth of this block in the octree
  47526. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47527. * @param creationFunc defines a callback to call when an element is added to the block
  47528. */
  47529. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47530. /**
  47531. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47532. */
  47533. get capacity(): number;
  47534. /**
  47535. * Gets the minimum vector (in world space) of the block's bounding box
  47536. */
  47537. get minPoint(): Vector3;
  47538. /**
  47539. * Gets the maximum vector (in world space) of the block's bounding box
  47540. */
  47541. get maxPoint(): Vector3;
  47542. /**
  47543. * Add a new element to this block
  47544. * @param entry defines the element to add
  47545. */
  47546. addEntry(entry: T): void;
  47547. /**
  47548. * Remove an element from this block
  47549. * @param entry defines the element to remove
  47550. */
  47551. removeEntry(entry: T): void;
  47552. /**
  47553. * Add an array of elements to this block
  47554. * @param entries defines the array of elements to add
  47555. */
  47556. addEntries(entries: T[]): void;
  47557. /**
  47558. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47559. * @param frustumPlanes defines the frustum planes to test
  47560. * @param selection defines the array to store current content if selection is positive
  47561. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47562. */
  47563. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47564. /**
  47565. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47566. * @param sphereCenter defines the bounding sphere center
  47567. * @param sphereRadius defines the bounding sphere radius
  47568. * @param selection defines the array to store current content if selection is positive
  47569. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47570. */
  47571. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47572. /**
  47573. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47574. * @param ray defines the ray to test with
  47575. * @param selection defines the array to store current content if selection is positive
  47576. */
  47577. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47578. /**
  47579. * Subdivide the content into child blocks (this block will then be empty)
  47580. */
  47581. createInnerBlocks(): void;
  47582. /**
  47583. * @hidden
  47584. */
  47585. 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;
  47586. }
  47587. }
  47588. declare module "babylonjs/Culling/Octrees/octree" {
  47589. import { SmartArray } from "babylonjs/Misc/smartArray";
  47590. import { Vector3 } from "babylonjs/Maths/math.vector";
  47591. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47593. import { Ray } from "babylonjs/Culling/ray";
  47594. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47595. import { Plane } from "babylonjs/Maths/math.plane";
  47596. /**
  47597. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47598. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47599. */
  47600. export class Octree<T> {
  47601. /** 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.) */
  47602. maxDepth: number;
  47603. /**
  47604. * Blocks within the octree containing objects
  47605. */
  47606. blocks: Array<OctreeBlock<T>>;
  47607. /**
  47608. * Content stored in the octree
  47609. */
  47610. dynamicContent: T[];
  47611. private _maxBlockCapacity;
  47612. private _selectionContent;
  47613. private _creationFunc;
  47614. /**
  47615. * Creates a octree
  47616. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47617. * @param creationFunc function to be used to instatiate the octree
  47618. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47619. * @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.)
  47620. */
  47621. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47622. /** 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.) */
  47623. maxDepth?: number);
  47624. /**
  47625. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47626. * @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);
  47627. * @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);
  47628. * @param entries meshes to be added to the octree blocks
  47629. */
  47630. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47631. /**
  47632. * Adds a mesh to the octree
  47633. * @param entry Mesh to add to the octree
  47634. */
  47635. addMesh(entry: T): void;
  47636. /**
  47637. * Remove an element from the octree
  47638. * @param entry defines the element to remove
  47639. */
  47640. removeMesh(entry: T): void;
  47641. /**
  47642. * Selects an array of meshes within the frustum
  47643. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47644. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47645. * @returns array of meshes within the frustum
  47646. */
  47647. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47648. /**
  47649. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47650. * @param sphereCenter defines the bounding sphere center
  47651. * @param sphereRadius defines the bounding sphere radius
  47652. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47653. * @returns an array of objects that intersect the sphere
  47654. */
  47655. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47656. /**
  47657. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47658. * @param ray defines the ray to test with
  47659. * @returns array of intersected objects
  47660. */
  47661. intersectsRay(ray: Ray): SmartArray<T>;
  47662. /**
  47663. * Adds a mesh into the octree block if it intersects the block
  47664. */
  47665. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47666. /**
  47667. * Adds a submesh into the octree block if it intersects the block
  47668. */
  47669. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47670. }
  47671. }
  47672. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47673. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47674. import { Scene } from "babylonjs/scene";
  47675. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47677. import { Ray } from "babylonjs/Culling/ray";
  47678. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47679. import { Collider } from "babylonjs/Collisions/collider";
  47680. module "babylonjs/scene" {
  47681. interface Scene {
  47682. /**
  47683. * @hidden
  47684. * Backing Filed
  47685. */
  47686. _selectionOctree: Octree<AbstractMesh>;
  47687. /**
  47688. * Gets the octree used to boost mesh selection (picking)
  47689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47690. */
  47691. selectionOctree: Octree<AbstractMesh>;
  47692. /**
  47693. * Creates or updates the octree used to boost selection (picking)
  47694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47695. * @param maxCapacity defines the maximum capacity per leaf
  47696. * @param maxDepth defines the maximum depth of the octree
  47697. * @returns an octree of AbstractMesh
  47698. */
  47699. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47700. }
  47701. }
  47702. module "babylonjs/Meshes/abstractMesh" {
  47703. interface AbstractMesh {
  47704. /**
  47705. * @hidden
  47706. * Backing Field
  47707. */
  47708. _submeshesOctree: Octree<SubMesh>;
  47709. /**
  47710. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47711. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47712. * @param maxCapacity defines the maximum size of each block (64 by default)
  47713. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47714. * @returns the new octree
  47715. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47717. */
  47718. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47719. }
  47720. }
  47721. /**
  47722. * Defines the octree scene component responsible to manage any octrees
  47723. * in a given scene.
  47724. */
  47725. export class OctreeSceneComponent {
  47726. /**
  47727. * The component name help to identify the component in the list of scene components.
  47728. */
  47729. readonly name: string;
  47730. /**
  47731. * The scene the component belongs to.
  47732. */
  47733. scene: Scene;
  47734. /**
  47735. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47736. */
  47737. readonly checksIsEnabled: boolean;
  47738. /**
  47739. * Creates a new instance of the component for the given scene
  47740. * @param scene Defines the scene to register the component in
  47741. */
  47742. constructor(scene: Scene);
  47743. /**
  47744. * Registers the component in a given scene
  47745. */
  47746. register(): void;
  47747. /**
  47748. * Return the list of active meshes
  47749. * @returns the list of active meshes
  47750. */
  47751. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47752. /**
  47753. * Return the list of active sub meshes
  47754. * @param mesh The mesh to get the candidates sub meshes from
  47755. * @returns the list of active sub meshes
  47756. */
  47757. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47758. private _tempRay;
  47759. /**
  47760. * Return the list of sub meshes intersecting with a given local ray
  47761. * @param mesh defines the mesh to find the submesh for
  47762. * @param localRay defines the ray in local space
  47763. * @returns the list of intersecting sub meshes
  47764. */
  47765. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47766. /**
  47767. * Return the list of sub meshes colliding with a collider
  47768. * @param mesh defines the mesh to find the submesh for
  47769. * @param collider defines the collider to evaluate the collision against
  47770. * @returns the list of colliding sub meshes
  47771. */
  47772. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47773. /**
  47774. * Rebuilds the elements related to this component in case of
  47775. * context lost for instance.
  47776. */
  47777. rebuild(): void;
  47778. /**
  47779. * Disposes the component and the associated ressources.
  47780. */
  47781. dispose(): void;
  47782. }
  47783. }
  47784. declare module "babylonjs/Culling/Octrees/index" {
  47785. export * from "babylonjs/Culling/Octrees/octree";
  47786. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47787. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47788. }
  47789. declare module "babylonjs/Culling/index" {
  47790. export * from "babylonjs/Culling/boundingBox";
  47791. export * from "babylonjs/Culling/boundingInfo";
  47792. export * from "babylonjs/Culling/boundingSphere";
  47793. export * from "babylonjs/Culling/Octrees/index";
  47794. export * from "babylonjs/Culling/ray";
  47795. }
  47796. declare module "babylonjs/Gizmos/gizmo" {
  47797. import { Nullable } from "babylonjs/types";
  47798. import { IDisposable } from "babylonjs/scene";
  47799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47800. import { Mesh } from "babylonjs/Meshes/mesh";
  47801. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47802. /**
  47803. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47804. */
  47805. export class Gizmo implements IDisposable {
  47806. /** The utility layer the gizmo will be added to */
  47807. gizmoLayer: UtilityLayerRenderer;
  47808. /**
  47809. * The root mesh of the gizmo
  47810. */
  47811. _rootMesh: Mesh;
  47812. private _attachedMesh;
  47813. /**
  47814. * Ratio for the scale of the gizmo (Default: 1)
  47815. */
  47816. scaleRatio: number;
  47817. /**
  47818. * If a custom mesh has been set (Default: false)
  47819. */
  47820. protected _customMeshSet: boolean;
  47821. /**
  47822. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47823. * * When set, interactions will be enabled
  47824. */
  47825. get attachedMesh(): Nullable<AbstractMesh>;
  47826. set attachedMesh(value: Nullable<AbstractMesh>);
  47827. /**
  47828. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47829. * @param mesh The mesh to replace the default mesh of the gizmo
  47830. */
  47831. setCustomMesh(mesh: Mesh): void;
  47832. /**
  47833. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47834. */
  47835. updateGizmoRotationToMatchAttachedMesh: boolean;
  47836. /**
  47837. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47838. */
  47839. updateGizmoPositionToMatchAttachedMesh: boolean;
  47840. /**
  47841. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47842. */
  47843. updateScale: boolean;
  47844. protected _interactionsEnabled: boolean;
  47845. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47846. private _beforeRenderObserver;
  47847. private _tempVector;
  47848. /**
  47849. * Creates a gizmo
  47850. * @param gizmoLayer The utility layer the gizmo will be added to
  47851. */
  47852. constructor(
  47853. /** The utility layer the gizmo will be added to */
  47854. gizmoLayer?: UtilityLayerRenderer);
  47855. /**
  47856. * Updates the gizmo to match the attached mesh's position/rotation
  47857. */
  47858. protected _update(): void;
  47859. /**
  47860. * Disposes of the gizmo
  47861. */
  47862. dispose(): void;
  47863. }
  47864. }
  47865. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47866. import { Observable } from "babylonjs/Misc/observable";
  47867. import { Nullable } from "babylonjs/types";
  47868. import { Vector3 } from "babylonjs/Maths/math.vector";
  47869. import { Color3 } from "babylonjs/Maths/math.color";
  47870. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47872. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47873. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47874. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47875. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47876. import { Scene } from "babylonjs/scene";
  47877. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47878. /**
  47879. * Single plane drag gizmo
  47880. */
  47881. export class PlaneDragGizmo extends Gizmo {
  47882. /**
  47883. * Drag behavior responsible for the gizmos dragging interactions
  47884. */
  47885. dragBehavior: PointerDragBehavior;
  47886. private _pointerObserver;
  47887. /**
  47888. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47889. */
  47890. snapDistance: number;
  47891. /**
  47892. * Event that fires each time the gizmo snaps to a new location.
  47893. * * snapDistance is the the change in distance
  47894. */
  47895. onSnapObservable: Observable<{
  47896. snapDistance: number;
  47897. }>;
  47898. private _plane;
  47899. private _coloredMaterial;
  47900. private _hoverMaterial;
  47901. private _isEnabled;
  47902. private _parent;
  47903. /** @hidden */
  47904. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47905. /** @hidden */
  47906. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47907. /**
  47908. * Creates a PlaneDragGizmo
  47909. * @param gizmoLayer The utility layer the gizmo will be added to
  47910. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47911. * @param color The color of the gizmo
  47912. */
  47913. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47914. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47915. /**
  47916. * If the gizmo is enabled
  47917. */
  47918. set isEnabled(value: boolean);
  47919. get isEnabled(): boolean;
  47920. /**
  47921. * Disposes of the gizmo
  47922. */
  47923. dispose(): void;
  47924. }
  47925. }
  47926. declare module "babylonjs/Gizmos/positionGizmo" {
  47927. import { Observable } from "babylonjs/Misc/observable";
  47928. import { Nullable } from "babylonjs/types";
  47929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47930. import { Mesh } from "babylonjs/Meshes/mesh";
  47931. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47932. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47933. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47934. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47935. /**
  47936. * Gizmo that enables dragging a mesh along 3 axis
  47937. */
  47938. export class PositionGizmo extends Gizmo {
  47939. /**
  47940. * Internal gizmo used for interactions on the x axis
  47941. */
  47942. xGizmo: AxisDragGizmo;
  47943. /**
  47944. * Internal gizmo used for interactions on the y axis
  47945. */
  47946. yGizmo: AxisDragGizmo;
  47947. /**
  47948. * Internal gizmo used for interactions on the z axis
  47949. */
  47950. zGizmo: AxisDragGizmo;
  47951. /**
  47952. * Internal gizmo used for interactions on the yz plane
  47953. */
  47954. xPlaneGizmo: PlaneDragGizmo;
  47955. /**
  47956. * Internal gizmo used for interactions on the xz plane
  47957. */
  47958. yPlaneGizmo: PlaneDragGizmo;
  47959. /**
  47960. * Internal gizmo used for interactions on the xy plane
  47961. */
  47962. zPlaneGizmo: PlaneDragGizmo;
  47963. /**
  47964. * private variables
  47965. */
  47966. private _meshAttached;
  47967. private _updateGizmoRotationToMatchAttachedMesh;
  47968. private _snapDistance;
  47969. private _scaleRatio;
  47970. /** Fires an event when any of it's sub gizmos are dragged */
  47971. onDragStartObservable: Observable<unknown>;
  47972. /** Fires an event when any of it's sub gizmos are released from dragging */
  47973. onDragEndObservable: Observable<unknown>;
  47974. /**
  47975. * If set to true, planar drag is enabled
  47976. */
  47977. private _planarGizmoEnabled;
  47978. get attachedMesh(): Nullable<AbstractMesh>;
  47979. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47980. /**
  47981. * Creates a PositionGizmo
  47982. * @param gizmoLayer The utility layer the gizmo will be added to
  47983. */
  47984. constructor(gizmoLayer?: UtilityLayerRenderer);
  47985. /**
  47986. * If the planar drag gizmo is enabled
  47987. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47988. */
  47989. set planarGizmoEnabled(value: boolean);
  47990. get planarGizmoEnabled(): boolean;
  47991. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47992. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47993. /**
  47994. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47995. */
  47996. set snapDistance(value: number);
  47997. get snapDistance(): number;
  47998. /**
  47999. * Ratio for the scale of the gizmo (Default: 1)
  48000. */
  48001. set scaleRatio(value: number);
  48002. get scaleRatio(): number;
  48003. /**
  48004. * Disposes of the gizmo
  48005. */
  48006. dispose(): void;
  48007. /**
  48008. * CustomMeshes are not supported by this gizmo
  48009. * @param mesh The mesh to replace the default mesh of the gizmo
  48010. */
  48011. setCustomMesh(mesh: Mesh): void;
  48012. }
  48013. }
  48014. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48015. import { Observable } from "babylonjs/Misc/observable";
  48016. import { Nullable } from "babylonjs/types";
  48017. import { Vector3 } from "babylonjs/Maths/math.vector";
  48018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48020. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48021. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48022. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48023. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48024. import { Scene } from "babylonjs/scene";
  48025. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48026. import { Color3 } from "babylonjs/Maths/math.color";
  48027. /**
  48028. * Single axis drag gizmo
  48029. */
  48030. export class AxisDragGizmo extends Gizmo {
  48031. /**
  48032. * Drag behavior responsible for the gizmos dragging interactions
  48033. */
  48034. dragBehavior: PointerDragBehavior;
  48035. private _pointerObserver;
  48036. /**
  48037. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48038. */
  48039. snapDistance: number;
  48040. /**
  48041. * Event that fires each time the gizmo snaps to a new location.
  48042. * * snapDistance is the the change in distance
  48043. */
  48044. onSnapObservable: Observable<{
  48045. snapDistance: number;
  48046. }>;
  48047. private _isEnabled;
  48048. private _parent;
  48049. private _arrow;
  48050. private _coloredMaterial;
  48051. private _hoverMaterial;
  48052. /** @hidden */
  48053. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48054. /** @hidden */
  48055. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48056. /**
  48057. * Creates an AxisDragGizmo
  48058. * @param gizmoLayer The utility layer the gizmo will be added to
  48059. * @param dragAxis The axis which the gizmo will be able to drag on
  48060. * @param color The color of the gizmo
  48061. */
  48062. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48063. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48064. /**
  48065. * If the gizmo is enabled
  48066. */
  48067. set isEnabled(value: boolean);
  48068. get isEnabled(): boolean;
  48069. /**
  48070. * Disposes of the gizmo
  48071. */
  48072. dispose(): void;
  48073. }
  48074. }
  48075. declare module "babylonjs/Debug/axesViewer" {
  48076. import { Vector3 } from "babylonjs/Maths/math.vector";
  48077. import { Nullable } from "babylonjs/types";
  48078. import { Scene } from "babylonjs/scene";
  48079. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48080. /**
  48081. * The Axes viewer will show 3 axes in a specific point in space
  48082. */
  48083. export class AxesViewer {
  48084. private _xAxis;
  48085. private _yAxis;
  48086. private _zAxis;
  48087. private _scaleLinesFactor;
  48088. private _instanced;
  48089. /**
  48090. * Gets the hosting scene
  48091. */
  48092. scene: Scene;
  48093. /**
  48094. * Gets or sets a number used to scale line length
  48095. */
  48096. scaleLines: number;
  48097. /** Gets the node hierarchy used to render x-axis */
  48098. get xAxis(): TransformNode;
  48099. /** Gets the node hierarchy used to render y-axis */
  48100. get yAxis(): TransformNode;
  48101. /** Gets the node hierarchy used to render z-axis */
  48102. get zAxis(): TransformNode;
  48103. /**
  48104. * Creates a new AxesViewer
  48105. * @param scene defines the hosting scene
  48106. * @param scaleLines defines a number used to scale line length (1 by default)
  48107. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48108. * @param xAxis defines the node hierarchy used to render the x-axis
  48109. * @param yAxis defines the node hierarchy used to render the y-axis
  48110. * @param zAxis defines the node hierarchy used to render the z-axis
  48111. */
  48112. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48113. /**
  48114. * Force the viewer to update
  48115. * @param position defines the position of the viewer
  48116. * @param xaxis defines the x axis of the viewer
  48117. * @param yaxis defines the y axis of the viewer
  48118. * @param zaxis defines the z axis of the viewer
  48119. */
  48120. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48121. /**
  48122. * Creates an instance of this axes viewer.
  48123. * @returns a new axes viewer with instanced meshes
  48124. */
  48125. createInstance(): AxesViewer;
  48126. /** Releases resources */
  48127. dispose(): void;
  48128. private static _SetRenderingGroupId;
  48129. }
  48130. }
  48131. declare module "babylonjs/Debug/boneAxesViewer" {
  48132. import { Nullable } from "babylonjs/types";
  48133. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48134. import { Vector3 } from "babylonjs/Maths/math.vector";
  48135. import { Mesh } from "babylonjs/Meshes/mesh";
  48136. import { Bone } from "babylonjs/Bones/bone";
  48137. import { Scene } from "babylonjs/scene";
  48138. /**
  48139. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48140. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48141. */
  48142. export class BoneAxesViewer extends AxesViewer {
  48143. /**
  48144. * Gets or sets the target mesh where to display the axes viewer
  48145. */
  48146. mesh: Nullable<Mesh>;
  48147. /**
  48148. * Gets or sets the target bone where to display the axes viewer
  48149. */
  48150. bone: Nullable<Bone>;
  48151. /** Gets current position */
  48152. pos: Vector3;
  48153. /** Gets direction of X axis */
  48154. xaxis: Vector3;
  48155. /** Gets direction of Y axis */
  48156. yaxis: Vector3;
  48157. /** Gets direction of Z axis */
  48158. zaxis: Vector3;
  48159. /**
  48160. * Creates a new BoneAxesViewer
  48161. * @param scene defines the hosting scene
  48162. * @param bone defines the target bone
  48163. * @param mesh defines the target mesh
  48164. * @param scaleLines defines a scaling factor for line length (1 by default)
  48165. */
  48166. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48167. /**
  48168. * Force the viewer to update
  48169. */
  48170. update(): void;
  48171. /** Releases resources */
  48172. dispose(): void;
  48173. }
  48174. }
  48175. declare module "babylonjs/Debug/debugLayer" {
  48176. import { Scene } from "babylonjs/scene";
  48177. /**
  48178. * Interface used to define scene explorer extensibility option
  48179. */
  48180. export interface IExplorerExtensibilityOption {
  48181. /**
  48182. * Define the option label
  48183. */
  48184. label: string;
  48185. /**
  48186. * Defines the action to execute on click
  48187. */
  48188. action: (entity: any) => void;
  48189. }
  48190. /**
  48191. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48192. */
  48193. export interface IExplorerExtensibilityGroup {
  48194. /**
  48195. * Defines a predicate to test if a given type mut be extended
  48196. */
  48197. predicate: (entity: any) => boolean;
  48198. /**
  48199. * Gets the list of options added to a type
  48200. */
  48201. entries: IExplorerExtensibilityOption[];
  48202. }
  48203. /**
  48204. * Interface used to define the options to use to create the Inspector
  48205. */
  48206. export interface IInspectorOptions {
  48207. /**
  48208. * Display in overlay mode (default: false)
  48209. */
  48210. overlay?: boolean;
  48211. /**
  48212. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48213. */
  48214. globalRoot?: HTMLElement;
  48215. /**
  48216. * Display the Scene explorer
  48217. */
  48218. showExplorer?: boolean;
  48219. /**
  48220. * Display the property inspector
  48221. */
  48222. showInspector?: boolean;
  48223. /**
  48224. * Display in embed mode (both panes on the right)
  48225. */
  48226. embedMode?: boolean;
  48227. /**
  48228. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48229. */
  48230. handleResize?: boolean;
  48231. /**
  48232. * Allow the panes to popup (default: true)
  48233. */
  48234. enablePopup?: boolean;
  48235. /**
  48236. * Allow the panes to be closed by users (default: true)
  48237. */
  48238. enableClose?: boolean;
  48239. /**
  48240. * Optional list of extensibility entries
  48241. */
  48242. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48243. /**
  48244. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48245. */
  48246. inspectorURL?: string;
  48247. /**
  48248. * Optional initial tab (default to DebugLayerTab.Properties)
  48249. */
  48250. initialTab?: DebugLayerTab;
  48251. }
  48252. module "babylonjs/scene" {
  48253. interface Scene {
  48254. /**
  48255. * @hidden
  48256. * Backing field
  48257. */
  48258. _debugLayer: DebugLayer;
  48259. /**
  48260. * Gets the debug layer (aka Inspector) associated with the scene
  48261. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48262. */
  48263. debugLayer: DebugLayer;
  48264. }
  48265. }
  48266. /**
  48267. * Enum of inspector action tab
  48268. */
  48269. export enum DebugLayerTab {
  48270. /**
  48271. * Properties tag (default)
  48272. */
  48273. Properties = 0,
  48274. /**
  48275. * Debug tab
  48276. */
  48277. Debug = 1,
  48278. /**
  48279. * Statistics tab
  48280. */
  48281. Statistics = 2,
  48282. /**
  48283. * Tools tab
  48284. */
  48285. Tools = 3,
  48286. /**
  48287. * Settings tab
  48288. */
  48289. Settings = 4
  48290. }
  48291. /**
  48292. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48293. * what is happening in your scene
  48294. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48295. */
  48296. export class DebugLayer {
  48297. /**
  48298. * Define the url to get the inspector script from.
  48299. * By default it uses the babylonjs CDN.
  48300. * @ignoreNaming
  48301. */
  48302. static InspectorURL: string;
  48303. private _scene;
  48304. private BJSINSPECTOR;
  48305. private _onPropertyChangedObservable?;
  48306. /**
  48307. * Observable triggered when a property is changed through the inspector.
  48308. */
  48309. get onPropertyChangedObservable(): any;
  48310. /**
  48311. * Instantiates a new debug layer.
  48312. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48313. * what is happening in your scene
  48314. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48315. * @param scene Defines the scene to inspect
  48316. */
  48317. constructor(scene: Scene);
  48318. /** Creates the inspector window. */
  48319. private _createInspector;
  48320. /**
  48321. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48322. * @param entity defines the entity to select
  48323. * @param lineContainerTitle defines the specific block to highlight
  48324. */
  48325. select(entity: any, lineContainerTitle?: string): void;
  48326. /** Get the inspector from bundle or global */
  48327. private _getGlobalInspector;
  48328. /**
  48329. * Get if the inspector is visible or not.
  48330. * @returns true if visible otherwise, false
  48331. */
  48332. isVisible(): boolean;
  48333. /**
  48334. * Hide the inspector and close its window.
  48335. */
  48336. hide(): void;
  48337. /**
  48338. * Launch the debugLayer.
  48339. * @param config Define the configuration of the inspector
  48340. * @return a promise fulfilled when the debug layer is visible
  48341. */
  48342. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48343. }
  48344. }
  48345. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48346. import { Nullable } from "babylonjs/types";
  48347. import { Scene } from "babylonjs/scene";
  48348. import { Vector4 } from "babylonjs/Maths/math.vector";
  48349. import { Color4 } from "babylonjs/Maths/math.color";
  48350. import { Mesh } from "babylonjs/Meshes/mesh";
  48351. /**
  48352. * Class containing static functions to help procedurally build meshes
  48353. */
  48354. export class BoxBuilder {
  48355. /**
  48356. * Creates a box mesh
  48357. * * The parameter `size` sets the size (float) of each box side (default 1)
  48358. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48359. * * 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)
  48360. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48361. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48362. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48364. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48365. * @param name defines the name of the mesh
  48366. * @param options defines the options used to create the mesh
  48367. * @param scene defines the hosting scene
  48368. * @returns the box mesh
  48369. */
  48370. static CreateBox(name: string, options: {
  48371. size?: number;
  48372. width?: number;
  48373. height?: number;
  48374. depth?: number;
  48375. faceUV?: Vector4[];
  48376. faceColors?: Color4[];
  48377. sideOrientation?: number;
  48378. frontUVs?: Vector4;
  48379. backUVs?: Vector4;
  48380. wrap?: boolean;
  48381. topBaseAt?: number;
  48382. bottomBaseAt?: number;
  48383. updatable?: boolean;
  48384. }, scene?: Nullable<Scene>): Mesh;
  48385. }
  48386. }
  48387. declare module "babylonjs/Debug/physicsViewer" {
  48388. import { Nullable } from "babylonjs/types";
  48389. import { Scene } from "babylonjs/scene";
  48390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48391. import { Mesh } from "babylonjs/Meshes/mesh";
  48392. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48393. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48394. /**
  48395. * Used to show the physics impostor around the specific mesh
  48396. */
  48397. export class PhysicsViewer {
  48398. /** @hidden */
  48399. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48400. /** @hidden */
  48401. protected _meshes: Array<Nullable<AbstractMesh>>;
  48402. /** @hidden */
  48403. protected _scene: Nullable<Scene>;
  48404. /** @hidden */
  48405. protected _numMeshes: number;
  48406. /** @hidden */
  48407. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48408. private _renderFunction;
  48409. private _utilityLayer;
  48410. private _debugBoxMesh;
  48411. private _debugSphereMesh;
  48412. private _debugCylinderMesh;
  48413. private _debugMaterial;
  48414. private _debugMeshMeshes;
  48415. /**
  48416. * Creates a new PhysicsViewer
  48417. * @param scene defines the hosting scene
  48418. */
  48419. constructor(scene: Scene);
  48420. /** @hidden */
  48421. protected _updateDebugMeshes(): void;
  48422. /**
  48423. * Renders a specified physic impostor
  48424. * @param impostor defines the impostor to render
  48425. * @param targetMesh defines the mesh represented by the impostor
  48426. * @returns the new debug mesh used to render the impostor
  48427. */
  48428. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48429. /**
  48430. * Hides a specified physic impostor
  48431. * @param impostor defines the impostor to hide
  48432. */
  48433. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48434. private _getDebugMaterial;
  48435. private _getDebugBoxMesh;
  48436. private _getDebugSphereMesh;
  48437. private _getDebugCylinderMesh;
  48438. private _getDebugMeshMesh;
  48439. private _getDebugMesh;
  48440. /** Releases all resources */
  48441. dispose(): void;
  48442. }
  48443. }
  48444. declare module "babylonjs/Debug/rayHelper" {
  48445. import { Nullable } from "babylonjs/types";
  48446. import { Ray } from "babylonjs/Culling/ray";
  48447. import { Vector3 } from "babylonjs/Maths/math.vector";
  48448. import { Color3 } from "babylonjs/Maths/math.color";
  48449. import { Scene } from "babylonjs/scene";
  48450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48451. import "babylonjs/Meshes/Builders/linesBuilder";
  48452. /**
  48453. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48454. * in order to better appreciate the issue one might have.
  48455. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48456. */
  48457. export class RayHelper {
  48458. /**
  48459. * Defines the ray we are currently tryin to visualize.
  48460. */
  48461. ray: Nullable<Ray>;
  48462. private _renderPoints;
  48463. private _renderLine;
  48464. private _renderFunction;
  48465. private _scene;
  48466. private _updateToMeshFunction;
  48467. private _attachedToMesh;
  48468. private _meshSpaceDirection;
  48469. private _meshSpaceOrigin;
  48470. /**
  48471. * Helper function to create a colored helper in a scene in one line.
  48472. * @param ray Defines the ray we are currently tryin to visualize
  48473. * @param scene Defines the scene the ray is used in
  48474. * @param color Defines the color we want to see the ray in
  48475. * @returns The newly created ray helper.
  48476. */
  48477. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48478. /**
  48479. * Instantiate a new ray helper.
  48480. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48481. * in order to better appreciate the issue one might have.
  48482. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48483. * @param ray Defines the ray we are currently tryin to visualize
  48484. */
  48485. constructor(ray: Ray);
  48486. /**
  48487. * Shows the ray we are willing to debug.
  48488. * @param scene Defines the scene the ray needs to be rendered in
  48489. * @param color Defines the color the ray needs to be rendered in
  48490. */
  48491. show(scene: Scene, color?: Color3): void;
  48492. /**
  48493. * Hides the ray we are debugging.
  48494. */
  48495. hide(): void;
  48496. private _render;
  48497. /**
  48498. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48499. * @param mesh Defines the mesh we want the helper attached to
  48500. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48501. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48502. * @param length Defines the length of the ray
  48503. */
  48504. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48505. /**
  48506. * Detach the ray helper from the mesh it has previously been attached to.
  48507. */
  48508. detachFromMesh(): void;
  48509. private _updateToMesh;
  48510. /**
  48511. * Dispose the helper and release its associated resources.
  48512. */
  48513. dispose(): void;
  48514. }
  48515. }
  48516. declare module "babylonjs/Debug/skeletonViewer" {
  48517. import { Color3 } from "babylonjs/Maths/math.color";
  48518. import { Scene } from "babylonjs/scene";
  48519. import { Nullable } from "babylonjs/types";
  48520. import { Skeleton } from "babylonjs/Bones/skeleton";
  48521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48522. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48523. /**
  48524. * Class used to render a debug view of a given skeleton
  48525. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48526. */
  48527. export class SkeletonViewer {
  48528. /** defines the skeleton to render */
  48529. skeleton: Skeleton;
  48530. /** defines the mesh attached to the skeleton */
  48531. mesh: AbstractMesh;
  48532. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48533. autoUpdateBonesMatrices: boolean;
  48534. /** defines the rendering group id to use with the viewer */
  48535. renderingGroupId: number;
  48536. /** Gets or sets the color used to render the skeleton */
  48537. color: Color3;
  48538. private _scene;
  48539. private _debugLines;
  48540. private _debugMesh;
  48541. private _isEnabled;
  48542. private _renderFunction;
  48543. private _utilityLayer;
  48544. /**
  48545. * Returns the mesh used to render the bones
  48546. */
  48547. get debugMesh(): Nullable<LinesMesh>;
  48548. /**
  48549. * Creates a new SkeletonViewer
  48550. * @param skeleton defines the skeleton to render
  48551. * @param mesh defines the mesh attached to the skeleton
  48552. * @param scene defines the hosting scene
  48553. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48554. * @param renderingGroupId defines the rendering group id to use with the viewer
  48555. */
  48556. constructor(
  48557. /** defines the skeleton to render */
  48558. skeleton: Skeleton,
  48559. /** defines the mesh attached to the skeleton */
  48560. mesh: AbstractMesh, scene: Scene,
  48561. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48562. autoUpdateBonesMatrices?: boolean,
  48563. /** defines the rendering group id to use with the viewer */
  48564. renderingGroupId?: number);
  48565. /** Gets or sets a boolean indicating if the viewer is enabled */
  48566. set isEnabled(value: boolean);
  48567. get isEnabled(): boolean;
  48568. private _getBonePosition;
  48569. private _getLinesForBonesWithLength;
  48570. private _getLinesForBonesNoLength;
  48571. /** Update the viewer to sync with current skeleton state */
  48572. update(): void;
  48573. /** Release associated resources */
  48574. dispose(): void;
  48575. }
  48576. }
  48577. declare module "babylonjs/Debug/index" {
  48578. export * from "babylonjs/Debug/axesViewer";
  48579. export * from "babylonjs/Debug/boneAxesViewer";
  48580. export * from "babylonjs/Debug/debugLayer";
  48581. export * from "babylonjs/Debug/physicsViewer";
  48582. export * from "babylonjs/Debug/rayHelper";
  48583. export * from "babylonjs/Debug/skeletonViewer";
  48584. }
  48585. declare module "babylonjs/Engines/nullEngine" {
  48586. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48587. import { Engine } from "babylonjs/Engines/engine";
  48588. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48589. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48590. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48591. import { Effect } from "babylonjs/Materials/effect";
  48592. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48593. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48594. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48595. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48596. /**
  48597. * Options to create the null engine
  48598. */
  48599. export class NullEngineOptions {
  48600. /**
  48601. * Render width (Default: 512)
  48602. */
  48603. renderWidth: number;
  48604. /**
  48605. * Render height (Default: 256)
  48606. */
  48607. renderHeight: number;
  48608. /**
  48609. * Texture size (Default: 512)
  48610. */
  48611. textureSize: number;
  48612. /**
  48613. * If delta time between frames should be constant
  48614. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48615. */
  48616. deterministicLockstep: boolean;
  48617. /**
  48618. * Maximum about of steps between frames (Default: 4)
  48619. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48620. */
  48621. lockstepMaxSteps: number;
  48622. }
  48623. /**
  48624. * The null engine class provides support for headless version of babylon.js.
  48625. * This can be used in server side scenario or for testing purposes
  48626. */
  48627. export class NullEngine extends Engine {
  48628. private _options;
  48629. /**
  48630. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48632. * @returns true if engine is in deterministic lock step mode
  48633. */
  48634. isDeterministicLockStep(): boolean;
  48635. /**
  48636. * Gets the max steps when engine is running in deterministic lock step
  48637. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48638. * @returns the max steps
  48639. */
  48640. getLockstepMaxSteps(): number;
  48641. /**
  48642. * Gets the current hardware scaling level.
  48643. * By default the hardware scaling level is computed from the window device ratio.
  48644. * 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.
  48645. * @returns a number indicating the current hardware scaling level
  48646. */
  48647. getHardwareScalingLevel(): number;
  48648. constructor(options?: NullEngineOptions);
  48649. /**
  48650. * Creates a vertex buffer
  48651. * @param vertices the data for the vertex buffer
  48652. * @returns the new WebGL static buffer
  48653. */
  48654. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48655. /**
  48656. * Creates a new index buffer
  48657. * @param indices defines the content of the index buffer
  48658. * @param updatable defines if the index buffer must be updatable
  48659. * @returns a new webGL buffer
  48660. */
  48661. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48662. /**
  48663. * Clear the current render buffer or the current render target (if any is set up)
  48664. * @param color defines the color to use
  48665. * @param backBuffer defines if the back buffer must be cleared
  48666. * @param depth defines if the depth buffer must be cleared
  48667. * @param stencil defines if the stencil buffer must be cleared
  48668. */
  48669. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48670. /**
  48671. * Gets the current render width
  48672. * @param useScreen defines if screen size must be used (or the current render target if any)
  48673. * @returns a number defining the current render width
  48674. */
  48675. getRenderWidth(useScreen?: boolean): number;
  48676. /**
  48677. * Gets the current render height
  48678. * @param useScreen defines if screen size must be used (or the current render target if any)
  48679. * @returns a number defining the current render height
  48680. */
  48681. getRenderHeight(useScreen?: boolean): number;
  48682. /**
  48683. * Set the WebGL's viewport
  48684. * @param viewport defines the viewport element to be used
  48685. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48686. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48687. */
  48688. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48689. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48690. /**
  48691. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48692. * @param pipelineContext defines the pipeline context to use
  48693. * @param uniformsNames defines the list of uniform names
  48694. * @returns an array of webGL uniform locations
  48695. */
  48696. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48697. /**
  48698. * Gets the lsit of active attributes for a given webGL program
  48699. * @param pipelineContext defines the pipeline context to use
  48700. * @param attributesNames defines the list of attribute names to get
  48701. * @returns an array of indices indicating the offset of each attribute
  48702. */
  48703. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48704. /**
  48705. * Binds an effect to the webGL context
  48706. * @param effect defines the effect to bind
  48707. */
  48708. bindSamplers(effect: Effect): void;
  48709. /**
  48710. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48711. * @param effect defines the effect to activate
  48712. */
  48713. enableEffect(effect: Effect): void;
  48714. /**
  48715. * Set various states to the webGL context
  48716. * @param culling defines backface culling state
  48717. * @param zOffset defines the value to apply to zOffset (0 by default)
  48718. * @param force defines if states must be applied even if cache is up to date
  48719. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48720. */
  48721. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48722. /**
  48723. * Set the value of an uniform to an array of int32
  48724. * @param uniform defines the webGL uniform location where to store the value
  48725. * @param array defines the array of int32 to store
  48726. */
  48727. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48728. /**
  48729. * Set the value of an uniform to an array of int32 (stored as vec2)
  48730. * @param uniform defines the webGL uniform location where to store the value
  48731. * @param array defines the array of int32 to store
  48732. */
  48733. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48734. /**
  48735. * Set the value of an uniform to an array of int32 (stored as vec3)
  48736. * @param uniform defines the webGL uniform location where to store the value
  48737. * @param array defines the array of int32 to store
  48738. */
  48739. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48740. /**
  48741. * Set the value of an uniform to an array of int32 (stored as vec4)
  48742. * @param uniform defines the webGL uniform location where to store the value
  48743. * @param array defines the array of int32 to store
  48744. */
  48745. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48746. /**
  48747. * Set the value of an uniform to an array of float32
  48748. * @param uniform defines the webGL uniform location where to store the value
  48749. * @param array defines the array of float32 to store
  48750. */
  48751. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48752. /**
  48753. * Set the value of an uniform to an array of float32 (stored as vec2)
  48754. * @param uniform defines the webGL uniform location where to store the value
  48755. * @param array defines the array of float32 to store
  48756. */
  48757. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48758. /**
  48759. * Set the value of an uniform to an array of float32 (stored as vec3)
  48760. * @param uniform defines the webGL uniform location where to store the value
  48761. * @param array defines the array of float32 to store
  48762. */
  48763. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48764. /**
  48765. * Set the value of an uniform to an array of float32 (stored as vec4)
  48766. * @param uniform defines the webGL uniform location where to store the value
  48767. * @param array defines the array of float32 to store
  48768. */
  48769. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48770. /**
  48771. * Set the value of an uniform to an array of number
  48772. * @param uniform defines the webGL uniform location where to store the value
  48773. * @param array defines the array of number to store
  48774. */
  48775. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48776. /**
  48777. * Set the value of an uniform to an array of number (stored as vec2)
  48778. * @param uniform defines the webGL uniform location where to store the value
  48779. * @param array defines the array of number to store
  48780. */
  48781. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48782. /**
  48783. * Set the value of an uniform to an array of number (stored as vec3)
  48784. * @param uniform defines the webGL uniform location where to store the value
  48785. * @param array defines the array of number to store
  48786. */
  48787. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48788. /**
  48789. * Set the value of an uniform to an array of number (stored as vec4)
  48790. * @param uniform defines the webGL uniform location where to store the value
  48791. * @param array defines the array of number to store
  48792. */
  48793. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48794. /**
  48795. * Set the value of an uniform to an array of float32 (stored as matrices)
  48796. * @param uniform defines the webGL uniform location where to store the value
  48797. * @param matrices defines the array of float32 to store
  48798. */
  48799. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48800. /**
  48801. * Set the value of an uniform to a matrix (3x3)
  48802. * @param uniform defines the webGL uniform location where to store the value
  48803. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48804. */
  48805. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48806. /**
  48807. * Set the value of an uniform to a matrix (2x2)
  48808. * @param uniform defines the webGL uniform location where to store the value
  48809. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48810. */
  48811. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48812. /**
  48813. * Set the value of an uniform to a number (float)
  48814. * @param uniform defines the webGL uniform location where to store the value
  48815. * @param value defines the float number to store
  48816. */
  48817. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48818. /**
  48819. * Set the value of an uniform to a vec2
  48820. * @param uniform defines the webGL uniform location where to store the value
  48821. * @param x defines the 1st component of the value
  48822. * @param y defines the 2nd component of the value
  48823. */
  48824. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48825. /**
  48826. * Set the value of an uniform to a vec3
  48827. * @param uniform defines the webGL uniform location where to store the value
  48828. * @param x defines the 1st component of the value
  48829. * @param y defines the 2nd component of the value
  48830. * @param z defines the 3rd component of the value
  48831. */
  48832. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48833. /**
  48834. * Set the value of an uniform to a boolean
  48835. * @param uniform defines the webGL uniform location where to store the value
  48836. * @param bool defines the boolean to store
  48837. */
  48838. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48839. /**
  48840. * Set the value of an uniform to a vec4
  48841. * @param uniform defines the webGL uniform location where to store the value
  48842. * @param x defines the 1st component of the value
  48843. * @param y defines the 2nd component of the value
  48844. * @param z defines the 3rd component of the value
  48845. * @param w defines the 4th component of the value
  48846. */
  48847. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48848. /**
  48849. * Sets the current alpha mode
  48850. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48851. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48852. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48853. */
  48854. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48855. /**
  48856. * Bind webGl buffers directly to the webGL context
  48857. * @param vertexBuffers defines the vertex buffer to bind
  48858. * @param indexBuffer defines the index buffer to bind
  48859. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48860. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48861. * @param effect defines the effect associated with the vertex buffer
  48862. */
  48863. bindBuffers(vertexBuffers: {
  48864. [key: string]: VertexBuffer;
  48865. }, indexBuffer: DataBuffer, effect: Effect): void;
  48866. /**
  48867. * Force the entire cache to be cleared
  48868. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48869. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48870. */
  48871. wipeCaches(bruteForce?: boolean): void;
  48872. /**
  48873. * Send a draw order
  48874. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48875. * @param indexStart defines the starting index
  48876. * @param indexCount defines the number of index to draw
  48877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48878. */
  48879. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48880. /**
  48881. * Draw a list of indexed primitives
  48882. * @param fillMode defines the primitive to use
  48883. * @param indexStart defines the starting index
  48884. * @param indexCount defines the number of index to draw
  48885. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48886. */
  48887. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48888. /**
  48889. * Draw a list of unindexed primitives
  48890. * @param fillMode defines the primitive to use
  48891. * @param verticesStart defines the index of first vertex to draw
  48892. * @param verticesCount defines the count of vertices to draw
  48893. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48894. */
  48895. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48896. /** @hidden */
  48897. _createTexture(): WebGLTexture;
  48898. /** @hidden */
  48899. _releaseTexture(texture: InternalTexture): void;
  48900. /**
  48901. * Usually called from Texture.ts.
  48902. * Passed information to create a WebGLTexture
  48903. * @param urlArg defines a value which contains one of the following:
  48904. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48905. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48906. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48907. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48908. * @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)
  48909. * @param scene needed for loading to the correct scene
  48910. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48911. * @param onLoad optional callback to be called upon successful completion
  48912. * @param onError optional callback to be called upon failure
  48913. * @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
  48914. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48915. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48916. * @param forcedExtension defines the extension to use to pick the right loader
  48917. * @param mimeType defines an optional mime type
  48918. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48919. */
  48920. 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;
  48921. /**
  48922. * Creates a new render target texture
  48923. * @param size defines the size of the texture
  48924. * @param options defines the options used to create the texture
  48925. * @returns a new render target texture stored in an InternalTexture
  48926. */
  48927. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48928. /**
  48929. * Update the sampling mode of a given texture
  48930. * @param samplingMode defines the required sampling mode
  48931. * @param texture defines the texture to update
  48932. */
  48933. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48934. /**
  48935. * Binds the frame buffer to the specified texture.
  48936. * @param texture The texture to render to or null for the default canvas
  48937. * @param faceIndex The face of the texture to render to in case of cube texture
  48938. * @param requiredWidth The width of the target to render to
  48939. * @param requiredHeight The height of the target to render to
  48940. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48941. * @param lodLevel defines le lod level to bind to the frame buffer
  48942. */
  48943. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48944. /**
  48945. * Unbind the current render target texture from the webGL context
  48946. * @param texture defines the render target texture to unbind
  48947. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48948. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48949. */
  48950. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48951. /**
  48952. * Creates a dynamic vertex buffer
  48953. * @param vertices the data for the dynamic vertex buffer
  48954. * @returns the new WebGL dynamic buffer
  48955. */
  48956. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48957. /**
  48958. * Update the content of a dynamic texture
  48959. * @param texture defines the texture to update
  48960. * @param canvas defines the canvas containing the source
  48961. * @param invertY defines if data must be stored with Y axis inverted
  48962. * @param premulAlpha defines if alpha is stored as premultiplied
  48963. * @param format defines the format of the data
  48964. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48965. */
  48966. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48967. /**
  48968. * Gets a boolean indicating if all created effects are ready
  48969. * @returns true if all effects are ready
  48970. */
  48971. areAllEffectsReady(): boolean;
  48972. /**
  48973. * @hidden
  48974. * Get the current error code of the webGL context
  48975. * @returns the error code
  48976. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48977. */
  48978. getError(): number;
  48979. /** @hidden */
  48980. _getUnpackAlignement(): number;
  48981. /** @hidden */
  48982. _unpackFlipY(value: boolean): void;
  48983. /**
  48984. * Update a dynamic index buffer
  48985. * @param indexBuffer defines the target index buffer
  48986. * @param indices defines the data to update
  48987. * @param offset defines the offset in the target index buffer where update should start
  48988. */
  48989. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48990. /**
  48991. * Updates a dynamic vertex buffer.
  48992. * @param vertexBuffer the vertex buffer to update
  48993. * @param vertices the data used to update the vertex buffer
  48994. * @param byteOffset the byte offset of the data (optional)
  48995. * @param byteLength the byte length of the data (optional)
  48996. */
  48997. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48998. /** @hidden */
  48999. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49000. /** @hidden */
  49001. _bindTexture(channel: number, texture: InternalTexture): void;
  49002. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49003. /**
  49004. * 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
  49005. */
  49006. releaseEffects(): void;
  49007. displayLoadingUI(): void;
  49008. hideLoadingUI(): void;
  49009. /** @hidden */
  49010. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49011. /** @hidden */
  49012. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49013. /** @hidden */
  49014. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49015. /** @hidden */
  49016. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49017. }
  49018. }
  49019. declare module "babylonjs/Instrumentation/timeToken" {
  49020. import { Nullable } from "babylonjs/types";
  49021. /**
  49022. * @hidden
  49023. **/
  49024. export class _TimeToken {
  49025. _startTimeQuery: Nullable<WebGLQuery>;
  49026. _endTimeQuery: Nullable<WebGLQuery>;
  49027. _timeElapsedQuery: Nullable<WebGLQuery>;
  49028. _timeElapsedQueryEnded: boolean;
  49029. }
  49030. }
  49031. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49032. import { Nullable, int } from "babylonjs/types";
  49033. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49034. /** @hidden */
  49035. export class _OcclusionDataStorage {
  49036. /** @hidden */
  49037. occlusionInternalRetryCounter: number;
  49038. /** @hidden */
  49039. isOcclusionQueryInProgress: boolean;
  49040. /** @hidden */
  49041. isOccluded: boolean;
  49042. /** @hidden */
  49043. occlusionRetryCount: number;
  49044. /** @hidden */
  49045. occlusionType: number;
  49046. /** @hidden */
  49047. occlusionQueryAlgorithmType: number;
  49048. }
  49049. module "babylonjs/Engines/engine" {
  49050. interface Engine {
  49051. /**
  49052. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49053. * @return the new query
  49054. */
  49055. createQuery(): WebGLQuery;
  49056. /**
  49057. * Delete and release a webGL query
  49058. * @param query defines the query to delete
  49059. * @return the current engine
  49060. */
  49061. deleteQuery(query: WebGLQuery): Engine;
  49062. /**
  49063. * Check if a given query has resolved and got its value
  49064. * @param query defines the query to check
  49065. * @returns true if the query got its value
  49066. */
  49067. isQueryResultAvailable(query: WebGLQuery): boolean;
  49068. /**
  49069. * Gets the value of a given query
  49070. * @param query defines the query to check
  49071. * @returns the value of the query
  49072. */
  49073. getQueryResult(query: WebGLQuery): number;
  49074. /**
  49075. * Initiates an occlusion query
  49076. * @param algorithmType defines the algorithm to use
  49077. * @param query defines the query to use
  49078. * @returns the current engine
  49079. * @see http://doc.babylonjs.com/features/occlusionquery
  49080. */
  49081. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49082. /**
  49083. * Ends an occlusion query
  49084. * @see http://doc.babylonjs.com/features/occlusionquery
  49085. * @param algorithmType defines the algorithm to use
  49086. * @returns the current engine
  49087. */
  49088. endOcclusionQuery(algorithmType: number): Engine;
  49089. /**
  49090. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49091. * Please note that only one query can be issued at a time
  49092. * @returns a time token used to track the time span
  49093. */
  49094. startTimeQuery(): Nullable<_TimeToken>;
  49095. /**
  49096. * Ends a time query
  49097. * @param token defines the token used to measure the time span
  49098. * @returns the time spent (in ns)
  49099. */
  49100. endTimeQuery(token: _TimeToken): int;
  49101. /** @hidden */
  49102. _currentNonTimestampToken: Nullable<_TimeToken>;
  49103. /** @hidden */
  49104. _createTimeQuery(): WebGLQuery;
  49105. /** @hidden */
  49106. _deleteTimeQuery(query: WebGLQuery): void;
  49107. /** @hidden */
  49108. _getGlAlgorithmType(algorithmType: number): number;
  49109. /** @hidden */
  49110. _getTimeQueryResult(query: WebGLQuery): any;
  49111. /** @hidden */
  49112. _getTimeQueryAvailability(query: WebGLQuery): any;
  49113. }
  49114. }
  49115. module "babylonjs/Meshes/abstractMesh" {
  49116. interface AbstractMesh {
  49117. /**
  49118. * Backing filed
  49119. * @hidden
  49120. */
  49121. __occlusionDataStorage: _OcclusionDataStorage;
  49122. /**
  49123. * Access property
  49124. * @hidden
  49125. */
  49126. _occlusionDataStorage: _OcclusionDataStorage;
  49127. /**
  49128. * 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.
  49129. * The default value is -1 which means don't break the query and wait till the result
  49130. * @see http://doc.babylonjs.com/features/occlusionquery
  49131. */
  49132. occlusionRetryCount: number;
  49133. /**
  49134. * 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:
  49135. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49136. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49137. * * 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.
  49138. * @see http://doc.babylonjs.com/features/occlusionquery
  49139. */
  49140. occlusionType: number;
  49141. /**
  49142. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49143. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49144. * * 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.
  49145. * @see http://doc.babylonjs.com/features/occlusionquery
  49146. */
  49147. occlusionQueryAlgorithmType: number;
  49148. /**
  49149. * 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
  49150. * @see http://doc.babylonjs.com/features/occlusionquery
  49151. */
  49152. isOccluded: boolean;
  49153. /**
  49154. * Flag to check the progress status of the query
  49155. * @see http://doc.babylonjs.com/features/occlusionquery
  49156. */
  49157. isOcclusionQueryInProgress: boolean;
  49158. }
  49159. }
  49160. }
  49161. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49162. import { Nullable } from "babylonjs/types";
  49163. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49164. /** @hidden */
  49165. export var _forceTransformFeedbackToBundle: boolean;
  49166. module "babylonjs/Engines/engine" {
  49167. interface Engine {
  49168. /**
  49169. * Creates a webGL transform feedback object
  49170. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49171. * @returns the webGL transform feedback object
  49172. */
  49173. createTransformFeedback(): WebGLTransformFeedback;
  49174. /**
  49175. * Delete a webGL transform feedback object
  49176. * @param value defines the webGL transform feedback object to delete
  49177. */
  49178. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49179. /**
  49180. * Bind a webGL transform feedback object to the webgl context
  49181. * @param value defines the webGL transform feedback object to bind
  49182. */
  49183. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49184. /**
  49185. * Begins a transform feedback operation
  49186. * @param usePoints defines if points or triangles must be used
  49187. */
  49188. beginTransformFeedback(usePoints: boolean): void;
  49189. /**
  49190. * Ends a transform feedback operation
  49191. */
  49192. endTransformFeedback(): void;
  49193. /**
  49194. * Specify the varyings to use with transform feedback
  49195. * @param program defines the associated webGL program
  49196. * @param value defines the list of strings representing the varying names
  49197. */
  49198. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49199. /**
  49200. * Bind a webGL buffer for a transform feedback operation
  49201. * @param value defines the webGL buffer to bind
  49202. */
  49203. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49204. }
  49205. }
  49206. }
  49207. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49208. import { Scene } from "babylonjs/scene";
  49209. import { Engine } from "babylonjs/Engines/engine";
  49210. import { Texture } from "babylonjs/Materials/Textures/texture";
  49211. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49212. import "babylonjs/Engines/Extensions/engine.multiRender";
  49213. /**
  49214. * Creation options of the multi render target texture.
  49215. */
  49216. export interface IMultiRenderTargetOptions {
  49217. /**
  49218. * Define if the texture needs to create mip maps after render.
  49219. */
  49220. generateMipMaps?: boolean;
  49221. /**
  49222. * Define the types of all the draw buffers we want to create
  49223. */
  49224. types?: number[];
  49225. /**
  49226. * Define the sampling modes of all the draw buffers we want to create
  49227. */
  49228. samplingModes?: number[];
  49229. /**
  49230. * Define if a depth buffer is required
  49231. */
  49232. generateDepthBuffer?: boolean;
  49233. /**
  49234. * Define if a stencil buffer is required
  49235. */
  49236. generateStencilBuffer?: boolean;
  49237. /**
  49238. * Define if a depth texture is required instead of a depth buffer
  49239. */
  49240. generateDepthTexture?: boolean;
  49241. /**
  49242. * Define the number of desired draw buffers
  49243. */
  49244. textureCount?: number;
  49245. /**
  49246. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49247. */
  49248. doNotChangeAspectRatio?: boolean;
  49249. /**
  49250. * Define the default type of the buffers we are creating
  49251. */
  49252. defaultType?: number;
  49253. }
  49254. /**
  49255. * A multi render target, like a render target provides the ability to render to a texture.
  49256. * Unlike the render target, it can render to several draw buffers in one draw.
  49257. * This is specially interesting in deferred rendering or for any effects requiring more than
  49258. * just one color from a single pass.
  49259. */
  49260. export class MultiRenderTarget extends RenderTargetTexture {
  49261. private _internalTextures;
  49262. private _textures;
  49263. private _multiRenderTargetOptions;
  49264. /**
  49265. * Get if draw buffers are currently supported by the used hardware and browser.
  49266. */
  49267. get isSupported(): boolean;
  49268. /**
  49269. * Get the list of textures generated by the multi render target.
  49270. */
  49271. get textures(): Texture[];
  49272. /**
  49273. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49274. */
  49275. get depthTexture(): Texture;
  49276. /**
  49277. * Set the wrapping mode on U of all the textures we are rendering to.
  49278. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49279. */
  49280. set wrapU(wrap: number);
  49281. /**
  49282. * Set the wrapping mode on V of all the textures we are rendering to.
  49283. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49284. */
  49285. set wrapV(wrap: number);
  49286. /**
  49287. * Instantiate a new multi render target texture.
  49288. * A multi render target, like a render target provides the ability to render to a texture.
  49289. * Unlike the render target, it can render to several draw buffers in one draw.
  49290. * This is specially interesting in deferred rendering or for any effects requiring more than
  49291. * just one color from a single pass.
  49292. * @param name Define the name of the texture
  49293. * @param size Define the size of the buffers to render to
  49294. * @param count Define the number of target we are rendering into
  49295. * @param scene Define the scene the texture belongs to
  49296. * @param options Define the options used to create the multi render target
  49297. */
  49298. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49299. /** @hidden */
  49300. _rebuild(): void;
  49301. private _createInternalTextures;
  49302. private _createTextures;
  49303. /**
  49304. * Define the number of samples used if MSAA is enabled.
  49305. */
  49306. get samples(): number;
  49307. set samples(value: number);
  49308. /**
  49309. * Resize all the textures in the multi render target.
  49310. * Be carrefull as it will recreate all the data in the new texture.
  49311. * @param size Define the new size
  49312. */
  49313. resize(size: any): void;
  49314. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49315. /**
  49316. * Dispose the render targets and their associated resources
  49317. */
  49318. dispose(): void;
  49319. /**
  49320. * Release all the underlying texture used as draw buffers.
  49321. */
  49322. releaseInternalTextures(): void;
  49323. }
  49324. }
  49325. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49327. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49328. import { Nullable } from "babylonjs/types";
  49329. module "babylonjs/Engines/thinEngine" {
  49330. interface ThinEngine {
  49331. /**
  49332. * Unbind a list of render target textures from the webGL context
  49333. * This is used only when drawBuffer extension or webGL2 are active
  49334. * @param textures defines the render target textures to unbind
  49335. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49336. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49337. */
  49338. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49339. /**
  49340. * Create a multi render target texture
  49341. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49342. * @param size defines the size of the texture
  49343. * @param options defines the creation options
  49344. * @returns the cube texture as an InternalTexture
  49345. */
  49346. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49347. /**
  49348. * Update the sample count for a given multiple render target texture
  49349. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49350. * @param textures defines the textures to update
  49351. * @param samples defines the sample count to set
  49352. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49353. */
  49354. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49355. }
  49356. }
  49357. }
  49358. declare module "babylonjs/Engines/Extensions/engine.views" {
  49359. import { Camera } from "babylonjs/Cameras/camera";
  49360. import { Nullable } from "babylonjs/types";
  49361. /**
  49362. * Class used to define an additional view for the engine
  49363. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49364. */
  49365. export class EngineView {
  49366. /** Defines the canvas where to render the view */
  49367. target: HTMLCanvasElement;
  49368. /** Defines an optional camera used to render the view (will use active camera else) */
  49369. camera?: Camera;
  49370. }
  49371. module "babylonjs/Engines/engine" {
  49372. interface Engine {
  49373. /**
  49374. * Gets or sets the HTML element to use for attaching events
  49375. */
  49376. inputElement: Nullable<HTMLElement>;
  49377. /**
  49378. * Gets the current engine view
  49379. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49380. */
  49381. activeView: Nullable<EngineView>;
  49382. /** Gets or sets the list of views */
  49383. views: EngineView[];
  49384. /**
  49385. * Register a new child canvas
  49386. * @param canvas defines the canvas to register
  49387. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49388. * @returns the associated view
  49389. */
  49390. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49391. /**
  49392. * Remove a registered child canvas
  49393. * @param canvas defines the canvas to remove
  49394. * @returns the current engine
  49395. */
  49396. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49397. }
  49398. }
  49399. }
  49400. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49401. import { Nullable } from "babylonjs/types";
  49402. module "babylonjs/Engines/engine" {
  49403. interface Engine {
  49404. /** @hidden */
  49405. _excludedCompressedTextures: string[];
  49406. /** @hidden */
  49407. _textureFormatInUse: string;
  49408. /**
  49409. * Gets the list of texture formats supported
  49410. */
  49411. readonly texturesSupported: Array<string>;
  49412. /**
  49413. * Gets the texture format in use
  49414. */
  49415. readonly textureFormatInUse: Nullable<string>;
  49416. /**
  49417. * Set the compressed texture extensions or file names to skip.
  49418. *
  49419. * @param skippedFiles defines the list of those texture files you want to skip
  49420. * Example: [".dds", ".env", "myfile.png"]
  49421. */
  49422. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49423. /**
  49424. * Set the compressed texture format to use, based on the formats you have, and the formats
  49425. * supported by the hardware / browser.
  49426. *
  49427. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49428. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49429. * to API arguments needed to compressed textures. This puts the burden on the container
  49430. * generator to house the arcane code for determining these for current & future formats.
  49431. *
  49432. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49433. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49434. *
  49435. * Note: The result of this call is not taken into account when a texture is base64.
  49436. *
  49437. * @param formatsAvailable defines the list of those format families you have created
  49438. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49439. *
  49440. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49441. * @returns The extension selected.
  49442. */
  49443. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49444. }
  49445. }
  49446. }
  49447. declare module "babylonjs/Engines/Extensions/index" {
  49448. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49449. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49450. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49451. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49452. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49453. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49454. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49455. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49456. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49457. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49458. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49459. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49460. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49461. export * from "babylonjs/Engines/Extensions/engine.views";
  49462. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49463. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49464. }
  49465. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49466. import { Nullable } from "babylonjs/types";
  49467. /**
  49468. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49469. */
  49470. export interface CubeMapInfo {
  49471. /**
  49472. * The pixel array for the front face.
  49473. * This is stored in format, left to right, up to down format.
  49474. */
  49475. front: Nullable<ArrayBufferView>;
  49476. /**
  49477. * The pixel array for the back face.
  49478. * This is stored in format, left to right, up to down format.
  49479. */
  49480. back: Nullable<ArrayBufferView>;
  49481. /**
  49482. * The pixel array for the left face.
  49483. * This is stored in format, left to right, up to down format.
  49484. */
  49485. left: Nullable<ArrayBufferView>;
  49486. /**
  49487. * The pixel array for the right face.
  49488. * This is stored in format, left to right, up to down format.
  49489. */
  49490. right: Nullable<ArrayBufferView>;
  49491. /**
  49492. * The pixel array for the up face.
  49493. * This is stored in format, left to right, up to down format.
  49494. */
  49495. up: Nullable<ArrayBufferView>;
  49496. /**
  49497. * The pixel array for the down face.
  49498. * This is stored in format, left to right, up to down format.
  49499. */
  49500. down: Nullable<ArrayBufferView>;
  49501. /**
  49502. * The size of the cubemap stored.
  49503. *
  49504. * Each faces will be size * size pixels.
  49505. */
  49506. size: number;
  49507. /**
  49508. * The format of the texture.
  49509. *
  49510. * RGBA, RGB.
  49511. */
  49512. format: number;
  49513. /**
  49514. * The type of the texture data.
  49515. *
  49516. * UNSIGNED_INT, FLOAT.
  49517. */
  49518. type: number;
  49519. /**
  49520. * Specifies whether the texture is in gamma space.
  49521. */
  49522. gammaSpace: boolean;
  49523. }
  49524. /**
  49525. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49526. */
  49527. export class PanoramaToCubeMapTools {
  49528. private static FACE_FRONT;
  49529. private static FACE_BACK;
  49530. private static FACE_RIGHT;
  49531. private static FACE_LEFT;
  49532. private static FACE_DOWN;
  49533. private static FACE_UP;
  49534. /**
  49535. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49536. *
  49537. * @param float32Array The source data.
  49538. * @param inputWidth The width of the input panorama.
  49539. * @param inputHeight The height of the input panorama.
  49540. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49541. * @return The cubemap data
  49542. */
  49543. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49544. private static CreateCubemapTexture;
  49545. private static CalcProjectionSpherical;
  49546. }
  49547. }
  49548. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49549. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49551. import { Nullable } from "babylonjs/types";
  49552. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49553. /**
  49554. * Helper class dealing with the extraction of spherical polynomial dataArray
  49555. * from a cube map.
  49556. */
  49557. export class CubeMapToSphericalPolynomialTools {
  49558. private static FileFaces;
  49559. /**
  49560. * Converts a texture to the according Spherical Polynomial data.
  49561. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49562. *
  49563. * @param texture The texture to extract the information from.
  49564. * @return The Spherical Polynomial data.
  49565. */
  49566. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49567. /**
  49568. * Converts a cubemap to the according Spherical Polynomial data.
  49569. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49570. *
  49571. * @param cubeInfo The Cube map to extract the information from.
  49572. * @return The Spherical Polynomial data.
  49573. */
  49574. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49575. }
  49576. }
  49577. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49578. import { Nullable } from "babylonjs/types";
  49579. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49580. module "babylonjs/Materials/Textures/baseTexture" {
  49581. interface BaseTexture {
  49582. /**
  49583. * Get the polynomial representation of the texture data.
  49584. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49585. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49586. */
  49587. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49588. }
  49589. }
  49590. }
  49591. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49592. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49593. /** @hidden */
  49594. export var rgbdEncodePixelShader: {
  49595. name: string;
  49596. shader: string;
  49597. };
  49598. }
  49599. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49600. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49601. /** @hidden */
  49602. export var rgbdDecodePixelShader: {
  49603. name: string;
  49604. shader: string;
  49605. };
  49606. }
  49607. declare module "babylonjs/Misc/environmentTextureTools" {
  49608. import { Nullable } from "babylonjs/types";
  49609. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49610. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49611. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49612. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49613. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49614. import "babylonjs/Shaders/rgbdEncode.fragment";
  49615. import "babylonjs/Shaders/rgbdDecode.fragment";
  49616. /**
  49617. * Raw texture data and descriptor sufficient for WebGL texture upload
  49618. */
  49619. export interface EnvironmentTextureInfo {
  49620. /**
  49621. * Version of the environment map
  49622. */
  49623. version: number;
  49624. /**
  49625. * Width of image
  49626. */
  49627. width: number;
  49628. /**
  49629. * Irradiance information stored in the file.
  49630. */
  49631. irradiance: any;
  49632. /**
  49633. * Specular information stored in the file.
  49634. */
  49635. specular: any;
  49636. }
  49637. /**
  49638. * Defines One Image in the file. It requires only the position in the file
  49639. * as well as the length.
  49640. */
  49641. interface BufferImageData {
  49642. /**
  49643. * Length of the image data.
  49644. */
  49645. length: number;
  49646. /**
  49647. * Position of the data from the null terminator delimiting the end of the JSON.
  49648. */
  49649. position: number;
  49650. }
  49651. /**
  49652. * Defines the specular data enclosed in the file.
  49653. * This corresponds to the version 1 of the data.
  49654. */
  49655. export interface EnvironmentTextureSpecularInfoV1 {
  49656. /**
  49657. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49658. */
  49659. specularDataPosition?: number;
  49660. /**
  49661. * This contains all the images data needed to reconstruct the cubemap.
  49662. */
  49663. mipmaps: Array<BufferImageData>;
  49664. /**
  49665. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49666. */
  49667. lodGenerationScale: number;
  49668. }
  49669. /**
  49670. * Sets of helpers addressing the serialization and deserialization of environment texture
  49671. * stored in a BabylonJS env file.
  49672. * Those files are usually stored as .env files.
  49673. */
  49674. export class EnvironmentTextureTools {
  49675. /**
  49676. * Magic number identifying the env file.
  49677. */
  49678. private static _MagicBytes;
  49679. /**
  49680. * Gets the environment info from an env file.
  49681. * @param data The array buffer containing the .env bytes.
  49682. * @returns the environment file info (the json header) if successfully parsed.
  49683. */
  49684. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49685. /**
  49686. * Creates an environment texture from a loaded cube texture.
  49687. * @param texture defines the cube texture to convert in env file
  49688. * @return a promise containing the environment data if succesfull.
  49689. */
  49690. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49691. /**
  49692. * Creates a JSON representation of the spherical data.
  49693. * @param texture defines the texture containing the polynomials
  49694. * @return the JSON representation of the spherical info
  49695. */
  49696. private static _CreateEnvTextureIrradiance;
  49697. /**
  49698. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49699. * @param data the image data
  49700. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49701. * @return the views described by info providing access to the underlying buffer
  49702. */
  49703. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49704. /**
  49705. * Uploads the texture info contained in the env file to the GPU.
  49706. * @param texture defines the internal texture to upload to
  49707. * @param data defines the data to load
  49708. * @param info defines the texture info retrieved through the GetEnvInfo method
  49709. * @returns a promise
  49710. */
  49711. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49712. private static _OnImageReadyAsync;
  49713. /**
  49714. * Uploads the levels of image data to the GPU.
  49715. * @param texture defines the internal texture to upload to
  49716. * @param imageData defines the array buffer views of image data [mipmap][face]
  49717. * @returns a promise
  49718. */
  49719. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49720. /**
  49721. * Uploads spherical polynomials information to the texture.
  49722. * @param texture defines the texture we are trying to upload the information to
  49723. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49724. */
  49725. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49726. /** @hidden */
  49727. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49728. }
  49729. }
  49730. declare module "babylonjs/Maths/math.vertexFormat" {
  49731. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49732. /**
  49733. * Contains position and normal vectors for a vertex
  49734. */
  49735. export class PositionNormalVertex {
  49736. /** the position of the vertex (defaut: 0,0,0) */
  49737. position: Vector3;
  49738. /** the normal of the vertex (defaut: 0,1,0) */
  49739. normal: Vector3;
  49740. /**
  49741. * Creates a PositionNormalVertex
  49742. * @param position the position of the vertex (defaut: 0,0,0)
  49743. * @param normal the normal of the vertex (defaut: 0,1,0)
  49744. */
  49745. constructor(
  49746. /** the position of the vertex (defaut: 0,0,0) */
  49747. position?: Vector3,
  49748. /** the normal of the vertex (defaut: 0,1,0) */
  49749. normal?: Vector3);
  49750. /**
  49751. * Clones the PositionNormalVertex
  49752. * @returns the cloned PositionNormalVertex
  49753. */
  49754. clone(): PositionNormalVertex;
  49755. }
  49756. /**
  49757. * Contains position, normal and uv vectors for a vertex
  49758. */
  49759. export class PositionNormalTextureVertex {
  49760. /** the position of the vertex (defaut: 0,0,0) */
  49761. position: Vector3;
  49762. /** the normal of the vertex (defaut: 0,1,0) */
  49763. normal: Vector3;
  49764. /** the uv of the vertex (default: 0,0) */
  49765. uv: Vector2;
  49766. /**
  49767. * Creates a PositionNormalTextureVertex
  49768. * @param position the position of the vertex (defaut: 0,0,0)
  49769. * @param normal the normal of the vertex (defaut: 0,1,0)
  49770. * @param uv the uv of the vertex (default: 0,0)
  49771. */
  49772. constructor(
  49773. /** the position of the vertex (defaut: 0,0,0) */
  49774. position?: Vector3,
  49775. /** the normal of the vertex (defaut: 0,1,0) */
  49776. normal?: Vector3,
  49777. /** the uv of the vertex (default: 0,0) */
  49778. uv?: Vector2);
  49779. /**
  49780. * Clones the PositionNormalTextureVertex
  49781. * @returns the cloned PositionNormalTextureVertex
  49782. */
  49783. clone(): PositionNormalTextureVertex;
  49784. }
  49785. }
  49786. declare module "babylonjs/Maths/math" {
  49787. export * from "babylonjs/Maths/math.axis";
  49788. export * from "babylonjs/Maths/math.color";
  49789. export * from "babylonjs/Maths/math.constants";
  49790. export * from "babylonjs/Maths/math.frustum";
  49791. export * from "babylonjs/Maths/math.path";
  49792. export * from "babylonjs/Maths/math.plane";
  49793. export * from "babylonjs/Maths/math.size";
  49794. export * from "babylonjs/Maths/math.vector";
  49795. export * from "babylonjs/Maths/math.vertexFormat";
  49796. export * from "babylonjs/Maths/math.viewport";
  49797. }
  49798. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49799. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49800. /** @hidden */
  49801. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49802. private _genericAttributeLocation;
  49803. private _varyingLocationCount;
  49804. private _varyingLocationMap;
  49805. private _replacements;
  49806. private _textureCount;
  49807. private _uniforms;
  49808. lineProcessor(line: string): string;
  49809. attributeProcessor(attribute: string): string;
  49810. varyingProcessor(varying: string, isFragment: boolean): string;
  49811. uniformProcessor(uniform: string): string;
  49812. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49813. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49814. }
  49815. }
  49816. declare module "babylonjs/Engines/nativeEngine" {
  49817. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49818. import { Engine } from "babylonjs/Engines/engine";
  49819. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49820. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49822. import { Effect } from "babylonjs/Materials/effect";
  49823. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49824. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49825. import { IColor4Like } from "babylonjs/Maths/math.like";
  49826. import { Scene } from "babylonjs/scene";
  49827. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49828. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49829. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49830. /**
  49831. * Container for accessors for natively-stored mesh data buffers.
  49832. */
  49833. class NativeDataBuffer extends DataBuffer {
  49834. /**
  49835. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49836. */
  49837. nativeIndexBuffer?: any;
  49838. /**
  49839. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49840. */
  49841. nativeVertexBuffer?: any;
  49842. }
  49843. /** @hidden */
  49844. class NativeTexture extends InternalTexture {
  49845. getInternalTexture(): InternalTexture;
  49846. getViewCount(): number;
  49847. }
  49848. /** @hidden */
  49849. export class NativeEngine extends Engine {
  49850. private readonly _native;
  49851. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49852. private readonly INVALID_HANDLE;
  49853. getHardwareScalingLevel(): number;
  49854. constructor();
  49855. /**
  49856. * Can be used to override the current requestAnimationFrame requester.
  49857. * @hidden
  49858. */
  49859. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49860. /**
  49861. * Override default engine behavior.
  49862. * @param color
  49863. * @param backBuffer
  49864. * @param depth
  49865. * @param stencil
  49866. */
  49867. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49868. /**
  49869. * Gets host document
  49870. * @returns the host document object
  49871. */
  49872. getHostDocument(): Nullable<Document>;
  49873. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49874. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49875. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49876. recordVertexArrayObject(vertexBuffers: {
  49877. [key: string]: VertexBuffer;
  49878. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49879. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49880. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49881. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49882. /**
  49883. * Draw a list of indexed primitives
  49884. * @param fillMode defines the primitive to use
  49885. * @param indexStart defines the starting index
  49886. * @param indexCount defines the number of index to draw
  49887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49888. */
  49889. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49890. /**
  49891. * Draw a list of unindexed primitives
  49892. * @param fillMode defines the primitive to use
  49893. * @param verticesStart defines the index of first vertex to draw
  49894. * @param verticesCount defines the count of vertices to draw
  49895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49896. */
  49897. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49898. createPipelineContext(): IPipelineContext;
  49899. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49900. /** @hidden */
  49901. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49902. /** @hidden */
  49903. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49904. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49905. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49906. protected _setProgram(program: WebGLProgram): void;
  49907. _releaseEffect(effect: Effect): void;
  49908. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49909. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49910. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49911. bindSamplers(effect: Effect): void;
  49912. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49913. getRenderWidth(useScreen?: boolean): number;
  49914. getRenderHeight(useScreen?: boolean): number;
  49915. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49916. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49917. /**
  49918. * Set the z offset to apply to current rendering
  49919. * @param value defines the offset to apply
  49920. */
  49921. setZOffset(value: number): void;
  49922. /**
  49923. * Gets the current value of the zOffset
  49924. * @returns the current zOffset state
  49925. */
  49926. getZOffset(): number;
  49927. /**
  49928. * Enable or disable depth buffering
  49929. * @param enable defines the state to set
  49930. */
  49931. setDepthBuffer(enable: boolean): void;
  49932. /**
  49933. * Gets a boolean indicating if depth writing is enabled
  49934. * @returns the current depth writing state
  49935. */
  49936. getDepthWrite(): boolean;
  49937. /**
  49938. * Enable or disable depth writing
  49939. * @param enable defines the state to set
  49940. */
  49941. setDepthWrite(enable: boolean): void;
  49942. /**
  49943. * Enable or disable color writing
  49944. * @param enable defines the state to set
  49945. */
  49946. setColorWrite(enable: boolean): void;
  49947. /**
  49948. * Gets a boolean indicating if color writing is enabled
  49949. * @returns the current color writing state
  49950. */
  49951. getColorWrite(): boolean;
  49952. /**
  49953. * Sets alpha constants used by some alpha blending modes
  49954. * @param r defines the red component
  49955. * @param g defines the green component
  49956. * @param b defines the blue component
  49957. * @param a defines the alpha component
  49958. */
  49959. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49960. /**
  49961. * Sets the current alpha mode
  49962. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49963. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49964. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49965. */
  49966. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49967. /**
  49968. * Gets the current alpha mode
  49969. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49970. * @returns the current alpha mode
  49971. */
  49972. getAlphaMode(): number;
  49973. setInt(uniform: WebGLUniformLocation, int: number): void;
  49974. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49975. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49976. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49977. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49978. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49979. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49980. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49981. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49982. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49983. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49984. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49985. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49986. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49987. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49988. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49989. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49990. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49991. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49992. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49993. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49994. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49995. wipeCaches(bruteForce?: boolean): void;
  49996. _createTexture(): WebGLTexture;
  49997. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49998. /**
  49999. * Usually called from Texture.ts.
  50000. * Passed information to create a WebGLTexture
  50001. * @param urlArg defines a value which contains one of the following:
  50002. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50003. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50004. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50005. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50006. * @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)
  50007. * @param scene needed for loading to the correct scene
  50008. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50009. * @param onLoad optional callback to be called upon successful completion
  50010. * @param onError optional callback to be called upon failure
  50011. * @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
  50012. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50013. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50014. * @param forcedExtension defines the extension to use to pick the right loader
  50015. * @param mimeType defines an optional mime type
  50016. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50017. */
  50018. 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;
  50019. /**
  50020. * Creates a cube texture
  50021. * @param rootUrl defines the url where the files to load is located
  50022. * @param scene defines the current scene
  50023. * @param files defines the list of files to load (1 per face)
  50024. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50025. * @param onLoad defines an optional callback raised when the texture is loaded
  50026. * @param onError defines an optional callback raised if there is an issue to load the texture
  50027. * @param format defines the format of the data
  50028. * @param forcedExtension defines the extension to use to pick the right loader
  50029. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50030. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50031. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50032. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50033. * @returns the cube texture as an InternalTexture
  50034. */
  50035. 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;
  50036. private _getSamplingFilter;
  50037. private static _GetNativeTextureFormat;
  50038. createRenderTargetTexture(size: number | {
  50039. width: number;
  50040. height: number;
  50041. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50042. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50043. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50044. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50045. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50046. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50047. /**
  50048. * Updates a dynamic vertex buffer.
  50049. * @param vertexBuffer the vertex buffer to update
  50050. * @param data the data used to update the vertex buffer
  50051. * @param byteOffset the byte offset of the data (optional)
  50052. * @param byteLength the byte length of the data (optional)
  50053. */
  50054. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50055. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50056. private _updateAnisotropicLevel;
  50057. private _getAddressMode;
  50058. /** @hidden */
  50059. _bindTexture(channel: number, texture: InternalTexture): void;
  50060. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50061. releaseEffects(): void;
  50062. /** @hidden */
  50063. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50064. /** @hidden */
  50065. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50066. /** @hidden */
  50067. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50068. /** @hidden */
  50069. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50070. }
  50071. }
  50072. declare module "babylonjs/Engines/index" {
  50073. export * from "babylonjs/Engines/constants";
  50074. export * from "babylonjs/Engines/engineCapabilities";
  50075. export * from "babylonjs/Engines/instancingAttributeInfo";
  50076. export * from "babylonjs/Engines/thinEngine";
  50077. export * from "babylonjs/Engines/engine";
  50078. export * from "babylonjs/Engines/engineStore";
  50079. export * from "babylonjs/Engines/nullEngine";
  50080. export * from "babylonjs/Engines/Extensions/index";
  50081. export * from "babylonjs/Engines/IPipelineContext";
  50082. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50083. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50084. export * from "babylonjs/Engines/nativeEngine";
  50085. }
  50086. declare module "babylonjs/Events/clipboardEvents" {
  50087. /**
  50088. * Gather the list of clipboard event types as constants.
  50089. */
  50090. export class ClipboardEventTypes {
  50091. /**
  50092. * The clipboard event is fired when a copy command is active (pressed).
  50093. */
  50094. static readonly COPY: number;
  50095. /**
  50096. * The clipboard event is fired when a cut command is active (pressed).
  50097. */
  50098. static readonly CUT: number;
  50099. /**
  50100. * The clipboard event is fired when a paste command is active (pressed).
  50101. */
  50102. static readonly PASTE: number;
  50103. }
  50104. /**
  50105. * This class is used to store clipboard related info for the onClipboardObservable event.
  50106. */
  50107. export class ClipboardInfo {
  50108. /**
  50109. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50110. */
  50111. type: number;
  50112. /**
  50113. * Defines the related dom event
  50114. */
  50115. event: ClipboardEvent;
  50116. /**
  50117. *Creates an instance of ClipboardInfo.
  50118. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50119. * @param event Defines the related dom event
  50120. */
  50121. constructor(
  50122. /**
  50123. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50124. */
  50125. type: number,
  50126. /**
  50127. * Defines the related dom event
  50128. */
  50129. event: ClipboardEvent);
  50130. /**
  50131. * Get the clipboard event's type from the keycode.
  50132. * @param keyCode Defines the keyCode for the current keyboard event.
  50133. * @return {number}
  50134. */
  50135. static GetTypeFromCharacter(keyCode: number): number;
  50136. }
  50137. }
  50138. declare module "babylonjs/Events/index" {
  50139. export * from "babylonjs/Events/keyboardEvents";
  50140. export * from "babylonjs/Events/pointerEvents";
  50141. export * from "babylonjs/Events/clipboardEvents";
  50142. }
  50143. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50144. import { Scene } from "babylonjs/scene";
  50145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50146. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50147. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50148. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50149. /**
  50150. * Google Daydream controller
  50151. */
  50152. export class DaydreamController extends WebVRController {
  50153. /**
  50154. * Base Url for the controller model.
  50155. */
  50156. static MODEL_BASE_URL: string;
  50157. /**
  50158. * File name for the controller model.
  50159. */
  50160. static MODEL_FILENAME: string;
  50161. /**
  50162. * Gamepad Id prefix used to identify Daydream Controller.
  50163. */
  50164. static readonly GAMEPAD_ID_PREFIX: string;
  50165. /**
  50166. * Creates a new DaydreamController from a gamepad
  50167. * @param vrGamepad the gamepad that the controller should be created from
  50168. */
  50169. constructor(vrGamepad: any);
  50170. /**
  50171. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50172. * @param scene scene in which to add meshes
  50173. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50174. */
  50175. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50176. /**
  50177. * Called once for each button that changed state since the last frame
  50178. * @param buttonIdx Which button index changed
  50179. * @param state New state of the button
  50180. * @param changes Which properties on the state changed since last frame
  50181. */
  50182. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50183. }
  50184. }
  50185. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50186. import { Scene } from "babylonjs/scene";
  50187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50188. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50189. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50190. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50191. /**
  50192. * Gear VR Controller
  50193. */
  50194. export class GearVRController extends WebVRController {
  50195. /**
  50196. * Base Url for the controller model.
  50197. */
  50198. static MODEL_BASE_URL: string;
  50199. /**
  50200. * File name for the controller model.
  50201. */
  50202. static MODEL_FILENAME: string;
  50203. /**
  50204. * Gamepad Id prefix used to identify this controller.
  50205. */
  50206. static readonly GAMEPAD_ID_PREFIX: string;
  50207. private readonly _buttonIndexToObservableNameMap;
  50208. /**
  50209. * Creates a new GearVRController from a gamepad
  50210. * @param vrGamepad the gamepad that the controller should be created from
  50211. */
  50212. constructor(vrGamepad: any);
  50213. /**
  50214. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50215. * @param scene scene in which to add meshes
  50216. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50217. */
  50218. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50219. /**
  50220. * Called once for each button that changed state since the last frame
  50221. * @param buttonIdx Which button index changed
  50222. * @param state New state of the button
  50223. * @param changes Which properties on the state changed since last frame
  50224. */
  50225. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50226. }
  50227. }
  50228. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50229. import { Scene } from "babylonjs/scene";
  50230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50231. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50232. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50233. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50234. /**
  50235. * Generic Controller
  50236. */
  50237. export class GenericController extends WebVRController {
  50238. /**
  50239. * Base Url for the controller model.
  50240. */
  50241. static readonly MODEL_BASE_URL: string;
  50242. /**
  50243. * File name for the controller model.
  50244. */
  50245. static readonly MODEL_FILENAME: string;
  50246. /**
  50247. * Creates a new GenericController from a gamepad
  50248. * @param vrGamepad the gamepad that the controller should be created from
  50249. */
  50250. constructor(vrGamepad: any);
  50251. /**
  50252. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50253. * @param scene scene in which to add meshes
  50254. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50255. */
  50256. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50257. /**
  50258. * Called once for each button that changed state since the last frame
  50259. * @param buttonIdx Which button index changed
  50260. * @param state New state of the button
  50261. * @param changes Which properties on the state changed since last frame
  50262. */
  50263. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50264. }
  50265. }
  50266. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50267. import { Observable } from "babylonjs/Misc/observable";
  50268. import { Scene } from "babylonjs/scene";
  50269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50270. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50271. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50272. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50273. /**
  50274. * Oculus Touch Controller
  50275. */
  50276. export class OculusTouchController extends WebVRController {
  50277. /**
  50278. * Base Url for the controller model.
  50279. */
  50280. static MODEL_BASE_URL: string;
  50281. /**
  50282. * File name for the left controller model.
  50283. */
  50284. static MODEL_LEFT_FILENAME: string;
  50285. /**
  50286. * File name for the right controller model.
  50287. */
  50288. static MODEL_RIGHT_FILENAME: string;
  50289. /**
  50290. * Base Url for the Quest controller model.
  50291. */
  50292. static QUEST_MODEL_BASE_URL: string;
  50293. /**
  50294. * @hidden
  50295. * If the controllers are running on a device that needs the updated Quest controller models
  50296. */
  50297. static _IsQuest: boolean;
  50298. /**
  50299. * Fired when the secondary trigger on this controller is modified
  50300. */
  50301. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50302. /**
  50303. * Fired when the thumb rest on this controller is modified
  50304. */
  50305. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50306. /**
  50307. * Creates a new OculusTouchController from a gamepad
  50308. * @param vrGamepad the gamepad that the controller should be created from
  50309. */
  50310. constructor(vrGamepad: any);
  50311. /**
  50312. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50313. * @param scene scene in which to add meshes
  50314. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50315. */
  50316. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50317. /**
  50318. * Fired when the A button on this controller is modified
  50319. */
  50320. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50321. /**
  50322. * Fired when the B button on this controller is modified
  50323. */
  50324. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50325. /**
  50326. * Fired when the X button on this controller is modified
  50327. */
  50328. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50329. /**
  50330. * Fired when the Y button on this controller is modified
  50331. */
  50332. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50333. /**
  50334. * Called once for each button that changed state since the last frame
  50335. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50336. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50337. * 2) secondary trigger (same)
  50338. * 3) A (right) X (left), touch, pressed = value
  50339. * 4) B / Y
  50340. * 5) thumb rest
  50341. * @param buttonIdx Which button index changed
  50342. * @param state New state of the button
  50343. * @param changes Which properties on the state changed since last frame
  50344. */
  50345. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50346. }
  50347. }
  50348. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50349. import { Scene } from "babylonjs/scene";
  50350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50351. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50352. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50353. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50354. import { Observable } from "babylonjs/Misc/observable";
  50355. /**
  50356. * Vive Controller
  50357. */
  50358. export class ViveController extends WebVRController {
  50359. /**
  50360. * Base Url for the controller model.
  50361. */
  50362. static MODEL_BASE_URL: string;
  50363. /**
  50364. * File name for the controller model.
  50365. */
  50366. static MODEL_FILENAME: string;
  50367. /**
  50368. * Creates a new ViveController from a gamepad
  50369. * @param vrGamepad the gamepad that the controller should be created from
  50370. */
  50371. constructor(vrGamepad: any);
  50372. /**
  50373. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50374. * @param scene scene in which to add meshes
  50375. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50376. */
  50377. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50378. /**
  50379. * Fired when the left button on this controller is modified
  50380. */
  50381. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50382. /**
  50383. * Fired when the right button on this controller is modified
  50384. */
  50385. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50386. /**
  50387. * Fired when the menu button on this controller is modified
  50388. */
  50389. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50390. /**
  50391. * Called once for each button that changed state since the last frame
  50392. * Vive mapping:
  50393. * 0: touchpad
  50394. * 1: trigger
  50395. * 2: left AND right buttons
  50396. * 3: menu button
  50397. * @param buttonIdx Which button index changed
  50398. * @param state New state of the button
  50399. * @param changes Which properties on the state changed since last frame
  50400. */
  50401. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50402. }
  50403. }
  50404. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50405. import { Observable } from "babylonjs/Misc/observable";
  50406. import { Scene } from "babylonjs/scene";
  50407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50408. import { Ray } from "babylonjs/Culling/ray";
  50409. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50410. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50411. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50412. /**
  50413. * Defines the WindowsMotionController object that the state of the windows motion controller
  50414. */
  50415. export class WindowsMotionController extends WebVRController {
  50416. /**
  50417. * The base url used to load the left and right controller models
  50418. */
  50419. static MODEL_BASE_URL: string;
  50420. /**
  50421. * The name of the left controller model file
  50422. */
  50423. static MODEL_LEFT_FILENAME: string;
  50424. /**
  50425. * The name of the right controller model file
  50426. */
  50427. static MODEL_RIGHT_FILENAME: string;
  50428. /**
  50429. * The controller name prefix for this controller type
  50430. */
  50431. static readonly GAMEPAD_ID_PREFIX: string;
  50432. /**
  50433. * The controller id pattern for this controller type
  50434. */
  50435. private static readonly GAMEPAD_ID_PATTERN;
  50436. private _loadedMeshInfo;
  50437. protected readonly _mapping: {
  50438. buttons: string[];
  50439. buttonMeshNames: {
  50440. 'trigger': string;
  50441. 'menu': string;
  50442. 'grip': string;
  50443. 'thumbstick': string;
  50444. 'trackpad': string;
  50445. };
  50446. buttonObservableNames: {
  50447. 'trigger': string;
  50448. 'menu': string;
  50449. 'grip': string;
  50450. 'thumbstick': string;
  50451. 'trackpad': string;
  50452. };
  50453. axisMeshNames: string[];
  50454. pointingPoseMeshName: string;
  50455. };
  50456. /**
  50457. * Fired when the trackpad on this controller is clicked
  50458. */
  50459. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50460. /**
  50461. * Fired when the trackpad on this controller is modified
  50462. */
  50463. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50464. /**
  50465. * The current x and y values of this controller's trackpad
  50466. */
  50467. trackpad: StickValues;
  50468. /**
  50469. * Creates a new WindowsMotionController from a gamepad
  50470. * @param vrGamepad the gamepad that the controller should be created from
  50471. */
  50472. constructor(vrGamepad: any);
  50473. /**
  50474. * Fired when the trigger on this controller is modified
  50475. */
  50476. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50477. /**
  50478. * Fired when the menu button on this controller is modified
  50479. */
  50480. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50481. /**
  50482. * Fired when the grip button on this controller is modified
  50483. */
  50484. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50485. /**
  50486. * Fired when the thumbstick button on this controller is modified
  50487. */
  50488. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50489. /**
  50490. * Fired when the touchpad button on this controller is modified
  50491. */
  50492. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50493. /**
  50494. * Fired when the touchpad values on this controller are modified
  50495. */
  50496. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50497. protected _updateTrackpad(): void;
  50498. /**
  50499. * Called once per frame by the engine.
  50500. */
  50501. update(): void;
  50502. /**
  50503. * Called once for each button that changed state since the last frame
  50504. * @param buttonIdx Which button index changed
  50505. * @param state New state of the button
  50506. * @param changes Which properties on the state changed since last frame
  50507. */
  50508. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50509. /**
  50510. * Moves the buttons on the controller mesh based on their current state
  50511. * @param buttonName the name of the button to move
  50512. * @param buttonValue the value of the button which determines the buttons new position
  50513. */
  50514. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50515. /**
  50516. * Moves the axis on the controller mesh based on its current state
  50517. * @param axis the index of the axis
  50518. * @param axisValue the value of the axis which determines the meshes new position
  50519. * @hidden
  50520. */
  50521. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50522. /**
  50523. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50524. * @param scene scene in which to add meshes
  50525. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50526. */
  50527. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50528. /**
  50529. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50530. * can be transformed by button presses and axes values, based on this._mapping.
  50531. *
  50532. * @param scene scene in which the meshes exist
  50533. * @param meshes list of meshes that make up the controller model to process
  50534. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50535. */
  50536. private processModel;
  50537. private createMeshInfo;
  50538. /**
  50539. * Gets the ray of the controller in the direction the controller is pointing
  50540. * @param length the length the resulting ray should be
  50541. * @returns a ray in the direction the controller is pointing
  50542. */
  50543. getForwardRay(length?: number): Ray;
  50544. /**
  50545. * Disposes of the controller
  50546. */
  50547. dispose(): void;
  50548. }
  50549. /**
  50550. * This class represents a new windows motion controller in XR.
  50551. */
  50552. export class XRWindowsMotionController extends WindowsMotionController {
  50553. /**
  50554. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50555. */
  50556. protected readonly _mapping: {
  50557. buttons: string[];
  50558. buttonMeshNames: {
  50559. 'trigger': string;
  50560. 'menu': string;
  50561. 'grip': string;
  50562. 'thumbstick': string;
  50563. 'trackpad': string;
  50564. };
  50565. buttonObservableNames: {
  50566. 'trigger': string;
  50567. 'menu': string;
  50568. 'grip': string;
  50569. 'thumbstick': string;
  50570. 'trackpad': string;
  50571. };
  50572. axisMeshNames: string[];
  50573. pointingPoseMeshName: string;
  50574. };
  50575. /**
  50576. * Construct a new XR-Based windows motion controller
  50577. *
  50578. * @param gamepadInfo the gamepad object from the browser
  50579. */
  50580. constructor(gamepadInfo: any);
  50581. /**
  50582. * holds the thumbstick values (X,Y)
  50583. */
  50584. thumbstickValues: StickValues;
  50585. /**
  50586. * Fired when the thumbstick on this controller is clicked
  50587. */
  50588. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50589. /**
  50590. * Fired when the thumbstick on this controller is modified
  50591. */
  50592. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50593. /**
  50594. * Fired when the touchpad button on this controller is modified
  50595. */
  50596. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50597. /**
  50598. * Fired when the touchpad values on this controller are modified
  50599. */
  50600. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50601. /**
  50602. * Fired when the thumbstick button on this controller is modified
  50603. * here to prevent breaking changes
  50604. */
  50605. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50606. /**
  50607. * updating the thumbstick(!) and not the trackpad.
  50608. * This is named this way due to the difference between WebVR and XR and to avoid
  50609. * changing the parent class.
  50610. */
  50611. protected _updateTrackpad(): void;
  50612. /**
  50613. * Disposes the class with joy
  50614. */
  50615. dispose(): void;
  50616. }
  50617. }
  50618. declare module "babylonjs/Gamepads/Controllers/index" {
  50619. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50620. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50621. export * from "babylonjs/Gamepads/Controllers/genericController";
  50622. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50623. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50624. export * from "babylonjs/Gamepads/Controllers/viveController";
  50625. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50626. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50627. }
  50628. declare module "babylonjs/Gamepads/index" {
  50629. export * from "babylonjs/Gamepads/Controllers/index";
  50630. export * from "babylonjs/Gamepads/gamepad";
  50631. export * from "babylonjs/Gamepads/gamepadManager";
  50632. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50633. export * from "babylonjs/Gamepads/xboxGamepad";
  50634. export * from "babylonjs/Gamepads/dualShockGamepad";
  50635. }
  50636. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50637. import { Scene } from "babylonjs/scene";
  50638. import { Vector4 } from "babylonjs/Maths/math.vector";
  50639. import { Color4 } from "babylonjs/Maths/math.color";
  50640. import { Mesh } from "babylonjs/Meshes/mesh";
  50641. import { Nullable } from "babylonjs/types";
  50642. /**
  50643. * Class containing static functions to help procedurally build meshes
  50644. */
  50645. export class PolyhedronBuilder {
  50646. /**
  50647. * Creates a polyhedron mesh
  50648. * * 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
  50649. * * The parameter `size` (positive float, default 1) sets the polygon size
  50650. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50651. * * 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`
  50652. * * 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
  50653. * * 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)`)
  50654. * * 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
  50655. * * 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
  50656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50659. * @param name defines the name of the mesh
  50660. * @param options defines the options used to create the mesh
  50661. * @param scene defines the hosting scene
  50662. * @returns the polyhedron mesh
  50663. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50664. */
  50665. static CreatePolyhedron(name: string, options: {
  50666. type?: number;
  50667. size?: number;
  50668. sizeX?: number;
  50669. sizeY?: number;
  50670. sizeZ?: number;
  50671. custom?: any;
  50672. faceUV?: Vector4[];
  50673. faceColors?: Color4[];
  50674. flat?: boolean;
  50675. updatable?: boolean;
  50676. sideOrientation?: number;
  50677. frontUVs?: Vector4;
  50678. backUVs?: Vector4;
  50679. }, scene?: Nullable<Scene>): Mesh;
  50680. }
  50681. }
  50682. declare module "babylonjs/Gizmos/scaleGizmo" {
  50683. import { Observable } from "babylonjs/Misc/observable";
  50684. import { Nullable } from "babylonjs/types";
  50685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50686. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50687. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50688. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50689. /**
  50690. * Gizmo that enables scaling a mesh along 3 axis
  50691. */
  50692. export class ScaleGizmo extends Gizmo {
  50693. /**
  50694. * Internal gizmo used for interactions on the x axis
  50695. */
  50696. xGizmo: AxisScaleGizmo;
  50697. /**
  50698. * Internal gizmo used for interactions on the y axis
  50699. */
  50700. yGizmo: AxisScaleGizmo;
  50701. /**
  50702. * Internal gizmo used for interactions on the z axis
  50703. */
  50704. zGizmo: AxisScaleGizmo;
  50705. /**
  50706. * Internal gizmo used to scale all axis equally
  50707. */
  50708. uniformScaleGizmo: AxisScaleGizmo;
  50709. private _meshAttached;
  50710. private _updateGizmoRotationToMatchAttachedMesh;
  50711. private _snapDistance;
  50712. private _scaleRatio;
  50713. private _uniformScalingMesh;
  50714. private _octahedron;
  50715. private _sensitivity;
  50716. /** Fires an event when any of it's sub gizmos are dragged */
  50717. onDragStartObservable: Observable<unknown>;
  50718. /** Fires an event when any of it's sub gizmos are released from dragging */
  50719. onDragEndObservable: Observable<unknown>;
  50720. get attachedMesh(): Nullable<AbstractMesh>;
  50721. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50722. /**
  50723. * Creates a ScaleGizmo
  50724. * @param gizmoLayer The utility layer the gizmo will be added to
  50725. */
  50726. constructor(gizmoLayer?: UtilityLayerRenderer);
  50727. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50728. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50729. /**
  50730. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50731. */
  50732. set snapDistance(value: number);
  50733. get snapDistance(): number;
  50734. /**
  50735. * Ratio for the scale of the gizmo (Default: 1)
  50736. */
  50737. set scaleRatio(value: number);
  50738. get scaleRatio(): number;
  50739. /**
  50740. * Sensitivity factor for dragging (Default: 1)
  50741. */
  50742. set sensitivity(value: number);
  50743. get sensitivity(): number;
  50744. /**
  50745. * Disposes of the gizmo
  50746. */
  50747. dispose(): void;
  50748. }
  50749. }
  50750. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50751. import { Observable } from "babylonjs/Misc/observable";
  50752. import { Nullable } from "babylonjs/types";
  50753. import { Vector3 } from "babylonjs/Maths/math.vector";
  50754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50755. import { Mesh } from "babylonjs/Meshes/mesh";
  50756. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50757. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50758. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50759. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50760. import { Color3 } from "babylonjs/Maths/math.color";
  50761. /**
  50762. * Single axis scale gizmo
  50763. */
  50764. export class AxisScaleGizmo extends Gizmo {
  50765. /**
  50766. * Drag behavior responsible for the gizmos dragging interactions
  50767. */
  50768. dragBehavior: PointerDragBehavior;
  50769. private _pointerObserver;
  50770. /**
  50771. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50772. */
  50773. snapDistance: number;
  50774. /**
  50775. * Event that fires each time the gizmo snaps to a new location.
  50776. * * snapDistance is the the change in distance
  50777. */
  50778. onSnapObservable: Observable<{
  50779. snapDistance: number;
  50780. }>;
  50781. /**
  50782. * If the scaling operation should be done on all axis (default: false)
  50783. */
  50784. uniformScaling: boolean;
  50785. /**
  50786. * Custom sensitivity value for the drag strength
  50787. */
  50788. sensitivity: number;
  50789. private _isEnabled;
  50790. private _parent;
  50791. private _arrow;
  50792. private _coloredMaterial;
  50793. private _hoverMaterial;
  50794. /**
  50795. * Creates an AxisScaleGizmo
  50796. * @param gizmoLayer The utility layer the gizmo will be added to
  50797. * @param dragAxis The axis which the gizmo will be able to scale on
  50798. * @param color The color of the gizmo
  50799. */
  50800. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50801. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50802. /**
  50803. * If the gizmo is enabled
  50804. */
  50805. set isEnabled(value: boolean);
  50806. get isEnabled(): boolean;
  50807. /**
  50808. * Disposes of the gizmo
  50809. */
  50810. dispose(): void;
  50811. /**
  50812. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50813. * @param mesh The mesh to replace the default mesh of the gizmo
  50814. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50815. */
  50816. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50817. }
  50818. }
  50819. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50820. import { Observable } from "babylonjs/Misc/observable";
  50821. import { Nullable } from "babylonjs/types";
  50822. import { Vector3 } from "babylonjs/Maths/math.vector";
  50823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50824. import { Mesh } from "babylonjs/Meshes/mesh";
  50825. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50826. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50827. import { Color3 } from "babylonjs/Maths/math.color";
  50828. import "babylonjs/Meshes/Builders/boxBuilder";
  50829. /**
  50830. * Bounding box gizmo
  50831. */
  50832. export class BoundingBoxGizmo extends Gizmo {
  50833. private _lineBoundingBox;
  50834. private _rotateSpheresParent;
  50835. private _scaleBoxesParent;
  50836. private _boundingDimensions;
  50837. private _renderObserver;
  50838. private _pointerObserver;
  50839. private _scaleDragSpeed;
  50840. private _tmpQuaternion;
  50841. private _tmpVector;
  50842. private _tmpRotationMatrix;
  50843. /**
  50844. * 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)
  50845. */
  50846. ignoreChildren: boolean;
  50847. /**
  50848. * 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)
  50849. */
  50850. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50851. /**
  50852. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50853. */
  50854. rotationSphereSize: number;
  50855. /**
  50856. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50857. */
  50858. scaleBoxSize: number;
  50859. /**
  50860. * 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)
  50861. */
  50862. fixedDragMeshScreenSize: boolean;
  50863. /**
  50864. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50865. */
  50866. fixedDragMeshScreenSizeDistanceFactor: number;
  50867. /**
  50868. * Fired when a rotation sphere or scale box is dragged
  50869. */
  50870. onDragStartObservable: Observable<{}>;
  50871. /**
  50872. * Fired when a scale box is dragged
  50873. */
  50874. onScaleBoxDragObservable: Observable<{}>;
  50875. /**
  50876. * Fired when a scale box drag is ended
  50877. */
  50878. onScaleBoxDragEndObservable: Observable<{}>;
  50879. /**
  50880. * Fired when a rotation sphere is dragged
  50881. */
  50882. onRotationSphereDragObservable: Observable<{}>;
  50883. /**
  50884. * Fired when a rotation sphere drag is ended
  50885. */
  50886. onRotationSphereDragEndObservable: Observable<{}>;
  50887. /**
  50888. * 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)
  50889. */
  50890. scalePivot: Nullable<Vector3>;
  50891. /**
  50892. * Mesh used as a pivot to rotate the attached mesh
  50893. */
  50894. private _anchorMesh;
  50895. private _existingMeshScale;
  50896. private _dragMesh;
  50897. private pointerDragBehavior;
  50898. private coloredMaterial;
  50899. private hoverColoredMaterial;
  50900. /**
  50901. * Sets the color of the bounding box gizmo
  50902. * @param color the color to set
  50903. */
  50904. setColor(color: Color3): void;
  50905. /**
  50906. * Creates an BoundingBoxGizmo
  50907. * @param gizmoLayer The utility layer the gizmo will be added to
  50908. * @param color The color of the gizmo
  50909. */
  50910. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50911. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50912. private _selectNode;
  50913. /**
  50914. * Updates the bounding box information for the Gizmo
  50915. */
  50916. updateBoundingBox(): void;
  50917. private _updateRotationSpheres;
  50918. private _updateScaleBoxes;
  50919. /**
  50920. * Enables rotation on the specified axis and disables rotation on the others
  50921. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50922. */
  50923. setEnabledRotationAxis(axis: string): void;
  50924. /**
  50925. * Enables/disables scaling
  50926. * @param enable if scaling should be enabled
  50927. * @param homogeneousScaling defines if scaling should only be homogeneous
  50928. */
  50929. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  50930. private _updateDummy;
  50931. /**
  50932. * Enables a pointer drag behavior on the bounding box of the gizmo
  50933. */
  50934. enableDragBehavior(): void;
  50935. /**
  50936. * Disposes of the gizmo
  50937. */
  50938. dispose(): void;
  50939. /**
  50940. * 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)
  50941. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50942. * @returns the bounding box mesh with the passed in mesh as a child
  50943. */
  50944. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50945. /**
  50946. * CustomMeshes are not supported by this gizmo
  50947. * @param mesh The mesh to replace the default mesh of the gizmo
  50948. */
  50949. setCustomMesh(mesh: Mesh): void;
  50950. }
  50951. }
  50952. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50953. import { Observable } from "babylonjs/Misc/observable";
  50954. import { Nullable } from "babylonjs/types";
  50955. import { Vector3 } from "babylonjs/Maths/math.vector";
  50956. import { Color3 } from "babylonjs/Maths/math.color";
  50957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50958. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50959. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50960. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50961. import "babylonjs/Meshes/Builders/linesBuilder";
  50962. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50963. /**
  50964. * Single plane rotation gizmo
  50965. */
  50966. export class PlaneRotationGizmo extends Gizmo {
  50967. /**
  50968. * Drag behavior responsible for the gizmos dragging interactions
  50969. */
  50970. dragBehavior: PointerDragBehavior;
  50971. private _pointerObserver;
  50972. /**
  50973. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50974. */
  50975. snapDistance: number;
  50976. /**
  50977. * Event that fires each time the gizmo snaps to a new location.
  50978. * * snapDistance is the the change in distance
  50979. */
  50980. onSnapObservable: Observable<{
  50981. snapDistance: number;
  50982. }>;
  50983. private _isEnabled;
  50984. private _parent;
  50985. /**
  50986. * Creates a PlaneRotationGizmo
  50987. * @param gizmoLayer The utility layer the gizmo will be added to
  50988. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50989. * @param color The color of the gizmo
  50990. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50991. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50992. */
  50993. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50994. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50995. /**
  50996. * If the gizmo is enabled
  50997. */
  50998. set isEnabled(value: boolean);
  50999. get isEnabled(): boolean;
  51000. /**
  51001. * Disposes of the gizmo
  51002. */
  51003. dispose(): void;
  51004. }
  51005. }
  51006. declare module "babylonjs/Gizmos/rotationGizmo" {
  51007. import { Observable } from "babylonjs/Misc/observable";
  51008. import { Nullable } from "babylonjs/types";
  51009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51010. import { Mesh } from "babylonjs/Meshes/mesh";
  51011. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51012. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51013. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51014. /**
  51015. * Gizmo that enables rotating a mesh along 3 axis
  51016. */
  51017. export class RotationGizmo extends Gizmo {
  51018. /**
  51019. * Internal gizmo used for interactions on the x axis
  51020. */
  51021. xGizmo: PlaneRotationGizmo;
  51022. /**
  51023. * Internal gizmo used for interactions on the y axis
  51024. */
  51025. yGizmo: PlaneRotationGizmo;
  51026. /**
  51027. * Internal gizmo used for interactions on the z axis
  51028. */
  51029. zGizmo: PlaneRotationGizmo;
  51030. /** Fires an event when any of it's sub gizmos are dragged */
  51031. onDragStartObservable: Observable<unknown>;
  51032. /** Fires an event when any of it's sub gizmos are released from dragging */
  51033. onDragEndObservable: Observable<unknown>;
  51034. private _meshAttached;
  51035. get attachedMesh(): Nullable<AbstractMesh>;
  51036. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51037. /**
  51038. * Creates a RotationGizmo
  51039. * @param gizmoLayer The utility layer the gizmo will be added to
  51040. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51041. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51042. */
  51043. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51044. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51045. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51046. /**
  51047. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51048. */
  51049. set snapDistance(value: number);
  51050. get snapDistance(): number;
  51051. /**
  51052. * Ratio for the scale of the gizmo (Default: 1)
  51053. */
  51054. set scaleRatio(value: number);
  51055. get scaleRatio(): number;
  51056. /**
  51057. * Disposes of the gizmo
  51058. */
  51059. dispose(): void;
  51060. /**
  51061. * CustomMeshes are not supported by this gizmo
  51062. * @param mesh The mesh to replace the default mesh of the gizmo
  51063. */
  51064. setCustomMesh(mesh: Mesh): void;
  51065. }
  51066. }
  51067. declare module "babylonjs/Gizmos/gizmoManager" {
  51068. import { Observable } from "babylonjs/Misc/observable";
  51069. import { Nullable } from "babylonjs/types";
  51070. import { Scene, IDisposable } from "babylonjs/scene";
  51071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51072. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51073. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51074. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51075. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51076. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51077. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51078. /**
  51079. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51080. */
  51081. export class GizmoManager implements IDisposable {
  51082. private scene;
  51083. /**
  51084. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51085. */
  51086. gizmos: {
  51087. positionGizmo: Nullable<PositionGizmo>;
  51088. rotationGizmo: Nullable<RotationGizmo>;
  51089. scaleGizmo: Nullable<ScaleGizmo>;
  51090. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51091. };
  51092. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51093. clearGizmoOnEmptyPointerEvent: boolean;
  51094. /** Fires an event when the manager is attached to a mesh */
  51095. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51096. private _gizmosEnabled;
  51097. private _pointerObserver;
  51098. private _attachedMesh;
  51099. private _boundingBoxColor;
  51100. private _defaultUtilityLayer;
  51101. private _defaultKeepDepthUtilityLayer;
  51102. /**
  51103. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51104. */
  51105. boundingBoxDragBehavior: SixDofDragBehavior;
  51106. /**
  51107. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51108. */
  51109. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51110. /**
  51111. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51112. */
  51113. usePointerToAttachGizmos: boolean;
  51114. /**
  51115. * Utility layer that the bounding box gizmo belongs to
  51116. */
  51117. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51118. /**
  51119. * Utility layer that all gizmos besides bounding box belong to
  51120. */
  51121. get utilityLayer(): UtilityLayerRenderer;
  51122. /**
  51123. * Instatiates a gizmo manager
  51124. * @param scene the scene to overlay the gizmos on top of
  51125. */
  51126. constructor(scene: Scene);
  51127. /**
  51128. * Attaches a set of gizmos to the specified mesh
  51129. * @param mesh The mesh the gizmo's should be attached to
  51130. */
  51131. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51132. /**
  51133. * If the position gizmo is enabled
  51134. */
  51135. set positionGizmoEnabled(value: boolean);
  51136. get positionGizmoEnabled(): boolean;
  51137. /**
  51138. * If the rotation gizmo is enabled
  51139. */
  51140. set rotationGizmoEnabled(value: boolean);
  51141. get rotationGizmoEnabled(): boolean;
  51142. /**
  51143. * If the scale gizmo is enabled
  51144. */
  51145. set scaleGizmoEnabled(value: boolean);
  51146. get scaleGizmoEnabled(): boolean;
  51147. /**
  51148. * If the boundingBox gizmo is enabled
  51149. */
  51150. set boundingBoxGizmoEnabled(value: boolean);
  51151. get boundingBoxGizmoEnabled(): boolean;
  51152. /**
  51153. * Disposes of the gizmo manager
  51154. */
  51155. dispose(): void;
  51156. }
  51157. }
  51158. declare module "babylonjs/Lights/directionalLight" {
  51159. import { Camera } from "babylonjs/Cameras/camera";
  51160. import { Scene } from "babylonjs/scene";
  51161. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51163. import { Light } from "babylonjs/Lights/light";
  51164. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51165. import { Effect } from "babylonjs/Materials/effect";
  51166. /**
  51167. * A directional light is defined by a direction (what a surprise!).
  51168. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51169. * 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.
  51170. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51171. */
  51172. export class DirectionalLight extends ShadowLight {
  51173. private _shadowFrustumSize;
  51174. /**
  51175. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51176. */
  51177. get shadowFrustumSize(): number;
  51178. /**
  51179. * Specifies a fix frustum size for the shadow generation.
  51180. */
  51181. set shadowFrustumSize(value: number);
  51182. private _shadowOrthoScale;
  51183. /**
  51184. * Gets the shadow projection scale against the optimal computed one.
  51185. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51186. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51187. */
  51188. get shadowOrthoScale(): number;
  51189. /**
  51190. * Sets the shadow projection scale against the optimal computed one.
  51191. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51192. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51193. */
  51194. set shadowOrthoScale(value: number);
  51195. /**
  51196. * Automatically compute the projection matrix to best fit (including all the casters)
  51197. * on each frame.
  51198. */
  51199. autoUpdateExtends: boolean;
  51200. /**
  51201. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51202. * on each frame. autoUpdateExtends must be set to true for this to work
  51203. */
  51204. autoCalcShadowZBounds: boolean;
  51205. private _orthoLeft;
  51206. private _orthoRight;
  51207. private _orthoTop;
  51208. private _orthoBottom;
  51209. /**
  51210. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51211. * The directional light is emitted from everywhere in the given direction.
  51212. * It can cast shadows.
  51213. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51214. * @param name The friendly name of the light
  51215. * @param direction The direction of the light
  51216. * @param scene The scene the light belongs to
  51217. */
  51218. constructor(name: string, direction: Vector3, scene: Scene);
  51219. /**
  51220. * Returns the string "DirectionalLight".
  51221. * @return The class name
  51222. */
  51223. getClassName(): string;
  51224. /**
  51225. * Returns the integer 1.
  51226. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51227. */
  51228. getTypeID(): number;
  51229. /**
  51230. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51231. * Returns the DirectionalLight Shadow projection matrix.
  51232. */
  51233. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51234. /**
  51235. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51236. * Returns the DirectionalLight Shadow projection matrix.
  51237. */
  51238. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51239. /**
  51240. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51241. * Returns the DirectionalLight Shadow projection matrix.
  51242. */
  51243. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51244. protected _buildUniformLayout(): void;
  51245. /**
  51246. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51247. * @param effect The effect to update
  51248. * @param lightIndex The index of the light in the effect to update
  51249. * @returns The directional light
  51250. */
  51251. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51252. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51253. /**
  51254. * Gets the minZ used for shadow according to both the scene and the light.
  51255. *
  51256. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51257. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51258. * @param activeCamera The camera we are returning the min for
  51259. * @returns the depth min z
  51260. */
  51261. getDepthMinZ(activeCamera: Camera): number;
  51262. /**
  51263. * Gets the maxZ used for shadow according to both the scene and the light.
  51264. *
  51265. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51266. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51267. * @param activeCamera The camera we are returning the max for
  51268. * @returns the depth max z
  51269. */
  51270. getDepthMaxZ(activeCamera: Camera): number;
  51271. /**
  51272. * Prepares the list of defines specific to the light type.
  51273. * @param defines the list of defines
  51274. * @param lightIndex defines the index of the light for the effect
  51275. */
  51276. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51277. }
  51278. }
  51279. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51280. import { Mesh } from "babylonjs/Meshes/mesh";
  51281. /**
  51282. * Class containing static functions to help procedurally build meshes
  51283. */
  51284. export class HemisphereBuilder {
  51285. /**
  51286. * Creates a hemisphere mesh
  51287. * @param name defines the name of the mesh
  51288. * @param options defines the options used to create the mesh
  51289. * @param scene defines the hosting scene
  51290. * @returns the hemisphere mesh
  51291. */
  51292. static CreateHemisphere(name: string, options: {
  51293. segments?: number;
  51294. diameter?: number;
  51295. sideOrientation?: number;
  51296. }, scene: any): Mesh;
  51297. }
  51298. }
  51299. declare module "babylonjs/Lights/spotLight" {
  51300. import { Nullable } from "babylonjs/types";
  51301. import { Scene } from "babylonjs/scene";
  51302. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51304. import { Effect } from "babylonjs/Materials/effect";
  51305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51306. import { Light } from "babylonjs/Lights/light";
  51307. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51308. /**
  51309. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51310. * These values define a cone of light starting from the position, emitting toward the direction.
  51311. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51312. * and the exponent defines the speed of the decay of the light with distance (reach).
  51313. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51314. */
  51315. export class SpotLight extends ShadowLight {
  51316. private _angle;
  51317. private _innerAngle;
  51318. private _cosHalfAngle;
  51319. private _lightAngleScale;
  51320. private _lightAngleOffset;
  51321. /**
  51322. * Gets the cone angle of the spot light in Radians.
  51323. */
  51324. get angle(): number;
  51325. /**
  51326. * Sets the cone angle of the spot light in Radians.
  51327. */
  51328. set angle(value: number);
  51329. /**
  51330. * Only used in gltf falloff mode, this defines the angle where
  51331. * the directional falloff will start before cutting at angle which could be seen
  51332. * as outer angle.
  51333. */
  51334. get innerAngle(): number;
  51335. /**
  51336. * Only used in gltf falloff mode, this defines the angle where
  51337. * the directional falloff will start before cutting at angle which could be seen
  51338. * as outer angle.
  51339. */
  51340. set innerAngle(value: number);
  51341. private _shadowAngleScale;
  51342. /**
  51343. * Allows scaling the angle of the light for shadow generation only.
  51344. */
  51345. get shadowAngleScale(): number;
  51346. /**
  51347. * Allows scaling the angle of the light for shadow generation only.
  51348. */
  51349. set shadowAngleScale(value: number);
  51350. /**
  51351. * The light decay speed with the distance from the emission spot.
  51352. */
  51353. exponent: number;
  51354. private _projectionTextureMatrix;
  51355. /**
  51356. * Allows reading the projecton texture
  51357. */
  51358. get projectionTextureMatrix(): Matrix;
  51359. protected _projectionTextureLightNear: number;
  51360. /**
  51361. * Gets the near clip of the Spotlight for texture projection.
  51362. */
  51363. get projectionTextureLightNear(): number;
  51364. /**
  51365. * Sets the near clip of the Spotlight for texture projection.
  51366. */
  51367. set projectionTextureLightNear(value: number);
  51368. protected _projectionTextureLightFar: number;
  51369. /**
  51370. * Gets the far clip of the Spotlight for texture projection.
  51371. */
  51372. get projectionTextureLightFar(): number;
  51373. /**
  51374. * Sets the far clip of the Spotlight for texture projection.
  51375. */
  51376. set projectionTextureLightFar(value: number);
  51377. protected _projectionTextureUpDirection: Vector3;
  51378. /**
  51379. * Gets the Up vector of the Spotlight for texture projection.
  51380. */
  51381. get projectionTextureUpDirection(): Vector3;
  51382. /**
  51383. * Sets the Up vector of the Spotlight for texture projection.
  51384. */
  51385. set projectionTextureUpDirection(value: Vector3);
  51386. private _projectionTexture;
  51387. /**
  51388. * Gets the projection texture of the light.
  51389. */
  51390. get projectionTexture(): Nullable<BaseTexture>;
  51391. /**
  51392. * Sets the projection texture of the light.
  51393. */
  51394. set projectionTexture(value: Nullable<BaseTexture>);
  51395. private _projectionTextureViewLightDirty;
  51396. private _projectionTextureProjectionLightDirty;
  51397. private _projectionTextureDirty;
  51398. private _projectionTextureViewTargetVector;
  51399. private _projectionTextureViewLightMatrix;
  51400. private _projectionTextureProjectionLightMatrix;
  51401. private _projectionTextureScalingMatrix;
  51402. /**
  51403. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51404. * It can cast shadows.
  51405. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51406. * @param name The light friendly name
  51407. * @param position The position of the spot light in the scene
  51408. * @param direction The direction of the light in the scene
  51409. * @param angle The cone angle of the light in Radians
  51410. * @param exponent The light decay speed with the distance from the emission spot
  51411. * @param scene The scene the lights belongs to
  51412. */
  51413. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51414. /**
  51415. * Returns the string "SpotLight".
  51416. * @returns the class name
  51417. */
  51418. getClassName(): string;
  51419. /**
  51420. * Returns the integer 2.
  51421. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51422. */
  51423. getTypeID(): number;
  51424. /**
  51425. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51426. */
  51427. protected _setDirection(value: Vector3): void;
  51428. /**
  51429. * Overrides the position setter to recompute the projection texture view light Matrix.
  51430. */
  51431. protected _setPosition(value: Vector3): void;
  51432. /**
  51433. * 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.
  51434. * Returns the SpotLight.
  51435. */
  51436. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51437. protected _computeProjectionTextureViewLightMatrix(): void;
  51438. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51439. /**
  51440. * Main function for light texture projection matrix computing.
  51441. */
  51442. protected _computeProjectionTextureMatrix(): void;
  51443. protected _buildUniformLayout(): void;
  51444. private _computeAngleValues;
  51445. /**
  51446. * Sets the passed Effect "effect" with the Light textures.
  51447. * @param effect The effect to update
  51448. * @param lightIndex The index of the light in the effect to update
  51449. * @returns The light
  51450. */
  51451. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51452. /**
  51453. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51454. * @param effect The effect to update
  51455. * @param lightIndex The index of the light in the effect to update
  51456. * @returns The spot light
  51457. */
  51458. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51459. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51460. /**
  51461. * Disposes the light and the associated resources.
  51462. */
  51463. dispose(): void;
  51464. /**
  51465. * Prepares the list of defines specific to the light type.
  51466. * @param defines the list of defines
  51467. * @param lightIndex defines the index of the light for the effect
  51468. */
  51469. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51470. }
  51471. }
  51472. declare module "babylonjs/Gizmos/lightGizmo" {
  51473. import { Nullable } from "babylonjs/types";
  51474. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51475. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51476. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51477. import { Light } from "babylonjs/Lights/light";
  51478. /**
  51479. * Gizmo that enables viewing a light
  51480. */
  51481. export class LightGizmo extends Gizmo {
  51482. private _lightMesh;
  51483. private _material;
  51484. private _cachedPosition;
  51485. private _cachedForward;
  51486. private _attachedMeshParent;
  51487. /**
  51488. * Creates a LightGizmo
  51489. * @param gizmoLayer The utility layer the gizmo will be added to
  51490. */
  51491. constructor(gizmoLayer?: UtilityLayerRenderer);
  51492. private _light;
  51493. /**
  51494. * The light that the gizmo is attached to
  51495. */
  51496. set light(light: Nullable<Light>);
  51497. get light(): Nullable<Light>;
  51498. /**
  51499. * Gets the material used to render the light gizmo
  51500. */
  51501. get material(): StandardMaterial;
  51502. /**
  51503. * @hidden
  51504. * Updates the gizmo to match the attached mesh's position/rotation
  51505. */
  51506. protected _update(): void;
  51507. private static _Scale;
  51508. /**
  51509. * Creates the lines for a light mesh
  51510. */
  51511. private static _CreateLightLines;
  51512. /**
  51513. * Disposes of the light gizmo
  51514. */
  51515. dispose(): void;
  51516. private static _CreateHemisphericLightMesh;
  51517. private static _CreatePointLightMesh;
  51518. private static _CreateSpotLightMesh;
  51519. private static _CreateDirectionalLightMesh;
  51520. }
  51521. }
  51522. declare module "babylonjs/Gizmos/index" {
  51523. export * from "babylonjs/Gizmos/axisDragGizmo";
  51524. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51525. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51526. export * from "babylonjs/Gizmos/gizmo";
  51527. export * from "babylonjs/Gizmos/gizmoManager";
  51528. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51529. export * from "babylonjs/Gizmos/positionGizmo";
  51530. export * from "babylonjs/Gizmos/rotationGizmo";
  51531. export * from "babylonjs/Gizmos/scaleGizmo";
  51532. export * from "babylonjs/Gizmos/lightGizmo";
  51533. export * from "babylonjs/Gizmos/planeDragGizmo";
  51534. }
  51535. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51536. /** @hidden */
  51537. export var backgroundFragmentDeclaration: {
  51538. name: string;
  51539. shader: string;
  51540. };
  51541. }
  51542. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51543. /** @hidden */
  51544. export var backgroundUboDeclaration: {
  51545. name: string;
  51546. shader: string;
  51547. };
  51548. }
  51549. declare module "babylonjs/Shaders/background.fragment" {
  51550. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51551. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51552. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51553. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51554. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51555. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51556. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51557. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51558. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51559. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51560. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51561. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51562. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51563. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51564. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51565. /** @hidden */
  51566. export var backgroundPixelShader: {
  51567. name: string;
  51568. shader: string;
  51569. };
  51570. }
  51571. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51572. /** @hidden */
  51573. export var backgroundVertexDeclaration: {
  51574. name: string;
  51575. shader: string;
  51576. };
  51577. }
  51578. declare module "babylonjs/Shaders/background.vertex" {
  51579. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51580. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51581. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51582. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51583. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51584. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51585. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51586. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51587. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51588. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51589. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51590. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51591. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51592. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51593. /** @hidden */
  51594. export var backgroundVertexShader: {
  51595. name: string;
  51596. shader: string;
  51597. };
  51598. }
  51599. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51600. import { Nullable, int, float } from "babylonjs/types";
  51601. import { Scene } from "babylonjs/scene";
  51602. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51603. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51605. import { Mesh } from "babylonjs/Meshes/mesh";
  51606. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51607. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51608. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51610. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51611. import { Color3 } from "babylonjs/Maths/math.color";
  51612. import "babylonjs/Shaders/background.fragment";
  51613. import "babylonjs/Shaders/background.vertex";
  51614. /**
  51615. * Background material used to create an efficient environement around your scene.
  51616. */
  51617. export class BackgroundMaterial extends PushMaterial {
  51618. /**
  51619. * Standard reflectance value at parallel view angle.
  51620. */
  51621. static StandardReflectance0: number;
  51622. /**
  51623. * Standard reflectance value at grazing angle.
  51624. */
  51625. static StandardReflectance90: number;
  51626. protected _primaryColor: Color3;
  51627. /**
  51628. * Key light Color (multiply against the environement texture)
  51629. */
  51630. primaryColor: Color3;
  51631. protected __perceptualColor: Nullable<Color3>;
  51632. /**
  51633. * Experimental Internal Use Only.
  51634. *
  51635. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51636. * This acts as a helper to set the primary color to a more "human friendly" value.
  51637. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51638. * output color as close as possible from the chosen value.
  51639. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51640. * part of lighting setup.)
  51641. */
  51642. get _perceptualColor(): Nullable<Color3>;
  51643. set _perceptualColor(value: Nullable<Color3>);
  51644. protected _primaryColorShadowLevel: float;
  51645. /**
  51646. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51647. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51648. */
  51649. get primaryColorShadowLevel(): float;
  51650. set primaryColorShadowLevel(value: float);
  51651. protected _primaryColorHighlightLevel: float;
  51652. /**
  51653. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51654. * The primary color is used at the level chosen to define what the white area would look.
  51655. */
  51656. get primaryColorHighlightLevel(): float;
  51657. set primaryColorHighlightLevel(value: float);
  51658. protected _reflectionTexture: Nullable<BaseTexture>;
  51659. /**
  51660. * Reflection Texture used in the material.
  51661. * Should be author in a specific way for the best result (refer to the documentation).
  51662. */
  51663. reflectionTexture: Nullable<BaseTexture>;
  51664. protected _reflectionBlur: float;
  51665. /**
  51666. * Reflection Texture level of blur.
  51667. *
  51668. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51669. * texture twice.
  51670. */
  51671. reflectionBlur: float;
  51672. protected _diffuseTexture: Nullable<BaseTexture>;
  51673. /**
  51674. * Diffuse Texture used in the material.
  51675. * Should be author in a specific way for the best result (refer to the documentation).
  51676. */
  51677. diffuseTexture: Nullable<BaseTexture>;
  51678. protected _shadowLights: Nullable<IShadowLight[]>;
  51679. /**
  51680. * Specify the list of lights casting shadow on the material.
  51681. * All scene shadow lights will be included if null.
  51682. */
  51683. shadowLights: Nullable<IShadowLight[]>;
  51684. protected _shadowLevel: float;
  51685. /**
  51686. * Helps adjusting the shadow to a softer level if required.
  51687. * 0 means black shadows and 1 means no shadows.
  51688. */
  51689. shadowLevel: float;
  51690. protected _sceneCenter: Vector3;
  51691. /**
  51692. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51693. * It is usually zero but might be interesting to modify according to your setup.
  51694. */
  51695. sceneCenter: Vector3;
  51696. protected _opacityFresnel: boolean;
  51697. /**
  51698. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51699. * This helps ensuring a nice transition when the camera goes under the ground.
  51700. */
  51701. opacityFresnel: boolean;
  51702. protected _reflectionFresnel: boolean;
  51703. /**
  51704. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51705. * This helps adding a mirror texture on the ground.
  51706. */
  51707. reflectionFresnel: boolean;
  51708. protected _reflectionFalloffDistance: number;
  51709. /**
  51710. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51711. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51712. */
  51713. reflectionFalloffDistance: number;
  51714. protected _reflectionAmount: number;
  51715. /**
  51716. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51717. */
  51718. reflectionAmount: number;
  51719. protected _reflectionReflectance0: number;
  51720. /**
  51721. * This specifies the weight of the reflection at grazing angle.
  51722. */
  51723. reflectionReflectance0: number;
  51724. protected _reflectionReflectance90: number;
  51725. /**
  51726. * This specifies the weight of the reflection at a perpendicular point of view.
  51727. */
  51728. reflectionReflectance90: number;
  51729. /**
  51730. * Sets the reflection reflectance fresnel values according to the default standard
  51731. * empirically know to work well :-)
  51732. */
  51733. set reflectionStandardFresnelWeight(value: number);
  51734. protected _useRGBColor: boolean;
  51735. /**
  51736. * Helps to directly use the maps channels instead of their level.
  51737. */
  51738. useRGBColor: boolean;
  51739. protected _enableNoise: boolean;
  51740. /**
  51741. * This helps reducing the banding effect that could occur on the background.
  51742. */
  51743. enableNoise: boolean;
  51744. /**
  51745. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51746. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51747. * Recommended to be keep at 1.0 except for special cases.
  51748. */
  51749. get fovMultiplier(): number;
  51750. set fovMultiplier(value: number);
  51751. private _fovMultiplier;
  51752. /**
  51753. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51754. */
  51755. useEquirectangularFOV: boolean;
  51756. private _maxSimultaneousLights;
  51757. /**
  51758. * Number of Simultaneous lights allowed on the material.
  51759. */
  51760. maxSimultaneousLights: int;
  51761. /**
  51762. * Default configuration related to image processing available in the Background Material.
  51763. */
  51764. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51765. /**
  51766. * Keep track of the image processing observer to allow dispose and replace.
  51767. */
  51768. private _imageProcessingObserver;
  51769. /**
  51770. * Attaches a new image processing configuration to the PBR Material.
  51771. * @param configuration (if null the scene configuration will be use)
  51772. */
  51773. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51774. /**
  51775. * Gets the image processing configuration used either in this material.
  51776. */
  51777. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51778. /**
  51779. * Sets the Default image processing configuration used either in the this material.
  51780. *
  51781. * If sets to null, the scene one is in use.
  51782. */
  51783. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51784. /**
  51785. * Gets wether the color curves effect is enabled.
  51786. */
  51787. get cameraColorCurvesEnabled(): boolean;
  51788. /**
  51789. * Sets wether the color curves effect is enabled.
  51790. */
  51791. set cameraColorCurvesEnabled(value: boolean);
  51792. /**
  51793. * Gets wether the color grading effect is enabled.
  51794. */
  51795. get cameraColorGradingEnabled(): boolean;
  51796. /**
  51797. * Gets wether the color grading effect is enabled.
  51798. */
  51799. set cameraColorGradingEnabled(value: boolean);
  51800. /**
  51801. * Gets wether tonemapping is enabled or not.
  51802. */
  51803. get cameraToneMappingEnabled(): boolean;
  51804. /**
  51805. * Sets wether tonemapping is enabled or not
  51806. */
  51807. set cameraToneMappingEnabled(value: boolean);
  51808. /**
  51809. * The camera exposure used on this material.
  51810. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51811. * This corresponds to a photographic exposure.
  51812. */
  51813. get cameraExposure(): float;
  51814. /**
  51815. * The camera exposure used on this material.
  51816. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51817. * This corresponds to a photographic exposure.
  51818. */
  51819. set cameraExposure(value: float);
  51820. /**
  51821. * Gets The camera contrast used on this material.
  51822. */
  51823. get cameraContrast(): float;
  51824. /**
  51825. * Sets The camera contrast used on this material.
  51826. */
  51827. set cameraContrast(value: float);
  51828. /**
  51829. * Gets the Color Grading 2D Lookup Texture.
  51830. */
  51831. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51832. /**
  51833. * Sets the Color Grading 2D Lookup Texture.
  51834. */
  51835. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51836. /**
  51837. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51838. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51839. * 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;
  51840. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51841. */
  51842. get cameraColorCurves(): Nullable<ColorCurves>;
  51843. /**
  51844. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51845. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51846. * 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;
  51847. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51848. */
  51849. set cameraColorCurves(value: Nullable<ColorCurves>);
  51850. /**
  51851. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51852. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51853. */
  51854. switchToBGR: boolean;
  51855. private _renderTargets;
  51856. private _reflectionControls;
  51857. private _white;
  51858. private _primaryShadowColor;
  51859. private _primaryHighlightColor;
  51860. /**
  51861. * Instantiates a Background Material in the given scene
  51862. * @param name The friendly name of the material
  51863. * @param scene The scene to add the material to
  51864. */
  51865. constructor(name: string, scene: Scene);
  51866. /**
  51867. * Gets a boolean indicating that current material needs to register RTT
  51868. */
  51869. get hasRenderTargetTextures(): boolean;
  51870. /**
  51871. * The entire material has been created in order to prevent overdraw.
  51872. * @returns false
  51873. */
  51874. needAlphaTesting(): boolean;
  51875. /**
  51876. * The entire material has been created in order to prevent overdraw.
  51877. * @returns true if blending is enable
  51878. */
  51879. needAlphaBlending(): boolean;
  51880. /**
  51881. * Checks wether the material is ready to be rendered for a given mesh.
  51882. * @param mesh The mesh to render
  51883. * @param subMesh The submesh to check against
  51884. * @param useInstances Specify wether or not the material is used with instances
  51885. * @returns true if all the dependencies are ready (Textures, Effects...)
  51886. */
  51887. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51888. /**
  51889. * Compute the primary color according to the chosen perceptual color.
  51890. */
  51891. private _computePrimaryColorFromPerceptualColor;
  51892. /**
  51893. * Compute the highlights and shadow colors according to their chosen levels.
  51894. */
  51895. private _computePrimaryColors;
  51896. /**
  51897. * Build the uniform buffer used in the material.
  51898. */
  51899. buildUniformLayout(): void;
  51900. /**
  51901. * Unbind the material.
  51902. */
  51903. unbind(): void;
  51904. /**
  51905. * Bind only the world matrix to the material.
  51906. * @param world The world matrix to bind.
  51907. */
  51908. bindOnlyWorldMatrix(world: Matrix): void;
  51909. /**
  51910. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51911. * @param world The world matrix to bind.
  51912. * @param subMesh The submesh to bind for.
  51913. */
  51914. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51915. /**
  51916. * Checks to see if a texture is used in the material.
  51917. * @param texture - Base texture to use.
  51918. * @returns - Boolean specifying if a texture is used in the material.
  51919. */
  51920. hasTexture(texture: BaseTexture): boolean;
  51921. /**
  51922. * Dispose the material.
  51923. * @param forceDisposeEffect Force disposal of the associated effect.
  51924. * @param forceDisposeTextures Force disposal of the associated textures.
  51925. */
  51926. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51927. /**
  51928. * Clones the material.
  51929. * @param name The cloned name.
  51930. * @returns The cloned material.
  51931. */
  51932. clone(name: string): BackgroundMaterial;
  51933. /**
  51934. * Serializes the current material to its JSON representation.
  51935. * @returns The JSON representation.
  51936. */
  51937. serialize(): any;
  51938. /**
  51939. * Gets the class name of the material
  51940. * @returns "BackgroundMaterial"
  51941. */
  51942. getClassName(): string;
  51943. /**
  51944. * Parse a JSON input to create back a background material.
  51945. * @param source The JSON data to parse
  51946. * @param scene The scene to create the parsed material in
  51947. * @param rootUrl The root url of the assets the material depends upon
  51948. * @returns the instantiated BackgroundMaterial.
  51949. */
  51950. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51951. }
  51952. }
  51953. declare module "babylonjs/Helpers/environmentHelper" {
  51954. import { Observable } from "babylonjs/Misc/observable";
  51955. import { Nullable } from "babylonjs/types";
  51956. import { Scene } from "babylonjs/scene";
  51957. import { Vector3 } from "babylonjs/Maths/math.vector";
  51958. import { Color3 } from "babylonjs/Maths/math.color";
  51959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51960. import { Mesh } from "babylonjs/Meshes/mesh";
  51961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51962. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51963. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51964. import "babylonjs/Meshes/Builders/planeBuilder";
  51965. import "babylonjs/Meshes/Builders/boxBuilder";
  51966. /**
  51967. * Represents the different options available during the creation of
  51968. * a Environment helper.
  51969. *
  51970. * This can control the default ground, skybox and image processing setup of your scene.
  51971. */
  51972. export interface IEnvironmentHelperOptions {
  51973. /**
  51974. * Specifies whether or not to create a ground.
  51975. * True by default.
  51976. */
  51977. createGround: boolean;
  51978. /**
  51979. * Specifies the ground size.
  51980. * 15 by default.
  51981. */
  51982. groundSize: number;
  51983. /**
  51984. * The texture used on the ground for the main color.
  51985. * Comes from the BabylonJS CDN by default.
  51986. *
  51987. * Remarks: Can be either a texture or a url.
  51988. */
  51989. groundTexture: string | BaseTexture;
  51990. /**
  51991. * The color mixed in the ground texture by default.
  51992. * BabylonJS clearColor by default.
  51993. */
  51994. groundColor: Color3;
  51995. /**
  51996. * Specifies the ground opacity.
  51997. * 1 by default.
  51998. */
  51999. groundOpacity: number;
  52000. /**
  52001. * Enables the ground to receive shadows.
  52002. * True by default.
  52003. */
  52004. enableGroundShadow: boolean;
  52005. /**
  52006. * Helps preventing the shadow to be fully black on the ground.
  52007. * 0.5 by default.
  52008. */
  52009. groundShadowLevel: number;
  52010. /**
  52011. * Creates a mirror texture attach to the ground.
  52012. * false by default.
  52013. */
  52014. enableGroundMirror: boolean;
  52015. /**
  52016. * Specifies the ground mirror size ratio.
  52017. * 0.3 by default as the default kernel is 64.
  52018. */
  52019. groundMirrorSizeRatio: number;
  52020. /**
  52021. * Specifies the ground mirror blur kernel size.
  52022. * 64 by default.
  52023. */
  52024. groundMirrorBlurKernel: number;
  52025. /**
  52026. * Specifies the ground mirror visibility amount.
  52027. * 1 by default
  52028. */
  52029. groundMirrorAmount: number;
  52030. /**
  52031. * Specifies the ground mirror reflectance weight.
  52032. * This uses the standard weight of the background material to setup the fresnel effect
  52033. * of the mirror.
  52034. * 1 by default.
  52035. */
  52036. groundMirrorFresnelWeight: number;
  52037. /**
  52038. * Specifies the ground mirror Falloff distance.
  52039. * This can helps reducing the size of the reflection.
  52040. * 0 by Default.
  52041. */
  52042. groundMirrorFallOffDistance: number;
  52043. /**
  52044. * Specifies the ground mirror texture type.
  52045. * Unsigned Int by Default.
  52046. */
  52047. groundMirrorTextureType: number;
  52048. /**
  52049. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52050. * the shown objects.
  52051. */
  52052. groundYBias: number;
  52053. /**
  52054. * Specifies whether or not to create a skybox.
  52055. * True by default.
  52056. */
  52057. createSkybox: boolean;
  52058. /**
  52059. * Specifies the skybox size.
  52060. * 20 by default.
  52061. */
  52062. skyboxSize: number;
  52063. /**
  52064. * The texture used on the skybox for the main color.
  52065. * Comes from the BabylonJS CDN by default.
  52066. *
  52067. * Remarks: Can be either a texture or a url.
  52068. */
  52069. skyboxTexture: string | BaseTexture;
  52070. /**
  52071. * The color mixed in the skybox texture by default.
  52072. * BabylonJS clearColor by default.
  52073. */
  52074. skyboxColor: Color3;
  52075. /**
  52076. * The background rotation around the Y axis of the scene.
  52077. * This helps aligning the key lights of your scene with the background.
  52078. * 0 by default.
  52079. */
  52080. backgroundYRotation: number;
  52081. /**
  52082. * Compute automatically the size of the elements to best fit with the scene.
  52083. */
  52084. sizeAuto: boolean;
  52085. /**
  52086. * Default position of the rootMesh if autoSize is not true.
  52087. */
  52088. rootPosition: Vector3;
  52089. /**
  52090. * Sets up the image processing in the scene.
  52091. * true by default.
  52092. */
  52093. setupImageProcessing: boolean;
  52094. /**
  52095. * The texture used as your environment texture in the scene.
  52096. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52097. *
  52098. * Remarks: Can be either a texture or a url.
  52099. */
  52100. environmentTexture: string | BaseTexture;
  52101. /**
  52102. * The value of the exposure to apply to the scene.
  52103. * 0.6 by default if setupImageProcessing is true.
  52104. */
  52105. cameraExposure: number;
  52106. /**
  52107. * The value of the contrast to apply to the scene.
  52108. * 1.6 by default if setupImageProcessing is true.
  52109. */
  52110. cameraContrast: number;
  52111. /**
  52112. * Specifies whether or not tonemapping should be enabled in the scene.
  52113. * true by default if setupImageProcessing is true.
  52114. */
  52115. toneMappingEnabled: boolean;
  52116. }
  52117. /**
  52118. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52119. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52120. * It also helps with the default setup of your imageProcessing configuration.
  52121. */
  52122. export class EnvironmentHelper {
  52123. /**
  52124. * Default ground texture URL.
  52125. */
  52126. private static _groundTextureCDNUrl;
  52127. /**
  52128. * Default skybox texture URL.
  52129. */
  52130. private static _skyboxTextureCDNUrl;
  52131. /**
  52132. * Default environment texture URL.
  52133. */
  52134. private static _environmentTextureCDNUrl;
  52135. /**
  52136. * Creates the default options for the helper.
  52137. */
  52138. private static _getDefaultOptions;
  52139. private _rootMesh;
  52140. /**
  52141. * Gets the root mesh created by the helper.
  52142. */
  52143. get rootMesh(): Mesh;
  52144. private _skybox;
  52145. /**
  52146. * Gets the skybox created by the helper.
  52147. */
  52148. get skybox(): Nullable<Mesh>;
  52149. private _skyboxTexture;
  52150. /**
  52151. * Gets the skybox texture created by the helper.
  52152. */
  52153. get skyboxTexture(): Nullable<BaseTexture>;
  52154. private _skyboxMaterial;
  52155. /**
  52156. * Gets the skybox material created by the helper.
  52157. */
  52158. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52159. private _ground;
  52160. /**
  52161. * Gets the ground mesh created by the helper.
  52162. */
  52163. get ground(): Nullable<Mesh>;
  52164. private _groundTexture;
  52165. /**
  52166. * Gets the ground texture created by the helper.
  52167. */
  52168. get groundTexture(): Nullable<BaseTexture>;
  52169. private _groundMirror;
  52170. /**
  52171. * Gets the ground mirror created by the helper.
  52172. */
  52173. get groundMirror(): Nullable<MirrorTexture>;
  52174. /**
  52175. * Gets the ground mirror render list to helps pushing the meshes
  52176. * you wish in the ground reflection.
  52177. */
  52178. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52179. private _groundMaterial;
  52180. /**
  52181. * Gets the ground material created by the helper.
  52182. */
  52183. get groundMaterial(): Nullable<BackgroundMaterial>;
  52184. /**
  52185. * Stores the creation options.
  52186. */
  52187. private readonly _scene;
  52188. private _options;
  52189. /**
  52190. * This observable will be notified with any error during the creation of the environment,
  52191. * mainly texture creation errors.
  52192. */
  52193. onErrorObservable: Observable<{
  52194. message?: string;
  52195. exception?: any;
  52196. }>;
  52197. /**
  52198. * constructor
  52199. * @param options Defines the options we want to customize the helper
  52200. * @param scene The scene to add the material to
  52201. */
  52202. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52203. /**
  52204. * Updates the background according to the new options
  52205. * @param options
  52206. */
  52207. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52208. /**
  52209. * Sets the primary color of all the available elements.
  52210. * @param color the main color to affect to the ground and the background
  52211. */
  52212. setMainColor(color: Color3): void;
  52213. /**
  52214. * Setup the image processing according to the specified options.
  52215. */
  52216. private _setupImageProcessing;
  52217. /**
  52218. * Setup the environment texture according to the specified options.
  52219. */
  52220. private _setupEnvironmentTexture;
  52221. /**
  52222. * Setup the background according to the specified options.
  52223. */
  52224. private _setupBackground;
  52225. /**
  52226. * Get the scene sizes according to the setup.
  52227. */
  52228. private _getSceneSize;
  52229. /**
  52230. * Setup the ground according to the specified options.
  52231. */
  52232. private _setupGround;
  52233. /**
  52234. * Setup the ground material according to the specified options.
  52235. */
  52236. private _setupGroundMaterial;
  52237. /**
  52238. * Setup the ground diffuse texture according to the specified options.
  52239. */
  52240. private _setupGroundDiffuseTexture;
  52241. /**
  52242. * Setup the ground mirror texture according to the specified options.
  52243. */
  52244. private _setupGroundMirrorTexture;
  52245. /**
  52246. * Setup the ground to receive the mirror texture.
  52247. */
  52248. private _setupMirrorInGroundMaterial;
  52249. /**
  52250. * Setup the skybox according to the specified options.
  52251. */
  52252. private _setupSkybox;
  52253. /**
  52254. * Setup the skybox material according to the specified options.
  52255. */
  52256. private _setupSkyboxMaterial;
  52257. /**
  52258. * Setup the skybox reflection texture according to the specified options.
  52259. */
  52260. private _setupSkyboxReflectionTexture;
  52261. private _errorHandler;
  52262. /**
  52263. * Dispose all the elements created by the Helper.
  52264. */
  52265. dispose(): void;
  52266. }
  52267. }
  52268. declare module "babylonjs/Helpers/photoDome" {
  52269. import { Observable } from "babylonjs/Misc/observable";
  52270. import { Nullable } from "babylonjs/types";
  52271. import { Scene } from "babylonjs/scene";
  52272. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52273. import { Mesh } from "babylonjs/Meshes/mesh";
  52274. import { Texture } from "babylonjs/Materials/Textures/texture";
  52275. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52276. import "babylonjs/Meshes/Builders/sphereBuilder";
  52277. /**
  52278. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52279. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52280. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52281. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52282. */
  52283. export class PhotoDome extends TransformNode {
  52284. /**
  52285. * Define the image as a Monoscopic panoramic 360 image.
  52286. */
  52287. static readonly MODE_MONOSCOPIC: number;
  52288. /**
  52289. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52290. */
  52291. static readonly MODE_TOPBOTTOM: number;
  52292. /**
  52293. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52294. */
  52295. static readonly MODE_SIDEBYSIDE: number;
  52296. private _useDirectMapping;
  52297. /**
  52298. * The texture being displayed on the sphere
  52299. */
  52300. protected _photoTexture: Texture;
  52301. /**
  52302. * Gets or sets the texture being displayed on the sphere
  52303. */
  52304. get photoTexture(): Texture;
  52305. set photoTexture(value: Texture);
  52306. /**
  52307. * Observable raised when an error occured while loading the 360 image
  52308. */
  52309. onLoadErrorObservable: Observable<string>;
  52310. /**
  52311. * The skybox material
  52312. */
  52313. protected _material: BackgroundMaterial;
  52314. /**
  52315. * The surface used for the skybox
  52316. */
  52317. protected _mesh: Mesh;
  52318. /**
  52319. * Gets the mesh used for the skybox.
  52320. */
  52321. get mesh(): Mesh;
  52322. /**
  52323. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52324. * Also see the options.resolution property.
  52325. */
  52326. get fovMultiplier(): number;
  52327. set fovMultiplier(value: number);
  52328. private _imageMode;
  52329. /**
  52330. * Gets or set the current video mode for the video. It can be:
  52331. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52332. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52333. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52334. */
  52335. get imageMode(): number;
  52336. set imageMode(value: number);
  52337. /**
  52338. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52339. * @param name Element's name, child elements will append suffixes for their own names.
  52340. * @param urlsOfPhoto defines the url of the photo to display
  52341. * @param options defines an object containing optional or exposed sub element properties
  52342. * @param onError defines a callback called when an error occured while loading the texture
  52343. */
  52344. constructor(name: string, urlOfPhoto: string, options: {
  52345. resolution?: number;
  52346. size?: number;
  52347. useDirectMapping?: boolean;
  52348. faceForward?: boolean;
  52349. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52350. private _onBeforeCameraRenderObserver;
  52351. private _changeImageMode;
  52352. /**
  52353. * Releases resources associated with this node.
  52354. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52355. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52356. */
  52357. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52358. }
  52359. }
  52360. declare module "babylonjs/Misc/rgbdTextureTools" {
  52361. import "babylonjs/Shaders/rgbdDecode.fragment";
  52362. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52363. import { Texture } from "babylonjs/Materials/Textures/texture";
  52364. /**
  52365. * Class used to host RGBD texture specific utilities
  52366. */
  52367. export class RGBDTextureTools {
  52368. /**
  52369. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52370. * @param texture the texture to expand.
  52371. */
  52372. static ExpandRGBDTexture(texture: Texture): void;
  52373. }
  52374. }
  52375. declare module "babylonjs/Misc/brdfTextureTools" {
  52376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52377. import { Scene } from "babylonjs/scene";
  52378. /**
  52379. * Class used to host texture specific utilities
  52380. */
  52381. export class BRDFTextureTools {
  52382. /**
  52383. * Prevents texture cache collision
  52384. */
  52385. private static _instanceNumber;
  52386. /**
  52387. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52388. * @param scene defines the hosting scene
  52389. * @returns the environment BRDF texture
  52390. */
  52391. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52392. private static _environmentBRDFBase64Texture;
  52393. }
  52394. }
  52395. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52396. import { Nullable } from "babylonjs/types";
  52397. import { Color3 } from "babylonjs/Maths/math.color";
  52398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52399. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52400. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52401. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52402. import { Engine } from "babylonjs/Engines/engine";
  52403. import { Scene } from "babylonjs/scene";
  52404. /**
  52405. * @hidden
  52406. */
  52407. export interface IMaterialClearCoatDefines {
  52408. CLEARCOAT: boolean;
  52409. CLEARCOAT_DEFAULTIOR: boolean;
  52410. CLEARCOAT_TEXTURE: boolean;
  52411. CLEARCOAT_TEXTUREDIRECTUV: number;
  52412. CLEARCOAT_BUMP: boolean;
  52413. CLEARCOAT_BUMPDIRECTUV: number;
  52414. CLEARCOAT_TINT: boolean;
  52415. CLEARCOAT_TINT_TEXTURE: boolean;
  52416. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52417. /** @hidden */
  52418. _areTexturesDirty: boolean;
  52419. }
  52420. /**
  52421. * Define the code related to the clear coat parameters of the pbr material.
  52422. */
  52423. export class PBRClearCoatConfiguration {
  52424. /**
  52425. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52426. * The default fits with a polyurethane material.
  52427. */
  52428. private static readonly _DefaultIndexOfRefraction;
  52429. private _isEnabled;
  52430. /**
  52431. * Defines if the clear coat is enabled in the material.
  52432. */
  52433. isEnabled: boolean;
  52434. /**
  52435. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52436. */
  52437. intensity: number;
  52438. /**
  52439. * Defines the clear coat layer roughness.
  52440. */
  52441. roughness: number;
  52442. private _indexOfRefraction;
  52443. /**
  52444. * Defines the index of refraction of the clear coat.
  52445. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52446. * The default fits with a polyurethane material.
  52447. * Changing the default value is more performance intensive.
  52448. */
  52449. indexOfRefraction: number;
  52450. private _texture;
  52451. /**
  52452. * Stores the clear coat values in a texture.
  52453. */
  52454. texture: Nullable<BaseTexture>;
  52455. private _bumpTexture;
  52456. /**
  52457. * Define the clear coat specific bump texture.
  52458. */
  52459. bumpTexture: Nullable<BaseTexture>;
  52460. private _isTintEnabled;
  52461. /**
  52462. * Defines if the clear coat tint is enabled in the material.
  52463. */
  52464. isTintEnabled: boolean;
  52465. /**
  52466. * Defines the clear coat tint of the material.
  52467. * This is only use if tint is enabled
  52468. */
  52469. tintColor: Color3;
  52470. /**
  52471. * Defines the distance at which the tint color should be found in the
  52472. * clear coat media.
  52473. * This is only use if tint is enabled
  52474. */
  52475. tintColorAtDistance: number;
  52476. /**
  52477. * Defines the clear coat layer thickness.
  52478. * This is only use if tint is enabled
  52479. */
  52480. tintThickness: number;
  52481. private _tintTexture;
  52482. /**
  52483. * Stores the clear tint values in a texture.
  52484. * rgb is tint
  52485. * a is a thickness factor
  52486. */
  52487. tintTexture: Nullable<BaseTexture>;
  52488. /** @hidden */
  52489. private _internalMarkAllSubMeshesAsTexturesDirty;
  52490. /** @hidden */
  52491. _markAllSubMeshesAsTexturesDirty(): void;
  52492. /**
  52493. * Instantiate a new istance of clear coat configuration.
  52494. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52495. */
  52496. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52497. /**
  52498. * Gets wehter the submesh is ready to be used or not.
  52499. * @param defines the list of "defines" to update.
  52500. * @param scene defines the scene the material belongs to.
  52501. * @param engine defines the engine the material belongs to.
  52502. * @param disableBumpMap defines wether the material disables bump or not.
  52503. * @returns - boolean indicating that the submesh is ready or not.
  52504. */
  52505. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52506. /**
  52507. * Checks to see if a texture is used in the material.
  52508. * @param defines the list of "defines" to update.
  52509. * @param scene defines the scene to the material belongs to.
  52510. */
  52511. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52512. /**
  52513. * Binds the material data.
  52514. * @param uniformBuffer defines the Uniform buffer to fill in.
  52515. * @param scene defines the scene the material belongs to.
  52516. * @param engine defines the engine the material belongs to.
  52517. * @param disableBumpMap defines wether the material disables bump or not.
  52518. * @param isFrozen defines wether the material is frozen or not.
  52519. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52520. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52521. */
  52522. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52523. /**
  52524. * Checks to see if a texture is used in the material.
  52525. * @param texture - Base texture to use.
  52526. * @returns - Boolean specifying if a texture is used in the material.
  52527. */
  52528. hasTexture(texture: BaseTexture): boolean;
  52529. /**
  52530. * Returns an array of the actively used textures.
  52531. * @param activeTextures Array of BaseTextures
  52532. */
  52533. getActiveTextures(activeTextures: BaseTexture[]): void;
  52534. /**
  52535. * Returns the animatable textures.
  52536. * @param animatables Array of animatable textures.
  52537. */
  52538. getAnimatables(animatables: IAnimatable[]): void;
  52539. /**
  52540. * Disposes the resources of the material.
  52541. * @param forceDisposeTextures - Forces the disposal of all textures.
  52542. */
  52543. dispose(forceDisposeTextures?: boolean): void;
  52544. /**
  52545. * Get the current class name of the texture useful for serialization or dynamic coding.
  52546. * @returns "PBRClearCoatConfiguration"
  52547. */
  52548. getClassName(): string;
  52549. /**
  52550. * Add fallbacks to the effect fallbacks list.
  52551. * @param defines defines the Base texture to use.
  52552. * @param fallbacks defines the current fallback list.
  52553. * @param currentRank defines the current fallback rank.
  52554. * @returns the new fallback rank.
  52555. */
  52556. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52557. /**
  52558. * Add the required uniforms to the current list.
  52559. * @param uniforms defines the current uniform list.
  52560. */
  52561. static AddUniforms(uniforms: string[]): void;
  52562. /**
  52563. * Add the required samplers to the current list.
  52564. * @param samplers defines the current sampler list.
  52565. */
  52566. static AddSamplers(samplers: string[]): void;
  52567. /**
  52568. * Add the required uniforms to the current buffer.
  52569. * @param uniformBuffer defines the current uniform buffer.
  52570. */
  52571. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52572. /**
  52573. * Makes a duplicate of the current configuration into another one.
  52574. * @param clearCoatConfiguration define the config where to copy the info
  52575. */
  52576. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52577. /**
  52578. * Serializes this clear coat configuration.
  52579. * @returns - An object with the serialized config.
  52580. */
  52581. serialize(): any;
  52582. /**
  52583. * Parses a anisotropy Configuration from a serialized object.
  52584. * @param source - Serialized object.
  52585. * @param scene Defines the scene we are parsing for
  52586. * @param rootUrl Defines the rootUrl to load from
  52587. */
  52588. parse(source: any, scene: Scene, rootUrl: string): void;
  52589. }
  52590. }
  52591. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52592. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52594. import { Vector2 } from "babylonjs/Maths/math.vector";
  52595. import { Scene } from "babylonjs/scene";
  52596. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52597. import { Nullable } from "babylonjs/types";
  52598. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52599. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52600. /**
  52601. * @hidden
  52602. */
  52603. export interface IMaterialAnisotropicDefines {
  52604. ANISOTROPIC: boolean;
  52605. ANISOTROPIC_TEXTURE: boolean;
  52606. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52607. MAINUV1: boolean;
  52608. _areTexturesDirty: boolean;
  52609. _needUVs: boolean;
  52610. }
  52611. /**
  52612. * Define the code related to the anisotropic parameters of the pbr material.
  52613. */
  52614. export class PBRAnisotropicConfiguration {
  52615. private _isEnabled;
  52616. /**
  52617. * Defines if the anisotropy is enabled in the material.
  52618. */
  52619. isEnabled: boolean;
  52620. /**
  52621. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52622. */
  52623. intensity: number;
  52624. /**
  52625. * Defines if the effect is along the tangents, bitangents or in between.
  52626. * By default, the effect is "strectching" the highlights along the tangents.
  52627. */
  52628. direction: Vector2;
  52629. private _texture;
  52630. /**
  52631. * Stores the anisotropy values in a texture.
  52632. * rg is direction (like normal from -1 to 1)
  52633. * b is a intensity
  52634. */
  52635. texture: Nullable<BaseTexture>;
  52636. /** @hidden */
  52637. private _internalMarkAllSubMeshesAsTexturesDirty;
  52638. /** @hidden */
  52639. _markAllSubMeshesAsTexturesDirty(): void;
  52640. /**
  52641. * Instantiate a new istance of anisotropy configuration.
  52642. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52643. */
  52644. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52645. /**
  52646. * Specifies that the submesh is ready to be used.
  52647. * @param defines the list of "defines" to update.
  52648. * @param scene defines the scene the material belongs to.
  52649. * @returns - boolean indicating that the submesh is ready or not.
  52650. */
  52651. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52652. /**
  52653. * Checks to see if a texture is used in the material.
  52654. * @param defines the list of "defines" to update.
  52655. * @param mesh the mesh we are preparing the defines for.
  52656. * @param scene defines the scene the material belongs to.
  52657. */
  52658. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52659. /**
  52660. * Binds the material data.
  52661. * @param uniformBuffer defines the Uniform buffer to fill in.
  52662. * @param scene defines the scene the material belongs to.
  52663. * @param isFrozen defines wether the material is frozen or not.
  52664. */
  52665. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52666. /**
  52667. * Checks to see if a texture is used in the material.
  52668. * @param texture - Base texture to use.
  52669. * @returns - Boolean specifying if a texture is used in the material.
  52670. */
  52671. hasTexture(texture: BaseTexture): boolean;
  52672. /**
  52673. * Returns an array of the actively used textures.
  52674. * @param activeTextures Array of BaseTextures
  52675. */
  52676. getActiveTextures(activeTextures: BaseTexture[]): void;
  52677. /**
  52678. * Returns the animatable textures.
  52679. * @param animatables Array of animatable textures.
  52680. */
  52681. getAnimatables(animatables: IAnimatable[]): void;
  52682. /**
  52683. * Disposes the resources of the material.
  52684. * @param forceDisposeTextures - Forces the disposal of all textures.
  52685. */
  52686. dispose(forceDisposeTextures?: boolean): void;
  52687. /**
  52688. * Get the current class name of the texture useful for serialization or dynamic coding.
  52689. * @returns "PBRAnisotropicConfiguration"
  52690. */
  52691. getClassName(): string;
  52692. /**
  52693. * Add fallbacks to the effect fallbacks list.
  52694. * @param defines defines the Base texture to use.
  52695. * @param fallbacks defines the current fallback list.
  52696. * @param currentRank defines the current fallback rank.
  52697. * @returns the new fallback rank.
  52698. */
  52699. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52700. /**
  52701. * Add the required uniforms to the current list.
  52702. * @param uniforms defines the current uniform list.
  52703. */
  52704. static AddUniforms(uniforms: string[]): void;
  52705. /**
  52706. * Add the required uniforms to the current buffer.
  52707. * @param uniformBuffer defines the current uniform buffer.
  52708. */
  52709. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52710. /**
  52711. * Add the required samplers to the current list.
  52712. * @param samplers defines the current sampler list.
  52713. */
  52714. static AddSamplers(samplers: string[]): void;
  52715. /**
  52716. * Makes a duplicate of the current configuration into another one.
  52717. * @param anisotropicConfiguration define the config where to copy the info
  52718. */
  52719. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52720. /**
  52721. * Serializes this anisotropy configuration.
  52722. * @returns - An object with the serialized config.
  52723. */
  52724. serialize(): any;
  52725. /**
  52726. * Parses a anisotropy Configuration from a serialized object.
  52727. * @param source - Serialized object.
  52728. * @param scene Defines the scene we are parsing for
  52729. * @param rootUrl Defines the rootUrl to load from
  52730. */
  52731. parse(source: any, scene: Scene, rootUrl: string): void;
  52732. }
  52733. }
  52734. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52735. import { Scene } from "babylonjs/scene";
  52736. /**
  52737. * @hidden
  52738. */
  52739. export interface IMaterialBRDFDefines {
  52740. BRDF_V_HEIGHT_CORRELATED: boolean;
  52741. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52742. SPHERICAL_HARMONICS: boolean;
  52743. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52744. /** @hidden */
  52745. _areMiscDirty: boolean;
  52746. }
  52747. /**
  52748. * Define the code related to the BRDF parameters of the pbr material.
  52749. */
  52750. export class PBRBRDFConfiguration {
  52751. /**
  52752. * Default value used for the energy conservation.
  52753. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52754. */
  52755. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52756. /**
  52757. * Default value used for the Smith Visibility Height Correlated mode.
  52758. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52759. */
  52760. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52761. /**
  52762. * Default value used for the IBL diffuse part.
  52763. * This can help switching back to the polynomials mode globally which is a tiny bit
  52764. * less GPU intensive at the drawback of a lower quality.
  52765. */
  52766. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52767. /**
  52768. * Default value used for activating energy conservation for the specular workflow.
  52769. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52770. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52771. */
  52772. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52773. private _useEnergyConservation;
  52774. /**
  52775. * Defines if the material uses energy conservation.
  52776. */
  52777. useEnergyConservation: boolean;
  52778. private _useSmithVisibilityHeightCorrelated;
  52779. /**
  52780. * LEGACY Mode set to false
  52781. * Defines if the material uses height smith correlated visibility term.
  52782. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52783. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52784. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52785. * Not relying on height correlated will also disable energy conservation.
  52786. */
  52787. useSmithVisibilityHeightCorrelated: boolean;
  52788. private _useSphericalHarmonics;
  52789. /**
  52790. * LEGACY Mode set to false
  52791. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52792. * diffuse part of the IBL.
  52793. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52794. * to the ground truth.
  52795. */
  52796. useSphericalHarmonics: boolean;
  52797. private _useSpecularGlossinessInputEnergyConservation;
  52798. /**
  52799. * Defines if the material uses energy conservation, when the specular workflow is active.
  52800. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52801. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52802. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52803. */
  52804. useSpecularGlossinessInputEnergyConservation: boolean;
  52805. /** @hidden */
  52806. private _internalMarkAllSubMeshesAsMiscDirty;
  52807. /** @hidden */
  52808. _markAllSubMeshesAsMiscDirty(): void;
  52809. /**
  52810. * Instantiate a new istance of clear coat configuration.
  52811. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52812. */
  52813. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52814. /**
  52815. * Checks to see if a texture is used in the material.
  52816. * @param defines the list of "defines" to update.
  52817. */
  52818. prepareDefines(defines: IMaterialBRDFDefines): void;
  52819. /**
  52820. * Get the current class name of the texture useful for serialization or dynamic coding.
  52821. * @returns "PBRClearCoatConfiguration"
  52822. */
  52823. getClassName(): string;
  52824. /**
  52825. * Makes a duplicate of the current configuration into another one.
  52826. * @param brdfConfiguration define the config where to copy the info
  52827. */
  52828. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52829. /**
  52830. * Serializes this BRDF configuration.
  52831. * @returns - An object with the serialized config.
  52832. */
  52833. serialize(): any;
  52834. /**
  52835. * Parses a anisotropy Configuration from a serialized object.
  52836. * @param source - Serialized object.
  52837. * @param scene Defines the scene we are parsing for
  52838. * @param rootUrl Defines the rootUrl to load from
  52839. */
  52840. parse(source: any, scene: Scene, rootUrl: string): void;
  52841. }
  52842. }
  52843. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52844. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52845. import { Color3 } from "babylonjs/Maths/math.color";
  52846. import { Scene } from "babylonjs/scene";
  52847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52848. import { Nullable } from "babylonjs/types";
  52849. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52850. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52851. /**
  52852. * @hidden
  52853. */
  52854. export interface IMaterialSheenDefines {
  52855. SHEEN: boolean;
  52856. SHEEN_TEXTURE: boolean;
  52857. SHEEN_TEXTUREDIRECTUV: number;
  52858. SHEEN_LINKWITHALBEDO: boolean;
  52859. SHEEN_ROUGHNESS: boolean;
  52860. SHEEN_ALBEDOSCALING: boolean;
  52861. /** @hidden */
  52862. _areTexturesDirty: boolean;
  52863. }
  52864. /**
  52865. * Define the code related to the Sheen parameters of the pbr material.
  52866. */
  52867. export class PBRSheenConfiguration {
  52868. private _isEnabled;
  52869. /**
  52870. * Defines if the material uses sheen.
  52871. */
  52872. isEnabled: boolean;
  52873. private _linkSheenWithAlbedo;
  52874. /**
  52875. * Defines if the sheen is linked to the sheen color.
  52876. */
  52877. linkSheenWithAlbedo: boolean;
  52878. /**
  52879. * Defines the sheen intensity.
  52880. */
  52881. intensity: number;
  52882. /**
  52883. * Defines the sheen color.
  52884. */
  52885. color: Color3;
  52886. private _texture;
  52887. /**
  52888. * Stores the sheen tint values in a texture.
  52889. * rgb is tint
  52890. * a is a intensity
  52891. */
  52892. texture: Nullable<BaseTexture>;
  52893. private _roughness;
  52894. /**
  52895. * Defines the sheen roughness.
  52896. * It is not taken into account if linkSheenWithAlbedo is true.
  52897. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52898. */
  52899. roughness: Nullable<number>;
  52900. private _albedoScaling;
  52901. /**
  52902. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52903. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52904. * making it easier to setup and tweak the effect
  52905. */
  52906. albedoScaling: boolean;
  52907. /** @hidden */
  52908. private _internalMarkAllSubMeshesAsTexturesDirty;
  52909. /** @hidden */
  52910. _markAllSubMeshesAsTexturesDirty(): void;
  52911. /**
  52912. * Instantiate a new istance of clear coat configuration.
  52913. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52914. */
  52915. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52916. /**
  52917. * Specifies that the submesh is ready to be used.
  52918. * @param defines the list of "defines" to update.
  52919. * @param scene defines the scene the material belongs to.
  52920. * @returns - boolean indicating that the submesh is ready or not.
  52921. */
  52922. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52923. /**
  52924. * Checks to see if a texture is used in the material.
  52925. * @param defines the list of "defines" to update.
  52926. * @param scene defines the scene the material belongs to.
  52927. */
  52928. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52929. /**
  52930. * Binds the material data.
  52931. * @param uniformBuffer defines the Uniform buffer to fill in.
  52932. * @param scene defines the scene the material belongs to.
  52933. * @param isFrozen defines wether the material is frozen or not.
  52934. */
  52935. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52936. /**
  52937. * Checks to see if a texture is used in the material.
  52938. * @param texture - Base texture to use.
  52939. * @returns - Boolean specifying if a texture is used in the material.
  52940. */
  52941. hasTexture(texture: BaseTexture): boolean;
  52942. /**
  52943. * Returns an array of the actively used textures.
  52944. * @param activeTextures Array of BaseTextures
  52945. */
  52946. getActiveTextures(activeTextures: BaseTexture[]): void;
  52947. /**
  52948. * Returns the animatable textures.
  52949. * @param animatables Array of animatable textures.
  52950. */
  52951. getAnimatables(animatables: IAnimatable[]): void;
  52952. /**
  52953. * Disposes the resources of the material.
  52954. * @param forceDisposeTextures - Forces the disposal of all textures.
  52955. */
  52956. dispose(forceDisposeTextures?: boolean): void;
  52957. /**
  52958. * Get the current class name of the texture useful for serialization or dynamic coding.
  52959. * @returns "PBRSheenConfiguration"
  52960. */
  52961. getClassName(): string;
  52962. /**
  52963. * Add fallbacks to the effect fallbacks list.
  52964. * @param defines defines the Base texture to use.
  52965. * @param fallbacks defines the current fallback list.
  52966. * @param currentRank defines the current fallback rank.
  52967. * @returns the new fallback rank.
  52968. */
  52969. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52970. /**
  52971. * Add the required uniforms to the current list.
  52972. * @param uniforms defines the current uniform list.
  52973. */
  52974. static AddUniforms(uniforms: string[]): void;
  52975. /**
  52976. * Add the required uniforms to the current buffer.
  52977. * @param uniformBuffer defines the current uniform buffer.
  52978. */
  52979. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52980. /**
  52981. * Add the required samplers to the current list.
  52982. * @param samplers defines the current sampler list.
  52983. */
  52984. static AddSamplers(samplers: string[]): void;
  52985. /**
  52986. * Makes a duplicate of the current configuration into another one.
  52987. * @param sheenConfiguration define the config where to copy the info
  52988. */
  52989. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52990. /**
  52991. * Serializes this BRDF configuration.
  52992. * @returns - An object with the serialized config.
  52993. */
  52994. serialize(): any;
  52995. /**
  52996. * Parses a anisotropy Configuration from a serialized object.
  52997. * @param source - Serialized object.
  52998. * @param scene Defines the scene we are parsing for
  52999. * @param rootUrl Defines the rootUrl to load from
  53000. */
  53001. parse(source: any, scene: Scene, rootUrl: string): void;
  53002. }
  53003. }
  53004. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53005. import { Nullable } from "babylonjs/types";
  53006. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53007. import { Color3 } from "babylonjs/Maths/math.color";
  53008. import { SmartArray } from "babylonjs/Misc/smartArray";
  53009. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53010. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53011. import { Effect } from "babylonjs/Materials/effect";
  53012. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53013. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53014. import { Engine } from "babylonjs/Engines/engine";
  53015. import { Scene } from "babylonjs/scene";
  53016. /**
  53017. * @hidden
  53018. */
  53019. export interface IMaterialSubSurfaceDefines {
  53020. SUBSURFACE: boolean;
  53021. SS_REFRACTION: boolean;
  53022. SS_TRANSLUCENCY: boolean;
  53023. SS_SCATERRING: boolean;
  53024. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53025. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53026. SS_REFRACTIONMAP_3D: boolean;
  53027. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53028. SS_LODINREFRACTIONALPHA: boolean;
  53029. SS_GAMMAREFRACTION: boolean;
  53030. SS_RGBDREFRACTION: boolean;
  53031. SS_LINEARSPECULARREFRACTION: boolean;
  53032. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53033. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53034. /** @hidden */
  53035. _areTexturesDirty: boolean;
  53036. }
  53037. /**
  53038. * Define the code related to the sub surface parameters of the pbr material.
  53039. */
  53040. export class PBRSubSurfaceConfiguration {
  53041. private _isRefractionEnabled;
  53042. /**
  53043. * Defines if the refraction is enabled in the material.
  53044. */
  53045. isRefractionEnabled: boolean;
  53046. private _isTranslucencyEnabled;
  53047. /**
  53048. * Defines if the translucency is enabled in the material.
  53049. */
  53050. isTranslucencyEnabled: boolean;
  53051. private _isScatteringEnabled;
  53052. /**
  53053. * Defines the refraction intensity of the material.
  53054. * The refraction when enabled replaces the Diffuse part of the material.
  53055. * The intensity helps transitionning between diffuse and refraction.
  53056. */
  53057. refractionIntensity: number;
  53058. /**
  53059. * Defines the translucency intensity of the material.
  53060. * When translucency has been enabled, this defines how much of the "translucency"
  53061. * is addded to the diffuse part of the material.
  53062. */
  53063. translucencyIntensity: number;
  53064. /**
  53065. * Defines the scattering intensity of the material.
  53066. * When scattering has been enabled, this defines how much of the "scattered light"
  53067. * is addded to the diffuse part of the material.
  53068. */
  53069. scatteringIntensity: number;
  53070. private _thicknessTexture;
  53071. /**
  53072. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53073. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53074. * 0 would mean minimumThickness
  53075. * 1 would mean maximumThickness
  53076. * The other channels might be use as a mask to vary the different effects intensity.
  53077. */
  53078. thicknessTexture: Nullable<BaseTexture>;
  53079. private _refractionTexture;
  53080. /**
  53081. * Defines the texture to use for refraction.
  53082. */
  53083. refractionTexture: Nullable<BaseTexture>;
  53084. private _indexOfRefraction;
  53085. /**
  53086. * Defines the index of refraction used in the material.
  53087. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53088. */
  53089. indexOfRefraction: number;
  53090. private _invertRefractionY;
  53091. /**
  53092. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53093. */
  53094. invertRefractionY: boolean;
  53095. private _linkRefractionWithTransparency;
  53096. /**
  53097. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53098. * Materials half opaque for instance using refraction could benefit from this control.
  53099. */
  53100. linkRefractionWithTransparency: boolean;
  53101. /**
  53102. * Defines the minimum thickness stored in the thickness map.
  53103. * If no thickness map is defined, this value will be used to simulate thickness.
  53104. */
  53105. minimumThickness: number;
  53106. /**
  53107. * Defines the maximum thickness stored in the thickness map.
  53108. */
  53109. maximumThickness: number;
  53110. /**
  53111. * Defines the volume tint of the material.
  53112. * This is used for both translucency and scattering.
  53113. */
  53114. tintColor: Color3;
  53115. /**
  53116. * Defines the distance at which the tint color should be found in the media.
  53117. * This is used for refraction only.
  53118. */
  53119. tintColorAtDistance: number;
  53120. /**
  53121. * Defines how far each channel transmit through the media.
  53122. * It is defined as a color to simplify it selection.
  53123. */
  53124. diffusionDistance: Color3;
  53125. private _useMaskFromThicknessTexture;
  53126. /**
  53127. * Stores the intensity of the different subsurface effects in the thickness texture.
  53128. * * the green channel is the translucency intensity.
  53129. * * the blue channel is the scattering intensity.
  53130. * * the alpha channel is the refraction intensity.
  53131. */
  53132. useMaskFromThicknessTexture: boolean;
  53133. /** @hidden */
  53134. private _internalMarkAllSubMeshesAsTexturesDirty;
  53135. /** @hidden */
  53136. _markAllSubMeshesAsTexturesDirty(): void;
  53137. /**
  53138. * Instantiate a new istance of sub surface configuration.
  53139. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53140. */
  53141. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53142. /**
  53143. * Gets wehter the submesh is ready to be used or not.
  53144. * @param defines the list of "defines" to update.
  53145. * @param scene defines the scene the material belongs to.
  53146. * @returns - boolean indicating that the submesh is ready or not.
  53147. */
  53148. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53149. /**
  53150. * Checks to see if a texture is used in the material.
  53151. * @param defines the list of "defines" to update.
  53152. * @param scene defines the scene to the material belongs to.
  53153. */
  53154. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53155. /**
  53156. * Binds the material data.
  53157. * @param uniformBuffer defines the Uniform buffer to fill in.
  53158. * @param scene defines the scene the material belongs to.
  53159. * @param engine defines the engine the material belongs to.
  53160. * @param isFrozen defines wether the material is frozen or not.
  53161. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53162. */
  53163. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53164. /**
  53165. * Unbinds the material from the mesh.
  53166. * @param activeEffect defines the effect that should be unbound from.
  53167. * @returns true if unbound, otherwise false
  53168. */
  53169. unbind(activeEffect: Effect): boolean;
  53170. /**
  53171. * Returns the texture used for refraction or null if none is used.
  53172. * @param scene defines the scene the material belongs to.
  53173. * @returns - Refraction texture if present. If no refraction texture and refraction
  53174. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53175. */
  53176. private _getRefractionTexture;
  53177. /**
  53178. * Returns true if alpha blending should be disabled.
  53179. */
  53180. get disableAlphaBlending(): boolean;
  53181. /**
  53182. * Fills the list of render target textures.
  53183. * @param renderTargets the list of render targets to update
  53184. */
  53185. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53186. /**
  53187. * Checks to see if a texture is used in the material.
  53188. * @param texture - Base texture to use.
  53189. * @returns - Boolean specifying if a texture is used in the material.
  53190. */
  53191. hasTexture(texture: BaseTexture): boolean;
  53192. /**
  53193. * Gets a boolean indicating that current material needs to register RTT
  53194. * @returns true if this uses a render target otherwise false.
  53195. */
  53196. hasRenderTargetTextures(): boolean;
  53197. /**
  53198. * Returns an array of the actively used textures.
  53199. * @param activeTextures Array of BaseTextures
  53200. */
  53201. getActiveTextures(activeTextures: BaseTexture[]): void;
  53202. /**
  53203. * Returns the animatable textures.
  53204. * @param animatables Array of animatable textures.
  53205. */
  53206. getAnimatables(animatables: IAnimatable[]): void;
  53207. /**
  53208. * Disposes the resources of the material.
  53209. * @param forceDisposeTextures - Forces the disposal of all textures.
  53210. */
  53211. dispose(forceDisposeTextures?: boolean): void;
  53212. /**
  53213. * Get the current class name of the texture useful for serialization or dynamic coding.
  53214. * @returns "PBRSubSurfaceConfiguration"
  53215. */
  53216. getClassName(): string;
  53217. /**
  53218. * Add fallbacks to the effect fallbacks list.
  53219. * @param defines defines the Base texture to use.
  53220. * @param fallbacks defines the current fallback list.
  53221. * @param currentRank defines the current fallback rank.
  53222. * @returns the new fallback rank.
  53223. */
  53224. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53225. /**
  53226. * Add the required uniforms to the current list.
  53227. * @param uniforms defines the current uniform list.
  53228. */
  53229. static AddUniforms(uniforms: string[]): void;
  53230. /**
  53231. * Add the required samplers to the current list.
  53232. * @param samplers defines the current sampler list.
  53233. */
  53234. static AddSamplers(samplers: string[]): void;
  53235. /**
  53236. * Add the required uniforms to the current buffer.
  53237. * @param uniformBuffer defines the current uniform buffer.
  53238. */
  53239. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53240. /**
  53241. * Makes a duplicate of the current configuration into another one.
  53242. * @param configuration define the config where to copy the info
  53243. */
  53244. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53245. /**
  53246. * Serializes this Sub Surface configuration.
  53247. * @returns - An object with the serialized config.
  53248. */
  53249. serialize(): any;
  53250. /**
  53251. * Parses a anisotropy Configuration from a serialized object.
  53252. * @param source - Serialized object.
  53253. * @param scene Defines the scene we are parsing for
  53254. * @param rootUrl Defines the rootUrl to load from
  53255. */
  53256. parse(source: any, scene: Scene, rootUrl: string): void;
  53257. }
  53258. }
  53259. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53260. /** @hidden */
  53261. export var pbrFragmentDeclaration: {
  53262. name: string;
  53263. shader: string;
  53264. };
  53265. }
  53266. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53267. /** @hidden */
  53268. export var pbrUboDeclaration: {
  53269. name: string;
  53270. shader: string;
  53271. };
  53272. }
  53273. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53274. /** @hidden */
  53275. export var pbrFragmentExtraDeclaration: {
  53276. name: string;
  53277. shader: string;
  53278. };
  53279. }
  53280. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53281. /** @hidden */
  53282. export var pbrFragmentSamplersDeclaration: {
  53283. name: string;
  53284. shader: string;
  53285. };
  53286. }
  53287. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53288. /** @hidden */
  53289. export var pbrHelperFunctions: {
  53290. name: string;
  53291. shader: string;
  53292. };
  53293. }
  53294. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53295. /** @hidden */
  53296. export var harmonicsFunctions: {
  53297. name: string;
  53298. shader: string;
  53299. };
  53300. }
  53301. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53302. /** @hidden */
  53303. export var pbrDirectLightingSetupFunctions: {
  53304. name: string;
  53305. shader: string;
  53306. };
  53307. }
  53308. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53309. /** @hidden */
  53310. export var pbrDirectLightingFalloffFunctions: {
  53311. name: string;
  53312. shader: string;
  53313. };
  53314. }
  53315. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53316. /** @hidden */
  53317. export var pbrBRDFFunctions: {
  53318. name: string;
  53319. shader: string;
  53320. };
  53321. }
  53322. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53323. /** @hidden */
  53324. export var pbrDirectLightingFunctions: {
  53325. name: string;
  53326. shader: string;
  53327. };
  53328. }
  53329. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53330. /** @hidden */
  53331. export var pbrIBLFunctions: {
  53332. name: string;
  53333. shader: string;
  53334. };
  53335. }
  53336. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53337. /** @hidden */
  53338. export var pbrDebug: {
  53339. name: string;
  53340. shader: string;
  53341. };
  53342. }
  53343. declare module "babylonjs/Shaders/pbr.fragment" {
  53344. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53345. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53346. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53347. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53348. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53349. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53350. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53351. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53352. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53353. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53354. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53355. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53356. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53357. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53358. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53359. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53360. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53361. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53362. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53363. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53364. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53365. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53366. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53367. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53368. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53369. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53370. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53371. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53372. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53373. /** @hidden */
  53374. export var pbrPixelShader: {
  53375. name: string;
  53376. shader: string;
  53377. };
  53378. }
  53379. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53380. /** @hidden */
  53381. export var pbrVertexDeclaration: {
  53382. name: string;
  53383. shader: string;
  53384. };
  53385. }
  53386. declare module "babylonjs/Shaders/pbr.vertex" {
  53387. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53388. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53389. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53390. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53391. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53392. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53393. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53394. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53395. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53396. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53397. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53399. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53400. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53402. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53403. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53404. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53405. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53406. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53407. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53408. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53409. /** @hidden */
  53410. export var pbrVertexShader: {
  53411. name: string;
  53412. shader: string;
  53413. };
  53414. }
  53415. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53416. import { Nullable } from "babylonjs/types";
  53417. import { Scene } from "babylonjs/scene";
  53418. import { Matrix } from "babylonjs/Maths/math.vector";
  53419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53421. import { Mesh } from "babylonjs/Meshes/mesh";
  53422. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53423. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53424. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53425. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53426. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53427. import { Color3 } from "babylonjs/Maths/math.color";
  53428. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53429. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53430. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53431. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53433. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53434. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53435. import "babylonjs/Shaders/pbr.fragment";
  53436. import "babylonjs/Shaders/pbr.vertex";
  53437. /**
  53438. * Manages the defines for the PBR Material.
  53439. * @hidden
  53440. */
  53441. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53442. PBR: boolean;
  53443. MAINUV1: boolean;
  53444. MAINUV2: boolean;
  53445. UV1: boolean;
  53446. UV2: boolean;
  53447. ALBEDO: boolean;
  53448. GAMMAALBEDO: boolean;
  53449. ALBEDODIRECTUV: number;
  53450. VERTEXCOLOR: boolean;
  53451. AMBIENT: boolean;
  53452. AMBIENTDIRECTUV: number;
  53453. AMBIENTINGRAYSCALE: boolean;
  53454. OPACITY: boolean;
  53455. VERTEXALPHA: boolean;
  53456. OPACITYDIRECTUV: number;
  53457. OPACITYRGB: boolean;
  53458. ALPHATEST: boolean;
  53459. DEPTHPREPASS: boolean;
  53460. ALPHABLEND: boolean;
  53461. ALPHAFROMALBEDO: boolean;
  53462. ALPHATESTVALUE: string;
  53463. SPECULAROVERALPHA: boolean;
  53464. RADIANCEOVERALPHA: boolean;
  53465. ALPHAFRESNEL: boolean;
  53466. LINEARALPHAFRESNEL: boolean;
  53467. PREMULTIPLYALPHA: boolean;
  53468. EMISSIVE: boolean;
  53469. EMISSIVEDIRECTUV: number;
  53470. REFLECTIVITY: boolean;
  53471. REFLECTIVITYDIRECTUV: number;
  53472. SPECULARTERM: boolean;
  53473. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53474. MICROSURFACEAUTOMATIC: boolean;
  53475. LODBASEDMICROSFURACE: boolean;
  53476. MICROSURFACEMAP: boolean;
  53477. MICROSURFACEMAPDIRECTUV: number;
  53478. METALLICWORKFLOW: boolean;
  53479. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53480. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53481. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53482. AOSTOREINMETALMAPRED: boolean;
  53483. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53484. ENVIRONMENTBRDF: boolean;
  53485. ENVIRONMENTBRDF_RGBD: boolean;
  53486. NORMAL: boolean;
  53487. TANGENT: boolean;
  53488. BUMP: boolean;
  53489. BUMPDIRECTUV: number;
  53490. OBJECTSPACE_NORMALMAP: boolean;
  53491. PARALLAX: boolean;
  53492. PARALLAXOCCLUSION: boolean;
  53493. NORMALXYSCALE: boolean;
  53494. LIGHTMAP: boolean;
  53495. LIGHTMAPDIRECTUV: number;
  53496. USELIGHTMAPASSHADOWMAP: boolean;
  53497. GAMMALIGHTMAP: boolean;
  53498. RGBDLIGHTMAP: boolean;
  53499. REFLECTION: boolean;
  53500. REFLECTIONMAP_3D: boolean;
  53501. REFLECTIONMAP_SPHERICAL: boolean;
  53502. REFLECTIONMAP_PLANAR: boolean;
  53503. REFLECTIONMAP_CUBIC: boolean;
  53504. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53505. REFLECTIONMAP_PROJECTION: boolean;
  53506. REFLECTIONMAP_SKYBOX: boolean;
  53507. REFLECTIONMAP_EXPLICIT: boolean;
  53508. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53509. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53510. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53511. INVERTCUBICMAP: boolean;
  53512. USESPHERICALFROMREFLECTIONMAP: boolean;
  53513. USEIRRADIANCEMAP: boolean;
  53514. SPHERICAL_HARMONICS: boolean;
  53515. USESPHERICALINVERTEX: boolean;
  53516. REFLECTIONMAP_OPPOSITEZ: boolean;
  53517. LODINREFLECTIONALPHA: boolean;
  53518. GAMMAREFLECTION: boolean;
  53519. RGBDREFLECTION: boolean;
  53520. LINEARSPECULARREFLECTION: boolean;
  53521. RADIANCEOCCLUSION: boolean;
  53522. HORIZONOCCLUSION: boolean;
  53523. INSTANCES: boolean;
  53524. NUM_BONE_INFLUENCERS: number;
  53525. BonesPerMesh: number;
  53526. BONETEXTURE: boolean;
  53527. NONUNIFORMSCALING: boolean;
  53528. MORPHTARGETS: boolean;
  53529. MORPHTARGETS_NORMAL: boolean;
  53530. MORPHTARGETS_TANGENT: boolean;
  53531. MORPHTARGETS_UV: boolean;
  53532. NUM_MORPH_INFLUENCERS: number;
  53533. IMAGEPROCESSING: boolean;
  53534. VIGNETTE: boolean;
  53535. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53536. VIGNETTEBLENDMODEOPAQUE: boolean;
  53537. TONEMAPPING: boolean;
  53538. TONEMAPPING_ACES: boolean;
  53539. CONTRAST: boolean;
  53540. COLORCURVES: boolean;
  53541. COLORGRADING: boolean;
  53542. COLORGRADING3D: boolean;
  53543. SAMPLER3DGREENDEPTH: boolean;
  53544. SAMPLER3DBGRMAP: boolean;
  53545. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53546. EXPOSURE: boolean;
  53547. MULTIVIEW: boolean;
  53548. USEPHYSICALLIGHTFALLOFF: boolean;
  53549. USEGLTFLIGHTFALLOFF: boolean;
  53550. TWOSIDEDLIGHTING: boolean;
  53551. SHADOWFLOAT: boolean;
  53552. CLIPPLANE: boolean;
  53553. CLIPPLANE2: boolean;
  53554. CLIPPLANE3: boolean;
  53555. CLIPPLANE4: boolean;
  53556. CLIPPLANE5: boolean;
  53557. CLIPPLANE6: boolean;
  53558. POINTSIZE: boolean;
  53559. FOG: boolean;
  53560. LOGARITHMICDEPTH: boolean;
  53561. FORCENORMALFORWARD: boolean;
  53562. SPECULARAA: boolean;
  53563. CLEARCOAT: boolean;
  53564. CLEARCOAT_DEFAULTIOR: boolean;
  53565. CLEARCOAT_TEXTURE: boolean;
  53566. CLEARCOAT_TEXTUREDIRECTUV: number;
  53567. CLEARCOAT_BUMP: boolean;
  53568. CLEARCOAT_BUMPDIRECTUV: number;
  53569. CLEARCOAT_TINT: boolean;
  53570. CLEARCOAT_TINT_TEXTURE: boolean;
  53571. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53572. ANISOTROPIC: boolean;
  53573. ANISOTROPIC_TEXTURE: boolean;
  53574. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53575. BRDF_V_HEIGHT_CORRELATED: boolean;
  53576. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53577. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53578. SHEEN: boolean;
  53579. SHEEN_TEXTURE: boolean;
  53580. SHEEN_TEXTUREDIRECTUV: number;
  53581. SHEEN_LINKWITHALBEDO: boolean;
  53582. SHEEN_ROUGHNESS: boolean;
  53583. SHEEN_ALBEDOSCALING: boolean;
  53584. SUBSURFACE: boolean;
  53585. SS_REFRACTION: boolean;
  53586. SS_TRANSLUCENCY: boolean;
  53587. SS_SCATERRING: boolean;
  53588. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53589. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53590. SS_REFRACTIONMAP_3D: boolean;
  53591. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53592. SS_LODINREFRACTIONALPHA: boolean;
  53593. SS_GAMMAREFRACTION: boolean;
  53594. SS_RGBDREFRACTION: boolean;
  53595. SS_LINEARSPECULARREFRACTION: boolean;
  53596. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53597. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53598. UNLIT: boolean;
  53599. DEBUGMODE: number;
  53600. /**
  53601. * Initializes the PBR Material defines.
  53602. */
  53603. constructor();
  53604. /**
  53605. * Resets the PBR Material defines.
  53606. */
  53607. reset(): void;
  53608. }
  53609. /**
  53610. * The Physically based material base class of BJS.
  53611. *
  53612. * This offers the main features of a standard PBR material.
  53613. * For more information, please refer to the documentation :
  53614. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53615. */
  53616. export abstract class PBRBaseMaterial extends PushMaterial {
  53617. /**
  53618. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53619. */
  53620. static readonly PBRMATERIAL_OPAQUE: number;
  53621. /**
  53622. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53623. */
  53624. static readonly PBRMATERIAL_ALPHATEST: number;
  53625. /**
  53626. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53627. */
  53628. static readonly PBRMATERIAL_ALPHABLEND: number;
  53629. /**
  53630. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53631. * They are also discarded below the alpha cutoff threshold to improve performances.
  53632. */
  53633. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53634. /**
  53635. * Defines the default value of how much AO map is occluding the analytical lights
  53636. * (point spot...).
  53637. */
  53638. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53639. /**
  53640. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53641. */
  53642. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53643. /**
  53644. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53645. * to enhance interoperability with other engines.
  53646. */
  53647. static readonly LIGHTFALLOFF_GLTF: number;
  53648. /**
  53649. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53650. * to enhance interoperability with other materials.
  53651. */
  53652. static readonly LIGHTFALLOFF_STANDARD: number;
  53653. /**
  53654. * Intensity of the direct lights e.g. the four lights available in your scene.
  53655. * This impacts both the direct diffuse and specular highlights.
  53656. */
  53657. protected _directIntensity: number;
  53658. /**
  53659. * Intensity of the emissive part of the material.
  53660. * This helps controlling the emissive effect without modifying the emissive color.
  53661. */
  53662. protected _emissiveIntensity: number;
  53663. /**
  53664. * Intensity of the environment e.g. how much the environment will light the object
  53665. * either through harmonics for rough material or through the refelction for shiny ones.
  53666. */
  53667. protected _environmentIntensity: number;
  53668. /**
  53669. * This is a special control allowing the reduction of the specular highlights coming from the
  53670. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53671. */
  53672. protected _specularIntensity: number;
  53673. /**
  53674. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53675. */
  53676. private _lightingInfos;
  53677. /**
  53678. * Debug Control allowing disabling the bump map on this material.
  53679. */
  53680. protected _disableBumpMap: boolean;
  53681. /**
  53682. * AKA Diffuse Texture in standard nomenclature.
  53683. */
  53684. protected _albedoTexture: Nullable<BaseTexture>;
  53685. /**
  53686. * AKA Occlusion Texture in other nomenclature.
  53687. */
  53688. protected _ambientTexture: Nullable<BaseTexture>;
  53689. /**
  53690. * AKA Occlusion Texture Intensity in other nomenclature.
  53691. */
  53692. protected _ambientTextureStrength: number;
  53693. /**
  53694. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53695. * 1 means it completely occludes it
  53696. * 0 mean it has no impact
  53697. */
  53698. protected _ambientTextureImpactOnAnalyticalLights: number;
  53699. /**
  53700. * Stores the alpha values in a texture.
  53701. */
  53702. protected _opacityTexture: Nullable<BaseTexture>;
  53703. /**
  53704. * Stores the reflection values in a texture.
  53705. */
  53706. protected _reflectionTexture: Nullable<BaseTexture>;
  53707. /**
  53708. * Stores the emissive values in a texture.
  53709. */
  53710. protected _emissiveTexture: Nullable<BaseTexture>;
  53711. /**
  53712. * AKA Specular texture in other nomenclature.
  53713. */
  53714. protected _reflectivityTexture: Nullable<BaseTexture>;
  53715. /**
  53716. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53717. */
  53718. protected _metallicTexture: Nullable<BaseTexture>;
  53719. /**
  53720. * Specifies the metallic scalar of the metallic/roughness workflow.
  53721. * Can also be used to scale the metalness values of the metallic texture.
  53722. */
  53723. protected _metallic: Nullable<number>;
  53724. /**
  53725. * Specifies the roughness scalar of the metallic/roughness workflow.
  53726. * Can also be used to scale the roughness values of the metallic texture.
  53727. */
  53728. protected _roughness: Nullable<number>;
  53729. /**
  53730. * Specifies the an F0 factor to help configuring the material F0.
  53731. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53732. * to 0.5 the previously hard coded value stays the same.
  53733. * Can also be used to scale the F0 values of the metallic texture.
  53734. */
  53735. protected _metallicF0Factor: number;
  53736. /**
  53737. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53738. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53739. * your expectation as it multiplies with the texture data.
  53740. */
  53741. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53742. /**
  53743. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53744. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53745. */
  53746. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53747. /**
  53748. * Stores surface normal data used to displace a mesh in a texture.
  53749. */
  53750. protected _bumpTexture: Nullable<BaseTexture>;
  53751. /**
  53752. * Stores the pre-calculated light information of a mesh in a texture.
  53753. */
  53754. protected _lightmapTexture: Nullable<BaseTexture>;
  53755. /**
  53756. * The color of a material in ambient lighting.
  53757. */
  53758. protected _ambientColor: Color3;
  53759. /**
  53760. * AKA Diffuse Color in other nomenclature.
  53761. */
  53762. protected _albedoColor: Color3;
  53763. /**
  53764. * AKA Specular Color in other nomenclature.
  53765. */
  53766. protected _reflectivityColor: Color3;
  53767. /**
  53768. * The color applied when light is reflected from a material.
  53769. */
  53770. protected _reflectionColor: Color3;
  53771. /**
  53772. * The color applied when light is emitted from a material.
  53773. */
  53774. protected _emissiveColor: Color3;
  53775. /**
  53776. * AKA Glossiness in other nomenclature.
  53777. */
  53778. protected _microSurface: number;
  53779. /**
  53780. * Specifies that the material will use the light map as a show map.
  53781. */
  53782. protected _useLightmapAsShadowmap: boolean;
  53783. /**
  53784. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53785. * makes the reflect vector face the model (under horizon).
  53786. */
  53787. protected _useHorizonOcclusion: boolean;
  53788. /**
  53789. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53790. * too much the area relying on ambient texture to define their ambient occlusion.
  53791. */
  53792. protected _useRadianceOcclusion: boolean;
  53793. /**
  53794. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53795. */
  53796. protected _useAlphaFromAlbedoTexture: boolean;
  53797. /**
  53798. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53799. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53800. */
  53801. protected _useSpecularOverAlpha: boolean;
  53802. /**
  53803. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53804. */
  53805. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53806. /**
  53807. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53808. */
  53809. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53810. /**
  53811. * Specifies if the metallic texture contains the roughness information in its green channel.
  53812. */
  53813. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53814. /**
  53815. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53816. */
  53817. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53818. /**
  53819. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53820. */
  53821. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53822. /**
  53823. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53824. */
  53825. protected _useAmbientInGrayScale: boolean;
  53826. /**
  53827. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53828. * The material will try to infer what glossiness each pixel should be.
  53829. */
  53830. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53831. /**
  53832. * Defines the falloff type used in this material.
  53833. * It by default is Physical.
  53834. */
  53835. protected _lightFalloff: number;
  53836. /**
  53837. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53838. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53839. */
  53840. protected _useRadianceOverAlpha: boolean;
  53841. /**
  53842. * Allows using an object space normal map (instead of tangent space).
  53843. */
  53844. protected _useObjectSpaceNormalMap: boolean;
  53845. /**
  53846. * Allows using the bump map in parallax mode.
  53847. */
  53848. protected _useParallax: boolean;
  53849. /**
  53850. * Allows using the bump map in parallax occlusion mode.
  53851. */
  53852. protected _useParallaxOcclusion: boolean;
  53853. /**
  53854. * Controls the scale bias of the parallax mode.
  53855. */
  53856. protected _parallaxScaleBias: number;
  53857. /**
  53858. * If sets to true, disables all the lights affecting the material.
  53859. */
  53860. protected _disableLighting: boolean;
  53861. /**
  53862. * Number of Simultaneous lights allowed on the material.
  53863. */
  53864. protected _maxSimultaneousLights: number;
  53865. /**
  53866. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53867. */
  53868. protected _invertNormalMapX: boolean;
  53869. /**
  53870. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53871. */
  53872. protected _invertNormalMapY: boolean;
  53873. /**
  53874. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53875. */
  53876. protected _twoSidedLighting: boolean;
  53877. /**
  53878. * Defines the alpha limits in alpha test mode.
  53879. */
  53880. protected _alphaCutOff: number;
  53881. /**
  53882. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53883. */
  53884. protected _forceAlphaTest: boolean;
  53885. /**
  53886. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53887. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53888. */
  53889. protected _useAlphaFresnel: boolean;
  53890. /**
  53891. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53892. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53893. */
  53894. protected _useLinearAlphaFresnel: boolean;
  53895. /**
  53896. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53897. * from cos thetav and roughness:
  53898. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53899. */
  53900. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53901. /**
  53902. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53903. */
  53904. protected _forceIrradianceInFragment: boolean;
  53905. /**
  53906. * Force normal to face away from face.
  53907. */
  53908. protected _forceNormalForward: boolean;
  53909. /**
  53910. * Enables specular anti aliasing in the PBR shader.
  53911. * It will both interacts on the Geometry for analytical and IBL lighting.
  53912. * It also prefilter the roughness map based on the bump values.
  53913. */
  53914. protected _enableSpecularAntiAliasing: boolean;
  53915. /**
  53916. * Default configuration related to image processing available in the PBR Material.
  53917. */
  53918. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53919. /**
  53920. * Keep track of the image processing observer to allow dispose and replace.
  53921. */
  53922. private _imageProcessingObserver;
  53923. /**
  53924. * Attaches a new image processing configuration to the PBR Material.
  53925. * @param configuration
  53926. */
  53927. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53928. /**
  53929. * Stores the available render targets.
  53930. */
  53931. private _renderTargets;
  53932. /**
  53933. * Sets the global ambient color for the material used in lighting calculations.
  53934. */
  53935. private _globalAmbientColor;
  53936. /**
  53937. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53938. */
  53939. private _useLogarithmicDepth;
  53940. /**
  53941. * If set to true, no lighting calculations will be applied.
  53942. */
  53943. private _unlit;
  53944. private _debugMode;
  53945. /**
  53946. * @hidden
  53947. * This is reserved for the inspector.
  53948. * Defines the material debug mode.
  53949. * It helps seeing only some components of the material while troubleshooting.
  53950. */
  53951. debugMode: number;
  53952. /**
  53953. * @hidden
  53954. * This is reserved for the inspector.
  53955. * Specify from where on screen the debug mode should start.
  53956. * The value goes from -1 (full screen) to 1 (not visible)
  53957. * It helps with side by side comparison against the final render
  53958. * This defaults to -1
  53959. */
  53960. private debugLimit;
  53961. /**
  53962. * @hidden
  53963. * This is reserved for the inspector.
  53964. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53965. * You can use the factor to better multiply the final value.
  53966. */
  53967. private debugFactor;
  53968. /**
  53969. * Defines the clear coat layer parameters for the material.
  53970. */
  53971. readonly clearCoat: PBRClearCoatConfiguration;
  53972. /**
  53973. * Defines the anisotropic parameters for the material.
  53974. */
  53975. readonly anisotropy: PBRAnisotropicConfiguration;
  53976. /**
  53977. * Defines the BRDF parameters for the material.
  53978. */
  53979. readonly brdf: PBRBRDFConfiguration;
  53980. /**
  53981. * Defines the Sheen parameters for the material.
  53982. */
  53983. readonly sheen: PBRSheenConfiguration;
  53984. /**
  53985. * Defines the SubSurface parameters for the material.
  53986. */
  53987. readonly subSurface: PBRSubSurfaceConfiguration;
  53988. /**
  53989. * Custom callback helping to override the default shader used in the material.
  53990. */
  53991. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  53992. protected _rebuildInParallel: boolean;
  53993. /**
  53994. * Instantiates a new PBRMaterial instance.
  53995. *
  53996. * @param name The material name
  53997. * @param scene The scene the material will be use in.
  53998. */
  53999. constructor(name: string, scene: Scene);
  54000. /**
  54001. * Gets a boolean indicating that current material needs to register RTT
  54002. */
  54003. get hasRenderTargetTextures(): boolean;
  54004. /**
  54005. * Gets the name of the material class.
  54006. */
  54007. getClassName(): string;
  54008. /**
  54009. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54010. */
  54011. get useLogarithmicDepth(): boolean;
  54012. /**
  54013. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54014. */
  54015. set useLogarithmicDepth(value: boolean);
  54016. /**
  54017. * Returns true if alpha blending should be disabled.
  54018. */
  54019. protected get _disableAlphaBlending(): boolean;
  54020. /**
  54021. * Specifies whether or not this material should be rendered in alpha blend mode.
  54022. */
  54023. needAlphaBlending(): boolean;
  54024. /**
  54025. * Specifies whether or not this material should be rendered in alpha test mode.
  54026. */
  54027. needAlphaTesting(): boolean;
  54028. /**
  54029. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54030. */
  54031. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54032. /**
  54033. * Gets the texture used for the alpha test.
  54034. */
  54035. getAlphaTestTexture(): Nullable<BaseTexture>;
  54036. /**
  54037. * Specifies that the submesh is ready to be used.
  54038. * @param mesh - BJS mesh.
  54039. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54040. * @param useInstances - Specifies that instances should be used.
  54041. * @returns - boolean indicating that the submesh is ready or not.
  54042. */
  54043. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54044. /**
  54045. * Specifies if the material uses metallic roughness workflow.
  54046. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54047. */
  54048. isMetallicWorkflow(): boolean;
  54049. private _prepareEffect;
  54050. private _prepareDefines;
  54051. /**
  54052. * Force shader compilation
  54053. */
  54054. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54055. /**
  54056. * Initializes the uniform buffer layout for the shader.
  54057. */
  54058. buildUniformLayout(): void;
  54059. /**
  54060. * Unbinds the material from the mesh
  54061. */
  54062. unbind(): void;
  54063. /**
  54064. * Binds the submesh data.
  54065. * @param world - The world matrix.
  54066. * @param mesh - The BJS mesh.
  54067. * @param subMesh - A submesh of the BJS mesh.
  54068. */
  54069. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54070. /**
  54071. * Returns the animatable textures.
  54072. * @returns - Array of animatable textures.
  54073. */
  54074. getAnimatables(): IAnimatable[];
  54075. /**
  54076. * Returns the texture used for reflections.
  54077. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54078. */
  54079. private _getReflectionTexture;
  54080. /**
  54081. * Returns an array of the actively used textures.
  54082. * @returns - Array of BaseTextures
  54083. */
  54084. getActiveTextures(): BaseTexture[];
  54085. /**
  54086. * Checks to see if a texture is used in the material.
  54087. * @param texture - Base texture to use.
  54088. * @returns - Boolean specifying if a texture is used in the material.
  54089. */
  54090. hasTexture(texture: BaseTexture): boolean;
  54091. /**
  54092. * Disposes the resources of the material.
  54093. * @param forceDisposeEffect - Forces the disposal of effects.
  54094. * @param forceDisposeTextures - Forces the disposal of all textures.
  54095. */
  54096. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54097. }
  54098. }
  54099. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54100. import { Nullable } from "babylonjs/types";
  54101. import { Scene } from "babylonjs/scene";
  54102. import { Color3 } from "babylonjs/Maths/math.color";
  54103. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54104. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54106. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54107. /**
  54108. * The Physically based material of BJS.
  54109. *
  54110. * This offers the main features of a standard PBR material.
  54111. * For more information, please refer to the documentation :
  54112. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54113. */
  54114. export class PBRMaterial extends PBRBaseMaterial {
  54115. /**
  54116. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54117. */
  54118. static readonly PBRMATERIAL_OPAQUE: number;
  54119. /**
  54120. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54121. */
  54122. static readonly PBRMATERIAL_ALPHATEST: number;
  54123. /**
  54124. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54125. */
  54126. static readonly PBRMATERIAL_ALPHABLEND: number;
  54127. /**
  54128. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54129. * They are also discarded below the alpha cutoff threshold to improve performances.
  54130. */
  54131. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54132. /**
  54133. * Defines the default value of how much AO map is occluding the analytical lights
  54134. * (point spot...).
  54135. */
  54136. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54137. /**
  54138. * Intensity of the direct lights e.g. the four lights available in your scene.
  54139. * This impacts both the direct diffuse and specular highlights.
  54140. */
  54141. directIntensity: number;
  54142. /**
  54143. * Intensity of the emissive part of the material.
  54144. * This helps controlling the emissive effect without modifying the emissive color.
  54145. */
  54146. emissiveIntensity: number;
  54147. /**
  54148. * Intensity of the environment e.g. how much the environment will light the object
  54149. * either through harmonics for rough material or through the refelction for shiny ones.
  54150. */
  54151. environmentIntensity: number;
  54152. /**
  54153. * This is a special control allowing the reduction of the specular highlights coming from the
  54154. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54155. */
  54156. specularIntensity: number;
  54157. /**
  54158. * Debug Control allowing disabling the bump map on this material.
  54159. */
  54160. disableBumpMap: boolean;
  54161. /**
  54162. * AKA Diffuse Texture in standard nomenclature.
  54163. */
  54164. albedoTexture: BaseTexture;
  54165. /**
  54166. * AKA Occlusion Texture in other nomenclature.
  54167. */
  54168. ambientTexture: BaseTexture;
  54169. /**
  54170. * AKA Occlusion Texture Intensity in other nomenclature.
  54171. */
  54172. ambientTextureStrength: number;
  54173. /**
  54174. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54175. * 1 means it completely occludes it
  54176. * 0 mean it has no impact
  54177. */
  54178. ambientTextureImpactOnAnalyticalLights: number;
  54179. /**
  54180. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54181. */
  54182. opacityTexture: BaseTexture;
  54183. /**
  54184. * Stores the reflection values in a texture.
  54185. */
  54186. reflectionTexture: Nullable<BaseTexture>;
  54187. /**
  54188. * Stores the emissive values in a texture.
  54189. */
  54190. emissiveTexture: BaseTexture;
  54191. /**
  54192. * AKA Specular texture in other nomenclature.
  54193. */
  54194. reflectivityTexture: BaseTexture;
  54195. /**
  54196. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54197. */
  54198. metallicTexture: BaseTexture;
  54199. /**
  54200. * Specifies the metallic scalar of the metallic/roughness workflow.
  54201. * Can also be used to scale the metalness values of the metallic texture.
  54202. */
  54203. metallic: Nullable<number>;
  54204. /**
  54205. * Specifies the roughness scalar of the metallic/roughness workflow.
  54206. * Can also be used to scale the roughness values of the metallic texture.
  54207. */
  54208. roughness: Nullable<number>;
  54209. /**
  54210. * Specifies the an F0 factor to help configuring the material F0.
  54211. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54212. * to 0.5 the previously hard coded value stays the same.
  54213. * Can also be used to scale the F0 values of the metallic texture.
  54214. */
  54215. metallicF0Factor: number;
  54216. /**
  54217. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54218. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54219. * your expectation as it multiplies with the texture data.
  54220. */
  54221. useMetallicF0FactorFromMetallicTexture: boolean;
  54222. /**
  54223. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54224. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54225. */
  54226. microSurfaceTexture: BaseTexture;
  54227. /**
  54228. * Stores surface normal data used to displace a mesh in a texture.
  54229. */
  54230. bumpTexture: BaseTexture;
  54231. /**
  54232. * Stores the pre-calculated light information of a mesh in a texture.
  54233. */
  54234. lightmapTexture: BaseTexture;
  54235. /**
  54236. * Stores the refracted light information in a texture.
  54237. */
  54238. get refractionTexture(): Nullable<BaseTexture>;
  54239. set refractionTexture(value: Nullable<BaseTexture>);
  54240. /**
  54241. * The color of a material in ambient lighting.
  54242. */
  54243. ambientColor: Color3;
  54244. /**
  54245. * AKA Diffuse Color in other nomenclature.
  54246. */
  54247. albedoColor: Color3;
  54248. /**
  54249. * AKA Specular Color in other nomenclature.
  54250. */
  54251. reflectivityColor: Color3;
  54252. /**
  54253. * The color reflected from the material.
  54254. */
  54255. reflectionColor: Color3;
  54256. /**
  54257. * The color emitted from the material.
  54258. */
  54259. emissiveColor: Color3;
  54260. /**
  54261. * AKA Glossiness in other nomenclature.
  54262. */
  54263. microSurface: number;
  54264. /**
  54265. * source material index of refraction (IOR)' / 'destination material IOR.
  54266. */
  54267. get indexOfRefraction(): number;
  54268. set indexOfRefraction(value: number);
  54269. /**
  54270. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54271. */
  54272. get invertRefractionY(): boolean;
  54273. set invertRefractionY(value: boolean);
  54274. /**
  54275. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54276. * Materials half opaque for instance using refraction could benefit from this control.
  54277. */
  54278. get linkRefractionWithTransparency(): boolean;
  54279. set linkRefractionWithTransparency(value: boolean);
  54280. /**
  54281. * If true, the light map contains occlusion information instead of lighting info.
  54282. */
  54283. useLightmapAsShadowmap: boolean;
  54284. /**
  54285. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54286. */
  54287. useAlphaFromAlbedoTexture: boolean;
  54288. /**
  54289. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54290. */
  54291. forceAlphaTest: boolean;
  54292. /**
  54293. * Defines the alpha limits in alpha test mode.
  54294. */
  54295. alphaCutOff: number;
  54296. /**
  54297. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54298. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54299. */
  54300. useSpecularOverAlpha: boolean;
  54301. /**
  54302. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54303. */
  54304. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54305. /**
  54306. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54307. */
  54308. useRoughnessFromMetallicTextureAlpha: boolean;
  54309. /**
  54310. * Specifies if the metallic texture contains the roughness information in its green channel.
  54311. */
  54312. useRoughnessFromMetallicTextureGreen: boolean;
  54313. /**
  54314. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54315. */
  54316. useMetallnessFromMetallicTextureBlue: boolean;
  54317. /**
  54318. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54319. */
  54320. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54321. /**
  54322. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54323. */
  54324. useAmbientInGrayScale: boolean;
  54325. /**
  54326. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54327. * The material will try to infer what glossiness each pixel should be.
  54328. */
  54329. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54330. /**
  54331. * BJS is using an harcoded light falloff based on a manually sets up range.
  54332. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54333. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54334. */
  54335. get usePhysicalLightFalloff(): boolean;
  54336. /**
  54337. * BJS is using an harcoded light falloff based on a manually sets up range.
  54338. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54339. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54340. */
  54341. set usePhysicalLightFalloff(value: boolean);
  54342. /**
  54343. * In order to support the falloff compatibility with gltf, a special mode has been added
  54344. * to reproduce the gltf light falloff.
  54345. */
  54346. get useGLTFLightFalloff(): boolean;
  54347. /**
  54348. * In order to support the falloff compatibility with gltf, a special mode has been added
  54349. * to reproduce the gltf light falloff.
  54350. */
  54351. set useGLTFLightFalloff(value: boolean);
  54352. /**
  54353. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54354. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54355. */
  54356. useRadianceOverAlpha: boolean;
  54357. /**
  54358. * Allows using an object space normal map (instead of tangent space).
  54359. */
  54360. useObjectSpaceNormalMap: boolean;
  54361. /**
  54362. * Allows using the bump map in parallax mode.
  54363. */
  54364. useParallax: boolean;
  54365. /**
  54366. * Allows using the bump map in parallax occlusion mode.
  54367. */
  54368. useParallaxOcclusion: boolean;
  54369. /**
  54370. * Controls the scale bias of the parallax mode.
  54371. */
  54372. parallaxScaleBias: number;
  54373. /**
  54374. * If sets to true, disables all the lights affecting the material.
  54375. */
  54376. disableLighting: boolean;
  54377. /**
  54378. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54379. */
  54380. forceIrradianceInFragment: boolean;
  54381. /**
  54382. * Number of Simultaneous lights allowed on the material.
  54383. */
  54384. maxSimultaneousLights: number;
  54385. /**
  54386. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54387. */
  54388. invertNormalMapX: boolean;
  54389. /**
  54390. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54391. */
  54392. invertNormalMapY: boolean;
  54393. /**
  54394. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54395. */
  54396. twoSidedLighting: boolean;
  54397. /**
  54398. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54399. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54400. */
  54401. useAlphaFresnel: boolean;
  54402. /**
  54403. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54404. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54405. */
  54406. useLinearAlphaFresnel: boolean;
  54407. /**
  54408. * Let user defines the brdf lookup texture used for IBL.
  54409. * A default 8bit version is embedded but you could point at :
  54410. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54411. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54412. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54413. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54414. */
  54415. environmentBRDFTexture: Nullable<BaseTexture>;
  54416. /**
  54417. * Force normal to face away from face.
  54418. */
  54419. forceNormalForward: boolean;
  54420. /**
  54421. * Enables specular anti aliasing in the PBR shader.
  54422. * It will both interacts on the Geometry for analytical and IBL lighting.
  54423. * It also prefilter the roughness map based on the bump values.
  54424. */
  54425. enableSpecularAntiAliasing: boolean;
  54426. /**
  54427. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54428. * makes the reflect vector face the model (under horizon).
  54429. */
  54430. useHorizonOcclusion: boolean;
  54431. /**
  54432. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54433. * too much the area relying on ambient texture to define their ambient occlusion.
  54434. */
  54435. useRadianceOcclusion: boolean;
  54436. /**
  54437. * If set to true, no lighting calculations will be applied.
  54438. */
  54439. unlit: boolean;
  54440. /**
  54441. * Gets the image processing configuration used either in this material.
  54442. */
  54443. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54444. /**
  54445. * Sets the Default image processing configuration used either in the this material.
  54446. *
  54447. * If sets to null, the scene one is in use.
  54448. */
  54449. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54450. /**
  54451. * Gets wether the color curves effect is enabled.
  54452. */
  54453. get cameraColorCurvesEnabled(): boolean;
  54454. /**
  54455. * Sets wether the color curves effect is enabled.
  54456. */
  54457. set cameraColorCurvesEnabled(value: boolean);
  54458. /**
  54459. * Gets wether the color grading effect is enabled.
  54460. */
  54461. get cameraColorGradingEnabled(): boolean;
  54462. /**
  54463. * Gets wether the color grading effect is enabled.
  54464. */
  54465. set cameraColorGradingEnabled(value: boolean);
  54466. /**
  54467. * Gets wether tonemapping is enabled or not.
  54468. */
  54469. get cameraToneMappingEnabled(): boolean;
  54470. /**
  54471. * Sets wether tonemapping is enabled or not
  54472. */
  54473. set cameraToneMappingEnabled(value: boolean);
  54474. /**
  54475. * The camera exposure used on this material.
  54476. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54477. * This corresponds to a photographic exposure.
  54478. */
  54479. get cameraExposure(): number;
  54480. /**
  54481. * The camera exposure used on this material.
  54482. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54483. * This corresponds to a photographic exposure.
  54484. */
  54485. set cameraExposure(value: number);
  54486. /**
  54487. * Gets The camera contrast used on this material.
  54488. */
  54489. get cameraContrast(): number;
  54490. /**
  54491. * Sets The camera contrast used on this material.
  54492. */
  54493. set cameraContrast(value: number);
  54494. /**
  54495. * Gets the Color Grading 2D Lookup Texture.
  54496. */
  54497. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54498. /**
  54499. * Sets the Color Grading 2D Lookup Texture.
  54500. */
  54501. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54502. /**
  54503. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54504. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54505. * 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;
  54506. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54507. */
  54508. get cameraColorCurves(): Nullable<ColorCurves>;
  54509. /**
  54510. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54511. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54512. * 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;
  54513. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54514. */
  54515. set cameraColorCurves(value: Nullable<ColorCurves>);
  54516. /**
  54517. * Instantiates a new PBRMaterial instance.
  54518. *
  54519. * @param name The material name
  54520. * @param scene The scene the material will be use in.
  54521. */
  54522. constructor(name: string, scene: Scene);
  54523. /**
  54524. * Returns the name of this material class.
  54525. */
  54526. getClassName(): string;
  54527. /**
  54528. * Makes a duplicate of the current material.
  54529. * @param name - name to use for the new material.
  54530. */
  54531. clone(name: string): PBRMaterial;
  54532. /**
  54533. * Serializes this PBR Material.
  54534. * @returns - An object with the serialized material.
  54535. */
  54536. serialize(): any;
  54537. /**
  54538. * Parses a PBR Material from a serialized object.
  54539. * @param source - Serialized object.
  54540. * @param scene - BJS scene instance.
  54541. * @param rootUrl - url for the scene object
  54542. * @returns - PBRMaterial
  54543. */
  54544. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54545. }
  54546. }
  54547. declare module "babylonjs/Misc/dds" {
  54548. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54550. import { Nullable } from "babylonjs/types";
  54551. import { Scene } from "babylonjs/scene";
  54552. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54553. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54554. /**
  54555. * Direct draw surface info
  54556. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54557. */
  54558. export interface DDSInfo {
  54559. /**
  54560. * Width of the texture
  54561. */
  54562. width: number;
  54563. /**
  54564. * Width of the texture
  54565. */
  54566. height: number;
  54567. /**
  54568. * Number of Mipmaps for the texture
  54569. * @see https://en.wikipedia.org/wiki/Mipmap
  54570. */
  54571. mipmapCount: number;
  54572. /**
  54573. * If the textures format is a known fourCC format
  54574. * @see https://www.fourcc.org/
  54575. */
  54576. isFourCC: boolean;
  54577. /**
  54578. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54579. */
  54580. isRGB: boolean;
  54581. /**
  54582. * If the texture is a lumincance format
  54583. */
  54584. isLuminance: boolean;
  54585. /**
  54586. * If this is a cube texture
  54587. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54588. */
  54589. isCube: boolean;
  54590. /**
  54591. * If the texture is a compressed format eg. FOURCC_DXT1
  54592. */
  54593. isCompressed: boolean;
  54594. /**
  54595. * The dxgiFormat of the texture
  54596. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54597. */
  54598. dxgiFormat: number;
  54599. /**
  54600. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54601. */
  54602. textureType: number;
  54603. /**
  54604. * Sphericle polynomial created for the dds texture
  54605. */
  54606. sphericalPolynomial?: SphericalPolynomial;
  54607. }
  54608. /**
  54609. * Class used to provide DDS decompression tools
  54610. */
  54611. export class DDSTools {
  54612. /**
  54613. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54614. */
  54615. static StoreLODInAlphaChannel: boolean;
  54616. /**
  54617. * Gets DDS information from an array buffer
  54618. * @param data defines the array buffer view to read data from
  54619. * @returns the DDS information
  54620. */
  54621. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54622. private static _FloatView;
  54623. private static _Int32View;
  54624. private static _ToHalfFloat;
  54625. private static _FromHalfFloat;
  54626. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54627. private static _GetHalfFloatRGBAArrayBuffer;
  54628. private static _GetFloatRGBAArrayBuffer;
  54629. private static _GetFloatAsUIntRGBAArrayBuffer;
  54630. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54631. private static _GetRGBAArrayBuffer;
  54632. private static _ExtractLongWordOrder;
  54633. private static _GetRGBArrayBuffer;
  54634. private static _GetLuminanceArrayBuffer;
  54635. /**
  54636. * Uploads DDS Levels to a Babylon Texture
  54637. * @hidden
  54638. */
  54639. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54640. }
  54641. module "babylonjs/Engines/thinEngine" {
  54642. interface ThinEngine {
  54643. /**
  54644. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54645. * @param rootUrl defines the url where the file to load is located
  54646. * @param scene defines the current scene
  54647. * @param lodScale defines scale to apply to the mip map selection
  54648. * @param lodOffset defines offset to apply to the mip map selection
  54649. * @param onLoad defines an optional callback raised when the texture is loaded
  54650. * @param onError defines an optional callback raised if there is an issue to load the texture
  54651. * @param format defines the format of the data
  54652. * @param forcedExtension defines the extension to use to pick the right loader
  54653. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54654. * @returns the cube texture as an InternalTexture
  54655. */
  54656. 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;
  54657. }
  54658. }
  54659. }
  54660. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54661. import { Nullable } from "babylonjs/types";
  54662. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54663. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54664. /**
  54665. * Implementation of the DDS Texture Loader.
  54666. * @hidden
  54667. */
  54668. export class _DDSTextureLoader implements IInternalTextureLoader {
  54669. /**
  54670. * Defines wether the loader supports cascade loading the different faces.
  54671. */
  54672. readonly supportCascades: boolean;
  54673. /**
  54674. * This returns if the loader support the current file information.
  54675. * @param extension defines the file extension of the file being loaded
  54676. * @returns true if the loader can load the specified file
  54677. */
  54678. canLoad(extension: string): boolean;
  54679. /**
  54680. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54681. * @param data contains the texture data
  54682. * @param texture defines the BabylonJS internal texture
  54683. * @param createPolynomials will be true if polynomials have been requested
  54684. * @param onLoad defines the callback to trigger once the texture is ready
  54685. * @param onError defines the callback to trigger in case of error
  54686. */
  54687. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54688. /**
  54689. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54690. * @param data contains the texture data
  54691. * @param texture defines the BabylonJS internal texture
  54692. * @param callback defines the method to call once ready to upload
  54693. */
  54694. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54695. }
  54696. }
  54697. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54698. import { Nullable } from "babylonjs/types";
  54699. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54700. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54701. /**
  54702. * Implementation of the ENV Texture Loader.
  54703. * @hidden
  54704. */
  54705. export class _ENVTextureLoader implements IInternalTextureLoader {
  54706. /**
  54707. * Defines wether the loader supports cascade loading the different faces.
  54708. */
  54709. readonly supportCascades: boolean;
  54710. /**
  54711. * This returns if the loader support the current file information.
  54712. * @param extension defines the file extension of the file being loaded
  54713. * @returns true if the loader can load the specified file
  54714. */
  54715. canLoad(extension: string): boolean;
  54716. /**
  54717. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54718. * @param data contains the texture data
  54719. * @param texture defines the BabylonJS internal texture
  54720. * @param createPolynomials will be true if polynomials have been requested
  54721. * @param onLoad defines the callback to trigger once the texture is ready
  54722. * @param onError defines the callback to trigger in case of error
  54723. */
  54724. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54725. /**
  54726. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54727. * @param data contains the texture data
  54728. * @param texture defines the BabylonJS internal texture
  54729. * @param callback defines the method to call once ready to upload
  54730. */
  54731. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54732. }
  54733. }
  54734. declare module "babylonjs/Misc/khronosTextureContainer" {
  54735. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54736. /**
  54737. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54738. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54739. */
  54740. export class KhronosTextureContainer {
  54741. /** contents of the KTX container file */
  54742. data: ArrayBufferView;
  54743. private static HEADER_LEN;
  54744. private static COMPRESSED_2D;
  54745. private static COMPRESSED_3D;
  54746. private static TEX_2D;
  54747. private static TEX_3D;
  54748. /**
  54749. * Gets the openGL type
  54750. */
  54751. glType: number;
  54752. /**
  54753. * Gets the openGL type size
  54754. */
  54755. glTypeSize: number;
  54756. /**
  54757. * Gets the openGL format
  54758. */
  54759. glFormat: number;
  54760. /**
  54761. * Gets the openGL internal format
  54762. */
  54763. glInternalFormat: number;
  54764. /**
  54765. * Gets the base internal format
  54766. */
  54767. glBaseInternalFormat: number;
  54768. /**
  54769. * Gets image width in pixel
  54770. */
  54771. pixelWidth: number;
  54772. /**
  54773. * Gets image height in pixel
  54774. */
  54775. pixelHeight: number;
  54776. /**
  54777. * Gets image depth in pixels
  54778. */
  54779. pixelDepth: number;
  54780. /**
  54781. * Gets the number of array elements
  54782. */
  54783. numberOfArrayElements: number;
  54784. /**
  54785. * Gets the number of faces
  54786. */
  54787. numberOfFaces: number;
  54788. /**
  54789. * Gets the number of mipmap levels
  54790. */
  54791. numberOfMipmapLevels: number;
  54792. /**
  54793. * Gets the bytes of key value data
  54794. */
  54795. bytesOfKeyValueData: number;
  54796. /**
  54797. * Gets the load type
  54798. */
  54799. loadType: number;
  54800. /**
  54801. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54802. */
  54803. isInvalid: boolean;
  54804. /**
  54805. * Creates a new KhronosTextureContainer
  54806. * @param data contents of the KTX container file
  54807. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54808. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54809. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54810. */
  54811. constructor(
  54812. /** contents of the KTX container file */
  54813. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54814. /**
  54815. * Uploads KTX content to a Babylon Texture.
  54816. * It is assumed that the texture has already been created & is currently bound
  54817. * @hidden
  54818. */
  54819. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54820. private _upload2DCompressedLevels;
  54821. /**
  54822. * Checks if the given data starts with a KTX file identifier.
  54823. * @param data the data to check
  54824. * @returns true if the data is a KTX file or false otherwise
  54825. */
  54826. static IsValid(data: ArrayBufferView): boolean;
  54827. }
  54828. }
  54829. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54830. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54831. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54832. /**
  54833. * Class for loading KTX2 files
  54834. * !!! Experimental Extension Subject to Changes !!!
  54835. * @hidden
  54836. */
  54837. export class KhronosTextureContainer2 {
  54838. private static _ModulePromise;
  54839. private static _TranscodeFormat;
  54840. constructor(engine: ThinEngine);
  54841. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54842. private _determineTranscodeFormat;
  54843. /**
  54844. * Checks if the given data starts with a KTX2 file identifier.
  54845. * @param data the data to check
  54846. * @returns true if the data is a KTX2 file or false otherwise
  54847. */
  54848. static IsValid(data: ArrayBufferView): boolean;
  54849. }
  54850. }
  54851. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54852. import { Nullable } from "babylonjs/types";
  54853. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54854. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54855. /**
  54856. * Implementation of the KTX Texture Loader.
  54857. * @hidden
  54858. */
  54859. export class _KTXTextureLoader implements IInternalTextureLoader {
  54860. /**
  54861. * Defines wether the loader supports cascade loading the different faces.
  54862. */
  54863. readonly supportCascades: boolean;
  54864. /**
  54865. * This returns if the loader support the current file information.
  54866. * @param extension defines the file extension of the file being loaded
  54867. * @returns true if the loader can load the specified file
  54868. */
  54869. canLoad(extension: string): boolean;
  54870. /**
  54871. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54872. * @param data contains the texture data
  54873. * @param texture defines the BabylonJS internal texture
  54874. * @param createPolynomials will be true if polynomials have been requested
  54875. * @param onLoad defines the callback to trigger once the texture is ready
  54876. * @param onError defines the callback to trigger in case of error
  54877. */
  54878. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54879. /**
  54880. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54881. * @param data contains the texture data
  54882. * @param texture defines the BabylonJS internal texture
  54883. * @param callback defines the method to call once ready to upload
  54884. */
  54885. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54886. }
  54887. }
  54888. declare module "babylonjs/Helpers/sceneHelpers" {
  54889. import { Nullable } from "babylonjs/types";
  54890. import { Mesh } from "babylonjs/Meshes/mesh";
  54891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54892. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54893. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54894. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54895. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54896. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54897. import "babylonjs/Meshes/Builders/boxBuilder";
  54898. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54899. /** @hidden */
  54900. export var _forceSceneHelpersToBundle: boolean;
  54901. module "babylonjs/scene" {
  54902. interface Scene {
  54903. /**
  54904. * Creates a default light for the scene.
  54905. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54906. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54907. */
  54908. createDefaultLight(replace?: boolean): void;
  54909. /**
  54910. * Creates a default camera for the scene.
  54911. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54912. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54913. * @param replace has default false, when true replaces the active camera in the scene
  54914. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54915. */
  54916. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54917. /**
  54918. * Creates a default camera and a default light.
  54919. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54920. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54921. * @param replace has the default false, when true replaces the active camera/light in the scene
  54922. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54923. */
  54924. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54925. /**
  54926. * Creates a new sky box
  54927. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54928. * @param environmentTexture defines the texture to use as environment texture
  54929. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54930. * @param scale defines the overall scale of the skybox
  54931. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54932. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54933. * @returns a new mesh holding the sky box
  54934. */
  54935. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54936. /**
  54937. * Creates a new environment
  54938. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54939. * @param options defines the options you can use to configure the environment
  54940. * @returns the new EnvironmentHelper
  54941. */
  54942. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54943. /**
  54944. * Creates a new VREXperienceHelper
  54945. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54946. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54947. * @returns a new VREXperienceHelper
  54948. */
  54949. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54950. /**
  54951. * Creates a new WebXRDefaultExperience
  54952. * @see http://doc.babylonjs.com/how_to/webxr
  54953. * @param options experience options
  54954. * @returns a promise for a new WebXRDefaultExperience
  54955. */
  54956. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54957. }
  54958. }
  54959. }
  54960. declare module "babylonjs/Helpers/videoDome" {
  54961. import { Scene } from "babylonjs/scene";
  54962. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54963. import { Mesh } from "babylonjs/Meshes/mesh";
  54964. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54965. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54966. import "babylonjs/Meshes/Builders/sphereBuilder";
  54967. /**
  54968. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54969. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54970. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54971. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54972. */
  54973. export class VideoDome extends TransformNode {
  54974. /**
  54975. * Define the video source as a Monoscopic panoramic 360 video.
  54976. */
  54977. static readonly MODE_MONOSCOPIC: number;
  54978. /**
  54979. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54980. */
  54981. static readonly MODE_TOPBOTTOM: number;
  54982. /**
  54983. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54984. */
  54985. static readonly MODE_SIDEBYSIDE: number;
  54986. private _halfDome;
  54987. private _useDirectMapping;
  54988. /**
  54989. * The video texture being displayed on the sphere
  54990. */
  54991. protected _videoTexture: VideoTexture;
  54992. /**
  54993. * Gets the video texture being displayed on the sphere
  54994. */
  54995. get videoTexture(): VideoTexture;
  54996. /**
  54997. * The skybox material
  54998. */
  54999. protected _material: BackgroundMaterial;
  55000. /**
  55001. * The surface used for the skybox
  55002. */
  55003. protected _mesh: Mesh;
  55004. /**
  55005. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55006. */
  55007. private _halfDomeMask;
  55008. /**
  55009. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55010. * Also see the options.resolution property.
  55011. */
  55012. get fovMultiplier(): number;
  55013. set fovMultiplier(value: number);
  55014. private _videoMode;
  55015. /**
  55016. * Gets or set the current video mode for the video. It can be:
  55017. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55018. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55019. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55020. */
  55021. get videoMode(): number;
  55022. set videoMode(value: number);
  55023. /**
  55024. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55025. *
  55026. */
  55027. get halfDome(): boolean;
  55028. /**
  55029. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55030. */
  55031. set halfDome(enabled: boolean);
  55032. /**
  55033. * Oberserver used in Stereoscopic VR Mode.
  55034. */
  55035. private _onBeforeCameraRenderObserver;
  55036. /**
  55037. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55038. * @param name Element's name, child elements will append suffixes for their own names.
  55039. * @param urlsOrVideo defines the url(s) or the video element to use
  55040. * @param options An object containing optional or exposed sub element properties
  55041. */
  55042. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55043. resolution?: number;
  55044. clickToPlay?: boolean;
  55045. autoPlay?: boolean;
  55046. loop?: boolean;
  55047. size?: number;
  55048. poster?: string;
  55049. faceForward?: boolean;
  55050. useDirectMapping?: boolean;
  55051. halfDomeMode?: boolean;
  55052. }, scene: Scene);
  55053. private _changeVideoMode;
  55054. /**
  55055. * Releases resources associated with this node.
  55056. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55057. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55058. */
  55059. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55060. }
  55061. }
  55062. declare module "babylonjs/Helpers/index" {
  55063. export * from "babylonjs/Helpers/environmentHelper";
  55064. export * from "babylonjs/Helpers/photoDome";
  55065. export * from "babylonjs/Helpers/sceneHelpers";
  55066. export * from "babylonjs/Helpers/videoDome";
  55067. }
  55068. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55069. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55070. import { IDisposable } from "babylonjs/scene";
  55071. import { Engine } from "babylonjs/Engines/engine";
  55072. /**
  55073. * This class can be used to get instrumentation data from a Babylon engine
  55074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55075. */
  55076. export class EngineInstrumentation implements IDisposable {
  55077. /**
  55078. * Define the instrumented engine.
  55079. */
  55080. engine: Engine;
  55081. private _captureGPUFrameTime;
  55082. private _gpuFrameTimeToken;
  55083. private _gpuFrameTime;
  55084. private _captureShaderCompilationTime;
  55085. private _shaderCompilationTime;
  55086. private _onBeginFrameObserver;
  55087. private _onEndFrameObserver;
  55088. private _onBeforeShaderCompilationObserver;
  55089. private _onAfterShaderCompilationObserver;
  55090. /**
  55091. * Gets the perf counter used for GPU frame time
  55092. */
  55093. get gpuFrameTimeCounter(): PerfCounter;
  55094. /**
  55095. * Gets the GPU frame time capture status
  55096. */
  55097. get captureGPUFrameTime(): boolean;
  55098. /**
  55099. * Enable or disable the GPU frame time capture
  55100. */
  55101. set captureGPUFrameTime(value: boolean);
  55102. /**
  55103. * Gets the perf counter used for shader compilation time
  55104. */
  55105. get shaderCompilationTimeCounter(): PerfCounter;
  55106. /**
  55107. * Gets the shader compilation time capture status
  55108. */
  55109. get captureShaderCompilationTime(): boolean;
  55110. /**
  55111. * Enable or disable the shader compilation time capture
  55112. */
  55113. set captureShaderCompilationTime(value: boolean);
  55114. /**
  55115. * Instantiates a new engine instrumentation.
  55116. * This class can be used to get instrumentation data from a Babylon engine
  55117. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55118. * @param engine Defines the engine to instrument
  55119. */
  55120. constructor(
  55121. /**
  55122. * Define the instrumented engine.
  55123. */
  55124. engine: Engine);
  55125. /**
  55126. * Dispose and release associated resources.
  55127. */
  55128. dispose(): void;
  55129. }
  55130. }
  55131. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55132. import { Scene, IDisposable } from "babylonjs/scene";
  55133. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55134. /**
  55135. * This class can be used to get instrumentation data from a Babylon engine
  55136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55137. */
  55138. export class SceneInstrumentation implements IDisposable {
  55139. /**
  55140. * Defines the scene to instrument
  55141. */
  55142. scene: Scene;
  55143. private _captureActiveMeshesEvaluationTime;
  55144. private _activeMeshesEvaluationTime;
  55145. private _captureRenderTargetsRenderTime;
  55146. private _renderTargetsRenderTime;
  55147. private _captureFrameTime;
  55148. private _frameTime;
  55149. private _captureRenderTime;
  55150. private _renderTime;
  55151. private _captureInterFrameTime;
  55152. private _interFrameTime;
  55153. private _captureParticlesRenderTime;
  55154. private _particlesRenderTime;
  55155. private _captureSpritesRenderTime;
  55156. private _spritesRenderTime;
  55157. private _capturePhysicsTime;
  55158. private _physicsTime;
  55159. private _captureAnimationsTime;
  55160. private _animationsTime;
  55161. private _captureCameraRenderTime;
  55162. private _cameraRenderTime;
  55163. private _onBeforeActiveMeshesEvaluationObserver;
  55164. private _onAfterActiveMeshesEvaluationObserver;
  55165. private _onBeforeRenderTargetsRenderObserver;
  55166. private _onAfterRenderTargetsRenderObserver;
  55167. private _onAfterRenderObserver;
  55168. private _onBeforeDrawPhaseObserver;
  55169. private _onAfterDrawPhaseObserver;
  55170. private _onBeforeAnimationsObserver;
  55171. private _onBeforeParticlesRenderingObserver;
  55172. private _onAfterParticlesRenderingObserver;
  55173. private _onBeforeSpritesRenderingObserver;
  55174. private _onAfterSpritesRenderingObserver;
  55175. private _onBeforePhysicsObserver;
  55176. private _onAfterPhysicsObserver;
  55177. private _onAfterAnimationsObserver;
  55178. private _onBeforeCameraRenderObserver;
  55179. private _onAfterCameraRenderObserver;
  55180. /**
  55181. * Gets the perf counter used for active meshes evaluation time
  55182. */
  55183. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55184. /**
  55185. * Gets the active meshes evaluation time capture status
  55186. */
  55187. get captureActiveMeshesEvaluationTime(): boolean;
  55188. /**
  55189. * Enable or disable the active meshes evaluation time capture
  55190. */
  55191. set captureActiveMeshesEvaluationTime(value: boolean);
  55192. /**
  55193. * Gets the perf counter used for render targets render time
  55194. */
  55195. get renderTargetsRenderTimeCounter(): PerfCounter;
  55196. /**
  55197. * Gets the render targets render time capture status
  55198. */
  55199. get captureRenderTargetsRenderTime(): boolean;
  55200. /**
  55201. * Enable or disable the render targets render time capture
  55202. */
  55203. set captureRenderTargetsRenderTime(value: boolean);
  55204. /**
  55205. * Gets the perf counter used for particles render time
  55206. */
  55207. get particlesRenderTimeCounter(): PerfCounter;
  55208. /**
  55209. * Gets the particles render time capture status
  55210. */
  55211. get captureParticlesRenderTime(): boolean;
  55212. /**
  55213. * Enable or disable the particles render time capture
  55214. */
  55215. set captureParticlesRenderTime(value: boolean);
  55216. /**
  55217. * Gets the perf counter used for sprites render time
  55218. */
  55219. get spritesRenderTimeCounter(): PerfCounter;
  55220. /**
  55221. * Gets the sprites render time capture status
  55222. */
  55223. get captureSpritesRenderTime(): boolean;
  55224. /**
  55225. * Enable or disable the sprites render time capture
  55226. */
  55227. set captureSpritesRenderTime(value: boolean);
  55228. /**
  55229. * Gets the perf counter used for physics time
  55230. */
  55231. get physicsTimeCounter(): PerfCounter;
  55232. /**
  55233. * Gets the physics time capture status
  55234. */
  55235. get capturePhysicsTime(): boolean;
  55236. /**
  55237. * Enable or disable the physics time capture
  55238. */
  55239. set capturePhysicsTime(value: boolean);
  55240. /**
  55241. * Gets the perf counter used for animations time
  55242. */
  55243. get animationsTimeCounter(): PerfCounter;
  55244. /**
  55245. * Gets the animations time capture status
  55246. */
  55247. get captureAnimationsTime(): boolean;
  55248. /**
  55249. * Enable or disable the animations time capture
  55250. */
  55251. set captureAnimationsTime(value: boolean);
  55252. /**
  55253. * Gets the perf counter used for frame time capture
  55254. */
  55255. get frameTimeCounter(): PerfCounter;
  55256. /**
  55257. * Gets the frame time capture status
  55258. */
  55259. get captureFrameTime(): boolean;
  55260. /**
  55261. * Enable or disable the frame time capture
  55262. */
  55263. set captureFrameTime(value: boolean);
  55264. /**
  55265. * Gets the perf counter used for inter-frames time capture
  55266. */
  55267. get interFrameTimeCounter(): PerfCounter;
  55268. /**
  55269. * Gets the inter-frames time capture status
  55270. */
  55271. get captureInterFrameTime(): boolean;
  55272. /**
  55273. * Enable or disable the inter-frames time capture
  55274. */
  55275. set captureInterFrameTime(value: boolean);
  55276. /**
  55277. * Gets the perf counter used for render time capture
  55278. */
  55279. get renderTimeCounter(): PerfCounter;
  55280. /**
  55281. * Gets the render time capture status
  55282. */
  55283. get captureRenderTime(): boolean;
  55284. /**
  55285. * Enable or disable the render time capture
  55286. */
  55287. set captureRenderTime(value: boolean);
  55288. /**
  55289. * Gets the perf counter used for camera render time capture
  55290. */
  55291. get cameraRenderTimeCounter(): PerfCounter;
  55292. /**
  55293. * Gets the camera render time capture status
  55294. */
  55295. get captureCameraRenderTime(): boolean;
  55296. /**
  55297. * Enable or disable the camera render time capture
  55298. */
  55299. set captureCameraRenderTime(value: boolean);
  55300. /**
  55301. * Gets the perf counter used for draw calls
  55302. */
  55303. get drawCallsCounter(): PerfCounter;
  55304. /**
  55305. * Instantiates a new scene instrumentation.
  55306. * This class can be used to get instrumentation data from a Babylon engine
  55307. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55308. * @param scene Defines the scene to instrument
  55309. */
  55310. constructor(
  55311. /**
  55312. * Defines the scene to instrument
  55313. */
  55314. scene: Scene);
  55315. /**
  55316. * Dispose and release associated resources.
  55317. */
  55318. dispose(): void;
  55319. }
  55320. }
  55321. declare module "babylonjs/Instrumentation/index" {
  55322. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55323. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55324. export * from "babylonjs/Instrumentation/timeToken";
  55325. }
  55326. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55327. /** @hidden */
  55328. export var glowMapGenerationPixelShader: {
  55329. name: string;
  55330. shader: string;
  55331. };
  55332. }
  55333. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55334. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55335. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55336. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55337. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55338. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55339. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55340. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55341. /** @hidden */
  55342. export var glowMapGenerationVertexShader: {
  55343. name: string;
  55344. shader: string;
  55345. };
  55346. }
  55347. declare module "babylonjs/Layers/effectLayer" {
  55348. import { Observable } from "babylonjs/Misc/observable";
  55349. import { Nullable } from "babylonjs/types";
  55350. import { Camera } from "babylonjs/Cameras/camera";
  55351. import { Scene } from "babylonjs/scene";
  55352. import { ISize } from "babylonjs/Maths/math.size";
  55353. import { Color4 } from "babylonjs/Maths/math.color";
  55354. import { Engine } from "babylonjs/Engines/engine";
  55355. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55357. import { Mesh } from "babylonjs/Meshes/mesh";
  55358. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55360. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55361. import { Effect } from "babylonjs/Materials/effect";
  55362. import { Material } from "babylonjs/Materials/material";
  55363. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55364. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55365. /**
  55366. * Effect layer options. This helps customizing the behaviour
  55367. * of the effect layer.
  55368. */
  55369. export interface IEffectLayerOptions {
  55370. /**
  55371. * Multiplication factor apply to the canvas size to compute the render target size
  55372. * used to generated the objects (the smaller the faster).
  55373. */
  55374. mainTextureRatio: number;
  55375. /**
  55376. * Enforces a fixed size texture to ensure effect stability across devices.
  55377. */
  55378. mainTextureFixedSize?: number;
  55379. /**
  55380. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55381. */
  55382. alphaBlendingMode: number;
  55383. /**
  55384. * The camera attached to the layer.
  55385. */
  55386. camera: Nullable<Camera>;
  55387. /**
  55388. * The rendering group to draw the layer in.
  55389. */
  55390. renderingGroupId: number;
  55391. }
  55392. /**
  55393. * The effect layer Helps adding post process effect blended with the main pass.
  55394. *
  55395. * This can be for instance use to generate glow or higlight effects on the scene.
  55396. *
  55397. * The effect layer class can not be used directly and is intented to inherited from to be
  55398. * customized per effects.
  55399. */
  55400. export abstract class EffectLayer {
  55401. private _vertexBuffers;
  55402. private _indexBuffer;
  55403. private _cachedDefines;
  55404. private _effectLayerMapGenerationEffect;
  55405. private _effectLayerOptions;
  55406. private _mergeEffect;
  55407. protected _scene: Scene;
  55408. protected _engine: Engine;
  55409. protected _maxSize: number;
  55410. protected _mainTextureDesiredSize: ISize;
  55411. protected _mainTexture: RenderTargetTexture;
  55412. protected _shouldRender: boolean;
  55413. protected _postProcesses: PostProcess[];
  55414. protected _textures: BaseTexture[];
  55415. protected _emissiveTextureAndColor: {
  55416. texture: Nullable<BaseTexture>;
  55417. color: Color4;
  55418. };
  55419. /**
  55420. * The name of the layer
  55421. */
  55422. name: string;
  55423. /**
  55424. * The clear color of the texture used to generate the glow map.
  55425. */
  55426. neutralColor: Color4;
  55427. /**
  55428. * Specifies whether the highlight layer is enabled or not.
  55429. */
  55430. isEnabled: boolean;
  55431. /**
  55432. * Gets the camera attached to the layer.
  55433. */
  55434. get camera(): Nullable<Camera>;
  55435. /**
  55436. * Gets the rendering group id the layer should render in.
  55437. */
  55438. get renderingGroupId(): number;
  55439. set renderingGroupId(renderingGroupId: number);
  55440. /**
  55441. * An event triggered when the effect layer has been disposed.
  55442. */
  55443. onDisposeObservable: Observable<EffectLayer>;
  55444. /**
  55445. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55446. */
  55447. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55448. /**
  55449. * An event triggered when the generated texture is being merged in the scene.
  55450. */
  55451. onBeforeComposeObservable: Observable<EffectLayer>;
  55452. /**
  55453. * An event triggered when the mesh is rendered into the effect render target.
  55454. */
  55455. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55456. /**
  55457. * An event triggered after the mesh has been rendered into the effect render target.
  55458. */
  55459. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55460. /**
  55461. * An event triggered when the generated texture has been merged in the scene.
  55462. */
  55463. onAfterComposeObservable: Observable<EffectLayer>;
  55464. /**
  55465. * An event triggered when the efffect layer changes its size.
  55466. */
  55467. onSizeChangedObservable: Observable<EffectLayer>;
  55468. /** @hidden */
  55469. static _SceneComponentInitialization: (scene: Scene) => void;
  55470. /**
  55471. * Instantiates a new effect Layer and references it in the scene.
  55472. * @param name The name of the layer
  55473. * @param scene The scene to use the layer in
  55474. */
  55475. constructor(
  55476. /** The Friendly of the effect in the scene */
  55477. name: string, scene: Scene);
  55478. /**
  55479. * Get the effect name of the layer.
  55480. * @return The effect name
  55481. */
  55482. abstract getEffectName(): string;
  55483. /**
  55484. * Checks for the readiness of the element composing the layer.
  55485. * @param subMesh the mesh to check for
  55486. * @param useInstances specify whether or not to use instances to render the mesh
  55487. * @return true if ready otherwise, false
  55488. */
  55489. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55490. /**
  55491. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55492. * @returns true if the effect requires stencil during the main canvas render pass.
  55493. */
  55494. abstract needStencil(): boolean;
  55495. /**
  55496. * Create the merge effect. This is the shader use to blit the information back
  55497. * to the main canvas at the end of the scene rendering.
  55498. * @returns The effect containing the shader used to merge the effect on the main canvas
  55499. */
  55500. protected abstract _createMergeEffect(): Effect;
  55501. /**
  55502. * Creates the render target textures and post processes used in the effect layer.
  55503. */
  55504. protected abstract _createTextureAndPostProcesses(): void;
  55505. /**
  55506. * Implementation specific of rendering the generating effect on the main canvas.
  55507. * @param effect The effect used to render through
  55508. */
  55509. protected abstract _internalRender(effect: Effect): void;
  55510. /**
  55511. * Sets the required values for both the emissive texture and and the main color.
  55512. */
  55513. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55514. /**
  55515. * Free any resources and references associated to a mesh.
  55516. * Internal use
  55517. * @param mesh The mesh to free.
  55518. */
  55519. abstract _disposeMesh(mesh: Mesh): void;
  55520. /**
  55521. * Serializes this layer (Glow or Highlight for example)
  55522. * @returns a serialized layer object
  55523. */
  55524. abstract serialize?(): any;
  55525. /**
  55526. * Initializes the effect layer with the required options.
  55527. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55528. */
  55529. protected _init(options: Partial<IEffectLayerOptions>): void;
  55530. /**
  55531. * Generates the index buffer of the full screen quad blending to the main canvas.
  55532. */
  55533. private _generateIndexBuffer;
  55534. /**
  55535. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55536. */
  55537. private _generateVertexBuffer;
  55538. /**
  55539. * Sets the main texture desired size which is the closest power of two
  55540. * of the engine canvas size.
  55541. */
  55542. private _setMainTextureSize;
  55543. /**
  55544. * Creates the main texture for the effect layer.
  55545. */
  55546. protected _createMainTexture(): void;
  55547. /**
  55548. * Adds specific effects defines.
  55549. * @param defines The defines to add specifics to.
  55550. */
  55551. protected _addCustomEffectDefines(defines: string[]): void;
  55552. /**
  55553. * Checks for the readiness of the element composing the layer.
  55554. * @param subMesh the mesh to check for
  55555. * @param useInstances specify whether or not to use instances to render the mesh
  55556. * @param emissiveTexture the associated emissive texture used to generate the glow
  55557. * @return true if ready otherwise, false
  55558. */
  55559. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55560. /**
  55561. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55562. */
  55563. render(): void;
  55564. /**
  55565. * Determine if a given mesh will be used in the current effect.
  55566. * @param mesh mesh to test
  55567. * @returns true if the mesh will be used
  55568. */
  55569. hasMesh(mesh: AbstractMesh): boolean;
  55570. /**
  55571. * Returns true if the layer contains information to display, otherwise false.
  55572. * @returns true if the glow layer should be rendered
  55573. */
  55574. shouldRender(): boolean;
  55575. /**
  55576. * Returns true if the mesh should render, otherwise false.
  55577. * @param mesh The mesh to render
  55578. * @returns true if it should render otherwise false
  55579. */
  55580. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55581. /**
  55582. * Returns true if the mesh can be rendered, otherwise false.
  55583. * @param mesh The mesh to render
  55584. * @param material The material used on the mesh
  55585. * @returns true if it can be rendered otherwise false
  55586. */
  55587. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55588. /**
  55589. * Returns true if the mesh should render, otherwise false.
  55590. * @param mesh The mesh to render
  55591. * @returns true if it should render otherwise false
  55592. */
  55593. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55594. /**
  55595. * Renders the submesh passed in parameter to the generation map.
  55596. */
  55597. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55598. /**
  55599. * Defines whether the current material of the mesh should be use to render the effect.
  55600. * @param mesh defines the current mesh to render
  55601. */
  55602. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55603. /**
  55604. * Rebuild the required buffers.
  55605. * @hidden Internal use only.
  55606. */
  55607. _rebuild(): void;
  55608. /**
  55609. * Dispose only the render target textures and post process.
  55610. */
  55611. private _disposeTextureAndPostProcesses;
  55612. /**
  55613. * Dispose the highlight layer and free resources.
  55614. */
  55615. dispose(): void;
  55616. /**
  55617. * Gets the class name of the effect layer
  55618. * @returns the string with the class name of the effect layer
  55619. */
  55620. getClassName(): string;
  55621. /**
  55622. * Creates an effect layer from parsed effect layer data
  55623. * @param parsedEffectLayer defines effect layer data
  55624. * @param scene defines the current scene
  55625. * @param rootUrl defines the root URL containing the effect layer information
  55626. * @returns a parsed effect Layer
  55627. */
  55628. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55629. }
  55630. }
  55631. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55632. import { Scene } from "babylonjs/scene";
  55633. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55634. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55635. import { AbstractScene } from "babylonjs/abstractScene";
  55636. module "babylonjs/abstractScene" {
  55637. interface AbstractScene {
  55638. /**
  55639. * The list of effect layers (highlights/glow) added to the scene
  55640. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55641. * @see http://doc.babylonjs.com/how_to/glow_layer
  55642. */
  55643. effectLayers: Array<EffectLayer>;
  55644. /**
  55645. * Removes the given effect layer from this scene.
  55646. * @param toRemove defines the effect layer to remove
  55647. * @returns the index of the removed effect layer
  55648. */
  55649. removeEffectLayer(toRemove: EffectLayer): number;
  55650. /**
  55651. * Adds the given effect layer to this scene
  55652. * @param newEffectLayer defines the effect layer to add
  55653. */
  55654. addEffectLayer(newEffectLayer: EffectLayer): void;
  55655. }
  55656. }
  55657. /**
  55658. * Defines the layer scene component responsible to manage any effect layers
  55659. * in a given scene.
  55660. */
  55661. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55662. /**
  55663. * The component name helpfull to identify the component in the list of scene components.
  55664. */
  55665. readonly name: string;
  55666. /**
  55667. * The scene the component belongs to.
  55668. */
  55669. scene: Scene;
  55670. private _engine;
  55671. private _renderEffects;
  55672. private _needStencil;
  55673. private _previousStencilState;
  55674. /**
  55675. * Creates a new instance of the component for the given scene
  55676. * @param scene Defines the scene to register the component in
  55677. */
  55678. constructor(scene: Scene);
  55679. /**
  55680. * Registers the component in a given scene
  55681. */
  55682. register(): void;
  55683. /**
  55684. * Rebuilds the elements related to this component in case of
  55685. * context lost for instance.
  55686. */
  55687. rebuild(): void;
  55688. /**
  55689. * Serializes the component data to the specified json object
  55690. * @param serializationObject The object to serialize to
  55691. */
  55692. serialize(serializationObject: any): void;
  55693. /**
  55694. * Adds all the elements from the container to the scene
  55695. * @param container the container holding the elements
  55696. */
  55697. addFromContainer(container: AbstractScene): void;
  55698. /**
  55699. * Removes all the elements in the container from the scene
  55700. * @param container contains the elements to remove
  55701. * @param dispose if the removed element should be disposed (default: false)
  55702. */
  55703. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55704. /**
  55705. * Disposes the component and the associated ressources.
  55706. */
  55707. dispose(): void;
  55708. private _isReadyForMesh;
  55709. private _renderMainTexture;
  55710. private _setStencil;
  55711. private _setStencilBack;
  55712. private _draw;
  55713. private _drawCamera;
  55714. private _drawRenderingGroup;
  55715. }
  55716. }
  55717. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55718. /** @hidden */
  55719. export var glowMapMergePixelShader: {
  55720. name: string;
  55721. shader: string;
  55722. };
  55723. }
  55724. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55725. /** @hidden */
  55726. export var glowMapMergeVertexShader: {
  55727. name: string;
  55728. shader: string;
  55729. };
  55730. }
  55731. declare module "babylonjs/Layers/glowLayer" {
  55732. import { Nullable } from "babylonjs/types";
  55733. import { Camera } from "babylonjs/Cameras/camera";
  55734. import { Scene } from "babylonjs/scene";
  55735. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55737. import { Mesh } from "babylonjs/Meshes/mesh";
  55738. import { Texture } from "babylonjs/Materials/Textures/texture";
  55739. import { Effect } from "babylonjs/Materials/effect";
  55740. import { Material } from "babylonjs/Materials/material";
  55741. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55742. import { Color4 } from "babylonjs/Maths/math.color";
  55743. import "babylonjs/Shaders/glowMapMerge.fragment";
  55744. import "babylonjs/Shaders/glowMapMerge.vertex";
  55745. import "babylonjs/Layers/effectLayerSceneComponent";
  55746. module "babylonjs/abstractScene" {
  55747. interface AbstractScene {
  55748. /**
  55749. * Return a the first highlight layer of the scene with a given name.
  55750. * @param name The name of the highlight layer to look for.
  55751. * @return The highlight layer if found otherwise null.
  55752. */
  55753. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55754. }
  55755. }
  55756. /**
  55757. * Glow layer options. This helps customizing the behaviour
  55758. * of the glow layer.
  55759. */
  55760. export interface IGlowLayerOptions {
  55761. /**
  55762. * Multiplication factor apply to the canvas size to compute the render target size
  55763. * used to generated the glowing objects (the smaller the faster).
  55764. */
  55765. mainTextureRatio: number;
  55766. /**
  55767. * Enforces a fixed size texture to ensure resize independant blur.
  55768. */
  55769. mainTextureFixedSize?: number;
  55770. /**
  55771. * How big is the kernel of the blur texture.
  55772. */
  55773. blurKernelSize: number;
  55774. /**
  55775. * The camera attached to the layer.
  55776. */
  55777. camera: Nullable<Camera>;
  55778. /**
  55779. * Enable MSAA by chosing the number of samples.
  55780. */
  55781. mainTextureSamples?: number;
  55782. /**
  55783. * The rendering group to draw the layer in.
  55784. */
  55785. renderingGroupId: number;
  55786. }
  55787. /**
  55788. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55789. *
  55790. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55791. *
  55792. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55793. */
  55794. export class GlowLayer extends EffectLayer {
  55795. /**
  55796. * Effect Name of the layer.
  55797. */
  55798. static readonly EffectName: string;
  55799. /**
  55800. * The default blur kernel size used for the glow.
  55801. */
  55802. static DefaultBlurKernelSize: number;
  55803. /**
  55804. * The default texture size ratio used for the glow.
  55805. */
  55806. static DefaultTextureRatio: number;
  55807. /**
  55808. * Sets the kernel size of the blur.
  55809. */
  55810. set blurKernelSize(value: number);
  55811. /**
  55812. * Gets the kernel size of the blur.
  55813. */
  55814. get blurKernelSize(): number;
  55815. /**
  55816. * Sets the glow intensity.
  55817. */
  55818. set intensity(value: number);
  55819. /**
  55820. * Gets the glow intensity.
  55821. */
  55822. get intensity(): number;
  55823. private _options;
  55824. private _intensity;
  55825. private _horizontalBlurPostprocess1;
  55826. private _verticalBlurPostprocess1;
  55827. private _horizontalBlurPostprocess2;
  55828. private _verticalBlurPostprocess2;
  55829. private _blurTexture1;
  55830. private _blurTexture2;
  55831. private _postProcesses1;
  55832. private _postProcesses2;
  55833. private _includedOnlyMeshes;
  55834. private _excludedMeshes;
  55835. private _meshesUsingTheirOwnMaterials;
  55836. /**
  55837. * Callback used to let the user override the color selection on a per mesh basis
  55838. */
  55839. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55840. /**
  55841. * Callback used to let the user override the texture selection on a per mesh basis
  55842. */
  55843. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55844. /**
  55845. * Instantiates a new glow Layer and references it to the scene.
  55846. * @param name The name of the layer
  55847. * @param scene The scene to use the layer in
  55848. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55849. */
  55850. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55851. /**
  55852. * Get the effect name of the layer.
  55853. * @return The effect name
  55854. */
  55855. getEffectName(): string;
  55856. /**
  55857. * Create the merge effect. This is the shader use to blit the information back
  55858. * to the main canvas at the end of the scene rendering.
  55859. */
  55860. protected _createMergeEffect(): Effect;
  55861. /**
  55862. * Creates the render target textures and post processes used in the glow layer.
  55863. */
  55864. protected _createTextureAndPostProcesses(): void;
  55865. /**
  55866. * Checks for the readiness of the element composing the layer.
  55867. * @param subMesh the mesh to check for
  55868. * @param useInstances specify wether or not to use instances to render the mesh
  55869. * @param emissiveTexture the associated emissive texture used to generate the glow
  55870. * @return true if ready otherwise, false
  55871. */
  55872. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55873. /**
  55874. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55875. */
  55876. needStencil(): boolean;
  55877. /**
  55878. * Returns true if the mesh can be rendered, otherwise false.
  55879. * @param mesh The mesh to render
  55880. * @param material The material used on the mesh
  55881. * @returns true if it can be rendered otherwise false
  55882. */
  55883. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55884. /**
  55885. * Implementation specific of rendering the generating effect on the main canvas.
  55886. * @param effect The effect used to render through
  55887. */
  55888. protected _internalRender(effect: Effect): void;
  55889. /**
  55890. * Sets the required values for both the emissive texture and and the main color.
  55891. */
  55892. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55893. /**
  55894. * Returns true if the mesh should render, otherwise false.
  55895. * @param mesh The mesh to render
  55896. * @returns true if it should render otherwise false
  55897. */
  55898. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55899. /**
  55900. * Adds specific effects defines.
  55901. * @param defines The defines to add specifics to.
  55902. */
  55903. protected _addCustomEffectDefines(defines: string[]): void;
  55904. /**
  55905. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55906. * @param mesh The mesh to exclude from the glow layer
  55907. */
  55908. addExcludedMesh(mesh: Mesh): void;
  55909. /**
  55910. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55911. * @param mesh The mesh to remove
  55912. */
  55913. removeExcludedMesh(mesh: Mesh): void;
  55914. /**
  55915. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55916. * @param mesh The mesh to include in the glow layer
  55917. */
  55918. addIncludedOnlyMesh(mesh: Mesh): void;
  55919. /**
  55920. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55921. * @param mesh The mesh to remove
  55922. */
  55923. removeIncludedOnlyMesh(mesh: Mesh): void;
  55924. /**
  55925. * Determine if a given mesh will be used in the glow layer
  55926. * @param mesh The mesh to test
  55927. * @returns true if the mesh will be highlighted by the current glow layer
  55928. */
  55929. hasMesh(mesh: AbstractMesh): boolean;
  55930. /**
  55931. * Defines whether the current material of the mesh should be use to render the effect.
  55932. * @param mesh defines the current mesh to render
  55933. */
  55934. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55935. /**
  55936. * Add a mesh to be rendered through its own material and not with emissive only.
  55937. * @param mesh The mesh for which we need to use its material
  55938. */
  55939. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55940. /**
  55941. * Remove a mesh from being rendered through its own material and not with emissive only.
  55942. * @param mesh The mesh for which we need to not use its material
  55943. */
  55944. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55945. /**
  55946. * Free any resources and references associated to a mesh.
  55947. * Internal use
  55948. * @param mesh The mesh to free.
  55949. * @hidden
  55950. */
  55951. _disposeMesh(mesh: Mesh): void;
  55952. /**
  55953. * Gets the class name of the effect layer
  55954. * @returns the string with the class name of the effect layer
  55955. */
  55956. getClassName(): string;
  55957. /**
  55958. * Serializes this glow layer
  55959. * @returns a serialized glow layer object
  55960. */
  55961. serialize(): any;
  55962. /**
  55963. * Creates a Glow Layer from parsed glow layer data
  55964. * @param parsedGlowLayer defines glow layer data
  55965. * @param scene defines the current scene
  55966. * @param rootUrl defines the root URL containing the glow layer information
  55967. * @returns a parsed Glow Layer
  55968. */
  55969. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55970. }
  55971. }
  55972. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55973. /** @hidden */
  55974. export var glowBlurPostProcessPixelShader: {
  55975. name: string;
  55976. shader: string;
  55977. };
  55978. }
  55979. declare module "babylonjs/Layers/highlightLayer" {
  55980. import { Observable } from "babylonjs/Misc/observable";
  55981. import { Nullable } from "babylonjs/types";
  55982. import { Camera } from "babylonjs/Cameras/camera";
  55983. import { Scene } from "babylonjs/scene";
  55984. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55986. import { Mesh } from "babylonjs/Meshes/mesh";
  55987. import { Effect } from "babylonjs/Materials/effect";
  55988. import { Material } from "babylonjs/Materials/material";
  55989. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55990. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55991. import "babylonjs/Shaders/glowMapMerge.fragment";
  55992. import "babylonjs/Shaders/glowMapMerge.vertex";
  55993. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55994. module "babylonjs/abstractScene" {
  55995. interface AbstractScene {
  55996. /**
  55997. * Return a the first highlight layer of the scene with a given name.
  55998. * @param name The name of the highlight layer to look for.
  55999. * @return The highlight layer if found otherwise null.
  56000. */
  56001. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56002. }
  56003. }
  56004. /**
  56005. * Highlight layer options. This helps customizing the behaviour
  56006. * of the highlight layer.
  56007. */
  56008. export interface IHighlightLayerOptions {
  56009. /**
  56010. * Multiplication factor apply to the canvas size to compute the render target size
  56011. * used to generated the glowing objects (the smaller the faster).
  56012. */
  56013. mainTextureRatio: number;
  56014. /**
  56015. * Enforces a fixed size texture to ensure resize independant blur.
  56016. */
  56017. mainTextureFixedSize?: number;
  56018. /**
  56019. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56020. * of the picture to blur (the smaller the faster).
  56021. */
  56022. blurTextureSizeRatio: number;
  56023. /**
  56024. * How big in texel of the blur texture is the vertical blur.
  56025. */
  56026. blurVerticalSize: number;
  56027. /**
  56028. * How big in texel of the blur texture is the horizontal blur.
  56029. */
  56030. blurHorizontalSize: number;
  56031. /**
  56032. * Alpha blending mode used to apply the blur. Default is combine.
  56033. */
  56034. alphaBlendingMode: number;
  56035. /**
  56036. * The camera attached to the layer.
  56037. */
  56038. camera: Nullable<Camera>;
  56039. /**
  56040. * Should we display highlight as a solid stroke?
  56041. */
  56042. isStroke?: boolean;
  56043. /**
  56044. * The rendering group to draw the layer in.
  56045. */
  56046. renderingGroupId: number;
  56047. }
  56048. /**
  56049. * The highlight layer Helps adding a glow effect around a mesh.
  56050. *
  56051. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56052. * glowy meshes to your scene.
  56053. *
  56054. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56055. */
  56056. export class HighlightLayer extends EffectLayer {
  56057. name: string;
  56058. /**
  56059. * Effect Name of the highlight layer.
  56060. */
  56061. static readonly EffectName: string;
  56062. /**
  56063. * The neutral color used during the preparation of the glow effect.
  56064. * This is black by default as the blend operation is a blend operation.
  56065. */
  56066. static NeutralColor: Color4;
  56067. /**
  56068. * Stencil value used for glowing meshes.
  56069. */
  56070. static GlowingMeshStencilReference: number;
  56071. /**
  56072. * Stencil value used for the other meshes in the scene.
  56073. */
  56074. static NormalMeshStencilReference: number;
  56075. /**
  56076. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56077. */
  56078. innerGlow: boolean;
  56079. /**
  56080. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56081. */
  56082. outerGlow: boolean;
  56083. /**
  56084. * Specifies the horizontal size of the blur.
  56085. */
  56086. set blurHorizontalSize(value: number);
  56087. /**
  56088. * Specifies the vertical size of the blur.
  56089. */
  56090. set blurVerticalSize(value: number);
  56091. /**
  56092. * Gets the horizontal size of the blur.
  56093. */
  56094. get blurHorizontalSize(): number;
  56095. /**
  56096. * Gets the vertical size of the blur.
  56097. */
  56098. get blurVerticalSize(): number;
  56099. /**
  56100. * An event triggered when the highlight layer is being blurred.
  56101. */
  56102. onBeforeBlurObservable: Observable<HighlightLayer>;
  56103. /**
  56104. * An event triggered when the highlight layer has been blurred.
  56105. */
  56106. onAfterBlurObservable: Observable<HighlightLayer>;
  56107. private _instanceGlowingMeshStencilReference;
  56108. private _options;
  56109. private _downSamplePostprocess;
  56110. private _horizontalBlurPostprocess;
  56111. private _verticalBlurPostprocess;
  56112. private _blurTexture;
  56113. private _meshes;
  56114. private _excludedMeshes;
  56115. /**
  56116. * Instantiates a new highlight Layer and references it to the scene..
  56117. * @param name The name of the layer
  56118. * @param scene The scene to use the layer in
  56119. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56120. */
  56121. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56122. /**
  56123. * Get the effect name of the layer.
  56124. * @return The effect name
  56125. */
  56126. getEffectName(): string;
  56127. /**
  56128. * Create the merge effect. This is the shader use to blit the information back
  56129. * to the main canvas at the end of the scene rendering.
  56130. */
  56131. protected _createMergeEffect(): Effect;
  56132. /**
  56133. * Creates the render target textures and post processes used in the highlight layer.
  56134. */
  56135. protected _createTextureAndPostProcesses(): void;
  56136. /**
  56137. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56138. */
  56139. needStencil(): boolean;
  56140. /**
  56141. * Checks for the readiness of the element composing the layer.
  56142. * @param subMesh the mesh to check for
  56143. * @param useInstances specify wether or not to use instances to render the mesh
  56144. * @param emissiveTexture the associated emissive texture used to generate the glow
  56145. * @return true if ready otherwise, false
  56146. */
  56147. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56148. /**
  56149. * Implementation specific of rendering the generating effect on the main canvas.
  56150. * @param effect The effect used to render through
  56151. */
  56152. protected _internalRender(effect: Effect): void;
  56153. /**
  56154. * Returns true if the layer contains information to display, otherwise false.
  56155. */
  56156. shouldRender(): boolean;
  56157. /**
  56158. * Returns true if the mesh should render, otherwise false.
  56159. * @param mesh The mesh to render
  56160. * @returns true if it should render otherwise false
  56161. */
  56162. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56163. /**
  56164. * Sets the required values for both the emissive texture and and the main color.
  56165. */
  56166. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56167. /**
  56168. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56169. * @param mesh The mesh to exclude from the highlight layer
  56170. */
  56171. addExcludedMesh(mesh: Mesh): void;
  56172. /**
  56173. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56174. * @param mesh The mesh to highlight
  56175. */
  56176. removeExcludedMesh(mesh: Mesh): void;
  56177. /**
  56178. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56179. * @param mesh mesh to test
  56180. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56181. */
  56182. hasMesh(mesh: AbstractMesh): boolean;
  56183. /**
  56184. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56185. * @param mesh The mesh to highlight
  56186. * @param color The color of the highlight
  56187. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56188. */
  56189. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56190. /**
  56191. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56192. * @param mesh The mesh to highlight
  56193. */
  56194. removeMesh(mesh: Mesh): void;
  56195. /**
  56196. * Remove all the meshes currently referenced in the highlight layer
  56197. */
  56198. removeAllMeshes(): void;
  56199. /**
  56200. * Force the stencil to the normal expected value for none glowing parts
  56201. */
  56202. private _defaultStencilReference;
  56203. /**
  56204. * Free any resources and references associated to a mesh.
  56205. * Internal use
  56206. * @param mesh The mesh to free.
  56207. * @hidden
  56208. */
  56209. _disposeMesh(mesh: Mesh): void;
  56210. /**
  56211. * Dispose the highlight layer and free resources.
  56212. */
  56213. dispose(): void;
  56214. /**
  56215. * Gets the class name of the effect layer
  56216. * @returns the string with the class name of the effect layer
  56217. */
  56218. getClassName(): string;
  56219. /**
  56220. * Serializes this Highlight layer
  56221. * @returns a serialized Highlight layer object
  56222. */
  56223. serialize(): any;
  56224. /**
  56225. * Creates a Highlight layer from parsed Highlight layer data
  56226. * @param parsedHightlightLayer defines the Highlight layer data
  56227. * @param scene defines the current scene
  56228. * @param rootUrl defines the root URL containing the Highlight layer information
  56229. * @returns a parsed Highlight layer
  56230. */
  56231. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56232. }
  56233. }
  56234. declare module "babylonjs/Layers/layerSceneComponent" {
  56235. import { Scene } from "babylonjs/scene";
  56236. import { ISceneComponent } from "babylonjs/sceneComponent";
  56237. import { Layer } from "babylonjs/Layers/layer";
  56238. import { AbstractScene } from "babylonjs/abstractScene";
  56239. module "babylonjs/abstractScene" {
  56240. interface AbstractScene {
  56241. /**
  56242. * The list of layers (background and foreground) of the scene
  56243. */
  56244. layers: Array<Layer>;
  56245. }
  56246. }
  56247. /**
  56248. * Defines the layer scene component responsible to manage any layers
  56249. * in a given scene.
  56250. */
  56251. export class LayerSceneComponent implements ISceneComponent {
  56252. /**
  56253. * The component name helpfull to identify the component in the list of scene components.
  56254. */
  56255. readonly name: string;
  56256. /**
  56257. * The scene the component belongs to.
  56258. */
  56259. scene: Scene;
  56260. private _engine;
  56261. /**
  56262. * Creates a new instance of the component for the given scene
  56263. * @param scene Defines the scene to register the component in
  56264. */
  56265. constructor(scene: Scene);
  56266. /**
  56267. * Registers the component in a given scene
  56268. */
  56269. register(): void;
  56270. /**
  56271. * Rebuilds the elements related to this component in case of
  56272. * context lost for instance.
  56273. */
  56274. rebuild(): void;
  56275. /**
  56276. * Disposes the component and the associated ressources.
  56277. */
  56278. dispose(): void;
  56279. private _draw;
  56280. private _drawCameraPredicate;
  56281. private _drawCameraBackground;
  56282. private _drawCameraForeground;
  56283. private _drawRenderTargetPredicate;
  56284. private _drawRenderTargetBackground;
  56285. private _drawRenderTargetForeground;
  56286. /**
  56287. * Adds all the elements from the container to the scene
  56288. * @param container the container holding the elements
  56289. */
  56290. addFromContainer(container: AbstractScene): void;
  56291. /**
  56292. * Removes all the elements in the container from the scene
  56293. * @param container contains the elements to remove
  56294. * @param dispose if the removed element should be disposed (default: false)
  56295. */
  56296. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56297. }
  56298. }
  56299. declare module "babylonjs/Shaders/layer.fragment" {
  56300. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56301. /** @hidden */
  56302. export var layerPixelShader: {
  56303. name: string;
  56304. shader: string;
  56305. };
  56306. }
  56307. declare module "babylonjs/Shaders/layer.vertex" {
  56308. /** @hidden */
  56309. export var layerVertexShader: {
  56310. name: string;
  56311. shader: string;
  56312. };
  56313. }
  56314. declare module "babylonjs/Layers/layer" {
  56315. import { Observable } from "babylonjs/Misc/observable";
  56316. import { Nullable } from "babylonjs/types";
  56317. import { Scene } from "babylonjs/scene";
  56318. import { Vector2 } from "babylonjs/Maths/math.vector";
  56319. import { Color4 } from "babylonjs/Maths/math.color";
  56320. import { Texture } from "babylonjs/Materials/Textures/texture";
  56321. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56322. import "babylonjs/Shaders/layer.fragment";
  56323. import "babylonjs/Shaders/layer.vertex";
  56324. /**
  56325. * This represents a full screen 2d layer.
  56326. * This can be useful to display a picture in the background of your scene for instance.
  56327. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56328. */
  56329. export class Layer {
  56330. /**
  56331. * Define the name of the layer.
  56332. */
  56333. name: string;
  56334. /**
  56335. * Define the texture the layer should display.
  56336. */
  56337. texture: Nullable<Texture>;
  56338. /**
  56339. * Is the layer in background or foreground.
  56340. */
  56341. isBackground: boolean;
  56342. /**
  56343. * Define the color of the layer (instead of texture).
  56344. */
  56345. color: Color4;
  56346. /**
  56347. * Define the scale of the layer in order to zoom in out of the texture.
  56348. */
  56349. scale: Vector2;
  56350. /**
  56351. * Define an offset for the layer in order to shift the texture.
  56352. */
  56353. offset: Vector2;
  56354. /**
  56355. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56356. */
  56357. alphaBlendingMode: number;
  56358. /**
  56359. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56360. * Alpha test will not mix with the background color in case of transparency.
  56361. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56362. */
  56363. alphaTest: boolean;
  56364. /**
  56365. * Define a mask to restrict the layer to only some of the scene cameras.
  56366. */
  56367. layerMask: number;
  56368. /**
  56369. * Define the list of render target the layer is visible into.
  56370. */
  56371. renderTargetTextures: RenderTargetTexture[];
  56372. /**
  56373. * Define if the layer is only used in renderTarget or if it also
  56374. * renders in the main frame buffer of the canvas.
  56375. */
  56376. renderOnlyInRenderTargetTextures: boolean;
  56377. private _scene;
  56378. private _vertexBuffers;
  56379. private _indexBuffer;
  56380. private _effect;
  56381. private _previousDefines;
  56382. /**
  56383. * An event triggered when the layer is disposed.
  56384. */
  56385. onDisposeObservable: Observable<Layer>;
  56386. private _onDisposeObserver;
  56387. /**
  56388. * Back compatibility with callback before the onDisposeObservable existed.
  56389. * The set callback will be triggered when the layer has been disposed.
  56390. */
  56391. set onDispose(callback: () => void);
  56392. /**
  56393. * An event triggered before rendering the scene
  56394. */
  56395. onBeforeRenderObservable: Observable<Layer>;
  56396. private _onBeforeRenderObserver;
  56397. /**
  56398. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56399. * The set callback will be triggered just before rendering the layer.
  56400. */
  56401. set onBeforeRender(callback: () => void);
  56402. /**
  56403. * An event triggered after rendering the scene
  56404. */
  56405. onAfterRenderObservable: Observable<Layer>;
  56406. private _onAfterRenderObserver;
  56407. /**
  56408. * Back compatibility with callback before the onAfterRenderObservable existed.
  56409. * The set callback will be triggered just after rendering the layer.
  56410. */
  56411. set onAfterRender(callback: () => void);
  56412. /**
  56413. * Instantiates a new layer.
  56414. * This represents a full screen 2d layer.
  56415. * This can be useful to display a picture in the background of your scene for instance.
  56416. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56417. * @param name Define the name of the layer in the scene
  56418. * @param imgUrl Define the url of the texture to display in the layer
  56419. * @param scene Define the scene the layer belongs to
  56420. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56421. * @param color Defines a color for the layer
  56422. */
  56423. constructor(
  56424. /**
  56425. * Define the name of the layer.
  56426. */
  56427. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56428. private _createIndexBuffer;
  56429. /** @hidden */
  56430. _rebuild(): void;
  56431. /**
  56432. * Renders the layer in the scene.
  56433. */
  56434. render(): void;
  56435. /**
  56436. * Disposes and releases the associated ressources.
  56437. */
  56438. dispose(): void;
  56439. }
  56440. }
  56441. declare module "babylonjs/Layers/index" {
  56442. export * from "babylonjs/Layers/effectLayer";
  56443. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56444. export * from "babylonjs/Layers/glowLayer";
  56445. export * from "babylonjs/Layers/highlightLayer";
  56446. export * from "babylonjs/Layers/layer";
  56447. export * from "babylonjs/Layers/layerSceneComponent";
  56448. }
  56449. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56450. /** @hidden */
  56451. export var lensFlarePixelShader: {
  56452. name: string;
  56453. shader: string;
  56454. };
  56455. }
  56456. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56457. /** @hidden */
  56458. export var lensFlareVertexShader: {
  56459. name: string;
  56460. shader: string;
  56461. };
  56462. }
  56463. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56464. import { Scene } from "babylonjs/scene";
  56465. import { Vector3 } from "babylonjs/Maths/math.vector";
  56466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56467. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56468. import "babylonjs/Shaders/lensFlare.fragment";
  56469. import "babylonjs/Shaders/lensFlare.vertex";
  56470. import { Viewport } from "babylonjs/Maths/math.viewport";
  56471. /**
  56472. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56473. * It is usually composed of several `lensFlare`.
  56474. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56475. */
  56476. export class LensFlareSystem {
  56477. /**
  56478. * Define the name of the lens flare system
  56479. */
  56480. name: string;
  56481. /**
  56482. * List of lens flares used in this system.
  56483. */
  56484. lensFlares: LensFlare[];
  56485. /**
  56486. * Define a limit from the border the lens flare can be visible.
  56487. */
  56488. borderLimit: number;
  56489. /**
  56490. * Define a viewport border we do not want to see the lens flare in.
  56491. */
  56492. viewportBorder: number;
  56493. /**
  56494. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56495. */
  56496. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56497. /**
  56498. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56499. */
  56500. layerMask: number;
  56501. /**
  56502. * Define the id of the lens flare system in the scene.
  56503. * (equal to name by default)
  56504. */
  56505. id: string;
  56506. private _scene;
  56507. private _emitter;
  56508. private _vertexBuffers;
  56509. private _indexBuffer;
  56510. private _effect;
  56511. private _positionX;
  56512. private _positionY;
  56513. private _isEnabled;
  56514. /** @hidden */
  56515. static _SceneComponentInitialization: (scene: Scene) => void;
  56516. /**
  56517. * Instantiates a lens flare system.
  56518. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56519. * It is usually composed of several `lensFlare`.
  56520. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56521. * @param name Define the name of the lens flare system in the scene
  56522. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56523. * @param scene Define the scene the lens flare system belongs to
  56524. */
  56525. constructor(
  56526. /**
  56527. * Define the name of the lens flare system
  56528. */
  56529. name: string, emitter: any, scene: Scene);
  56530. /**
  56531. * Define if the lens flare system is enabled.
  56532. */
  56533. get isEnabled(): boolean;
  56534. set isEnabled(value: boolean);
  56535. /**
  56536. * Get the scene the effects belongs to.
  56537. * @returns the scene holding the lens flare system
  56538. */
  56539. getScene(): Scene;
  56540. /**
  56541. * Get the emitter of the lens flare system.
  56542. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56543. * @returns the emitter of the lens flare system
  56544. */
  56545. getEmitter(): any;
  56546. /**
  56547. * Set the emitter of the lens flare system.
  56548. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56549. * @param newEmitter Define the new emitter of the system
  56550. */
  56551. setEmitter(newEmitter: any): void;
  56552. /**
  56553. * Get the lens flare system emitter position.
  56554. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56555. * @returns the position
  56556. */
  56557. getEmitterPosition(): Vector3;
  56558. /**
  56559. * @hidden
  56560. */
  56561. computeEffectivePosition(globalViewport: Viewport): boolean;
  56562. /** @hidden */
  56563. _isVisible(): boolean;
  56564. /**
  56565. * @hidden
  56566. */
  56567. render(): boolean;
  56568. /**
  56569. * Dispose and release the lens flare with its associated resources.
  56570. */
  56571. dispose(): void;
  56572. /**
  56573. * Parse a lens flare system from a JSON repressentation
  56574. * @param parsedLensFlareSystem Define the JSON to parse
  56575. * @param scene Define the scene the parsed system should be instantiated in
  56576. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56577. * @returns the parsed system
  56578. */
  56579. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56580. /**
  56581. * Serialize the current Lens Flare System into a JSON representation.
  56582. * @returns the serialized JSON
  56583. */
  56584. serialize(): any;
  56585. }
  56586. }
  56587. declare module "babylonjs/LensFlares/lensFlare" {
  56588. import { Nullable } from "babylonjs/types";
  56589. import { Color3 } from "babylonjs/Maths/math.color";
  56590. import { Texture } from "babylonjs/Materials/Textures/texture";
  56591. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56592. /**
  56593. * This represents one of the lens effect in a `lensFlareSystem`.
  56594. * It controls one of the indiviual texture used in the effect.
  56595. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56596. */
  56597. export class LensFlare {
  56598. /**
  56599. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56600. */
  56601. size: number;
  56602. /**
  56603. * 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.
  56604. */
  56605. position: number;
  56606. /**
  56607. * Define the lens color.
  56608. */
  56609. color: Color3;
  56610. /**
  56611. * Define the lens texture.
  56612. */
  56613. texture: Nullable<Texture>;
  56614. /**
  56615. * Define the alpha mode to render this particular lens.
  56616. */
  56617. alphaMode: number;
  56618. private _system;
  56619. /**
  56620. * Creates a new Lens Flare.
  56621. * This represents one of the lens effect in a `lensFlareSystem`.
  56622. * It controls one of the indiviual texture used in the effect.
  56623. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56624. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56625. * @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.
  56626. * @param color Define the lens color
  56627. * @param imgUrl Define the lens texture url
  56628. * @param system Define the `lensFlareSystem` this flare is part of
  56629. * @returns The newly created Lens Flare
  56630. */
  56631. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56632. /**
  56633. * Instantiates a new Lens Flare.
  56634. * This represents one of the lens effect in a `lensFlareSystem`.
  56635. * It controls one of the indiviual texture used in the effect.
  56636. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56637. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56638. * @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.
  56639. * @param color Define the lens color
  56640. * @param imgUrl Define the lens texture url
  56641. * @param system Define the `lensFlareSystem` this flare is part of
  56642. */
  56643. constructor(
  56644. /**
  56645. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56646. */
  56647. size: number,
  56648. /**
  56649. * 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.
  56650. */
  56651. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56652. /**
  56653. * Dispose and release the lens flare with its associated resources.
  56654. */
  56655. dispose(): void;
  56656. }
  56657. }
  56658. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56659. import { Nullable } from "babylonjs/types";
  56660. import { Scene } from "babylonjs/scene";
  56661. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56662. import { AbstractScene } from "babylonjs/abstractScene";
  56663. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56664. module "babylonjs/abstractScene" {
  56665. interface AbstractScene {
  56666. /**
  56667. * The list of lens flare system added to the scene
  56668. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56669. */
  56670. lensFlareSystems: Array<LensFlareSystem>;
  56671. /**
  56672. * Removes the given lens flare system from this scene.
  56673. * @param toRemove The lens flare system to remove
  56674. * @returns The index of the removed lens flare system
  56675. */
  56676. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56677. /**
  56678. * Adds the given lens flare system to this scene
  56679. * @param newLensFlareSystem The lens flare system to add
  56680. */
  56681. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56682. /**
  56683. * Gets a lens flare system using its name
  56684. * @param name defines the name to look for
  56685. * @returns the lens flare system or null if not found
  56686. */
  56687. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56688. /**
  56689. * Gets a lens flare system using its id
  56690. * @param id defines the id to look for
  56691. * @returns the lens flare system or null if not found
  56692. */
  56693. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56694. }
  56695. }
  56696. /**
  56697. * Defines the lens flare scene component responsible to manage any lens flares
  56698. * in a given scene.
  56699. */
  56700. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56701. /**
  56702. * The component name helpfull to identify the component in the list of scene components.
  56703. */
  56704. readonly name: string;
  56705. /**
  56706. * The scene the component belongs to.
  56707. */
  56708. scene: Scene;
  56709. /**
  56710. * Creates a new instance of the component for the given scene
  56711. * @param scene Defines the scene to register the component in
  56712. */
  56713. constructor(scene: Scene);
  56714. /**
  56715. * Registers the component in a given scene
  56716. */
  56717. register(): void;
  56718. /**
  56719. * Rebuilds the elements related to this component in case of
  56720. * context lost for instance.
  56721. */
  56722. rebuild(): void;
  56723. /**
  56724. * Adds all the elements from the container to the scene
  56725. * @param container the container holding the elements
  56726. */
  56727. addFromContainer(container: AbstractScene): void;
  56728. /**
  56729. * Removes all the elements in the container from the scene
  56730. * @param container contains the elements to remove
  56731. * @param dispose if the removed element should be disposed (default: false)
  56732. */
  56733. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56734. /**
  56735. * Serializes the component data to the specified json object
  56736. * @param serializationObject The object to serialize to
  56737. */
  56738. serialize(serializationObject: any): void;
  56739. /**
  56740. * Disposes the component and the associated ressources.
  56741. */
  56742. dispose(): void;
  56743. private _draw;
  56744. }
  56745. }
  56746. declare module "babylonjs/LensFlares/index" {
  56747. export * from "babylonjs/LensFlares/lensFlare";
  56748. export * from "babylonjs/LensFlares/lensFlareSystem";
  56749. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56750. }
  56751. declare module "babylonjs/Shaders/depth.fragment" {
  56752. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56753. /** @hidden */
  56754. export var depthPixelShader: {
  56755. name: string;
  56756. shader: string;
  56757. };
  56758. }
  56759. declare module "babylonjs/Shaders/depth.vertex" {
  56760. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56761. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56763. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56765. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56766. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56767. /** @hidden */
  56768. export var depthVertexShader: {
  56769. name: string;
  56770. shader: string;
  56771. };
  56772. }
  56773. declare module "babylonjs/Rendering/depthRenderer" {
  56774. import { Nullable } from "babylonjs/types";
  56775. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56776. import { Scene } from "babylonjs/scene";
  56777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56778. import { Camera } from "babylonjs/Cameras/camera";
  56779. import "babylonjs/Shaders/depth.fragment";
  56780. import "babylonjs/Shaders/depth.vertex";
  56781. /**
  56782. * This represents a depth renderer in Babylon.
  56783. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56784. */
  56785. export class DepthRenderer {
  56786. private _scene;
  56787. private _depthMap;
  56788. private _effect;
  56789. private readonly _storeNonLinearDepth;
  56790. private readonly _clearColor;
  56791. /** Get if the depth renderer is using packed depth or not */
  56792. readonly isPacked: boolean;
  56793. private _cachedDefines;
  56794. private _camera;
  56795. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56796. enabled: boolean;
  56797. /**
  56798. * Specifiess that the depth renderer will only be used within
  56799. * the camera it is created for.
  56800. * This can help forcing its rendering during the camera processing.
  56801. */
  56802. useOnlyInActiveCamera: boolean;
  56803. /** @hidden */
  56804. static _SceneComponentInitialization: (scene: Scene) => void;
  56805. /**
  56806. * Instantiates a depth renderer
  56807. * @param scene The scene the renderer belongs to
  56808. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56809. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56810. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56811. */
  56812. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56813. /**
  56814. * Creates the depth rendering effect and checks if the effect is ready.
  56815. * @param subMesh The submesh to be used to render the depth map of
  56816. * @param useInstances If multiple world instances should be used
  56817. * @returns if the depth renderer is ready to render the depth map
  56818. */
  56819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56820. /**
  56821. * Gets the texture which the depth map will be written to.
  56822. * @returns The depth map texture
  56823. */
  56824. getDepthMap(): RenderTargetTexture;
  56825. /**
  56826. * Disposes of the depth renderer.
  56827. */
  56828. dispose(): void;
  56829. }
  56830. }
  56831. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56832. /** @hidden */
  56833. export var minmaxReduxPixelShader: {
  56834. name: string;
  56835. shader: string;
  56836. };
  56837. }
  56838. declare module "babylonjs/Misc/minMaxReducer" {
  56839. import { Nullable } from "babylonjs/types";
  56840. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56841. import { Camera } from "babylonjs/Cameras/camera";
  56842. import { Observer } from "babylonjs/Misc/observable";
  56843. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56844. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56845. import { Observable } from "babylonjs/Misc/observable";
  56846. import "babylonjs/Shaders/minmaxRedux.fragment";
  56847. /**
  56848. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56849. * and maximum values from all values of the texture.
  56850. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56851. * The source values are read from the red channel of the texture.
  56852. */
  56853. export class MinMaxReducer {
  56854. /**
  56855. * Observable triggered when the computation has been performed
  56856. */
  56857. onAfterReductionPerformed: Observable<{
  56858. min: number;
  56859. max: number;
  56860. }>;
  56861. protected _camera: Camera;
  56862. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56863. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56864. protected _postProcessManager: PostProcessManager;
  56865. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56866. protected _forceFullscreenViewport: boolean;
  56867. /**
  56868. * Creates a min/max reducer
  56869. * @param camera The camera to use for the post processes
  56870. */
  56871. constructor(camera: Camera);
  56872. /**
  56873. * Gets the texture used to read the values from.
  56874. */
  56875. get sourceTexture(): Nullable<RenderTargetTexture>;
  56876. /**
  56877. * Sets the source texture to read the values from.
  56878. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56879. * because in such textures '1' value must not be taken into account to compute the maximum
  56880. * as this value is used to clear the texture.
  56881. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56882. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56883. * @param depthRedux Indicates if the texture is a depth texture or not
  56884. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56885. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56886. */
  56887. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56888. /**
  56889. * Defines the refresh rate of the computation.
  56890. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56891. */
  56892. get refreshRate(): number;
  56893. set refreshRate(value: number);
  56894. protected _activated: boolean;
  56895. /**
  56896. * Gets the activation status of the reducer
  56897. */
  56898. get activated(): boolean;
  56899. /**
  56900. * Activates the reduction computation.
  56901. * When activated, the observers registered in onAfterReductionPerformed are
  56902. * called after the compuation is performed
  56903. */
  56904. activate(): void;
  56905. /**
  56906. * Deactivates the reduction computation.
  56907. */
  56908. deactivate(): void;
  56909. /**
  56910. * Disposes the min/max reducer
  56911. * @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.
  56912. */
  56913. dispose(disposeAll?: boolean): void;
  56914. }
  56915. }
  56916. declare module "babylonjs/Misc/depthReducer" {
  56917. import { Nullable } from "babylonjs/types";
  56918. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56919. import { Camera } from "babylonjs/Cameras/camera";
  56920. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56921. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56922. /**
  56923. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56924. */
  56925. export class DepthReducer extends MinMaxReducer {
  56926. private _depthRenderer;
  56927. private _depthRendererId;
  56928. /**
  56929. * Gets the depth renderer used for the computation.
  56930. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56931. */
  56932. get depthRenderer(): Nullable<DepthRenderer>;
  56933. /**
  56934. * Creates a depth reducer
  56935. * @param camera The camera used to render the depth texture
  56936. */
  56937. constructor(camera: Camera);
  56938. /**
  56939. * Sets the depth renderer to use to generate the depth map
  56940. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56941. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56942. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56943. */
  56944. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56945. /** @hidden */
  56946. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56947. /**
  56948. * Activates the reduction computation.
  56949. * When activated, the observers registered in onAfterReductionPerformed are
  56950. * called after the compuation is performed
  56951. */
  56952. activate(): void;
  56953. /**
  56954. * Deactivates the reduction computation.
  56955. */
  56956. deactivate(): void;
  56957. /**
  56958. * Disposes the depth reducer
  56959. * @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.
  56960. */
  56961. dispose(disposeAll?: boolean): void;
  56962. }
  56963. }
  56964. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56965. import { Nullable } from "babylonjs/types";
  56966. import { Scene } from "babylonjs/scene";
  56967. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56968. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56969. import { Effect } from "babylonjs/Materials/effect";
  56970. import "babylonjs/Shaders/shadowMap.fragment";
  56971. import "babylonjs/Shaders/shadowMap.vertex";
  56972. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56973. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56974. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56975. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56976. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56977. /**
  56978. * A CSM implementation allowing casting shadows on large scenes.
  56979. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56980. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56981. */
  56982. export class CascadedShadowGenerator extends ShadowGenerator {
  56983. private static readonly frustumCornersNDCSpace;
  56984. /**
  56985. * Name of the CSM class
  56986. */
  56987. static CLASSNAME: string;
  56988. /**
  56989. * Defines the default number of cascades used by the CSM.
  56990. */
  56991. static readonly DEFAULT_CASCADES_COUNT: number;
  56992. /**
  56993. * Defines the minimum number of cascades used by the CSM.
  56994. */
  56995. static readonly MIN_CASCADES_COUNT: number;
  56996. /**
  56997. * Defines the maximum number of cascades used by the CSM.
  56998. */
  56999. static readonly MAX_CASCADES_COUNT: number;
  57000. protected _validateFilter(filter: number): number;
  57001. /**
  57002. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57003. */
  57004. penumbraDarkness: number;
  57005. private _numCascades;
  57006. /**
  57007. * Gets or set the number of cascades used by the CSM.
  57008. */
  57009. get numCascades(): number;
  57010. set numCascades(value: number);
  57011. /**
  57012. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57013. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57014. */
  57015. stabilizeCascades: boolean;
  57016. private _freezeShadowCastersBoundingInfo;
  57017. private _freezeShadowCastersBoundingInfoObservable;
  57018. /**
  57019. * Enables or disables the shadow casters bounding info computation.
  57020. * If your shadow casters don't move, you can disable this feature.
  57021. * If it is enabled, the bounding box computation is done every frame.
  57022. */
  57023. get freezeShadowCastersBoundingInfo(): boolean;
  57024. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57025. private _scbiMin;
  57026. private _scbiMax;
  57027. protected _computeShadowCastersBoundingInfo(): void;
  57028. protected _shadowCastersBoundingInfo: BoundingInfo;
  57029. /**
  57030. * Gets or sets the shadow casters bounding info.
  57031. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57032. * so that the system won't overwrite the bounds you provide
  57033. */
  57034. get shadowCastersBoundingInfo(): BoundingInfo;
  57035. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57036. protected _breaksAreDirty: boolean;
  57037. protected _minDistance: number;
  57038. protected _maxDistance: number;
  57039. /**
  57040. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57041. *
  57042. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57043. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57044. * @param min minimal distance for the breaks (default to 0.)
  57045. * @param max maximal distance for the breaks (default to 1.)
  57046. */
  57047. setMinMaxDistance(min: number, max: number): void;
  57048. /** Gets the minimal distance used in the cascade break computation */
  57049. get minDistance(): number;
  57050. /** Gets the maximal distance used in the cascade break computation */
  57051. get maxDistance(): number;
  57052. /**
  57053. * Gets the class name of that object
  57054. * @returns "CascadedShadowGenerator"
  57055. */
  57056. getClassName(): string;
  57057. private _cascadeMinExtents;
  57058. private _cascadeMaxExtents;
  57059. /**
  57060. * Gets a cascade minimum extents
  57061. * @param cascadeIndex index of the cascade
  57062. * @returns the minimum cascade extents
  57063. */
  57064. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57065. /**
  57066. * Gets a cascade maximum extents
  57067. * @param cascadeIndex index of the cascade
  57068. * @returns the maximum cascade extents
  57069. */
  57070. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57071. private _cascades;
  57072. private _currentLayer;
  57073. private _viewSpaceFrustumsZ;
  57074. private _viewMatrices;
  57075. private _projectionMatrices;
  57076. private _transformMatrices;
  57077. private _transformMatricesAsArray;
  57078. private _frustumLengths;
  57079. private _lightSizeUVCorrection;
  57080. private _depthCorrection;
  57081. private _frustumCornersWorldSpace;
  57082. private _frustumCenter;
  57083. private _shadowCameraPos;
  57084. private _shadowMaxZ;
  57085. /**
  57086. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57087. * It defaults to camera.maxZ
  57088. */
  57089. get shadowMaxZ(): number;
  57090. /**
  57091. * Sets the shadow max z distance.
  57092. */
  57093. set shadowMaxZ(value: number);
  57094. protected _debug: boolean;
  57095. /**
  57096. * Gets or sets the debug flag.
  57097. * When enabled, the cascades are materialized by different colors on the screen.
  57098. */
  57099. get debug(): boolean;
  57100. set debug(dbg: boolean);
  57101. private _depthClamp;
  57102. /**
  57103. * Gets or sets the depth clamping value.
  57104. *
  57105. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57106. * to account for the shadow casters far away.
  57107. *
  57108. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57109. */
  57110. get depthClamp(): boolean;
  57111. set depthClamp(value: boolean);
  57112. private _cascadeBlendPercentage;
  57113. /**
  57114. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57115. * It defaults to 0.1 (10% blending).
  57116. */
  57117. get cascadeBlendPercentage(): number;
  57118. set cascadeBlendPercentage(value: number);
  57119. private _lambda;
  57120. /**
  57121. * Gets or set the lambda parameter.
  57122. * This parameter is used to split the camera frustum and create the cascades.
  57123. * 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.
  57124. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57125. */
  57126. get lambda(): number;
  57127. set lambda(value: number);
  57128. /**
  57129. * Gets the view matrix corresponding to a given cascade
  57130. * @param cascadeNum cascade to retrieve the view matrix from
  57131. * @returns the cascade view matrix
  57132. */
  57133. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57134. /**
  57135. * Gets the projection matrix corresponding to a given cascade
  57136. * @param cascadeNum cascade to retrieve the projection matrix from
  57137. * @returns the cascade projection matrix
  57138. */
  57139. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57140. /**
  57141. * Gets the transformation matrix corresponding to a given cascade
  57142. * @param cascadeNum cascade to retrieve the transformation matrix from
  57143. * @returns the cascade transformation matrix
  57144. */
  57145. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57146. private _depthRenderer;
  57147. /**
  57148. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57149. *
  57150. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57151. *
  57152. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57153. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57154. * @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
  57155. */
  57156. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57157. private _depthReducer;
  57158. private _autoCalcDepthBounds;
  57159. /**
  57160. * Gets or sets the autoCalcDepthBounds property.
  57161. *
  57162. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57163. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57164. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57165. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57166. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57167. */
  57168. get autoCalcDepthBounds(): boolean;
  57169. set autoCalcDepthBounds(value: boolean);
  57170. /**
  57171. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57172. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57173. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57174. * for setting the refresh rate on the renderer yourself!
  57175. */
  57176. get autoCalcDepthBoundsRefreshRate(): number;
  57177. set autoCalcDepthBoundsRefreshRate(value: number);
  57178. /**
  57179. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57180. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57181. * you change the camera near/far planes!
  57182. */
  57183. splitFrustum(): void;
  57184. private _splitFrustum;
  57185. private _computeMatrices;
  57186. private _computeFrustumInWorldSpace;
  57187. private _computeCascadeFrustum;
  57188. /**
  57189. * Support test.
  57190. */
  57191. static get IsSupported(): boolean;
  57192. /** @hidden */
  57193. static _SceneComponentInitialization: (scene: Scene) => void;
  57194. /**
  57195. * Creates a Cascaded Shadow Generator object.
  57196. * A ShadowGenerator is the required tool to use the shadows.
  57197. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57198. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57199. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57200. * @param light The directional light object generating the shadows.
  57201. * @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.
  57202. */
  57203. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57204. protected _initializeGenerator(): void;
  57205. protected _createTargetRenderTexture(): void;
  57206. protected _initializeShadowMap(): void;
  57207. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  57208. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57209. /**
  57210. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57211. * @param defines Defines of the material we want to update
  57212. * @param lightIndex Index of the light in the enabled light list of the material
  57213. */
  57214. prepareDefines(defines: any, lightIndex: number): void;
  57215. /**
  57216. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57217. * defined in the generator but impacting the effect).
  57218. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57219. * @param effect The effect we are binfing the information for
  57220. */
  57221. bindShadowLight(lightIndex: string, effect: Effect): void;
  57222. /**
  57223. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57224. * (eq to view projection * shadow projection matrices)
  57225. * @returns The transform matrix used to create the shadow map
  57226. */
  57227. getTransformMatrix(): Matrix;
  57228. /**
  57229. * Disposes the ShadowGenerator.
  57230. * Returns nothing.
  57231. */
  57232. dispose(): void;
  57233. /**
  57234. * Serializes the shadow generator setup to a json object.
  57235. * @returns The serialized JSON object
  57236. */
  57237. serialize(): any;
  57238. /**
  57239. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57240. * @param parsedShadowGenerator The JSON object to parse
  57241. * @param scene The scene to create the shadow map for
  57242. * @returns The parsed shadow generator
  57243. */
  57244. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57245. }
  57246. }
  57247. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57248. import { Scene } from "babylonjs/scene";
  57249. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57250. import { AbstractScene } from "babylonjs/abstractScene";
  57251. /**
  57252. * Defines the shadow generator component responsible to manage any shadow generators
  57253. * in a given scene.
  57254. */
  57255. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57256. /**
  57257. * The component name helpfull to identify the component in the list of scene components.
  57258. */
  57259. readonly name: string;
  57260. /**
  57261. * The scene the component belongs to.
  57262. */
  57263. scene: Scene;
  57264. /**
  57265. * Creates a new instance of the component for the given scene
  57266. * @param scene Defines the scene to register the component in
  57267. */
  57268. constructor(scene: Scene);
  57269. /**
  57270. * Registers the component in a given scene
  57271. */
  57272. register(): void;
  57273. /**
  57274. * Rebuilds the elements related to this component in case of
  57275. * context lost for instance.
  57276. */
  57277. rebuild(): void;
  57278. /**
  57279. * Serializes the component data to the specified json object
  57280. * @param serializationObject The object to serialize to
  57281. */
  57282. serialize(serializationObject: any): void;
  57283. /**
  57284. * Adds all the elements from the container to the scene
  57285. * @param container the container holding the elements
  57286. */
  57287. addFromContainer(container: AbstractScene): void;
  57288. /**
  57289. * Removes all the elements in the container from the scene
  57290. * @param container contains the elements to remove
  57291. * @param dispose if the removed element should be disposed (default: false)
  57292. */
  57293. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57294. /**
  57295. * Rebuilds the elements related to this component in case of
  57296. * context lost for instance.
  57297. */
  57298. dispose(): void;
  57299. private _gatherRenderTargets;
  57300. }
  57301. }
  57302. declare module "babylonjs/Lights/Shadows/index" {
  57303. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57304. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57305. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57306. }
  57307. declare module "babylonjs/Lights/pointLight" {
  57308. import { Scene } from "babylonjs/scene";
  57309. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57311. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57312. import { Effect } from "babylonjs/Materials/effect";
  57313. /**
  57314. * A point light is a light defined by an unique point in world space.
  57315. * The light is emitted in every direction from this point.
  57316. * A good example of a point light is a standard light bulb.
  57317. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57318. */
  57319. export class PointLight extends ShadowLight {
  57320. private _shadowAngle;
  57321. /**
  57322. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57323. * This specifies what angle the shadow will use to be created.
  57324. *
  57325. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57326. */
  57327. get shadowAngle(): number;
  57328. /**
  57329. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57330. * This specifies what angle the shadow will use to be created.
  57331. *
  57332. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57333. */
  57334. set shadowAngle(value: number);
  57335. /**
  57336. * Gets the direction if it has been set.
  57337. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57338. */
  57339. get direction(): Vector3;
  57340. /**
  57341. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57342. */
  57343. set direction(value: Vector3);
  57344. /**
  57345. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57346. * A PointLight emits the light in every direction.
  57347. * It can cast shadows.
  57348. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57349. * ```javascript
  57350. * var pointLight = new PointLight("pl", camera.position, scene);
  57351. * ```
  57352. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57353. * @param name The light friendly name
  57354. * @param position The position of the point light in the scene
  57355. * @param scene The scene the lights belongs to
  57356. */
  57357. constructor(name: string, position: Vector3, scene: Scene);
  57358. /**
  57359. * Returns the string "PointLight"
  57360. * @returns the class name
  57361. */
  57362. getClassName(): string;
  57363. /**
  57364. * Returns the integer 0.
  57365. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57366. */
  57367. getTypeID(): number;
  57368. /**
  57369. * Specifies wether or not the shadowmap should be a cube texture.
  57370. * @returns true if the shadowmap needs to be a cube texture.
  57371. */
  57372. needCube(): boolean;
  57373. /**
  57374. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57375. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57376. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57377. */
  57378. getShadowDirection(faceIndex?: number): Vector3;
  57379. /**
  57380. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57381. * - fov = PI / 2
  57382. * - aspect ratio : 1.0
  57383. * - z-near and far equal to the active camera minZ and maxZ.
  57384. * Returns the PointLight.
  57385. */
  57386. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57387. protected _buildUniformLayout(): void;
  57388. /**
  57389. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57390. * @param effect The effect to update
  57391. * @param lightIndex The index of the light in the effect to update
  57392. * @returns The point light
  57393. */
  57394. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57395. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57396. /**
  57397. * Prepares the list of defines specific to the light type.
  57398. * @param defines the list of defines
  57399. * @param lightIndex defines the index of the light for the effect
  57400. */
  57401. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57402. }
  57403. }
  57404. declare module "babylonjs/Lights/index" {
  57405. export * from "babylonjs/Lights/light";
  57406. export * from "babylonjs/Lights/shadowLight";
  57407. export * from "babylonjs/Lights/Shadows/index";
  57408. export * from "babylonjs/Lights/directionalLight";
  57409. export * from "babylonjs/Lights/hemisphericLight";
  57410. export * from "babylonjs/Lights/pointLight";
  57411. export * from "babylonjs/Lights/spotLight";
  57412. }
  57413. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57414. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57415. /**
  57416. * Header information of HDR texture files.
  57417. */
  57418. export interface HDRInfo {
  57419. /**
  57420. * The height of the texture in pixels.
  57421. */
  57422. height: number;
  57423. /**
  57424. * The width of the texture in pixels.
  57425. */
  57426. width: number;
  57427. /**
  57428. * The index of the beginning of the data in the binary file.
  57429. */
  57430. dataPosition: number;
  57431. }
  57432. /**
  57433. * This groups tools to convert HDR texture to native colors array.
  57434. */
  57435. export class HDRTools {
  57436. private static Ldexp;
  57437. private static Rgbe2float;
  57438. private static readStringLine;
  57439. /**
  57440. * Reads header information from an RGBE texture stored in a native array.
  57441. * More information on this format are available here:
  57442. * https://en.wikipedia.org/wiki/RGBE_image_format
  57443. *
  57444. * @param uint8array The binary file stored in native array.
  57445. * @return The header information.
  57446. */
  57447. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57448. /**
  57449. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57450. * This RGBE texture needs to store the information as a panorama.
  57451. *
  57452. * More information on this format are available here:
  57453. * https://en.wikipedia.org/wiki/RGBE_image_format
  57454. *
  57455. * @param buffer The binary file stored in an array buffer.
  57456. * @param size The expected size of the extracted cubemap.
  57457. * @return The Cube Map information.
  57458. */
  57459. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57460. /**
  57461. * Returns the pixels data extracted from an RGBE texture.
  57462. * This pixels will be stored left to right up to down in the R G B order in one array.
  57463. *
  57464. * More information on this format are available here:
  57465. * https://en.wikipedia.org/wiki/RGBE_image_format
  57466. *
  57467. * @param uint8array The binary file stored in an array buffer.
  57468. * @param hdrInfo The header information of the file.
  57469. * @return The pixels data in RGB right to left up to down order.
  57470. */
  57471. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57472. private static RGBE_ReadPixels_RLE;
  57473. }
  57474. }
  57475. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57476. import { Nullable } from "babylonjs/types";
  57477. import { Scene } from "babylonjs/scene";
  57478. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57480. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57481. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57482. /**
  57483. * This represents a texture coming from an HDR input.
  57484. *
  57485. * The only supported format is currently panorama picture stored in RGBE format.
  57486. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57487. */
  57488. export class HDRCubeTexture extends BaseTexture {
  57489. private static _facesMapping;
  57490. private _generateHarmonics;
  57491. private _noMipmap;
  57492. private _textureMatrix;
  57493. private _size;
  57494. private _onLoad;
  57495. private _onError;
  57496. /**
  57497. * The texture URL.
  57498. */
  57499. url: string;
  57500. /**
  57501. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57502. */
  57503. coordinatesMode: number;
  57504. protected _isBlocking: boolean;
  57505. /**
  57506. * Sets wether or not the texture is blocking during loading.
  57507. */
  57508. set isBlocking(value: boolean);
  57509. /**
  57510. * Gets wether or not the texture is blocking during loading.
  57511. */
  57512. get isBlocking(): boolean;
  57513. protected _rotationY: number;
  57514. /**
  57515. * Sets texture matrix rotation angle around Y axis in radians.
  57516. */
  57517. set rotationY(value: number);
  57518. /**
  57519. * Gets texture matrix rotation angle around Y axis radians.
  57520. */
  57521. get rotationY(): number;
  57522. /**
  57523. * Gets or sets the center of the bounding box associated with the cube texture
  57524. * It must define where the camera used to render the texture was set
  57525. */
  57526. boundingBoxPosition: Vector3;
  57527. private _boundingBoxSize;
  57528. /**
  57529. * Gets or sets the size of the bounding box associated with the cube texture
  57530. * When defined, the cubemap will switch to local mode
  57531. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57532. * @example https://www.babylonjs-playground.com/#RNASML
  57533. */
  57534. set boundingBoxSize(value: Vector3);
  57535. get boundingBoxSize(): Vector3;
  57536. /**
  57537. * Instantiates an HDRTexture from the following parameters.
  57538. *
  57539. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57540. * @param scene The scene the texture will be used in
  57541. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57542. * @param noMipmap Forces to not generate the mipmap if true
  57543. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57544. * @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)
  57545. * @param reserved Reserved flag for internal use.
  57546. */
  57547. 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>);
  57548. /**
  57549. * Get the current class name of the texture useful for serialization or dynamic coding.
  57550. * @returns "HDRCubeTexture"
  57551. */
  57552. getClassName(): string;
  57553. /**
  57554. * Occurs when the file is raw .hdr file.
  57555. */
  57556. private loadTexture;
  57557. clone(): HDRCubeTexture;
  57558. delayLoad(): void;
  57559. /**
  57560. * Get the texture reflection matrix used to rotate/transform the reflection.
  57561. * @returns the reflection matrix
  57562. */
  57563. getReflectionTextureMatrix(): Matrix;
  57564. /**
  57565. * Set the texture reflection matrix used to rotate/transform the reflection.
  57566. * @param value Define the reflection matrix to set
  57567. */
  57568. setReflectionTextureMatrix(value: Matrix): void;
  57569. /**
  57570. * Parses a JSON representation of an HDR Texture in order to create the texture
  57571. * @param parsedTexture Define the JSON representation
  57572. * @param scene Define the scene the texture should be created in
  57573. * @param rootUrl Define the root url in case we need to load relative dependencies
  57574. * @returns the newly created texture after parsing
  57575. */
  57576. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57577. serialize(): any;
  57578. }
  57579. }
  57580. declare module "babylonjs/Physics/physicsEngine" {
  57581. import { Nullable } from "babylonjs/types";
  57582. import { Vector3 } from "babylonjs/Maths/math.vector";
  57583. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57584. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57585. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57586. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57587. /**
  57588. * Class used to control physics engine
  57589. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57590. */
  57591. export class PhysicsEngine implements IPhysicsEngine {
  57592. private _physicsPlugin;
  57593. /**
  57594. * Global value used to control the smallest number supported by the simulation
  57595. */
  57596. static Epsilon: number;
  57597. private _impostors;
  57598. private _joints;
  57599. private _subTimeStep;
  57600. /**
  57601. * Gets the gravity vector used by the simulation
  57602. */
  57603. gravity: Vector3;
  57604. /**
  57605. * Factory used to create the default physics plugin.
  57606. * @returns The default physics plugin
  57607. */
  57608. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57609. /**
  57610. * Creates a new Physics Engine
  57611. * @param gravity defines the gravity vector used by the simulation
  57612. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57613. */
  57614. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57615. /**
  57616. * Sets the gravity vector used by the simulation
  57617. * @param gravity defines the gravity vector to use
  57618. */
  57619. setGravity(gravity: Vector3): void;
  57620. /**
  57621. * Set the time step of the physics engine.
  57622. * Default is 1/60.
  57623. * To slow it down, enter 1/600 for example.
  57624. * To speed it up, 1/30
  57625. * @param newTimeStep defines the new timestep to apply to this world.
  57626. */
  57627. setTimeStep(newTimeStep?: number): void;
  57628. /**
  57629. * Get the time step of the physics engine.
  57630. * @returns the current time step
  57631. */
  57632. getTimeStep(): number;
  57633. /**
  57634. * Set the sub time step of the physics engine.
  57635. * Default is 0 meaning there is no sub steps
  57636. * To increase physics resolution precision, set a small value (like 1 ms)
  57637. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57638. */
  57639. setSubTimeStep(subTimeStep?: number): void;
  57640. /**
  57641. * Get the sub time step of the physics engine.
  57642. * @returns the current sub time step
  57643. */
  57644. getSubTimeStep(): number;
  57645. /**
  57646. * Release all resources
  57647. */
  57648. dispose(): void;
  57649. /**
  57650. * Gets the name of the current physics plugin
  57651. * @returns the name of the plugin
  57652. */
  57653. getPhysicsPluginName(): string;
  57654. /**
  57655. * Adding a new impostor for the impostor tracking.
  57656. * This will be done by the impostor itself.
  57657. * @param impostor the impostor to add
  57658. */
  57659. addImpostor(impostor: PhysicsImpostor): void;
  57660. /**
  57661. * Remove an impostor from the engine.
  57662. * This impostor and its mesh will not longer be updated by the physics engine.
  57663. * @param impostor the impostor to remove
  57664. */
  57665. removeImpostor(impostor: PhysicsImpostor): void;
  57666. /**
  57667. * Add a joint to the physics engine
  57668. * @param mainImpostor defines the main impostor to which the joint is added.
  57669. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57670. * @param joint defines the joint that will connect both impostors.
  57671. */
  57672. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57673. /**
  57674. * Removes a joint from the simulation
  57675. * @param mainImpostor defines the impostor used with the joint
  57676. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57677. * @param joint defines the joint to remove
  57678. */
  57679. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57680. /**
  57681. * Called by the scene. No need to call it.
  57682. * @param delta defines the timespam between frames
  57683. */
  57684. _step(delta: number): void;
  57685. /**
  57686. * Gets the current plugin used to run the simulation
  57687. * @returns current plugin
  57688. */
  57689. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57690. /**
  57691. * Gets the list of physic impostors
  57692. * @returns an array of PhysicsImpostor
  57693. */
  57694. getImpostors(): Array<PhysicsImpostor>;
  57695. /**
  57696. * Gets the impostor for a physics enabled object
  57697. * @param object defines the object impersonated by the impostor
  57698. * @returns the PhysicsImpostor or null if not found
  57699. */
  57700. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57701. /**
  57702. * Gets the impostor for a physics body object
  57703. * @param body defines physics body used by the impostor
  57704. * @returns the PhysicsImpostor or null if not found
  57705. */
  57706. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57707. /**
  57708. * Does a raycast in the physics world
  57709. * @param from when should the ray start?
  57710. * @param to when should the ray end?
  57711. * @returns PhysicsRaycastResult
  57712. */
  57713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57714. }
  57715. }
  57716. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57717. import { Nullable } from "babylonjs/types";
  57718. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57720. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57721. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57722. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57723. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57724. /** @hidden */
  57725. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57726. private _useDeltaForWorldStep;
  57727. world: any;
  57728. name: string;
  57729. private _physicsMaterials;
  57730. private _fixedTimeStep;
  57731. private _cannonRaycastResult;
  57732. private _raycastResult;
  57733. private _physicsBodysToRemoveAfterStep;
  57734. BJSCANNON: any;
  57735. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57736. setGravity(gravity: Vector3): void;
  57737. setTimeStep(timeStep: number): void;
  57738. getTimeStep(): number;
  57739. executeStep(delta: number): void;
  57740. private _removeMarkedPhysicsBodiesFromWorld;
  57741. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57742. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57743. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57744. private _processChildMeshes;
  57745. removePhysicsBody(impostor: PhysicsImpostor): void;
  57746. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57747. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57748. private _addMaterial;
  57749. private _checkWithEpsilon;
  57750. private _createShape;
  57751. private _createHeightmap;
  57752. private _minus90X;
  57753. private _plus90X;
  57754. private _tmpPosition;
  57755. private _tmpDeltaPosition;
  57756. private _tmpUnityRotation;
  57757. private _updatePhysicsBodyTransformation;
  57758. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57759. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57760. isSupported(): boolean;
  57761. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57762. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57763. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57764. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57765. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57766. getBodyMass(impostor: PhysicsImpostor): number;
  57767. getBodyFriction(impostor: PhysicsImpostor): number;
  57768. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57769. getBodyRestitution(impostor: PhysicsImpostor): number;
  57770. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57771. sleepBody(impostor: PhysicsImpostor): void;
  57772. wakeUpBody(impostor: PhysicsImpostor): void;
  57773. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57774. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57775. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57776. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57777. getRadius(impostor: PhysicsImpostor): number;
  57778. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57779. dispose(): void;
  57780. private _extendNamespace;
  57781. /**
  57782. * Does a raycast in the physics world
  57783. * @param from when should the ray start?
  57784. * @param to when should the ray end?
  57785. * @returns PhysicsRaycastResult
  57786. */
  57787. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57788. }
  57789. }
  57790. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57791. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57792. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57793. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57795. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57796. import { Nullable } from "babylonjs/types";
  57797. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57798. /** @hidden */
  57799. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57800. world: any;
  57801. name: string;
  57802. BJSOIMO: any;
  57803. private _raycastResult;
  57804. constructor(iterations?: number, oimoInjection?: any);
  57805. setGravity(gravity: Vector3): void;
  57806. setTimeStep(timeStep: number): void;
  57807. getTimeStep(): number;
  57808. private _tmpImpostorsArray;
  57809. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57810. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57811. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57812. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57813. private _tmpPositionVector;
  57814. removePhysicsBody(impostor: PhysicsImpostor): void;
  57815. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57816. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57817. isSupported(): boolean;
  57818. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57819. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57820. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57821. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57822. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57823. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57824. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57825. getBodyMass(impostor: PhysicsImpostor): number;
  57826. getBodyFriction(impostor: PhysicsImpostor): number;
  57827. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57828. getBodyRestitution(impostor: PhysicsImpostor): number;
  57829. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57830. sleepBody(impostor: PhysicsImpostor): void;
  57831. wakeUpBody(impostor: PhysicsImpostor): void;
  57832. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57833. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57834. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57835. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57836. getRadius(impostor: PhysicsImpostor): number;
  57837. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57838. dispose(): void;
  57839. /**
  57840. * Does a raycast in the physics world
  57841. * @param from when should the ray start?
  57842. * @param to when should the ray end?
  57843. * @returns PhysicsRaycastResult
  57844. */
  57845. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57846. }
  57847. }
  57848. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57849. import { Nullable } from "babylonjs/types";
  57850. import { Scene } from "babylonjs/scene";
  57851. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57852. import { Color4 } from "babylonjs/Maths/math.color";
  57853. import { Mesh } from "babylonjs/Meshes/mesh";
  57854. /**
  57855. * Class containing static functions to help procedurally build meshes
  57856. */
  57857. export class RibbonBuilder {
  57858. /**
  57859. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57860. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57861. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57862. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57863. * * 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
  57864. * * 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
  57865. * * 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
  57866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57867. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57868. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57869. * * 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
  57870. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57871. * * 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
  57872. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57874. * @param name defines the name of the mesh
  57875. * @param options defines the options used to create the mesh
  57876. * @param scene defines the hosting scene
  57877. * @returns the ribbon mesh
  57878. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57879. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57880. */
  57881. static CreateRibbon(name: string, options: {
  57882. pathArray: Vector3[][];
  57883. closeArray?: boolean;
  57884. closePath?: boolean;
  57885. offset?: number;
  57886. updatable?: boolean;
  57887. sideOrientation?: number;
  57888. frontUVs?: Vector4;
  57889. backUVs?: Vector4;
  57890. instance?: Mesh;
  57891. invertUV?: boolean;
  57892. uvs?: Vector2[];
  57893. colors?: Color4[];
  57894. }, scene?: Nullable<Scene>): Mesh;
  57895. }
  57896. }
  57897. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57898. import { Nullable } from "babylonjs/types";
  57899. import { Scene } from "babylonjs/scene";
  57900. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57901. import { Mesh } from "babylonjs/Meshes/mesh";
  57902. /**
  57903. * Class containing static functions to help procedurally build meshes
  57904. */
  57905. export class ShapeBuilder {
  57906. /**
  57907. * 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.
  57908. * * 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.
  57909. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57910. * * 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.
  57911. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57912. * * 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
  57913. * * 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
  57914. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57919. * @param name defines the name of the mesh
  57920. * @param options defines the options used to create the mesh
  57921. * @param scene defines the hosting scene
  57922. * @returns the extruded shape mesh
  57923. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57925. */
  57926. static ExtrudeShape(name: string, options: {
  57927. shape: Vector3[];
  57928. path: Vector3[];
  57929. scale?: number;
  57930. rotation?: number;
  57931. cap?: number;
  57932. updatable?: boolean;
  57933. sideOrientation?: number;
  57934. frontUVs?: Vector4;
  57935. backUVs?: Vector4;
  57936. instance?: Mesh;
  57937. invertUV?: boolean;
  57938. }, scene?: Nullable<Scene>): Mesh;
  57939. /**
  57940. * Creates an custom extruded shape mesh.
  57941. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57942. * * 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.
  57943. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57944. * * 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
  57945. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57946. * * 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
  57947. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57948. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57949. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57950. * * 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
  57951. * * 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
  57952. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57955. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57957. * @param name defines the name of the mesh
  57958. * @param options defines the options used to create the mesh
  57959. * @param scene defines the hosting scene
  57960. * @returns the custom extruded shape mesh
  57961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57962. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57964. */
  57965. static ExtrudeShapeCustom(name: string, options: {
  57966. shape: Vector3[];
  57967. path: Vector3[];
  57968. scaleFunction?: any;
  57969. rotationFunction?: any;
  57970. ribbonCloseArray?: boolean;
  57971. ribbonClosePath?: boolean;
  57972. cap?: number;
  57973. updatable?: boolean;
  57974. sideOrientation?: number;
  57975. frontUVs?: Vector4;
  57976. backUVs?: Vector4;
  57977. instance?: Mesh;
  57978. invertUV?: boolean;
  57979. }, scene?: Nullable<Scene>): Mesh;
  57980. private static _ExtrudeShapeGeneric;
  57981. }
  57982. }
  57983. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57984. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57985. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57986. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57987. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57988. import { Nullable } from "babylonjs/types";
  57989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57990. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57991. /**
  57992. * AmmoJS Physics plugin
  57993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57994. * @see https://github.com/kripken/ammo.js/
  57995. */
  57996. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57997. private _useDeltaForWorldStep;
  57998. /**
  57999. * Reference to the Ammo library
  58000. */
  58001. bjsAMMO: any;
  58002. /**
  58003. * Created ammoJS world which physics bodies are added to
  58004. */
  58005. world: any;
  58006. /**
  58007. * Name of the plugin
  58008. */
  58009. name: string;
  58010. private _timeStep;
  58011. private _fixedTimeStep;
  58012. private _maxSteps;
  58013. private _tmpQuaternion;
  58014. private _tmpAmmoTransform;
  58015. private _tmpAmmoQuaternion;
  58016. private _tmpAmmoConcreteContactResultCallback;
  58017. private _collisionConfiguration;
  58018. private _dispatcher;
  58019. private _overlappingPairCache;
  58020. private _solver;
  58021. private _softBodySolver;
  58022. private _tmpAmmoVectorA;
  58023. private _tmpAmmoVectorB;
  58024. private _tmpAmmoVectorC;
  58025. private _tmpAmmoVectorD;
  58026. private _tmpContactCallbackResult;
  58027. private _tmpAmmoVectorRCA;
  58028. private _tmpAmmoVectorRCB;
  58029. private _raycastResult;
  58030. private static readonly DISABLE_COLLISION_FLAG;
  58031. private static readonly KINEMATIC_FLAG;
  58032. private static readonly DISABLE_DEACTIVATION_FLAG;
  58033. /**
  58034. * Initializes the ammoJS plugin
  58035. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58036. * @param ammoInjection can be used to inject your own ammo reference
  58037. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58038. */
  58039. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58040. /**
  58041. * Sets the gravity of the physics world (m/(s^2))
  58042. * @param gravity Gravity to set
  58043. */
  58044. setGravity(gravity: Vector3): void;
  58045. /**
  58046. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58047. * @param timeStep timestep to use in seconds
  58048. */
  58049. setTimeStep(timeStep: number): void;
  58050. /**
  58051. * 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)
  58052. * @param fixedTimeStep fixedTimeStep to use in seconds
  58053. */
  58054. setFixedTimeStep(fixedTimeStep: number): void;
  58055. /**
  58056. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58057. * @param maxSteps the maximum number of steps by the physics engine per frame
  58058. */
  58059. setMaxSteps(maxSteps: number): void;
  58060. /**
  58061. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58062. * @returns the current timestep in seconds
  58063. */
  58064. getTimeStep(): number;
  58065. /**
  58066. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58067. */
  58068. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58069. private _isImpostorInContact;
  58070. private _isImpostorPairInContact;
  58071. private _stepSimulation;
  58072. /**
  58073. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58074. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58075. * After the step the babylon meshes are set to the position of the physics imposters
  58076. * @param delta amount of time to step forward
  58077. * @param impostors array of imposters to update before/after the step
  58078. */
  58079. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58080. /**
  58081. * Update babylon mesh to match physics world object
  58082. * @param impostor imposter to match
  58083. */
  58084. private _afterSoftStep;
  58085. /**
  58086. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58087. * @param impostor imposter to match
  58088. */
  58089. private _ropeStep;
  58090. /**
  58091. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58092. * @param impostor imposter to match
  58093. */
  58094. private _softbodyOrClothStep;
  58095. private _tmpVector;
  58096. private _tmpMatrix;
  58097. /**
  58098. * Applies an impulse on the imposter
  58099. * @param impostor imposter to apply impulse to
  58100. * @param force amount of force to be applied to the imposter
  58101. * @param contactPoint the location to apply the impulse on the imposter
  58102. */
  58103. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58104. /**
  58105. * Applies a force on the imposter
  58106. * @param impostor imposter to apply force
  58107. * @param force amount of force to be applied to the imposter
  58108. * @param contactPoint the location to apply the force on the imposter
  58109. */
  58110. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58111. /**
  58112. * Creates a physics body using the plugin
  58113. * @param impostor the imposter to create the physics body on
  58114. */
  58115. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58116. /**
  58117. * Removes the physics body from the imposter and disposes of the body's memory
  58118. * @param impostor imposter to remove the physics body from
  58119. */
  58120. removePhysicsBody(impostor: PhysicsImpostor): void;
  58121. /**
  58122. * Generates a joint
  58123. * @param impostorJoint the imposter joint to create the joint with
  58124. */
  58125. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58126. /**
  58127. * Removes a joint
  58128. * @param impostorJoint the imposter joint to remove the joint from
  58129. */
  58130. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58131. private _addMeshVerts;
  58132. /**
  58133. * Initialise the soft body vertices to match its object's (mesh) vertices
  58134. * Softbody vertices (nodes) are in world space and to match this
  58135. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58136. * @param impostor to create the softbody for
  58137. */
  58138. private _softVertexData;
  58139. /**
  58140. * Create an impostor's soft body
  58141. * @param impostor to create the softbody for
  58142. */
  58143. private _createSoftbody;
  58144. /**
  58145. * Create cloth for an impostor
  58146. * @param impostor to create the softbody for
  58147. */
  58148. private _createCloth;
  58149. /**
  58150. * Create rope for an impostor
  58151. * @param impostor to create the softbody for
  58152. */
  58153. private _createRope;
  58154. /**
  58155. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58156. * @param impostor to create the custom physics shape for
  58157. */
  58158. private _createCustom;
  58159. private _addHullVerts;
  58160. private _createShape;
  58161. /**
  58162. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58163. * @param impostor imposter containing the physics body and babylon object
  58164. */
  58165. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58166. /**
  58167. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58168. * @param impostor imposter containing the physics body and babylon object
  58169. * @param newPosition new position
  58170. * @param newRotation new rotation
  58171. */
  58172. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58173. /**
  58174. * If this plugin is supported
  58175. * @returns true if its supported
  58176. */
  58177. isSupported(): boolean;
  58178. /**
  58179. * Sets the linear velocity of the physics body
  58180. * @param impostor imposter to set the velocity on
  58181. * @param velocity velocity to set
  58182. */
  58183. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58184. /**
  58185. * Sets the angular velocity of the physics body
  58186. * @param impostor imposter to set the velocity on
  58187. * @param velocity velocity to set
  58188. */
  58189. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58190. /**
  58191. * gets the linear velocity
  58192. * @param impostor imposter to get linear velocity from
  58193. * @returns linear velocity
  58194. */
  58195. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58196. /**
  58197. * gets the angular velocity
  58198. * @param impostor imposter to get angular velocity from
  58199. * @returns angular velocity
  58200. */
  58201. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58202. /**
  58203. * Sets the mass of physics body
  58204. * @param impostor imposter to set the mass on
  58205. * @param mass mass to set
  58206. */
  58207. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58208. /**
  58209. * Gets the mass of the physics body
  58210. * @param impostor imposter to get the mass from
  58211. * @returns mass
  58212. */
  58213. getBodyMass(impostor: PhysicsImpostor): number;
  58214. /**
  58215. * Gets friction of the impostor
  58216. * @param impostor impostor to get friction from
  58217. * @returns friction value
  58218. */
  58219. getBodyFriction(impostor: PhysicsImpostor): number;
  58220. /**
  58221. * Sets friction of the impostor
  58222. * @param impostor impostor to set friction on
  58223. * @param friction friction value
  58224. */
  58225. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58226. /**
  58227. * Gets restitution of the impostor
  58228. * @param impostor impostor to get restitution from
  58229. * @returns restitution value
  58230. */
  58231. getBodyRestitution(impostor: PhysicsImpostor): number;
  58232. /**
  58233. * Sets resitution of the impostor
  58234. * @param impostor impostor to set resitution on
  58235. * @param restitution resitution value
  58236. */
  58237. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58238. /**
  58239. * Gets pressure inside the impostor
  58240. * @param impostor impostor to get pressure from
  58241. * @returns pressure value
  58242. */
  58243. getBodyPressure(impostor: PhysicsImpostor): number;
  58244. /**
  58245. * Sets pressure inside a soft body impostor
  58246. * Cloth and rope must remain 0 pressure
  58247. * @param impostor impostor to set pressure on
  58248. * @param pressure pressure value
  58249. */
  58250. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58251. /**
  58252. * Gets stiffness of the impostor
  58253. * @param impostor impostor to get stiffness from
  58254. * @returns pressure value
  58255. */
  58256. getBodyStiffness(impostor: PhysicsImpostor): number;
  58257. /**
  58258. * Sets stiffness of the impostor
  58259. * @param impostor impostor to set stiffness on
  58260. * @param stiffness stiffness value from 0 to 1
  58261. */
  58262. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58263. /**
  58264. * Gets velocityIterations of the impostor
  58265. * @param impostor impostor to get velocity iterations from
  58266. * @returns velocityIterations value
  58267. */
  58268. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58269. /**
  58270. * Sets velocityIterations of the impostor
  58271. * @param impostor impostor to set velocity iterations on
  58272. * @param velocityIterations velocityIterations value
  58273. */
  58274. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58275. /**
  58276. * Gets positionIterations of the impostor
  58277. * @param impostor impostor to get position iterations from
  58278. * @returns positionIterations value
  58279. */
  58280. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58281. /**
  58282. * Sets positionIterations of the impostor
  58283. * @param impostor impostor to set position on
  58284. * @param positionIterations positionIterations value
  58285. */
  58286. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58287. /**
  58288. * Append an anchor to a cloth object
  58289. * @param impostor is the cloth impostor to add anchor to
  58290. * @param otherImpostor is the rigid impostor to anchor to
  58291. * @param width ratio across width from 0 to 1
  58292. * @param height ratio up height from 0 to 1
  58293. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58294. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58295. */
  58296. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58297. /**
  58298. * Append an hook to a rope object
  58299. * @param impostor is the rope impostor to add hook to
  58300. * @param otherImpostor is the rigid impostor to hook to
  58301. * @param length ratio along the rope from 0 to 1
  58302. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58303. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58304. */
  58305. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58306. /**
  58307. * Sleeps the physics body and stops it from being active
  58308. * @param impostor impostor to sleep
  58309. */
  58310. sleepBody(impostor: PhysicsImpostor): void;
  58311. /**
  58312. * Activates the physics body
  58313. * @param impostor impostor to activate
  58314. */
  58315. wakeUpBody(impostor: PhysicsImpostor): void;
  58316. /**
  58317. * Updates the distance parameters of the joint
  58318. * @param joint joint to update
  58319. * @param maxDistance maximum distance of the joint
  58320. * @param minDistance minimum distance of the joint
  58321. */
  58322. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58323. /**
  58324. * Sets a motor on the joint
  58325. * @param joint joint to set motor on
  58326. * @param speed speed of the motor
  58327. * @param maxForce maximum force of the motor
  58328. * @param motorIndex index of the motor
  58329. */
  58330. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58331. /**
  58332. * Sets the motors limit
  58333. * @param joint joint to set limit on
  58334. * @param upperLimit upper limit
  58335. * @param lowerLimit lower limit
  58336. */
  58337. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58338. /**
  58339. * Syncs the position and rotation of a mesh with the impostor
  58340. * @param mesh mesh to sync
  58341. * @param impostor impostor to update the mesh with
  58342. */
  58343. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58344. /**
  58345. * Gets the radius of the impostor
  58346. * @param impostor impostor to get radius from
  58347. * @returns the radius
  58348. */
  58349. getRadius(impostor: PhysicsImpostor): number;
  58350. /**
  58351. * Gets the box size of the impostor
  58352. * @param impostor impostor to get box size from
  58353. * @param result the resulting box size
  58354. */
  58355. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58356. /**
  58357. * Disposes of the impostor
  58358. */
  58359. dispose(): void;
  58360. /**
  58361. * Does a raycast in the physics world
  58362. * @param from when should the ray start?
  58363. * @param to when should the ray end?
  58364. * @returns PhysicsRaycastResult
  58365. */
  58366. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58367. }
  58368. }
  58369. declare module "babylonjs/Probes/reflectionProbe" {
  58370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58371. import { Vector3 } from "babylonjs/Maths/math.vector";
  58372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58373. import { Nullable } from "babylonjs/types";
  58374. import { Scene } from "babylonjs/scene";
  58375. module "babylonjs/abstractScene" {
  58376. interface AbstractScene {
  58377. /**
  58378. * The list of reflection probes added to the scene
  58379. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58380. */
  58381. reflectionProbes: Array<ReflectionProbe>;
  58382. /**
  58383. * Removes the given reflection probe from this scene.
  58384. * @param toRemove The reflection probe to remove
  58385. * @returns The index of the removed reflection probe
  58386. */
  58387. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58388. /**
  58389. * Adds the given reflection probe to this scene.
  58390. * @param newReflectionProbe The reflection probe to add
  58391. */
  58392. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58393. }
  58394. }
  58395. /**
  58396. * Class used to generate realtime reflection / refraction cube textures
  58397. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58398. */
  58399. export class ReflectionProbe {
  58400. /** defines the name of the probe */
  58401. name: string;
  58402. private _scene;
  58403. private _renderTargetTexture;
  58404. private _projectionMatrix;
  58405. private _viewMatrix;
  58406. private _target;
  58407. private _add;
  58408. private _attachedMesh;
  58409. private _invertYAxis;
  58410. /** Gets or sets probe position (center of the cube map) */
  58411. position: Vector3;
  58412. /**
  58413. * Creates a new reflection probe
  58414. * @param name defines the name of the probe
  58415. * @param size defines the texture resolution (for each face)
  58416. * @param scene defines the hosting scene
  58417. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58418. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58419. */
  58420. constructor(
  58421. /** defines the name of the probe */
  58422. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58423. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58424. get samples(): number;
  58425. set samples(value: number);
  58426. /** Gets or sets the refresh rate to use (on every frame by default) */
  58427. get refreshRate(): number;
  58428. set refreshRate(value: number);
  58429. /**
  58430. * Gets the hosting scene
  58431. * @returns a Scene
  58432. */
  58433. getScene(): Scene;
  58434. /** Gets the internal CubeTexture used to render to */
  58435. get cubeTexture(): RenderTargetTexture;
  58436. /** Gets the list of meshes to render */
  58437. get renderList(): Nullable<AbstractMesh[]>;
  58438. /**
  58439. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58440. * @param mesh defines the mesh to attach to
  58441. */
  58442. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58443. /**
  58444. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58445. * @param renderingGroupId The rendering group id corresponding to its index
  58446. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58447. */
  58448. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58449. /**
  58450. * Clean all associated resources
  58451. */
  58452. dispose(): void;
  58453. /**
  58454. * Converts the reflection probe information to a readable string for debug purpose.
  58455. * @param fullDetails Supports for multiple levels of logging within scene loading
  58456. * @returns the human readable reflection probe info
  58457. */
  58458. toString(fullDetails?: boolean): string;
  58459. /**
  58460. * Get the class name of the relfection probe.
  58461. * @returns "ReflectionProbe"
  58462. */
  58463. getClassName(): string;
  58464. /**
  58465. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58466. * @returns The JSON representation of the texture
  58467. */
  58468. serialize(): any;
  58469. /**
  58470. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58471. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58472. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58473. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58474. * @returns The parsed reflection probe if successful
  58475. */
  58476. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58477. }
  58478. }
  58479. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58480. /** @hidden */
  58481. export var _BabylonLoaderRegistered: boolean;
  58482. /**
  58483. * Helps setting up some configuration for the babylon file loader.
  58484. */
  58485. export class BabylonFileLoaderConfiguration {
  58486. /**
  58487. * The loader does not allow injecting custom physix engine into the plugins.
  58488. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58489. * So you could set this variable to your engine import to make it work.
  58490. */
  58491. static LoaderInjectedPhysicsEngine: any;
  58492. }
  58493. }
  58494. declare module "babylonjs/Loading/Plugins/index" {
  58495. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58496. }
  58497. declare module "babylonjs/Loading/index" {
  58498. export * from "babylonjs/Loading/loadingScreen";
  58499. export * from "babylonjs/Loading/Plugins/index";
  58500. export * from "babylonjs/Loading/sceneLoader";
  58501. export * from "babylonjs/Loading/sceneLoaderFlags";
  58502. }
  58503. declare module "babylonjs/Materials/Background/index" {
  58504. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58505. }
  58506. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58507. import { Scene } from "babylonjs/scene";
  58508. import { Color3 } from "babylonjs/Maths/math.color";
  58509. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58510. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58511. /**
  58512. * The Physically based simple base material of BJS.
  58513. *
  58514. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58515. * It is used as the base class for both the specGloss and metalRough conventions.
  58516. */
  58517. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58518. /**
  58519. * Number of Simultaneous lights allowed on the material.
  58520. */
  58521. maxSimultaneousLights: number;
  58522. /**
  58523. * If sets to true, disables all the lights affecting the material.
  58524. */
  58525. disableLighting: boolean;
  58526. /**
  58527. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58528. */
  58529. environmentTexture: BaseTexture;
  58530. /**
  58531. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58532. */
  58533. invertNormalMapX: boolean;
  58534. /**
  58535. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58536. */
  58537. invertNormalMapY: boolean;
  58538. /**
  58539. * Normal map used in the model.
  58540. */
  58541. normalTexture: BaseTexture;
  58542. /**
  58543. * Emissivie color used to self-illuminate the model.
  58544. */
  58545. emissiveColor: Color3;
  58546. /**
  58547. * Emissivie texture used to self-illuminate the model.
  58548. */
  58549. emissiveTexture: BaseTexture;
  58550. /**
  58551. * Occlusion Channel Strenght.
  58552. */
  58553. occlusionStrength: number;
  58554. /**
  58555. * Occlusion Texture of the material (adding extra occlusion effects).
  58556. */
  58557. occlusionTexture: BaseTexture;
  58558. /**
  58559. * Defines the alpha limits in alpha test mode.
  58560. */
  58561. alphaCutOff: number;
  58562. /**
  58563. * Gets the current double sided mode.
  58564. */
  58565. get doubleSided(): boolean;
  58566. /**
  58567. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58568. */
  58569. set doubleSided(value: boolean);
  58570. /**
  58571. * Stores the pre-calculated light information of a mesh in a texture.
  58572. */
  58573. lightmapTexture: BaseTexture;
  58574. /**
  58575. * If true, the light map contains occlusion information instead of lighting info.
  58576. */
  58577. useLightmapAsShadowmap: boolean;
  58578. /**
  58579. * Instantiates a new PBRMaterial instance.
  58580. *
  58581. * @param name The material name
  58582. * @param scene The scene the material will be use in.
  58583. */
  58584. constructor(name: string, scene: Scene);
  58585. getClassName(): string;
  58586. }
  58587. }
  58588. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58589. import { Scene } from "babylonjs/scene";
  58590. import { Color3 } from "babylonjs/Maths/math.color";
  58591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58592. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58593. /**
  58594. * The PBR material of BJS following the metal roughness convention.
  58595. *
  58596. * This fits to the PBR convention in the GLTF definition:
  58597. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58598. */
  58599. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58600. /**
  58601. * The base color has two different interpretations depending on the value of metalness.
  58602. * When the material is a metal, the base color is the specific measured reflectance value
  58603. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58604. * of the material.
  58605. */
  58606. baseColor: Color3;
  58607. /**
  58608. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58609. * well as opacity information in the alpha channel.
  58610. */
  58611. baseTexture: BaseTexture;
  58612. /**
  58613. * Specifies the metallic scalar value of the material.
  58614. * Can also be used to scale the metalness values of the metallic texture.
  58615. */
  58616. metallic: number;
  58617. /**
  58618. * Specifies the roughness scalar value of the material.
  58619. * Can also be used to scale the roughness values of the metallic texture.
  58620. */
  58621. roughness: number;
  58622. /**
  58623. * Texture containing both the metallic value in the B channel and the
  58624. * roughness value in the G channel to keep better precision.
  58625. */
  58626. metallicRoughnessTexture: BaseTexture;
  58627. /**
  58628. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58629. *
  58630. * @param name The material name
  58631. * @param scene The scene the material will be use in.
  58632. */
  58633. constructor(name: string, scene: Scene);
  58634. /**
  58635. * Return the currrent class name of the material.
  58636. */
  58637. getClassName(): string;
  58638. /**
  58639. * Makes a duplicate of the current material.
  58640. * @param name - name to use for the new material.
  58641. */
  58642. clone(name: string): PBRMetallicRoughnessMaterial;
  58643. /**
  58644. * Serialize the material to a parsable JSON object.
  58645. */
  58646. serialize(): any;
  58647. /**
  58648. * Parses a JSON object correponding to the serialize function.
  58649. */
  58650. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58651. }
  58652. }
  58653. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58654. import { Scene } from "babylonjs/scene";
  58655. import { Color3 } from "babylonjs/Maths/math.color";
  58656. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58657. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58658. /**
  58659. * The PBR material of BJS following the specular glossiness convention.
  58660. *
  58661. * This fits to the PBR convention in the GLTF definition:
  58662. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58663. */
  58664. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58665. /**
  58666. * Specifies the diffuse color of the material.
  58667. */
  58668. diffuseColor: Color3;
  58669. /**
  58670. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58671. * channel.
  58672. */
  58673. diffuseTexture: BaseTexture;
  58674. /**
  58675. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58676. */
  58677. specularColor: Color3;
  58678. /**
  58679. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58680. */
  58681. glossiness: number;
  58682. /**
  58683. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58684. */
  58685. specularGlossinessTexture: BaseTexture;
  58686. /**
  58687. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58688. *
  58689. * @param name The material name
  58690. * @param scene The scene the material will be use in.
  58691. */
  58692. constructor(name: string, scene: Scene);
  58693. /**
  58694. * Return the currrent class name of the material.
  58695. */
  58696. getClassName(): string;
  58697. /**
  58698. * Makes a duplicate of the current material.
  58699. * @param name - name to use for the new material.
  58700. */
  58701. clone(name: string): PBRSpecularGlossinessMaterial;
  58702. /**
  58703. * Serialize the material to a parsable JSON object.
  58704. */
  58705. serialize(): any;
  58706. /**
  58707. * Parses a JSON object correponding to the serialize function.
  58708. */
  58709. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58710. }
  58711. }
  58712. declare module "babylonjs/Materials/PBR/index" {
  58713. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58714. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58715. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58716. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58717. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58718. }
  58719. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58720. import { Nullable } from "babylonjs/types";
  58721. import { Scene } from "babylonjs/scene";
  58722. import { Matrix } from "babylonjs/Maths/math.vector";
  58723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58724. /**
  58725. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58726. * It can help converting any input color in a desired output one. This can then be used to create effects
  58727. * from sepia, black and white to sixties or futuristic rendering...
  58728. *
  58729. * The only supported format is currently 3dl.
  58730. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58731. */
  58732. export class ColorGradingTexture extends BaseTexture {
  58733. /**
  58734. * The current texture matrix. (will always be identity in color grading texture)
  58735. */
  58736. private _textureMatrix;
  58737. /**
  58738. * The texture URL.
  58739. */
  58740. url: string;
  58741. /**
  58742. * Empty line regex stored for GC.
  58743. */
  58744. private static _noneEmptyLineRegex;
  58745. private _engine;
  58746. /**
  58747. * Instantiates a ColorGradingTexture from the following parameters.
  58748. *
  58749. * @param url The location of the color gradind data (currently only supporting 3dl)
  58750. * @param scene The scene the texture will be used in
  58751. */
  58752. constructor(url: string, scene: Scene);
  58753. /**
  58754. * Returns the texture matrix used in most of the material.
  58755. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58756. */
  58757. getTextureMatrix(): Matrix;
  58758. /**
  58759. * Occurs when the file being loaded is a .3dl LUT file.
  58760. */
  58761. private load3dlTexture;
  58762. /**
  58763. * Starts the loading process of the texture.
  58764. */
  58765. private loadTexture;
  58766. /**
  58767. * Clones the color gradind texture.
  58768. */
  58769. clone(): ColorGradingTexture;
  58770. /**
  58771. * Called during delayed load for textures.
  58772. */
  58773. delayLoad(): void;
  58774. /**
  58775. * Parses a color grading texture serialized by Babylon.
  58776. * @param parsedTexture The texture information being parsedTexture
  58777. * @param scene The scene to load the texture in
  58778. * @param rootUrl The root url of the data assets to load
  58779. * @return A color gradind texture
  58780. */
  58781. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58782. /**
  58783. * Serializes the LUT texture to json format.
  58784. */
  58785. serialize(): any;
  58786. }
  58787. }
  58788. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58790. import { Scene } from "babylonjs/scene";
  58791. import { Nullable } from "babylonjs/types";
  58792. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58793. /**
  58794. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58795. */
  58796. export class EquiRectangularCubeTexture extends BaseTexture {
  58797. /** The six faces of the cube. */
  58798. private static _FacesMapping;
  58799. private _noMipmap;
  58800. private _onLoad;
  58801. private _onError;
  58802. /** The size of the cubemap. */
  58803. private _size;
  58804. /** The buffer of the image. */
  58805. private _buffer;
  58806. /** The width of the input image. */
  58807. private _width;
  58808. /** The height of the input image. */
  58809. private _height;
  58810. /** The URL to the image. */
  58811. url: string;
  58812. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58813. coordinatesMode: number;
  58814. /**
  58815. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58816. * @param url The location of the image
  58817. * @param scene The scene the texture will be used in
  58818. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58819. * @param noMipmap Forces to not generate the mipmap if true
  58820. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58821. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58822. * @param onLoad — defines a callback called when texture is loaded
  58823. * @param onError — defines a callback called if there is an error
  58824. */
  58825. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58826. /**
  58827. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58828. */
  58829. private loadImage;
  58830. /**
  58831. * Convert the image buffer into a cubemap and create a CubeTexture.
  58832. */
  58833. private loadTexture;
  58834. /**
  58835. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58836. * @param buffer The ArrayBuffer that should be converted.
  58837. * @returns The buffer as Float32Array.
  58838. */
  58839. private getFloat32ArrayFromArrayBuffer;
  58840. /**
  58841. * Get the current class name of the texture useful for serialization or dynamic coding.
  58842. * @returns "EquiRectangularCubeTexture"
  58843. */
  58844. getClassName(): string;
  58845. /**
  58846. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58847. * @returns A clone of the current EquiRectangularCubeTexture.
  58848. */
  58849. clone(): EquiRectangularCubeTexture;
  58850. }
  58851. }
  58852. declare module "babylonjs/Misc/tga" {
  58853. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58854. /**
  58855. * Based on jsTGALoader - Javascript loader for TGA file
  58856. * By Vincent Thibault
  58857. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58858. */
  58859. export class TGATools {
  58860. private static _TYPE_INDEXED;
  58861. private static _TYPE_RGB;
  58862. private static _TYPE_GREY;
  58863. private static _TYPE_RLE_INDEXED;
  58864. private static _TYPE_RLE_RGB;
  58865. private static _TYPE_RLE_GREY;
  58866. private static _ORIGIN_MASK;
  58867. private static _ORIGIN_SHIFT;
  58868. private static _ORIGIN_BL;
  58869. private static _ORIGIN_BR;
  58870. private static _ORIGIN_UL;
  58871. private static _ORIGIN_UR;
  58872. /**
  58873. * Gets the header of a TGA file
  58874. * @param data defines the TGA data
  58875. * @returns the header
  58876. */
  58877. static GetTGAHeader(data: Uint8Array): any;
  58878. /**
  58879. * Uploads TGA content to a Babylon Texture
  58880. * @hidden
  58881. */
  58882. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58883. /** @hidden */
  58884. 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;
  58885. /** @hidden */
  58886. 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;
  58887. /** @hidden */
  58888. 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;
  58889. /** @hidden */
  58890. 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;
  58891. /** @hidden */
  58892. 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;
  58893. /** @hidden */
  58894. 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;
  58895. }
  58896. }
  58897. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58898. import { Nullable } from "babylonjs/types";
  58899. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58900. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58901. /**
  58902. * Implementation of the TGA Texture Loader.
  58903. * @hidden
  58904. */
  58905. export class _TGATextureLoader implements IInternalTextureLoader {
  58906. /**
  58907. * Defines wether the loader supports cascade loading the different faces.
  58908. */
  58909. readonly supportCascades: boolean;
  58910. /**
  58911. * This returns if the loader support the current file information.
  58912. * @param extension defines the file extension of the file being loaded
  58913. * @returns true if the loader can load the specified file
  58914. */
  58915. canLoad(extension: string): boolean;
  58916. /**
  58917. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58918. * @param data contains the texture data
  58919. * @param texture defines the BabylonJS internal texture
  58920. * @param createPolynomials will be true if polynomials have been requested
  58921. * @param onLoad defines the callback to trigger once the texture is ready
  58922. * @param onError defines the callback to trigger in case of error
  58923. */
  58924. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58925. /**
  58926. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58927. * @param data contains the texture data
  58928. * @param texture defines the BabylonJS internal texture
  58929. * @param callback defines the method to call once ready to upload
  58930. */
  58931. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58932. }
  58933. }
  58934. declare module "babylonjs/Misc/basis" {
  58935. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58936. /**
  58937. * Info about the .basis files
  58938. */
  58939. class BasisFileInfo {
  58940. /**
  58941. * If the file has alpha
  58942. */
  58943. hasAlpha: boolean;
  58944. /**
  58945. * Info about each image of the basis file
  58946. */
  58947. images: Array<{
  58948. levels: Array<{
  58949. width: number;
  58950. height: number;
  58951. transcodedPixels: ArrayBufferView;
  58952. }>;
  58953. }>;
  58954. }
  58955. /**
  58956. * Result of transcoding a basis file
  58957. */
  58958. class TranscodeResult {
  58959. /**
  58960. * Info about the .basis file
  58961. */
  58962. fileInfo: BasisFileInfo;
  58963. /**
  58964. * Format to use when loading the file
  58965. */
  58966. format: number;
  58967. }
  58968. /**
  58969. * Configuration options for the Basis transcoder
  58970. */
  58971. export class BasisTranscodeConfiguration {
  58972. /**
  58973. * Supported compression formats used to determine the supported output format of the transcoder
  58974. */
  58975. supportedCompressionFormats?: {
  58976. /**
  58977. * etc1 compression format
  58978. */
  58979. etc1?: boolean;
  58980. /**
  58981. * s3tc compression format
  58982. */
  58983. s3tc?: boolean;
  58984. /**
  58985. * pvrtc compression format
  58986. */
  58987. pvrtc?: boolean;
  58988. /**
  58989. * etc2 compression format
  58990. */
  58991. etc2?: boolean;
  58992. };
  58993. /**
  58994. * If mipmap levels should be loaded for transcoded images (Default: true)
  58995. */
  58996. loadMipmapLevels?: boolean;
  58997. /**
  58998. * Index of a single image to load (Default: all images)
  58999. */
  59000. loadSingleImage?: number;
  59001. }
  59002. /**
  59003. * Used to load .Basis files
  59004. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59005. */
  59006. export class BasisTools {
  59007. private static _IgnoreSupportedFormats;
  59008. /**
  59009. * URL to use when loading the basis transcoder
  59010. */
  59011. static JSModuleURL: string;
  59012. /**
  59013. * URL to use when loading the wasm module for the transcoder
  59014. */
  59015. static WasmModuleURL: string;
  59016. /**
  59017. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59018. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59019. * @returns internal format corresponding to the Basis format
  59020. */
  59021. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59022. private static _WorkerPromise;
  59023. private static _Worker;
  59024. private static _actionId;
  59025. private static _CreateWorkerAsync;
  59026. /**
  59027. * Transcodes a loaded image file to compressed pixel data
  59028. * @param data image data to transcode
  59029. * @param config configuration options for the transcoding
  59030. * @returns a promise resulting in the transcoded image
  59031. */
  59032. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59033. /**
  59034. * Loads a texture from the transcode result
  59035. * @param texture texture load to
  59036. * @param transcodeResult the result of transcoding the basis file to load from
  59037. */
  59038. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59039. }
  59040. }
  59041. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59042. import { Nullable } from "babylonjs/types";
  59043. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59044. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59045. /**
  59046. * Loader for .basis file format
  59047. */
  59048. export class _BasisTextureLoader implements IInternalTextureLoader {
  59049. /**
  59050. * Defines whether the loader supports cascade loading the different faces.
  59051. */
  59052. readonly supportCascades: boolean;
  59053. /**
  59054. * This returns if the loader support the current file information.
  59055. * @param extension defines the file extension of the file being loaded
  59056. * @returns true if the loader can load the specified file
  59057. */
  59058. canLoad(extension: string): boolean;
  59059. /**
  59060. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59061. * @param data contains the texture data
  59062. * @param texture defines the BabylonJS internal texture
  59063. * @param createPolynomials will be true if polynomials have been requested
  59064. * @param onLoad defines the callback to trigger once the texture is ready
  59065. * @param onError defines the callback to trigger in case of error
  59066. */
  59067. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59068. /**
  59069. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59070. * @param data contains the texture data
  59071. * @param texture defines the BabylonJS internal texture
  59072. * @param callback defines the method to call once ready to upload
  59073. */
  59074. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59075. }
  59076. }
  59077. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59078. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59079. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59080. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59081. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59082. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59083. }
  59084. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59085. import { Scene } from "babylonjs/scene";
  59086. import { Texture } from "babylonjs/Materials/Textures/texture";
  59087. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59088. /**
  59089. * 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.
  59090. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59091. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59092. */
  59093. export class CustomProceduralTexture extends ProceduralTexture {
  59094. private _animate;
  59095. private _time;
  59096. private _config;
  59097. private _texturePath;
  59098. /**
  59099. * Instantiates a new Custom Procedural Texture.
  59100. * 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.
  59101. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59102. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59103. * @param name Define the name of the texture
  59104. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59105. * @param size Define the size of the texture to create
  59106. * @param scene Define the scene the texture belongs to
  59107. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59108. * @param generateMipMaps Define if the texture should creates mip maps or not
  59109. */
  59110. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59111. private _loadJson;
  59112. /**
  59113. * Is the texture ready to be used ? (rendered at least once)
  59114. * @returns true if ready, otherwise, false.
  59115. */
  59116. isReady(): boolean;
  59117. /**
  59118. * Render the texture to its associated render target.
  59119. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59120. */
  59121. render(useCameraPostProcess?: boolean): void;
  59122. /**
  59123. * Update the list of dependant textures samplers in the shader.
  59124. */
  59125. updateTextures(): void;
  59126. /**
  59127. * Update the uniform values of the procedural texture in the shader.
  59128. */
  59129. updateShaderUniforms(): void;
  59130. /**
  59131. * Define if the texture animates or not.
  59132. */
  59133. get animate(): boolean;
  59134. set animate(value: boolean);
  59135. }
  59136. }
  59137. declare module "babylonjs/Shaders/noise.fragment" {
  59138. /** @hidden */
  59139. export var noisePixelShader: {
  59140. name: string;
  59141. shader: string;
  59142. };
  59143. }
  59144. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59145. import { Nullable } from "babylonjs/types";
  59146. import { Scene } from "babylonjs/scene";
  59147. import { Texture } from "babylonjs/Materials/Textures/texture";
  59148. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59149. import "babylonjs/Shaders/noise.fragment";
  59150. /**
  59151. * Class used to generate noise procedural textures
  59152. */
  59153. export class NoiseProceduralTexture extends ProceduralTexture {
  59154. private _time;
  59155. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59156. brightness: number;
  59157. /** Defines the number of octaves to process */
  59158. octaves: number;
  59159. /** Defines the level of persistence (0.8 by default) */
  59160. persistence: number;
  59161. /** Gets or sets animation speed factor (default is 1) */
  59162. animationSpeedFactor: number;
  59163. /**
  59164. * Creates a new NoiseProceduralTexture
  59165. * @param name defines the name fo the texture
  59166. * @param size defines the size of the texture (default is 256)
  59167. * @param scene defines the hosting scene
  59168. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59169. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59170. */
  59171. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59172. private _updateShaderUniforms;
  59173. protected _getDefines(): string;
  59174. /** Generate the current state of the procedural texture */
  59175. render(useCameraPostProcess?: boolean): void;
  59176. /**
  59177. * Serializes this noise procedural texture
  59178. * @returns a serialized noise procedural texture object
  59179. */
  59180. serialize(): any;
  59181. /**
  59182. * Clone the texture.
  59183. * @returns the cloned texture
  59184. */
  59185. clone(): NoiseProceduralTexture;
  59186. /**
  59187. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59188. * @param parsedTexture defines parsed texture data
  59189. * @param scene defines the current scene
  59190. * @param rootUrl defines the root URL containing noise procedural texture information
  59191. * @returns a parsed NoiseProceduralTexture
  59192. */
  59193. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59194. }
  59195. }
  59196. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59197. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59198. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59199. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59200. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59201. }
  59202. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59203. import { Nullable } from "babylonjs/types";
  59204. import { Scene } from "babylonjs/scene";
  59205. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59206. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59207. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59208. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59209. /**
  59210. * Raw cube texture where the raw buffers are passed in
  59211. */
  59212. export class RawCubeTexture extends CubeTexture {
  59213. /**
  59214. * Creates a cube texture where the raw buffers are passed in.
  59215. * @param scene defines the scene the texture is attached to
  59216. * @param data defines the array of data to use to create each face
  59217. * @param size defines the size of the textures
  59218. * @param format defines the format of the data
  59219. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59220. * @param generateMipMaps defines if the engine should generate the mip levels
  59221. * @param invertY defines if data must be stored with Y axis inverted
  59222. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59223. * @param compression defines the compression used (null by default)
  59224. */
  59225. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59226. /**
  59227. * Updates the raw cube texture.
  59228. * @param data defines the data to store
  59229. * @param format defines the data format
  59230. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59231. * @param invertY defines if data must be stored with Y axis inverted
  59232. * @param compression defines the compression used (null by default)
  59233. * @param level defines which level of the texture to update
  59234. */
  59235. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59236. /**
  59237. * Updates a raw cube texture with RGBD encoded data.
  59238. * @param data defines the array of data [mipmap][face] to use to create each face
  59239. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59240. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59241. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59242. * @returns a promsie that resolves when the operation is complete
  59243. */
  59244. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59245. /**
  59246. * Clones the raw cube texture.
  59247. * @return a new cube texture
  59248. */
  59249. clone(): CubeTexture;
  59250. /** @hidden */
  59251. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59252. }
  59253. }
  59254. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59255. import { Scene } from "babylonjs/scene";
  59256. import { Texture } from "babylonjs/Materials/Textures/texture";
  59257. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59258. /**
  59259. * Class used to store 3D textures containing user data
  59260. */
  59261. export class RawTexture3D extends Texture {
  59262. /** Gets or sets the texture format to use */
  59263. format: number;
  59264. private _engine;
  59265. /**
  59266. * Create a new RawTexture3D
  59267. * @param data defines the data of the texture
  59268. * @param width defines the width of the texture
  59269. * @param height defines the height of the texture
  59270. * @param depth defines the depth of the texture
  59271. * @param format defines the texture format to use
  59272. * @param scene defines the hosting scene
  59273. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59274. * @param invertY defines if texture must be stored with Y axis inverted
  59275. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59276. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59277. */
  59278. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59279. /** Gets or sets the texture format to use */
  59280. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59281. /**
  59282. * Update the texture with new data
  59283. * @param data defines the data to store in the texture
  59284. */
  59285. update(data: ArrayBufferView): void;
  59286. }
  59287. }
  59288. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59289. import { Scene } from "babylonjs/scene";
  59290. import { Texture } from "babylonjs/Materials/Textures/texture";
  59291. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59292. /**
  59293. * Class used to store 2D array textures containing user data
  59294. */
  59295. export class RawTexture2DArray extends Texture {
  59296. /** Gets or sets the texture format to use */
  59297. format: number;
  59298. private _engine;
  59299. /**
  59300. * Create a new RawTexture2DArray
  59301. * @param data defines the data of the texture
  59302. * @param width defines the width of the texture
  59303. * @param height defines the height of the texture
  59304. * @param depth defines the number of layers of the texture
  59305. * @param format defines the texture format to use
  59306. * @param scene defines the hosting scene
  59307. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59308. * @param invertY defines if texture must be stored with Y axis inverted
  59309. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59310. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59311. */
  59312. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59313. /** Gets or sets the texture format to use */
  59314. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59315. /**
  59316. * Update the texture with new data
  59317. * @param data defines the data to store in the texture
  59318. */
  59319. update(data: ArrayBufferView): void;
  59320. }
  59321. }
  59322. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59323. import { Scene } from "babylonjs/scene";
  59324. import { Plane } from "babylonjs/Maths/math.plane";
  59325. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59326. /**
  59327. * Creates a refraction texture used by refraction channel of the standard material.
  59328. * It is like a mirror but to see through a material.
  59329. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59330. */
  59331. export class RefractionTexture extends RenderTargetTexture {
  59332. /**
  59333. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59334. * 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.
  59335. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59336. */
  59337. refractionPlane: Plane;
  59338. /**
  59339. * Define how deep under the surface we should see.
  59340. */
  59341. depth: number;
  59342. /**
  59343. * Creates a refraction texture used by refraction channel of the standard material.
  59344. * It is like a mirror but to see through a material.
  59345. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59346. * @param name Define the texture name
  59347. * @param size Define the size of the underlying texture
  59348. * @param scene Define the scene the refraction belongs to
  59349. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59350. */
  59351. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59352. /**
  59353. * Clone the refraction texture.
  59354. * @returns the cloned texture
  59355. */
  59356. clone(): RefractionTexture;
  59357. /**
  59358. * Serialize the texture to a JSON representation you could use in Parse later on
  59359. * @returns the serialized JSON representation
  59360. */
  59361. serialize(): any;
  59362. }
  59363. }
  59364. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59365. import { Nullable } from "babylonjs/types";
  59366. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59367. import { Matrix } from "babylonjs/Maths/math.vector";
  59368. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59369. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59370. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59371. import { Scene } from "babylonjs/scene";
  59372. /**
  59373. * Defines the options related to the creation of an HtmlElementTexture
  59374. */
  59375. export interface IHtmlElementTextureOptions {
  59376. /**
  59377. * Defines wether mip maps should be created or not.
  59378. */
  59379. generateMipMaps?: boolean;
  59380. /**
  59381. * Defines the sampling mode of the texture.
  59382. */
  59383. samplingMode?: number;
  59384. /**
  59385. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59386. */
  59387. engine: Nullable<ThinEngine>;
  59388. /**
  59389. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59390. */
  59391. scene: Nullable<Scene>;
  59392. }
  59393. /**
  59394. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59395. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59396. * is automatically managed.
  59397. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59398. * in your application.
  59399. *
  59400. * As the update is not automatic, you need to call them manually.
  59401. */
  59402. export class HtmlElementTexture extends BaseTexture {
  59403. /**
  59404. * The texture URL.
  59405. */
  59406. element: HTMLVideoElement | HTMLCanvasElement;
  59407. private static readonly DefaultOptions;
  59408. private _textureMatrix;
  59409. private _engine;
  59410. private _isVideo;
  59411. private _generateMipMaps;
  59412. private _samplingMode;
  59413. /**
  59414. * Instantiates a HtmlElementTexture from the following parameters.
  59415. *
  59416. * @param name Defines the name of the texture
  59417. * @param element Defines the video or canvas the texture is filled with
  59418. * @param options Defines the other none mandatory texture creation options
  59419. */
  59420. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59421. private _createInternalTexture;
  59422. /**
  59423. * Returns the texture matrix used in most of the material.
  59424. */
  59425. getTextureMatrix(): Matrix;
  59426. /**
  59427. * Updates the content of the texture.
  59428. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59429. */
  59430. update(invertY?: Nullable<boolean>): void;
  59431. }
  59432. }
  59433. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59434. import { Vector2 } from "babylonjs/Maths/math.vector";
  59435. /**
  59436. * Defines the basic options interface of a TexturePacker Frame
  59437. */
  59438. export interface ITexturePackerFrame {
  59439. /**
  59440. * The frame ID
  59441. */
  59442. id: number;
  59443. /**
  59444. * The frames Scale
  59445. */
  59446. scale: Vector2;
  59447. /**
  59448. * The Frames offset
  59449. */
  59450. offset: Vector2;
  59451. }
  59452. /**
  59453. * This is a support class for frame Data on texture packer sets.
  59454. */
  59455. export class TexturePackerFrame implements ITexturePackerFrame {
  59456. /**
  59457. * The frame ID
  59458. */
  59459. id: number;
  59460. /**
  59461. * The frames Scale
  59462. */
  59463. scale: Vector2;
  59464. /**
  59465. * The Frames offset
  59466. */
  59467. offset: Vector2;
  59468. /**
  59469. * Initializes a texture package frame.
  59470. * @param id The numerical frame identifier
  59471. * @param scale Scalar Vector2 for UV frame
  59472. * @param offset Vector2 for the frame position in UV units.
  59473. * @returns TexturePackerFrame
  59474. */
  59475. constructor(id: number, scale: Vector2, offset: Vector2);
  59476. }
  59477. }
  59478. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59480. import { Scene } from "babylonjs/scene";
  59481. import { Nullable } from "babylonjs/types";
  59482. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59483. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59484. /**
  59485. * Defines the basic options interface of a TexturePacker
  59486. */
  59487. export interface ITexturePackerOptions {
  59488. /**
  59489. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59490. */
  59491. map?: string[];
  59492. /**
  59493. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59494. */
  59495. uvsIn?: string;
  59496. /**
  59497. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59498. */
  59499. uvsOut?: string;
  59500. /**
  59501. * number representing the layout style. Defaults to LAYOUT_STRIP
  59502. */
  59503. layout?: number;
  59504. /**
  59505. * number of columns if using custom column count layout(2). This defaults to 4.
  59506. */
  59507. colnum?: number;
  59508. /**
  59509. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59510. */
  59511. updateInputMeshes?: boolean;
  59512. /**
  59513. * boolean flag to dispose all the source textures. Defaults to true.
  59514. */
  59515. disposeSources?: boolean;
  59516. /**
  59517. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59518. */
  59519. fillBlanks?: boolean;
  59520. /**
  59521. * string value representing the context fill style color. Defaults to 'black'.
  59522. */
  59523. customFillColor?: string;
  59524. /**
  59525. * Width and Height Value of each Frame in the TexturePacker Sets
  59526. */
  59527. frameSize?: number;
  59528. /**
  59529. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59530. */
  59531. paddingRatio?: number;
  59532. /**
  59533. * Number that declares the fill method for the padding gutter.
  59534. */
  59535. paddingMode?: number;
  59536. /**
  59537. * If in SUBUV_COLOR padding mode what color to use.
  59538. */
  59539. paddingColor?: Color3 | Color4;
  59540. }
  59541. /**
  59542. * Defines the basic interface of a TexturePacker JSON File
  59543. */
  59544. export interface ITexturePackerJSON {
  59545. /**
  59546. * The frame ID
  59547. */
  59548. name: string;
  59549. /**
  59550. * The base64 channel data
  59551. */
  59552. sets: any;
  59553. /**
  59554. * The options of the Packer
  59555. */
  59556. options: ITexturePackerOptions;
  59557. /**
  59558. * The frame data of the Packer
  59559. */
  59560. frames: Array<number>;
  59561. }
  59562. /**
  59563. * This is a support class that generates a series of packed texture sets.
  59564. * @see https://doc.babylonjs.com/babylon101/materials
  59565. */
  59566. export class TexturePacker {
  59567. /** Packer Layout Constant 0 */
  59568. static readonly LAYOUT_STRIP: number;
  59569. /** Packer Layout Constant 1 */
  59570. static readonly LAYOUT_POWER2: number;
  59571. /** Packer Layout Constant 2 */
  59572. static readonly LAYOUT_COLNUM: number;
  59573. /** Packer Layout Constant 0 */
  59574. static readonly SUBUV_WRAP: number;
  59575. /** Packer Layout Constant 1 */
  59576. static readonly SUBUV_EXTEND: number;
  59577. /** Packer Layout Constant 2 */
  59578. static readonly SUBUV_COLOR: number;
  59579. /** The Name of the Texture Package */
  59580. name: string;
  59581. /** The scene scope of the TexturePacker */
  59582. scene: Scene;
  59583. /** The Meshes to target */
  59584. meshes: AbstractMesh[];
  59585. /** Arguments passed with the Constructor */
  59586. options: ITexturePackerOptions;
  59587. /** The promise that is started upon initialization */
  59588. promise: Nullable<Promise<TexturePacker | string>>;
  59589. /** The Container object for the channel sets that are generated */
  59590. sets: object;
  59591. /** The Container array for the frames that are generated */
  59592. frames: TexturePackerFrame[];
  59593. /** The expected number of textures the system is parsing. */
  59594. private _expecting;
  59595. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59596. private _paddingValue;
  59597. /**
  59598. * Initializes a texture package series from an array of meshes or a single mesh.
  59599. * @param name The name of the package
  59600. * @param meshes The target meshes to compose the package from
  59601. * @param options The arguments that texture packer should follow while building.
  59602. * @param scene The scene which the textures are scoped to.
  59603. * @returns TexturePacker
  59604. */
  59605. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59606. /**
  59607. * Starts the package process
  59608. * @param resolve The promises resolution function
  59609. * @returns TexturePacker
  59610. */
  59611. private _createFrames;
  59612. /**
  59613. * Calculates the Size of the Channel Sets
  59614. * @returns Vector2
  59615. */
  59616. private _calculateSize;
  59617. /**
  59618. * Calculates the UV data for the frames.
  59619. * @param baseSize the base frameSize
  59620. * @param padding the base frame padding
  59621. * @param dtSize size of the Dynamic Texture for that channel
  59622. * @param dtUnits is 1/dtSize
  59623. * @param update flag to update the input meshes
  59624. */
  59625. private _calculateMeshUVFrames;
  59626. /**
  59627. * Calculates the frames Offset.
  59628. * @param index of the frame
  59629. * @returns Vector2
  59630. */
  59631. private _getFrameOffset;
  59632. /**
  59633. * Updates a Mesh to the frame data
  59634. * @param mesh that is the target
  59635. * @param frameID or the frame index
  59636. */
  59637. private _updateMeshUV;
  59638. /**
  59639. * Updates a Meshes materials to use the texture packer channels
  59640. * @param m is the mesh to target
  59641. * @param force all channels on the packer to be set.
  59642. */
  59643. private _updateTextureReferences;
  59644. /**
  59645. * Public method to set a Mesh to a frame
  59646. * @param m that is the target
  59647. * @param frameID or the frame index
  59648. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59649. */
  59650. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59651. /**
  59652. * Starts the async promise to compile the texture packer.
  59653. * @returns Promise<void>
  59654. */
  59655. processAsync(): Promise<void>;
  59656. /**
  59657. * Disposes all textures associated with this packer
  59658. */
  59659. dispose(): void;
  59660. /**
  59661. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59662. * @param imageType is the image type to use.
  59663. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59664. */
  59665. download(imageType?: string, quality?: number): void;
  59666. /**
  59667. * Public method to load a texturePacker JSON file.
  59668. * @param data of the JSON file in string format.
  59669. */
  59670. updateFromJSON(data: string): void;
  59671. }
  59672. }
  59673. declare module "babylonjs/Materials/Textures/Packer/index" {
  59674. export * from "babylonjs/Materials/Textures/Packer/packer";
  59675. export * from "babylonjs/Materials/Textures/Packer/frame";
  59676. }
  59677. declare module "babylonjs/Materials/Textures/index" {
  59678. export * from "babylonjs/Materials/Textures/baseTexture";
  59679. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59680. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59681. export * from "babylonjs/Materials/Textures/cubeTexture";
  59682. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59683. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59684. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59685. export * from "babylonjs/Materials/Textures/internalTexture";
  59686. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59687. export * from "babylonjs/Materials/Textures/Loaders/index";
  59688. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59689. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59690. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59691. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59692. export * from "babylonjs/Materials/Textures/rawTexture";
  59693. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59694. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59695. export * from "babylonjs/Materials/Textures/refractionTexture";
  59696. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59697. export * from "babylonjs/Materials/Textures/texture";
  59698. export * from "babylonjs/Materials/Textures/videoTexture";
  59699. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59700. export * from "babylonjs/Materials/Textures/Packer/index";
  59701. }
  59702. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59703. /**
  59704. * Enum used to define the target of a block
  59705. */
  59706. export enum NodeMaterialBlockTargets {
  59707. /** Vertex shader */
  59708. Vertex = 1,
  59709. /** Fragment shader */
  59710. Fragment = 2,
  59711. /** Neutral */
  59712. Neutral = 4,
  59713. /** Vertex and Fragment */
  59714. VertexAndFragment = 3
  59715. }
  59716. }
  59717. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59718. /**
  59719. * Defines the kind of connection point for node based material
  59720. */
  59721. export enum NodeMaterialBlockConnectionPointTypes {
  59722. /** Float */
  59723. Float = 1,
  59724. /** Int */
  59725. Int = 2,
  59726. /** Vector2 */
  59727. Vector2 = 4,
  59728. /** Vector3 */
  59729. Vector3 = 8,
  59730. /** Vector4 */
  59731. Vector4 = 16,
  59732. /** Color3 */
  59733. Color3 = 32,
  59734. /** Color4 */
  59735. Color4 = 64,
  59736. /** Matrix */
  59737. Matrix = 128,
  59738. /** Detect type based on connection */
  59739. AutoDetect = 1024,
  59740. /** Output type that will be defined by input type */
  59741. BasedOnInput = 2048
  59742. }
  59743. }
  59744. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59745. /**
  59746. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59747. */
  59748. export enum NodeMaterialBlockConnectionPointMode {
  59749. /** Value is an uniform */
  59750. Uniform = 0,
  59751. /** Value is a mesh attribute */
  59752. Attribute = 1,
  59753. /** Value is a varying between vertex and fragment shaders */
  59754. Varying = 2,
  59755. /** Mode is undefined */
  59756. Undefined = 3
  59757. }
  59758. }
  59759. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59760. /**
  59761. * Enum used to define system values e.g. values automatically provided by the system
  59762. */
  59763. export enum NodeMaterialSystemValues {
  59764. /** World */
  59765. World = 1,
  59766. /** View */
  59767. View = 2,
  59768. /** Projection */
  59769. Projection = 3,
  59770. /** ViewProjection */
  59771. ViewProjection = 4,
  59772. /** WorldView */
  59773. WorldView = 5,
  59774. /** WorldViewProjection */
  59775. WorldViewProjection = 6,
  59776. /** CameraPosition */
  59777. CameraPosition = 7,
  59778. /** Fog Color */
  59779. FogColor = 8,
  59780. /** Delta time */
  59781. DeltaTime = 9
  59782. }
  59783. }
  59784. declare module "babylonjs/Materials/Node/Enums/index" {
  59785. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59786. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59787. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59788. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59789. }
  59790. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59792. /**
  59793. * Root class for all node material optimizers
  59794. */
  59795. export class NodeMaterialOptimizer {
  59796. /**
  59797. * Function used to optimize a NodeMaterial graph
  59798. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59799. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59800. */
  59801. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59802. }
  59803. }
  59804. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59808. import { Scene } from "babylonjs/scene";
  59809. /**
  59810. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59811. */
  59812. export class TransformBlock extends NodeMaterialBlock {
  59813. /**
  59814. * Defines the value to use to complement W value to transform it to a Vector4
  59815. */
  59816. complementW: number;
  59817. /**
  59818. * Defines the value to use to complement z value to transform it to a Vector4
  59819. */
  59820. complementZ: number;
  59821. /**
  59822. * Creates a new TransformBlock
  59823. * @param name defines the block name
  59824. */
  59825. constructor(name: string);
  59826. /**
  59827. * Gets the current class name
  59828. * @returns the class name
  59829. */
  59830. getClassName(): string;
  59831. /**
  59832. * Gets the vector input
  59833. */
  59834. get vector(): NodeMaterialConnectionPoint;
  59835. /**
  59836. * Gets the output component
  59837. */
  59838. get output(): NodeMaterialConnectionPoint;
  59839. /**
  59840. * Gets the xyz output component
  59841. */
  59842. get xyz(): NodeMaterialConnectionPoint;
  59843. /**
  59844. * Gets the matrix transform input
  59845. */
  59846. get transform(): NodeMaterialConnectionPoint;
  59847. protected _buildBlock(state: NodeMaterialBuildState): this;
  59848. serialize(): any;
  59849. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59850. protected _dumpPropertiesCode(): string;
  59851. }
  59852. }
  59853. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59854. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59855. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59857. /**
  59858. * Block used to output the vertex position
  59859. */
  59860. export class VertexOutputBlock extends NodeMaterialBlock {
  59861. /**
  59862. * Creates a new VertexOutputBlock
  59863. * @param name defines the block name
  59864. */
  59865. constructor(name: string);
  59866. /**
  59867. * Gets the current class name
  59868. * @returns the class name
  59869. */
  59870. getClassName(): string;
  59871. /**
  59872. * Gets the vector input component
  59873. */
  59874. get vector(): NodeMaterialConnectionPoint;
  59875. protected _buildBlock(state: NodeMaterialBuildState): this;
  59876. }
  59877. }
  59878. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59879. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59880. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59881. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59882. /**
  59883. * Block used to output the final color
  59884. */
  59885. export class FragmentOutputBlock extends NodeMaterialBlock {
  59886. /**
  59887. * Create a new FragmentOutputBlock
  59888. * @param name defines the block name
  59889. */
  59890. constructor(name: string);
  59891. /**
  59892. * Gets the current class name
  59893. * @returns the class name
  59894. */
  59895. getClassName(): string;
  59896. /**
  59897. * Gets the rgba input component
  59898. */
  59899. get rgba(): NodeMaterialConnectionPoint;
  59900. /**
  59901. * Gets the rgb input component
  59902. */
  59903. get rgb(): NodeMaterialConnectionPoint;
  59904. /**
  59905. * Gets the a input component
  59906. */
  59907. get a(): NodeMaterialConnectionPoint;
  59908. protected _buildBlock(state: NodeMaterialBuildState): this;
  59909. }
  59910. }
  59911. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59912. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59913. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59914. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59917. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59918. import { Effect } from "babylonjs/Materials/effect";
  59919. import { Mesh } from "babylonjs/Meshes/mesh";
  59920. import { Nullable } from "babylonjs/types";
  59921. import { Scene } from "babylonjs/scene";
  59922. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59923. /**
  59924. * Block used to read a reflection texture from a sampler
  59925. */
  59926. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59927. private _define3DName;
  59928. private _defineCubicName;
  59929. private _defineExplicitName;
  59930. private _defineProjectionName;
  59931. private _defineLocalCubicName;
  59932. private _defineSphericalName;
  59933. private _definePlanarName;
  59934. private _defineEquirectangularName;
  59935. private _defineMirroredEquirectangularFixedName;
  59936. private _defineEquirectangularFixedName;
  59937. private _defineSkyboxName;
  59938. private _cubeSamplerName;
  59939. private _2DSamplerName;
  59940. private _positionUVWName;
  59941. private _directionWName;
  59942. private _reflectionCoordsName;
  59943. private _reflection2DCoordsName;
  59944. private _reflectionColorName;
  59945. private _reflectionMatrixName;
  59946. /**
  59947. * Gets or sets the texture associated with the node
  59948. */
  59949. texture: Nullable<BaseTexture>;
  59950. /**
  59951. * Create a new TextureBlock
  59952. * @param name defines the block name
  59953. */
  59954. constructor(name: string);
  59955. /**
  59956. * Gets the current class name
  59957. * @returns the class name
  59958. */
  59959. getClassName(): string;
  59960. /**
  59961. * Gets the world position input component
  59962. */
  59963. get position(): NodeMaterialConnectionPoint;
  59964. /**
  59965. * Gets the world position input component
  59966. */
  59967. get worldPosition(): NodeMaterialConnectionPoint;
  59968. /**
  59969. * Gets the world normal input component
  59970. */
  59971. get worldNormal(): NodeMaterialConnectionPoint;
  59972. /**
  59973. * Gets the world input component
  59974. */
  59975. get world(): NodeMaterialConnectionPoint;
  59976. /**
  59977. * Gets the camera (or eye) position component
  59978. */
  59979. get cameraPosition(): NodeMaterialConnectionPoint;
  59980. /**
  59981. * Gets the view input component
  59982. */
  59983. get view(): NodeMaterialConnectionPoint;
  59984. /**
  59985. * Gets the rgb output component
  59986. */
  59987. get rgb(): NodeMaterialConnectionPoint;
  59988. /**
  59989. * Gets the r output component
  59990. */
  59991. get r(): NodeMaterialConnectionPoint;
  59992. /**
  59993. * Gets the g output component
  59994. */
  59995. get g(): NodeMaterialConnectionPoint;
  59996. /**
  59997. * Gets the b output component
  59998. */
  59999. get b(): NodeMaterialConnectionPoint;
  60000. autoConfigure(material: NodeMaterial): void;
  60001. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60002. isReady(): boolean;
  60003. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60004. private _injectVertexCode;
  60005. private _writeOutput;
  60006. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60007. protected _dumpPropertiesCode(): string;
  60008. serialize(): any;
  60009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60010. }
  60011. }
  60012. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60014. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60015. import { Scene } from "babylonjs/scene";
  60016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60017. import { Matrix } from "babylonjs/Maths/math.vector";
  60018. import { Mesh } from "babylonjs/Meshes/mesh";
  60019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60020. import { Observable } from "babylonjs/Misc/observable";
  60021. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60022. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60023. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60024. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60025. import { Nullable } from "babylonjs/types";
  60026. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60027. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60028. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60029. /**
  60030. * Interface used to configure the node material editor
  60031. */
  60032. export interface INodeMaterialEditorOptions {
  60033. /** Define the URl to load node editor script */
  60034. editorURL?: string;
  60035. }
  60036. /** @hidden */
  60037. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60038. NORMAL: boolean;
  60039. TANGENT: boolean;
  60040. UV1: boolean;
  60041. /** BONES */
  60042. NUM_BONE_INFLUENCERS: number;
  60043. BonesPerMesh: number;
  60044. BONETEXTURE: boolean;
  60045. /** MORPH TARGETS */
  60046. MORPHTARGETS: boolean;
  60047. MORPHTARGETS_NORMAL: boolean;
  60048. MORPHTARGETS_TANGENT: boolean;
  60049. MORPHTARGETS_UV: boolean;
  60050. NUM_MORPH_INFLUENCERS: number;
  60051. /** IMAGE PROCESSING */
  60052. IMAGEPROCESSING: boolean;
  60053. VIGNETTE: boolean;
  60054. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60055. VIGNETTEBLENDMODEOPAQUE: boolean;
  60056. TONEMAPPING: boolean;
  60057. TONEMAPPING_ACES: boolean;
  60058. CONTRAST: boolean;
  60059. EXPOSURE: boolean;
  60060. COLORCURVES: boolean;
  60061. COLORGRADING: boolean;
  60062. COLORGRADING3D: boolean;
  60063. SAMPLER3DGREENDEPTH: boolean;
  60064. SAMPLER3DBGRMAP: boolean;
  60065. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60066. /** MISC. */
  60067. BUMPDIRECTUV: number;
  60068. constructor();
  60069. setValue(name: string, value: boolean): void;
  60070. }
  60071. /**
  60072. * Class used to configure NodeMaterial
  60073. */
  60074. export interface INodeMaterialOptions {
  60075. /**
  60076. * Defines if blocks should emit comments
  60077. */
  60078. emitComments: boolean;
  60079. }
  60080. /**
  60081. * Class used to create a node based material built by assembling shader blocks
  60082. */
  60083. export class NodeMaterial extends PushMaterial {
  60084. private static _BuildIdGenerator;
  60085. private _options;
  60086. private _vertexCompilationState;
  60087. private _fragmentCompilationState;
  60088. private _sharedData;
  60089. private _buildId;
  60090. private _buildWasSuccessful;
  60091. private _cachedWorldViewMatrix;
  60092. private _cachedWorldViewProjectionMatrix;
  60093. private _optimizers;
  60094. private _animationFrame;
  60095. /** Define the Url to load node editor script */
  60096. static EditorURL: string;
  60097. /** Define the Url to load snippets */
  60098. static SnippetUrl: string;
  60099. private BJSNODEMATERIALEDITOR;
  60100. /** Get the inspector from bundle or global */
  60101. private _getGlobalNodeMaterialEditor;
  60102. /**
  60103. * Gets or sets data used by visual editor
  60104. * @see https://nme.babylonjs.com
  60105. */
  60106. editorData: any;
  60107. /**
  60108. * 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)
  60109. */
  60110. ignoreAlpha: boolean;
  60111. /**
  60112. * Defines the maximum number of lights that can be used in the material
  60113. */
  60114. maxSimultaneousLights: number;
  60115. /**
  60116. * Observable raised when the material is built
  60117. */
  60118. onBuildObservable: Observable<NodeMaterial>;
  60119. /**
  60120. * Gets or sets the root nodes of the material vertex shader
  60121. */
  60122. _vertexOutputNodes: NodeMaterialBlock[];
  60123. /**
  60124. * Gets or sets the root nodes of the material fragment (pixel) shader
  60125. */
  60126. _fragmentOutputNodes: NodeMaterialBlock[];
  60127. /** Gets or sets options to control the node material overall behavior */
  60128. get options(): INodeMaterialOptions;
  60129. set options(options: INodeMaterialOptions);
  60130. /**
  60131. * Default configuration related to image processing available in the standard Material.
  60132. */
  60133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60134. /**
  60135. * Gets the image processing configuration used either in this material.
  60136. */
  60137. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60138. /**
  60139. * Sets the Default image processing configuration used either in the this material.
  60140. *
  60141. * If sets to null, the scene one is in use.
  60142. */
  60143. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60144. /**
  60145. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60146. */
  60147. attachedBlocks: NodeMaterialBlock[];
  60148. /**
  60149. * Create a new node based material
  60150. * @param name defines the material name
  60151. * @param scene defines the hosting scene
  60152. * @param options defines creation option
  60153. */
  60154. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60155. /**
  60156. * Gets the current class name of the material e.g. "NodeMaterial"
  60157. * @returns the class name
  60158. */
  60159. getClassName(): string;
  60160. /**
  60161. * Keep track of the image processing observer to allow dispose and replace.
  60162. */
  60163. private _imageProcessingObserver;
  60164. /**
  60165. * Attaches a new image processing configuration to the Standard Material.
  60166. * @param configuration
  60167. */
  60168. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60169. /**
  60170. * Get a block by its name
  60171. * @param name defines the name of the block to retrieve
  60172. * @returns the required block or null if not found
  60173. */
  60174. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60175. /**
  60176. * Get a block by its name
  60177. * @param predicate defines the predicate used to find the good candidate
  60178. * @returns the required block or null if not found
  60179. */
  60180. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60181. /**
  60182. * Get an input block by its name
  60183. * @param predicate defines the predicate used to find the good candidate
  60184. * @returns the required input block or null if not found
  60185. */
  60186. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60187. /**
  60188. * Gets the list of input blocks attached to this material
  60189. * @returns an array of InputBlocks
  60190. */
  60191. getInputBlocks(): InputBlock[];
  60192. /**
  60193. * Adds a new optimizer to the list of optimizers
  60194. * @param optimizer defines the optimizers to add
  60195. * @returns the current material
  60196. */
  60197. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60198. /**
  60199. * Remove an optimizer from the list of optimizers
  60200. * @param optimizer defines the optimizers to remove
  60201. * @returns the current material
  60202. */
  60203. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60204. /**
  60205. * Add a new block to the list of output nodes
  60206. * @param node defines the node to add
  60207. * @returns the current material
  60208. */
  60209. addOutputNode(node: NodeMaterialBlock): this;
  60210. /**
  60211. * Remove a block from the list of root nodes
  60212. * @param node defines the node to remove
  60213. * @returns the current material
  60214. */
  60215. removeOutputNode(node: NodeMaterialBlock): this;
  60216. private _addVertexOutputNode;
  60217. private _removeVertexOutputNode;
  60218. private _addFragmentOutputNode;
  60219. private _removeFragmentOutputNode;
  60220. /**
  60221. * Specifies if the material will require alpha blending
  60222. * @returns a boolean specifying if alpha blending is needed
  60223. */
  60224. needAlphaBlending(): boolean;
  60225. /**
  60226. * Specifies if this material should be rendered in alpha test mode
  60227. * @returns a boolean specifying if an alpha test is needed.
  60228. */
  60229. needAlphaTesting(): boolean;
  60230. private _initializeBlock;
  60231. private _resetDualBlocks;
  60232. /**
  60233. * Remove a block from the current node material
  60234. * @param block defines the block to remove
  60235. */
  60236. removeBlock(block: NodeMaterialBlock): void;
  60237. /**
  60238. * Build the material and generates the inner effect
  60239. * @param verbose defines if the build should log activity
  60240. */
  60241. build(verbose?: boolean): void;
  60242. /**
  60243. * Runs an otpimization phase to try to improve the shader code
  60244. */
  60245. optimize(): void;
  60246. private _prepareDefinesForAttributes;
  60247. /**
  60248. * Get if the submesh is ready to be used and all its information available.
  60249. * Child classes can use it to update shaders
  60250. * @param mesh defines the mesh to check
  60251. * @param subMesh defines which submesh to check
  60252. * @param useInstances specifies that instances should be used
  60253. * @returns a boolean indicating that the submesh is ready or not
  60254. */
  60255. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60256. /**
  60257. * Get a string representing the shaders built by the current node graph
  60258. */
  60259. get compiledShaders(): string;
  60260. /**
  60261. * Binds the world matrix to the material
  60262. * @param world defines the world transformation matrix
  60263. */
  60264. bindOnlyWorldMatrix(world: Matrix): void;
  60265. /**
  60266. * Binds the submesh to this material by preparing the effect and shader to draw
  60267. * @param world defines the world transformation matrix
  60268. * @param mesh defines the mesh containing the submesh
  60269. * @param subMesh defines the submesh to bind the material to
  60270. */
  60271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60272. /**
  60273. * Gets the active textures from the material
  60274. * @returns an array of textures
  60275. */
  60276. getActiveTextures(): BaseTexture[];
  60277. /**
  60278. * Gets the list of texture blocks
  60279. * @returns an array of texture blocks
  60280. */
  60281. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60282. /**
  60283. * Specifies if the material uses a texture
  60284. * @param texture defines the texture to check against the material
  60285. * @returns a boolean specifying if the material uses the texture
  60286. */
  60287. hasTexture(texture: BaseTexture): boolean;
  60288. /**
  60289. * Disposes the material
  60290. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60291. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60292. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60293. */
  60294. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60295. /** Creates the node editor window. */
  60296. private _createNodeEditor;
  60297. /**
  60298. * Launch the node material editor
  60299. * @param config Define the configuration of the editor
  60300. * @return a promise fulfilled when the node editor is visible
  60301. */
  60302. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60303. /**
  60304. * Clear the current material
  60305. */
  60306. clear(): void;
  60307. /**
  60308. * Clear the current material and set it to a default state
  60309. */
  60310. setToDefault(): void;
  60311. /**
  60312. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60313. * @param url defines the url to load from
  60314. * @returns a promise that will fullfil when the material is fully loaded
  60315. */
  60316. loadAsync(url: string): Promise<void>;
  60317. private _gatherBlocks;
  60318. /**
  60319. * Generate a string containing the code declaration required to create an equivalent of this material
  60320. * @returns a string
  60321. */
  60322. generateCode(): string;
  60323. /**
  60324. * Serializes this material in a JSON representation
  60325. * @returns the serialized material object
  60326. */
  60327. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60328. private _restoreConnections;
  60329. /**
  60330. * Clear the current graph and load a new one from a serialization object
  60331. * @param source defines the JSON representation of the material
  60332. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60333. */
  60334. loadFromSerialization(source: any, rootUrl?: string): void;
  60335. /**
  60336. * Makes a duplicate of the current material.
  60337. * @param name - name to use for the new material.
  60338. */
  60339. clone(name: string): NodeMaterial;
  60340. /**
  60341. * Creates a node material from parsed material data
  60342. * @param source defines the JSON representation of the material
  60343. * @param scene defines the hosting scene
  60344. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60345. * @returns a new node material
  60346. */
  60347. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60348. /**
  60349. * Creates a node material from a snippet saved in a remote file
  60350. * @param name defines the name of the material to create
  60351. * @param url defines the url to load from
  60352. * @param scene defines the hosting scene
  60353. * @returns a promise that will resolve to the new node material
  60354. */
  60355. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60356. /**
  60357. * Creates a node material from a snippet saved by the node material editor
  60358. * @param snippetId defines the snippet to load
  60359. * @param scene defines the hosting scene
  60360. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60361. * @returns a promise that will resolve to the new node material
  60362. */
  60363. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  60364. /**
  60365. * Creates a new node material set to default basic configuration
  60366. * @param name defines the name of the material
  60367. * @param scene defines the hosting scene
  60368. * @returns a new NodeMaterial
  60369. */
  60370. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60371. }
  60372. }
  60373. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60376. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60379. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60380. import { Effect } from "babylonjs/Materials/effect";
  60381. import { Mesh } from "babylonjs/Meshes/mesh";
  60382. import { Nullable } from "babylonjs/types";
  60383. import { Texture } from "babylonjs/Materials/Textures/texture";
  60384. import { Scene } from "babylonjs/scene";
  60385. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60386. /**
  60387. * Block used to read a texture from a sampler
  60388. */
  60389. export class TextureBlock extends NodeMaterialBlock {
  60390. private _defineName;
  60391. private _linearDefineName;
  60392. private _tempTextureRead;
  60393. private _samplerName;
  60394. private _transformedUVName;
  60395. private _textureTransformName;
  60396. private _textureInfoName;
  60397. private _mainUVName;
  60398. private _mainUVDefineName;
  60399. /**
  60400. * Gets or sets the texture associated with the node
  60401. */
  60402. texture: Nullable<Texture>;
  60403. /**
  60404. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60405. */
  60406. convertToGammaSpace: boolean;
  60407. /**
  60408. * Create a new TextureBlock
  60409. * @param name defines the block name
  60410. */
  60411. constructor(name: string);
  60412. /**
  60413. * Gets the current class name
  60414. * @returns the class name
  60415. */
  60416. getClassName(): string;
  60417. /**
  60418. * Gets the uv input component
  60419. */
  60420. get uv(): NodeMaterialConnectionPoint;
  60421. /**
  60422. * Gets the rgba output component
  60423. */
  60424. get rgba(): NodeMaterialConnectionPoint;
  60425. /**
  60426. * Gets the rgb output component
  60427. */
  60428. get rgb(): NodeMaterialConnectionPoint;
  60429. /**
  60430. * Gets the r output component
  60431. */
  60432. get r(): NodeMaterialConnectionPoint;
  60433. /**
  60434. * Gets the g output component
  60435. */
  60436. get g(): NodeMaterialConnectionPoint;
  60437. /**
  60438. * Gets the b output component
  60439. */
  60440. get b(): NodeMaterialConnectionPoint;
  60441. /**
  60442. * Gets the a output component
  60443. */
  60444. get a(): NodeMaterialConnectionPoint;
  60445. get target(): NodeMaterialBlockTargets;
  60446. autoConfigure(material: NodeMaterial): void;
  60447. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60449. isReady(): boolean;
  60450. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60451. private get _isMixed();
  60452. private _injectVertexCode;
  60453. private _writeTextureRead;
  60454. private _writeOutput;
  60455. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60456. protected _dumpPropertiesCode(): string;
  60457. serialize(): any;
  60458. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60459. }
  60460. }
  60461. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60464. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60465. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60466. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60467. import { Scene } from "babylonjs/scene";
  60468. /**
  60469. * Class used to store shared data between 2 NodeMaterialBuildState
  60470. */
  60471. export class NodeMaterialBuildStateSharedData {
  60472. /**
  60473. * Gets the list of emitted varyings
  60474. */
  60475. temps: string[];
  60476. /**
  60477. * Gets the list of emitted varyings
  60478. */
  60479. varyings: string[];
  60480. /**
  60481. * Gets the varying declaration string
  60482. */
  60483. varyingDeclaration: string;
  60484. /**
  60485. * Input blocks
  60486. */
  60487. inputBlocks: InputBlock[];
  60488. /**
  60489. * Input blocks
  60490. */
  60491. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60492. /**
  60493. * Bindable blocks (Blocks that need to set data to the effect)
  60494. */
  60495. bindableBlocks: NodeMaterialBlock[];
  60496. /**
  60497. * List of blocks that can provide a compilation fallback
  60498. */
  60499. blocksWithFallbacks: NodeMaterialBlock[];
  60500. /**
  60501. * List of blocks that can provide a define update
  60502. */
  60503. blocksWithDefines: NodeMaterialBlock[];
  60504. /**
  60505. * List of blocks that can provide a repeatable content
  60506. */
  60507. repeatableContentBlocks: NodeMaterialBlock[];
  60508. /**
  60509. * List of blocks that can provide a dynamic list of uniforms
  60510. */
  60511. dynamicUniformBlocks: NodeMaterialBlock[];
  60512. /**
  60513. * List of blocks that can block the isReady function for the material
  60514. */
  60515. blockingBlocks: NodeMaterialBlock[];
  60516. /**
  60517. * Gets the list of animated inputs
  60518. */
  60519. animatedInputs: InputBlock[];
  60520. /**
  60521. * Build Id used to avoid multiple recompilations
  60522. */
  60523. buildId: number;
  60524. /** List of emitted variables */
  60525. variableNames: {
  60526. [key: string]: number;
  60527. };
  60528. /** List of emitted defines */
  60529. defineNames: {
  60530. [key: string]: number;
  60531. };
  60532. /** Should emit comments? */
  60533. emitComments: boolean;
  60534. /** Emit build activity */
  60535. verbose: boolean;
  60536. /** Gets or sets the hosting scene */
  60537. scene: Scene;
  60538. /**
  60539. * Gets the compilation hints emitted at compilation time
  60540. */
  60541. hints: {
  60542. needWorldViewMatrix: boolean;
  60543. needWorldViewProjectionMatrix: boolean;
  60544. needAlphaBlending: boolean;
  60545. needAlphaTesting: boolean;
  60546. };
  60547. /**
  60548. * List of compilation checks
  60549. */
  60550. checks: {
  60551. emitVertex: boolean;
  60552. emitFragment: boolean;
  60553. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60554. };
  60555. /** Creates a new shared data */
  60556. constructor();
  60557. /**
  60558. * Emits console errors and exceptions if there is a failing check
  60559. */
  60560. emitErrors(): void;
  60561. }
  60562. }
  60563. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60564. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60565. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60566. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60567. /**
  60568. * Class used to store node based material build state
  60569. */
  60570. export class NodeMaterialBuildState {
  60571. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60572. supportUniformBuffers: boolean;
  60573. /**
  60574. * Gets the list of emitted attributes
  60575. */
  60576. attributes: string[];
  60577. /**
  60578. * Gets the list of emitted uniforms
  60579. */
  60580. uniforms: string[];
  60581. /**
  60582. * Gets the list of emitted constants
  60583. */
  60584. constants: string[];
  60585. /**
  60586. * Gets the list of emitted samplers
  60587. */
  60588. samplers: string[];
  60589. /**
  60590. * Gets the list of emitted functions
  60591. */
  60592. functions: {
  60593. [key: string]: string;
  60594. };
  60595. /**
  60596. * Gets the list of emitted extensions
  60597. */
  60598. extensions: {
  60599. [key: string]: string;
  60600. };
  60601. /**
  60602. * Gets the target of the compilation state
  60603. */
  60604. target: NodeMaterialBlockTargets;
  60605. /**
  60606. * Gets the list of emitted counters
  60607. */
  60608. counters: {
  60609. [key: string]: number;
  60610. };
  60611. /**
  60612. * Shared data between multiple NodeMaterialBuildState instances
  60613. */
  60614. sharedData: NodeMaterialBuildStateSharedData;
  60615. /** @hidden */
  60616. _vertexState: NodeMaterialBuildState;
  60617. /** @hidden */
  60618. _attributeDeclaration: string;
  60619. /** @hidden */
  60620. _uniformDeclaration: string;
  60621. /** @hidden */
  60622. _constantDeclaration: string;
  60623. /** @hidden */
  60624. _samplerDeclaration: string;
  60625. /** @hidden */
  60626. _varyingTransfer: string;
  60627. private _repeatableContentAnchorIndex;
  60628. /** @hidden */
  60629. _builtCompilationString: string;
  60630. /**
  60631. * Gets the emitted compilation strings
  60632. */
  60633. compilationString: string;
  60634. /**
  60635. * Finalize the compilation strings
  60636. * @param state defines the current compilation state
  60637. */
  60638. finalize(state: NodeMaterialBuildState): void;
  60639. /** @hidden */
  60640. get _repeatableContentAnchor(): string;
  60641. /** @hidden */
  60642. _getFreeVariableName(prefix: string): string;
  60643. /** @hidden */
  60644. _getFreeDefineName(prefix: string): string;
  60645. /** @hidden */
  60646. _excludeVariableName(name: string): void;
  60647. /** @hidden */
  60648. _emit2DSampler(name: string): void;
  60649. /** @hidden */
  60650. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60651. /** @hidden */
  60652. _emitExtension(name: string, extension: string): void;
  60653. /** @hidden */
  60654. _emitFunction(name: string, code: string, comments: string): void;
  60655. /** @hidden */
  60656. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60657. replaceStrings?: {
  60658. search: RegExp;
  60659. replace: string;
  60660. }[];
  60661. repeatKey?: string;
  60662. }): string;
  60663. /** @hidden */
  60664. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60665. repeatKey?: string;
  60666. removeAttributes?: boolean;
  60667. removeUniforms?: boolean;
  60668. removeVaryings?: boolean;
  60669. removeIfDef?: boolean;
  60670. replaceStrings?: {
  60671. search: RegExp;
  60672. replace: string;
  60673. }[];
  60674. }, storeKey?: string): void;
  60675. /** @hidden */
  60676. _registerTempVariable(name: string): boolean;
  60677. /** @hidden */
  60678. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60679. /** @hidden */
  60680. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60681. /** @hidden */
  60682. _emitFloat(value: number): string;
  60683. }
  60684. }
  60685. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60686. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60687. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60688. import { Nullable } from "babylonjs/types";
  60689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60690. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60691. import { Effect } from "babylonjs/Materials/effect";
  60692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60693. import { Mesh } from "babylonjs/Meshes/mesh";
  60694. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60695. import { Scene } from "babylonjs/scene";
  60696. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60697. /**
  60698. * Defines a block that can be used inside a node based material
  60699. */
  60700. export class NodeMaterialBlock {
  60701. private _buildId;
  60702. private _buildTarget;
  60703. private _target;
  60704. private _isFinalMerger;
  60705. private _isInput;
  60706. protected _isUnique: boolean;
  60707. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60708. inputsAreExclusive: boolean;
  60709. /** @hidden */
  60710. _codeVariableName: string;
  60711. /** @hidden */
  60712. _inputs: NodeMaterialConnectionPoint[];
  60713. /** @hidden */
  60714. _outputs: NodeMaterialConnectionPoint[];
  60715. /** @hidden */
  60716. _preparationId: number;
  60717. /**
  60718. * Gets or sets the name of the block
  60719. */
  60720. name: string;
  60721. /**
  60722. * Gets or sets the unique id of the node
  60723. */
  60724. uniqueId: number;
  60725. /**
  60726. * Gets or sets the comments associated with this block
  60727. */
  60728. comments: string;
  60729. /**
  60730. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60731. */
  60732. get isUnique(): boolean;
  60733. /**
  60734. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60735. */
  60736. get isFinalMerger(): boolean;
  60737. /**
  60738. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60739. */
  60740. get isInput(): boolean;
  60741. /**
  60742. * Gets or sets the build Id
  60743. */
  60744. get buildId(): number;
  60745. set buildId(value: number);
  60746. /**
  60747. * Gets or sets the target of the block
  60748. */
  60749. get target(): NodeMaterialBlockTargets;
  60750. set target(value: NodeMaterialBlockTargets);
  60751. /**
  60752. * Gets the list of input points
  60753. */
  60754. get inputs(): NodeMaterialConnectionPoint[];
  60755. /** Gets the list of output points */
  60756. get outputs(): NodeMaterialConnectionPoint[];
  60757. /**
  60758. * Find an input by its name
  60759. * @param name defines the name of the input to look for
  60760. * @returns the input or null if not found
  60761. */
  60762. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60763. /**
  60764. * Find an output by its name
  60765. * @param name defines the name of the outputto look for
  60766. * @returns the output or null if not found
  60767. */
  60768. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60769. /**
  60770. * Creates a new NodeMaterialBlock
  60771. * @param name defines the block name
  60772. * @param target defines the target of that block (Vertex by default)
  60773. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60774. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60775. */
  60776. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60777. /**
  60778. * Initialize the block and prepare the context for build
  60779. * @param state defines the state that will be used for the build
  60780. */
  60781. initialize(state: NodeMaterialBuildState): void;
  60782. /**
  60783. * Bind data to effect. Will only be called for blocks with isBindable === true
  60784. * @param effect defines the effect to bind data to
  60785. * @param nodeMaterial defines the hosting NodeMaterial
  60786. * @param mesh defines the mesh that will be rendered
  60787. */
  60788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60789. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60790. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60791. protected _writeFloat(value: number): string;
  60792. /**
  60793. * Gets the current class name e.g. "NodeMaterialBlock"
  60794. * @returns the class name
  60795. */
  60796. getClassName(): string;
  60797. /**
  60798. * Register a new input. Must be called inside a block constructor
  60799. * @param name defines the connection point name
  60800. * @param type defines the connection point type
  60801. * @param isOptional defines a boolean indicating that this input can be omitted
  60802. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60803. * @returns the current block
  60804. */
  60805. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60806. /**
  60807. * Register a new output. Must be called inside a block constructor
  60808. * @param name defines the connection point name
  60809. * @param type defines the connection point type
  60810. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60811. * @returns the current block
  60812. */
  60813. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60814. /**
  60815. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60816. * @param forOutput defines an optional connection point to check compatibility with
  60817. * @returns the first available input or null
  60818. */
  60819. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60820. /**
  60821. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60822. * @param forBlock defines an optional block to check compatibility with
  60823. * @returns the first available input or null
  60824. */
  60825. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60826. /**
  60827. * Gets the sibling of the given output
  60828. * @param current defines the current output
  60829. * @returns the next output in the list or null
  60830. */
  60831. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60832. /**
  60833. * Connect current block with another block
  60834. * @param other defines the block to connect with
  60835. * @param options define the various options to help pick the right connections
  60836. * @returns the current block
  60837. */
  60838. connectTo(other: NodeMaterialBlock, options?: {
  60839. input?: string;
  60840. output?: string;
  60841. outputSwizzle?: string;
  60842. }): this | undefined;
  60843. protected _buildBlock(state: NodeMaterialBuildState): void;
  60844. /**
  60845. * Add uniforms, samplers and uniform buffers at compilation time
  60846. * @param state defines the state to update
  60847. * @param nodeMaterial defines the node material requesting the update
  60848. * @param defines defines the material defines to update
  60849. * @param uniformBuffers defines the list of uniform buffer names
  60850. */
  60851. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60852. /**
  60853. * Add potential fallbacks if shader compilation fails
  60854. * @param mesh defines the mesh to be rendered
  60855. * @param fallbacks defines the current prioritized list of fallbacks
  60856. */
  60857. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60858. /**
  60859. * Initialize defines for shader compilation
  60860. * @param mesh defines the mesh to be rendered
  60861. * @param nodeMaterial defines the node material requesting the update
  60862. * @param defines defines the material defines to update
  60863. * @param useInstances specifies that instances should be used
  60864. */
  60865. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60866. /**
  60867. * Update defines for shader compilation
  60868. * @param mesh defines the mesh to be rendered
  60869. * @param nodeMaterial defines the node material requesting the update
  60870. * @param defines defines the material defines to update
  60871. * @param useInstances specifies that instances should be used
  60872. */
  60873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60874. /**
  60875. * Lets the block try to connect some inputs automatically
  60876. * @param material defines the hosting NodeMaterial
  60877. */
  60878. autoConfigure(material: NodeMaterial): void;
  60879. /**
  60880. * Function called when a block is declared as repeatable content generator
  60881. * @param vertexShaderState defines the current compilation state for the vertex shader
  60882. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60883. * @param mesh defines the mesh to be rendered
  60884. * @param defines defines the material defines to update
  60885. */
  60886. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60887. /**
  60888. * Checks if the block is ready
  60889. * @param mesh defines the mesh to be rendered
  60890. * @param nodeMaterial defines the node material requesting the update
  60891. * @param defines defines the material defines to update
  60892. * @param useInstances specifies that instances should be used
  60893. * @returns true if the block is ready
  60894. */
  60895. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60896. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60897. private _processBuild;
  60898. /**
  60899. * Compile the current node and generate the shader code
  60900. * @param state defines the current compilation state (uniforms, samplers, current string)
  60901. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60902. * @returns true if already built
  60903. */
  60904. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60905. protected _inputRename(name: string): string;
  60906. protected _outputRename(name: string): string;
  60907. protected _dumpPropertiesCode(): string;
  60908. /** @hidden */
  60909. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60910. /** @hidden */
  60911. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60912. /**
  60913. * Clone the current block to a new identical block
  60914. * @param scene defines the hosting scene
  60915. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60916. * @returns a copy of the current block
  60917. */
  60918. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60919. /**
  60920. * Serializes this block in a JSON representation
  60921. * @returns the serialized block object
  60922. */
  60923. serialize(): any;
  60924. /** @hidden */
  60925. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60926. /**
  60927. * Release resources
  60928. */
  60929. dispose(): void;
  60930. }
  60931. }
  60932. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60933. /**
  60934. * Enum defining the type of animations supported by InputBlock
  60935. */
  60936. export enum AnimatedInputBlockTypes {
  60937. /** No animation */
  60938. None = 0,
  60939. /** Time based animation. Will only work for floats */
  60940. Time = 1
  60941. }
  60942. }
  60943. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60945. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60946. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60947. import { Nullable } from "babylonjs/types";
  60948. import { Effect } from "babylonjs/Materials/effect";
  60949. import { Matrix } from "babylonjs/Maths/math.vector";
  60950. import { Scene } from "babylonjs/scene";
  60951. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60953. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60954. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60955. import { Observable } from "babylonjs/Misc/observable";
  60956. /**
  60957. * Block used to expose an input value
  60958. */
  60959. export class InputBlock extends NodeMaterialBlock {
  60960. private _mode;
  60961. private _associatedVariableName;
  60962. private _storedValue;
  60963. private _valueCallback;
  60964. private _type;
  60965. private _animationType;
  60966. /** Gets or set a value used to limit the range of float values */
  60967. min: number;
  60968. /** Gets or set a value used to limit the range of float values */
  60969. max: number;
  60970. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60971. isBoolean: boolean;
  60972. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60973. matrixMode: number;
  60974. /** @hidden */
  60975. _systemValue: Nullable<NodeMaterialSystemValues>;
  60976. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60977. visibleInInspector: boolean;
  60978. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60979. isConstant: boolean;
  60980. /** Gets or sets the group to use to display this block in the Inspector */
  60981. groupInInspector: string;
  60982. /** Gets an observable raised when the value is changed */
  60983. onValueChangedObservable: Observable<InputBlock>;
  60984. /**
  60985. * Gets or sets the connection point type (default is float)
  60986. */
  60987. get type(): NodeMaterialBlockConnectionPointTypes;
  60988. /**
  60989. * Creates a new InputBlock
  60990. * @param name defines the block name
  60991. * @param target defines the target of that block (Vertex by default)
  60992. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60993. */
  60994. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60995. /**
  60996. * Gets the output component
  60997. */
  60998. get output(): NodeMaterialConnectionPoint;
  60999. /**
  61000. * Set the source of this connection point to a vertex attribute
  61001. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61002. * @returns the current connection point
  61003. */
  61004. setAsAttribute(attributeName?: string): InputBlock;
  61005. /**
  61006. * Set the source of this connection point to a system value
  61007. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61008. * @returns the current connection point
  61009. */
  61010. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61011. /**
  61012. * Gets or sets the value of that point.
  61013. * Please note that this value will be ignored if valueCallback is defined
  61014. */
  61015. get value(): any;
  61016. set value(value: any);
  61017. /**
  61018. * Gets or sets a callback used to get the value of that point.
  61019. * Please note that setting this value will force the connection point to ignore the value property
  61020. */
  61021. get valueCallback(): () => any;
  61022. set valueCallback(value: () => any);
  61023. /**
  61024. * Gets or sets the associated variable name in the shader
  61025. */
  61026. get associatedVariableName(): string;
  61027. set associatedVariableName(value: string);
  61028. /** Gets or sets the type of animation applied to the input */
  61029. get animationType(): AnimatedInputBlockTypes;
  61030. set animationType(value: AnimatedInputBlockTypes);
  61031. /**
  61032. * Gets a boolean indicating that this connection point not defined yet
  61033. */
  61034. get isUndefined(): boolean;
  61035. /**
  61036. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61037. * In this case the connection point name must be the name of the uniform to use.
  61038. * Can only be set on inputs
  61039. */
  61040. get isUniform(): boolean;
  61041. set isUniform(value: boolean);
  61042. /**
  61043. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61044. * In this case the connection point name must be the name of the attribute to use
  61045. * Can only be set on inputs
  61046. */
  61047. get isAttribute(): boolean;
  61048. set isAttribute(value: boolean);
  61049. /**
  61050. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61051. * Can only be set on exit points
  61052. */
  61053. get isVarying(): boolean;
  61054. set isVarying(value: boolean);
  61055. /**
  61056. * Gets a boolean indicating that the current connection point is a system value
  61057. */
  61058. get isSystemValue(): boolean;
  61059. /**
  61060. * Gets or sets the current well known value or null if not defined as a system value
  61061. */
  61062. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61063. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61064. /**
  61065. * Gets the current class name
  61066. * @returns the class name
  61067. */
  61068. getClassName(): string;
  61069. /**
  61070. * Animate the input if animationType !== None
  61071. * @param scene defines the rendering scene
  61072. */
  61073. animate(scene: Scene): void;
  61074. private _emitDefine;
  61075. initialize(state: NodeMaterialBuildState): void;
  61076. /**
  61077. * Set the input block to its default value (based on its type)
  61078. */
  61079. setDefaultValue(): void;
  61080. private _emitConstant;
  61081. private _emit;
  61082. /** @hidden */
  61083. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61084. /** @hidden */
  61085. _transmit(effect: Effect, scene: Scene): void;
  61086. protected _buildBlock(state: NodeMaterialBuildState): void;
  61087. protected _dumpPropertiesCode(): string;
  61088. dispose(): void;
  61089. serialize(): any;
  61090. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61091. }
  61092. }
  61093. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61094. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61095. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61096. import { Nullable } from "babylonjs/types";
  61097. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61098. import { Observable } from "babylonjs/Misc/observable";
  61099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61100. /**
  61101. * Enum used to define the compatibility state between two connection points
  61102. */
  61103. export enum NodeMaterialConnectionPointCompatibilityStates {
  61104. /** Points are compatibles */
  61105. Compatible = 0,
  61106. /** Points are incompatible because of their types */
  61107. TypeIncompatible = 1,
  61108. /** Points are incompatible because of their targets (vertex vs fragment) */
  61109. TargetIncompatible = 2
  61110. }
  61111. /**
  61112. * Defines the direction of a connection point
  61113. */
  61114. export enum NodeMaterialConnectionPointDirection {
  61115. /** Input */
  61116. Input = 0,
  61117. /** Output */
  61118. Output = 1
  61119. }
  61120. /**
  61121. * Defines a connection point for a block
  61122. */
  61123. export class NodeMaterialConnectionPoint {
  61124. /** @hidden */
  61125. _ownerBlock: NodeMaterialBlock;
  61126. /** @hidden */
  61127. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61128. private _endpoints;
  61129. private _associatedVariableName;
  61130. private _direction;
  61131. /** @hidden */
  61132. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61133. /** @hidden */
  61134. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61135. private _type;
  61136. /** @hidden */
  61137. _enforceAssociatedVariableName: boolean;
  61138. /** Gets the direction of the point */
  61139. get direction(): NodeMaterialConnectionPointDirection;
  61140. /**
  61141. * Gets or sets the additional types supported by this connection point
  61142. */
  61143. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61144. /**
  61145. * Gets or sets the additional types excluded by this connection point
  61146. */
  61147. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61148. /**
  61149. * Observable triggered when this point is connected
  61150. */
  61151. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61152. /**
  61153. * Gets or sets the associated variable name in the shader
  61154. */
  61155. get associatedVariableName(): string;
  61156. set associatedVariableName(value: string);
  61157. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61158. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61159. /**
  61160. * Gets or sets the connection point type (default is float)
  61161. */
  61162. get type(): NodeMaterialBlockConnectionPointTypes;
  61163. set type(value: NodeMaterialBlockConnectionPointTypes);
  61164. /**
  61165. * Gets or sets the connection point name
  61166. */
  61167. name: string;
  61168. /**
  61169. * Gets or sets a boolean indicating that this connection point can be omitted
  61170. */
  61171. isOptional: boolean;
  61172. /**
  61173. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61174. */
  61175. define: string;
  61176. /** @hidden */
  61177. _prioritizeVertex: boolean;
  61178. private _target;
  61179. /** Gets or sets the target of that connection point */
  61180. get target(): NodeMaterialBlockTargets;
  61181. set target(value: NodeMaterialBlockTargets);
  61182. /**
  61183. * Gets a boolean indicating that the current point is connected
  61184. */
  61185. get isConnected(): boolean;
  61186. /**
  61187. * Gets a boolean indicating that the current point is connected to an input block
  61188. */
  61189. get isConnectedToInputBlock(): boolean;
  61190. /**
  61191. * Gets a the connected input block (if any)
  61192. */
  61193. get connectInputBlock(): Nullable<InputBlock>;
  61194. /** Get the other side of the connection (if any) */
  61195. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61196. /** Get the block that owns this connection point */
  61197. get ownerBlock(): NodeMaterialBlock;
  61198. /** Get the block connected on the other side of this connection (if any) */
  61199. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61200. /** Get the block connected on the endpoints of this connection (if any) */
  61201. get connectedBlocks(): Array<NodeMaterialBlock>;
  61202. /** Gets the list of connected endpoints */
  61203. get endpoints(): NodeMaterialConnectionPoint[];
  61204. /** Gets a boolean indicating if that output point is connected to at least one input */
  61205. get hasEndpoints(): boolean;
  61206. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61207. get isConnectedInVertexShader(): boolean;
  61208. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61209. get isConnectedInFragmentShader(): boolean;
  61210. /**
  61211. * Creates a new connection point
  61212. * @param name defines the connection point name
  61213. * @param ownerBlock defines the block hosting this connection point
  61214. * @param direction defines the direction of the connection point
  61215. */
  61216. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61217. /**
  61218. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61219. * @returns the class name
  61220. */
  61221. getClassName(): string;
  61222. /**
  61223. * Gets a boolean indicating if the current point can be connected to another point
  61224. * @param connectionPoint defines the other connection point
  61225. * @returns a boolean
  61226. */
  61227. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61228. /**
  61229. * Gets a number indicating if the current point can be connected to another point
  61230. * @param connectionPoint defines the other connection point
  61231. * @returns a number defining the compatibility state
  61232. */
  61233. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61234. /**
  61235. * Connect this point to another connection point
  61236. * @param connectionPoint defines the other connection point
  61237. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61238. * @returns the current connection point
  61239. */
  61240. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61241. /**
  61242. * Disconnect this point from one of his endpoint
  61243. * @param endpoint defines the other connection point
  61244. * @returns the current connection point
  61245. */
  61246. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61247. /**
  61248. * Serializes this point in a JSON representation
  61249. * @returns the serialized point object
  61250. */
  61251. serialize(): any;
  61252. /**
  61253. * Release resources
  61254. */
  61255. dispose(): void;
  61256. }
  61257. }
  61258. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61259. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61260. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61262. import { Mesh } from "babylonjs/Meshes/mesh";
  61263. import { Effect } from "babylonjs/Materials/effect";
  61264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61265. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61266. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61268. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61269. /**
  61270. * Block used to add support for vertex skinning (bones)
  61271. */
  61272. export class BonesBlock extends NodeMaterialBlock {
  61273. /**
  61274. * Creates a new BonesBlock
  61275. * @param name defines the block name
  61276. */
  61277. constructor(name: string);
  61278. /**
  61279. * Initialize the block and prepare the context for build
  61280. * @param state defines the state that will be used for the build
  61281. */
  61282. initialize(state: NodeMaterialBuildState): void;
  61283. /**
  61284. * Gets the current class name
  61285. * @returns the class name
  61286. */
  61287. getClassName(): string;
  61288. /**
  61289. * Gets the matrix indices input component
  61290. */
  61291. get matricesIndices(): NodeMaterialConnectionPoint;
  61292. /**
  61293. * Gets the matrix weights input component
  61294. */
  61295. get matricesWeights(): NodeMaterialConnectionPoint;
  61296. /**
  61297. * Gets the extra matrix indices input component
  61298. */
  61299. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61300. /**
  61301. * Gets the extra matrix weights input component
  61302. */
  61303. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61304. /**
  61305. * Gets the world input component
  61306. */
  61307. get world(): NodeMaterialConnectionPoint;
  61308. /**
  61309. * Gets the output component
  61310. */
  61311. get output(): NodeMaterialConnectionPoint;
  61312. autoConfigure(material: NodeMaterial): void;
  61313. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61314. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61316. protected _buildBlock(state: NodeMaterialBuildState): this;
  61317. }
  61318. }
  61319. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61321. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61324. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61325. /**
  61326. * Block used to add support for instances
  61327. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61328. */
  61329. export class InstancesBlock extends NodeMaterialBlock {
  61330. /**
  61331. * Creates a new InstancesBlock
  61332. * @param name defines the block name
  61333. */
  61334. constructor(name: string);
  61335. /**
  61336. * Gets the current class name
  61337. * @returns the class name
  61338. */
  61339. getClassName(): string;
  61340. /**
  61341. * Gets the first world row input component
  61342. */
  61343. get world0(): NodeMaterialConnectionPoint;
  61344. /**
  61345. * Gets the second world row input component
  61346. */
  61347. get world1(): NodeMaterialConnectionPoint;
  61348. /**
  61349. * Gets the third world row input component
  61350. */
  61351. get world2(): NodeMaterialConnectionPoint;
  61352. /**
  61353. * Gets the forth world row input component
  61354. */
  61355. get world3(): NodeMaterialConnectionPoint;
  61356. /**
  61357. * Gets the world input component
  61358. */
  61359. get world(): NodeMaterialConnectionPoint;
  61360. /**
  61361. * Gets the output component
  61362. */
  61363. get output(): NodeMaterialConnectionPoint;
  61364. /**
  61365. * Gets the isntanceID component
  61366. */
  61367. get instanceID(): NodeMaterialConnectionPoint;
  61368. autoConfigure(material: NodeMaterial): void;
  61369. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61370. protected _buildBlock(state: NodeMaterialBuildState): this;
  61371. }
  61372. }
  61373. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61378. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61379. import { Effect } from "babylonjs/Materials/effect";
  61380. import { Mesh } from "babylonjs/Meshes/mesh";
  61381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61382. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61383. /**
  61384. * Block used to add morph targets support to vertex shader
  61385. */
  61386. export class MorphTargetsBlock extends NodeMaterialBlock {
  61387. private _repeatableContentAnchor;
  61388. /**
  61389. * Create a new MorphTargetsBlock
  61390. * @param name defines the block name
  61391. */
  61392. constructor(name: string);
  61393. /**
  61394. * Gets the current class name
  61395. * @returns the class name
  61396. */
  61397. getClassName(): string;
  61398. /**
  61399. * Gets the position input component
  61400. */
  61401. get position(): NodeMaterialConnectionPoint;
  61402. /**
  61403. * Gets the normal input component
  61404. */
  61405. get normal(): NodeMaterialConnectionPoint;
  61406. /**
  61407. * Gets the tangent input component
  61408. */
  61409. get tangent(): NodeMaterialConnectionPoint;
  61410. /**
  61411. * Gets the tangent input component
  61412. */
  61413. get uv(): NodeMaterialConnectionPoint;
  61414. /**
  61415. * Gets the position output component
  61416. */
  61417. get positionOutput(): NodeMaterialConnectionPoint;
  61418. /**
  61419. * Gets the normal output component
  61420. */
  61421. get normalOutput(): NodeMaterialConnectionPoint;
  61422. /**
  61423. * Gets the tangent output component
  61424. */
  61425. get tangentOutput(): NodeMaterialConnectionPoint;
  61426. /**
  61427. * Gets the tangent output component
  61428. */
  61429. get uvOutput(): NodeMaterialConnectionPoint;
  61430. initialize(state: NodeMaterialBuildState): void;
  61431. autoConfigure(material: NodeMaterial): void;
  61432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61434. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61435. protected _buildBlock(state: NodeMaterialBuildState): this;
  61436. }
  61437. }
  61438. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61439. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61440. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61441. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61442. import { Nullable } from "babylonjs/types";
  61443. import { Scene } from "babylonjs/scene";
  61444. import { Effect } from "babylonjs/Materials/effect";
  61445. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61446. import { Mesh } from "babylonjs/Meshes/mesh";
  61447. import { Light } from "babylonjs/Lights/light";
  61448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61449. /**
  61450. * Block used to get data information from a light
  61451. */
  61452. export class LightInformationBlock extends NodeMaterialBlock {
  61453. private _lightDataUniformName;
  61454. private _lightColorUniformName;
  61455. private _lightTypeDefineName;
  61456. /**
  61457. * Gets or sets the light associated with this block
  61458. */
  61459. light: Nullable<Light>;
  61460. /**
  61461. * Creates a new LightInformationBlock
  61462. * @param name defines the block name
  61463. */
  61464. constructor(name: string);
  61465. /**
  61466. * Gets the current class name
  61467. * @returns the class name
  61468. */
  61469. getClassName(): string;
  61470. /**
  61471. * Gets the world position input component
  61472. */
  61473. get worldPosition(): NodeMaterialConnectionPoint;
  61474. /**
  61475. * Gets the direction output component
  61476. */
  61477. get direction(): NodeMaterialConnectionPoint;
  61478. /**
  61479. * Gets the direction output component
  61480. */
  61481. get color(): NodeMaterialConnectionPoint;
  61482. /**
  61483. * Gets the direction output component
  61484. */
  61485. get intensity(): NodeMaterialConnectionPoint;
  61486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61487. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61488. protected _buildBlock(state: NodeMaterialBuildState): this;
  61489. serialize(): any;
  61490. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61491. }
  61492. }
  61493. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61494. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61495. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61496. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61497. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61498. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61499. }
  61500. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61501. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61502. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61503. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61505. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61506. import { Effect } from "babylonjs/Materials/effect";
  61507. import { Mesh } from "babylonjs/Meshes/mesh";
  61508. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61509. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61510. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61511. /**
  61512. * Block used to add image processing support to fragment shader
  61513. */
  61514. export class ImageProcessingBlock extends NodeMaterialBlock {
  61515. /**
  61516. * Create a new ImageProcessingBlock
  61517. * @param name defines the block name
  61518. */
  61519. constructor(name: string);
  61520. /**
  61521. * Gets the current class name
  61522. * @returns the class name
  61523. */
  61524. getClassName(): string;
  61525. /**
  61526. * Gets the color input component
  61527. */
  61528. get color(): NodeMaterialConnectionPoint;
  61529. /**
  61530. * Gets the output component
  61531. */
  61532. get output(): NodeMaterialConnectionPoint;
  61533. /**
  61534. * Initialize the block and prepare the context for build
  61535. * @param state defines the state that will be used for the build
  61536. */
  61537. initialize(state: NodeMaterialBuildState): void;
  61538. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61540. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61541. protected _buildBlock(state: NodeMaterialBuildState): this;
  61542. }
  61543. }
  61544. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61548. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61550. import { Effect } from "babylonjs/Materials/effect";
  61551. import { Mesh } from "babylonjs/Meshes/mesh";
  61552. import { Scene } from "babylonjs/scene";
  61553. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61554. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61555. /**
  61556. * Block used to pertub normals based on a normal map
  61557. */
  61558. export class PerturbNormalBlock extends NodeMaterialBlock {
  61559. private _tangentSpaceParameterName;
  61560. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61561. invertX: boolean;
  61562. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61563. invertY: boolean;
  61564. /**
  61565. * Create a new PerturbNormalBlock
  61566. * @param name defines the block name
  61567. */
  61568. constructor(name: string);
  61569. /**
  61570. * Gets the current class name
  61571. * @returns the class name
  61572. */
  61573. getClassName(): string;
  61574. /**
  61575. * Gets the world position input component
  61576. */
  61577. get worldPosition(): NodeMaterialConnectionPoint;
  61578. /**
  61579. * Gets the world normal input component
  61580. */
  61581. get worldNormal(): NodeMaterialConnectionPoint;
  61582. /**
  61583. * Gets the world tangent input component
  61584. */
  61585. get worldTangent(): NodeMaterialConnectionPoint;
  61586. /**
  61587. * Gets the uv input component
  61588. */
  61589. get uv(): NodeMaterialConnectionPoint;
  61590. /**
  61591. * Gets the normal map color input component
  61592. */
  61593. get normalMapColor(): NodeMaterialConnectionPoint;
  61594. /**
  61595. * Gets the strength input component
  61596. */
  61597. get strength(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the output component
  61600. */
  61601. get output(): NodeMaterialConnectionPoint;
  61602. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61603. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61604. autoConfigure(material: NodeMaterial): void;
  61605. protected _buildBlock(state: NodeMaterialBuildState): this;
  61606. protected _dumpPropertiesCode(): string;
  61607. serialize(): any;
  61608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61609. }
  61610. }
  61611. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61612. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61613. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61614. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61615. /**
  61616. * Block used to discard a pixel if a value is smaller than a cutoff
  61617. */
  61618. export class DiscardBlock extends NodeMaterialBlock {
  61619. /**
  61620. * Create a new DiscardBlock
  61621. * @param name defines the block name
  61622. */
  61623. constructor(name: string);
  61624. /**
  61625. * Gets the current class name
  61626. * @returns the class name
  61627. */
  61628. getClassName(): string;
  61629. /**
  61630. * Gets the color input component
  61631. */
  61632. get value(): NodeMaterialConnectionPoint;
  61633. /**
  61634. * Gets the cutoff input component
  61635. */
  61636. get cutoff(): NodeMaterialConnectionPoint;
  61637. protected _buildBlock(state: NodeMaterialBuildState): this;
  61638. }
  61639. }
  61640. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61641. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61642. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61643. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61644. /**
  61645. * Block used to test if the fragment shader is front facing
  61646. */
  61647. export class FrontFacingBlock extends NodeMaterialBlock {
  61648. /**
  61649. * Creates a new FrontFacingBlock
  61650. * @param name defines the block name
  61651. */
  61652. constructor(name: string);
  61653. /**
  61654. * Gets the current class name
  61655. * @returns the class name
  61656. */
  61657. getClassName(): string;
  61658. /**
  61659. * Gets the output component
  61660. */
  61661. get output(): NodeMaterialConnectionPoint;
  61662. protected _buildBlock(state: NodeMaterialBuildState): this;
  61663. }
  61664. }
  61665. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61666. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61667. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61668. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61669. /**
  61670. * Block used to get the derivative value on x and y of a given input
  61671. */
  61672. export class DerivativeBlock extends NodeMaterialBlock {
  61673. /**
  61674. * Create a new DerivativeBlock
  61675. * @param name defines the block name
  61676. */
  61677. constructor(name: string);
  61678. /**
  61679. * Gets the current class name
  61680. * @returns the class name
  61681. */
  61682. getClassName(): string;
  61683. /**
  61684. * Gets the input component
  61685. */
  61686. get input(): NodeMaterialConnectionPoint;
  61687. /**
  61688. * Gets the derivative output on x
  61689. */
  61690. get dx(): NodeMaterialConnectionPoint;
  61691. /**
  61692. * Gets the derivative output on y
  61693. */
  61694. get dy(): NodeMaterialConnectionPoint;
  61695. protected _buildBlock(state: NodeMaterialBuildState): this;
  61696. }
  61697. }
  61698. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61699. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61700. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61701. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61702. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61703. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61704. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61705. }
  61706. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61709. import { Mesh } from "babylonjs/Meshes/mesh";
  61710. import { Effect } from "babylonjs/Materials/effect";
  61711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61713. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61714. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61715. /**
  61716. * Block used to add support for scene fog
  61717. */
  61718. export class FogBlock extends NodeMaterialBlock {
  61719. private _fogDistanceName;
  61720. private _fogParameters;
  61721. /**
  61722. * Create a new FogBlock
  61723. * @param name defines the block name
  61724. */
  61725. constructor(name: string);
  61726. /**
  61727. * Gets the current class name
  61728. * @returns the class name
  61729. */
  61730. getClassName(): string;
  61731. /**
  61732. * Gets the world position input component
  61733. */
  61734. get worldPosition(): NodeMaterialConnectionPoint;
  61735. /**
  61736. * Gets the view input component
  61737. */
  61738. get view(): NodeMaterialConnectionPoint;
  61739. /**
  61740. * Gets the color input component
  61741. */
  61742. get input(): NodeMaterialConnectionPoint;
  61743. /**
  61744. * Gets the fog color input component
  61745. */
  61746. get fogColor(): NodeMaterialConnectionPoint;
  61747. /**
  61748. * Gets the output component
  61749. */
  61750. get output(): NodeMaterialConnectionPoint;
  61751. autoConfigure(material: NodeMaterial): void;
  61752. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61753. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61754. protected _buildBlock(state: NodeMaterialBuildState): this;
  61755. }
  61756. }
  61757. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61762. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61763. import { Effect } from "babylonjs/Materials/effect";
  61764. import { Mesh } from "babylonjs/Meshes/mesh";
  61765. import { Light } from "babylonjs/Lights/light";
  61766. import { Nullable } from "babylonjs/types";
  61767. import { Scene } from "babylonjs/scene";
  61768. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61769. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61770. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61771. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61772. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61773. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61774. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61775. /**
  61776. * Block used to add light in the fragment shader
  61777. */
  61778. export class LightBlock extends NodeMaterialBlock {
  61779. private _lightId;
  61780. /**
  61781. * Gets or sets the light associated with this block
  61782. */
  61783. light: Nullable<Light>;
  61784. /**
  61785. * Create a new LightBlock
  61786. * @param name defines the block name
  61787. */
  61788. constructor(name: string);
  61789. /**
  61790. * Gets the current class name
  61791. * @returns the class name
  61792. */
  61793. getClassName(): string;
  61794. /**
  61795. * Gets the world position input component
  61796. */
  61797. get worldPosition(): NodeMaterialConnectionPoint;
  61798. /**
  61799. * Gets the world normal input component
  61800. */
  61801. get worldNormal(): NodeMaterialConnectionPoint;
  61802. /**
  61803. * Gets the camera (or eye) position component
  61804. */
  61805. get cameraPosition(): NodeMaterialConnectionPoint;
  61806. /**
  61807. * Gets the glossiness component
  61808. */
  61809. get glossiness(): NodeMaterialConnectionPoint;
  61810. /**
  61811. * Gets the glossinness power component
  61812. */
  61813. get glossPower(): NodeMaterialConnectionPoint;
  61814. /**
  61815. * Gets the diffuse color component
  61816. */
  61817. get diffuseColor(): NodeMaterialConnectionPoint;
  61818. /**
  61819. * Gets the specular color component
  61820. */
  61821. get specularColor(): NodeMaterialConnectionPoint;
  61822. /**
  61823. * Gets the diffuse output component
  61824. */
  61825. get diffuseOutput(): NodeMaterialConnectionPoint;
  61826. /**
  61827. * Gets the specular output component
  61828. */
  61829. get specularOutput(): NodeMaterialConnectionPoint;
  61830. /**
  61831. * Gets the shadow output component
  61832. */
  61833. get shadow(): NodeMaterialConnectionPoint;
  61834. autoConfigure(material: NodeMaterial): void;
  61835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61836. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61837. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61838. private _injectVertexCode;
  61839. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61840. serialize(): any;
  61841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61842. }
  61843. }
  61844. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61845. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61846. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61847. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61848. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61849. }
  61850. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61851. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61852. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61853. }
  61854. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61858. /**
  61859. * Block used to multiply 2 values
  61860. */
  61861. export class MultiplyBlock extends NodeMaterialBlock {
  61862. /**
  61863. * Creates a new MultiplyBlock
  61864. * @param name defines the block name
  61865. */
  61866. constructor(name: string);
  61867. /**
  61868. * Gets the current class name
  61869. * @returns the class name
  61870. */
  61871. getClassName(): string;
  61872. /**
  61873. * Gets the left operand input component
  61874. */
  61875. get left(): NodeMaterialConnectionPoint;
  61876. /**
  61877. * Gets the right operand input component
  61878. */
  61879. get right(): NodeMaterialConnectionPoint;
  61880. /**
  61881. * Gets the output component
  61882. */
  61883. get output(): NodeMaterialConnectionPoint;
  61884. protected _buildBlock(state: NodeMaterialBuildState): this;
  61885. }
  61886. }
  61887. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61888. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61889. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61890. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61891. /**
  61892. * Block used to add 2 vectors
  61893. */
  61894. export class AddBlock extends NodeMaterialBlock {
  61895. /**
  61896. * Creates a new AddBlock
  61897. * @param name defines the block name
  61898. */
  61899. constructor(name: string);
  61900. /**
  61901. * Gets the current class name
  61902. * @returns the class name
  61903. */
  61904. getClassName(): string;
  61905. /**
  61906. * Gets the left operand input component
  61907. */
  61908. get left(): NodeMaterialConnectionPoint;
  61909. /**
  61910. * Gets the right operand input component
  61911. */
  61912. get right(): NodeMaterialConnectionPoint;
  61913. /**
  61914. * Gets the output component
  61915. */
  61916. get output(): NodeMaterialConnectionPoint;
  61917. protected _buildBlock(state: NodeMaterialBuildState): this;
  61918. }
  61919. }
  61920. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61924. /**
  61925. * Block used to scale a vector by a float
  61926. */
  61927. export class ScaleBlock extends NodeMaterialBlock {
  61928. /**
  61929. * Creates a new ScaleBlock
  61930. * @param name defines the block name
  61931. */
  61932. constructor(name: string);
  61933. /**
  61934. * Gets the current class name
  61935. * @returns the class name
  61936. */
  61937. getClassName(): string;
  61938. /**
  61939. * Gets the input component
  61940. */
  61941. get input(): NodeMaterialConnectionPoint;
  61942. /**
  61943. * Gets the factor input component
  61944. */
  61945. get factor(): NodeMaterialConnectionPoint;
  61946. /**
  61947. * Gets the output component
  61948. */
  61949. get output(): NodeMaterialConnectionPoint;
  61950. protected _buildBlock(state: NodeMaterialBuildState): this;
  61951. }
  61952. }
  61953. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61957. import { Scene } from "babylonjs/scene";
  61958. /**
  61959. * Block used to clamp a float
  61960. */
  61961. export class ClampBlock extends NodeMaterialBlock {
  61962. /** Gets or sets the minimum range */
  61963. minimum: number;
  61964. /** Gets or sets the maximum range */
  61965. maximum: number;
  61966. /**
  61967. * Creates a new ClampBlock
  61968. * @param name defines the block name
  61969. */
  61970. constructor(name: string);
  61971. /**
  61972. * Gets the current class name
  61973. * @returns the class name
  61974. */
  61975. getClassName(): string;
  61976. /**
  61977. * Gets the value input component
  61978. */
  61979. get value(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the output component
  61982. */
  61983. get output(): NodeMaterialConnectionPoint;
  61984. protected _buildBlock(state: NodeMaterialBuildState): this;
  61985. protected _dumpPropertiesCode(): string;
  61986. serialize(): any;
  61987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61988. }
  61989. }
  61990. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61994. /**
  61995. * Block used to apply a cross product between 2 vectors
  61996. */
  61997. export class CrossBlock extends NodeMaterialBlock {
  61998. /**
  61999. * Creates a new CrossBlock
  62000. * @param name defines the block name
  62001. */
  62002. constructor(name: string);
  62003. /**
  62004. * Gets the current class name
  62005. * @returns the class name
  62006. */
  62007. getClassName(): string;
  62008. /**
  62009. * Gets the left operand input component
  62010. */
  62011. get left(): NodeMaterialConnectionPoint;
  62012. /**
  62013. * Gets the right operand input component
  62014. */
  62015. get right(): NodeMaterialConnectionPoint;
  62016. /**
  62017. * Gets the output component
  62018. */
  62019. get output(): NodeMaterialConnectionPoint;
  62020. protected _buildBlock(state: NodeMaterialBuildState): this;
  62021. }
  62022. }
  62023. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62027. /**
  62028. * Block used to apply a dot product between 2 vectors
  62029. */
  62030. export class DotBlock extends NodeMaterialBlock {
  62031. /**
  62032. * Creates a new DotBlock
  62033. * @param name defines the block name
  62034. */
  62035. constructor(name: string);
  62036. /**
  62037. * Gets the current class name
  62038. * @returns the class name
  62039. */
  62040. getClassName(): string;
  62041. /**
  62042. * Gets the left operand input component
  62043. */
  62044. get left(): NodeMaterialConnectionPoint;
  62045. /**
  62046. * Gets the right operand input component
  62047. */
  62048. get right(): NodeMaterialConnectionPoint;
  62049. /**
  62050. * Gets the output component
  62051. */
  62052. get output(): NodeMaterialConnectionPoint;
  62053. protected _buildBlock(state: NodeMaterialBuildState): this;
  62054. }
  62055. }
  62056. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62060. import { Vector2 } from "babylonjs/Maths/math.vector";
  62061. import { Scene } from "babylonjs/scene";
  62062. /**
  62063. * Block used to remap a float from a range to a new one
  62064. */
  62065. export class RemapBlock extends NodeMaterialBlock {
  62066. /**
  62067. * Gets or sets the source range
  62068. */
  62069. sourceRange: Vector2;
  62070. /**
  62071. * Gets or sets the target range
  62072. */
  62073. targetRange: Vector2;
  62074. /**
  62075. * Creates a new RemapBlock
  62076. * @param name defines the block name
  62077. */
  62078. constructor(name: string);
  62079. /**
  62080. * Gets the current class name
  62081. * @returns the class name
  62082. */
  62083. getClassName(): string;
  62084. /**
  62085. * Gets the input component
  62086. */
  62087. get input(): NodeMaterialConnectionPoint;
  62088. /**
  62089. * Gets the source min input component
  62090. */
  62091. get sourceMin(): NodeMaterialConnectionPoint;
  62092. /**
  62093. * Gets the source max input component
  62094. */
  62095. get sourceMax(): NodeMaterialConnectionPoint;
  62096. /**
  62097. * Gets the target min input component
  62098. */
  62099. get targetMin(): NodeMaterialConnectionPoint;
  62100. /**
  62101. * Gets the target max input component
  62102. */
  62103. get targetMax(): NodeMaterialConnectionPoint;
  62104. /**
  62105. * Gets the output component
  62106. */
  62107. get output(): NodeMaterialConnectionPoint;
  62108. protected _buildBlock(state: NodeMaterialBuildState): this;
  62109. protected _dumpPropertiesCode(): string;
  62110. serialize(): any;
  62111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62112. }
  62113. }
  62114. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62115. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62118. /**
  62119. * Block used to normalize a vector
  62120. */
  62121. export class NormalizeBlock extends NodeMaterialBlock {
  62122. /**
  62123. * Creates a new NormalizeBlock
  62124. * @param name defines the block name
  62125. */
  62126. constructor(name: string);
  62127. /**
  62128. * Gets the current class name
  62129. * @returns the class name
  62130. */
  62131. getClassName(): string;
  62132. /**
  62133. * Gets the input component
  62134. */
  62135. get input(): NodeMaterialConnectionPoint;
  62136. /**
  62137. * Gets the output component
  62138. */
  62139. get output(): NodeMaterialConnectionPoint;
  62140. protected _buildBlock(state: NodeMaterialBuildState): this;
  62141. }
  62142. }
  62143. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62147. import { Scene } from "babylonjs/scene";
  62148. /**
  62149. * Operations supported by the Trigonometry block
  62150. */
  62151. export enum TrigonometryBlockOperations {
  62152. /** Cos */
  62153. Cos = 0,
  62154. /** Sin */
  62155. Sin = 1,
  62156. /** Abs */
  62157. Abs = 2,
  62158. /** Exp */
  62159. Exp = 3,
  62160. /** Exp2 */
  62161. Exp2 = 4,
  62162. /** Round */
  62163. Round = 5,
  62164. /** Floor */
  62165. Floor = 6,
  62166. /** Ceiling */
  62167. Ceiling = 7,
  62168. /** Square root */
  62169. Sqrt = 8,
  62170. /** Log */
  62171. Log = 9,
  62172. /** Tangent */
  62173. Tan = 10,
  62174. /** Arc tangent */
  62175. ArcTan = 11,
  62176. /** Arc cosinus */
  62177. ArcCos = 12,
  62178. /** Arc sinus */
  62179. ArcSin = 13,
  62180. /** Fraction */
  62181. Fract = 14,
  62182. /** Sign */
  62183. Sign = 15,
  62184. /** To radians (from degrees) */
  62185. Radians = 16,
  62186. /** To degrees (from radians) */
  62187. Degrees = 17
  62188. }
  62189. /**
  62190. * Block used to apply trigonometry operation to floats
  62191. */
  62192. export class TrigonometryBlock extends NodeMaterialBlock {
  62193. /**
  62194. * Gets or sets the operation applied by the block
  62195. */
  62196. operation: TrigonometryBlockOperations;
  62197. /**
  62198. * Creates a new TrigonometryBlock
  62199. * @param name defines the block name
  62200. */
  62201. constructor(name: string);
  62202. /**
  62203. * Gets the current class name
  62204. * @returns the class name
  62205. */
  62206. getClassName(): string;
  62207. /**
  62208. * Gets the input component
  62209. */
  62210. get input(): NodeMaterialConnectionPoint;
  62211. /**
  62212. * Gets the output component
  62213. */
  62214. get output(): NodeMaterialConnectionPoint;
  62215. protected _buildBlock(state: NodeMaterialBuildState): this;
  62216. serialize(): any;
  62217. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62218. protected _dumpPropertiesCode(): string;
  62219. }
  62220. }
  62221. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  62222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62225. /**
  62226. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62227. */
  62228. export class ColorMergerBlock extends NodeMaterialBlock {
  62229. /**
  62230. * Create a new ColorMergerBlock
  62231. * @param name defines the block name
  62232. */
  62233. constructor(name: string);
  62234. /**
  62235. * Gets the current class name
  62236. * @returns the class name
  62237. */
  62238. getClassName(): string;
  62239. /**
  62240. * Gets the rgb component (input)
  62241. */
  62242. get rgbIn(): NodeMaterialConnectionPoint;
  62243. /**
  62244. * Gets the r component (input)
  62245. */
  62246. get r(): NodeMaterialConnectionPoint;
  62247. /**
  62248. * Gets the g component (input)
  62249. */
  62250. get g(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the b component (input)
  62253. */
  62254. get b(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the a component (input)
  62257. */
  62258. get a(): NodeMaterialConnectionPoint;
  62259. /**
  62260. * Gets the rgba component (output)
  62261. */
  62262. get rgba(): NodeMaterialConnectionPoint;
  62263. /**
  62264. * Gets the rgb component (output)
  62265. */
  62266. get rgbOut(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the rgb component (output)
  62269. * @deprecated Please use rgbOut instead.
  62270. */
  62271. get rgb(): NodeMaterialConnectionPoint;
  62272. protected _buildBlock(state: NodeMaterialBuildState): this;
  62273. }
  62274. }
  62275. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62276. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62277. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62278. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62279. /**
  62280. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62281. */
  62282. export class VectorMergerBlock extends NodeMaterialBlock {
  62283. /**
  62284. * Create a new VectorMergerBlock
  62285. * @param name defines the block name
  62286. */
  62287. constructor(name: string);
  62288. /**
  62289. * Gets the current class name
  62290. * @returns the class name
  62291. */
  62292. getClassName(): string;
  62293. /**
  62294. * Gets the xyz component (input)
  62295. */
  62296. get xyzIn(): NodeMaterialConnectionPoint;
  62297. /**
  62298. * Gets the xy component (input)
  62299. */
  62300. get xyIn(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the x component (input)
  62303. */
  62304. get x(): NodeMaterialConnectionPoint;
  62305. /**
  62306. * Gets the y component (input)
  62307. */
  62308. get y(): NodeMaterialConnectionPoint;
  62309. /**
  62310. * Gets the z component (input)
  62311. */
  62312. get z(): NodeMaterialConnectionPoint;
  62313. /**
  62314. * Gets the w component (input)
  62315. */
  62316. get w(): NodeMaterialConnectionPoint;
  62317. /**
  62318. * Gets the xyzw component (output)
  62319. */
  62320. get xyzw(): NodeMaterialConnectionPoint;
  62321. /**
  62322. * Gets the xyz component (output)
  62323. */
  62324. get xyzOut(): NodeMaterialConnectionPoint;
  62325. /**
  62326. * Gets the xy component (output)
  62327. */
  62328. get xyOut(): NodeMaterialConnectionPoint;
  62329. /**
  62330. * Gets the xy component (output)
  62331. * @deprecated Please use xyOut instead.
  62332. */
  62333. get xy(): NodeMaterialConnectionPoint;
  62334. /**
  62335. * Gets the xyz component (output)
  62336. * @deprecated Please use xyzOut instead.
  62337. */
  62338. get xyz(): NodeMaterialConnectionPoint;
  62339. protected _buildBlock(state: NodeMaterialBuildState): this;
  62340. }
  62341. }
  62342. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62346. /**
  62347. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62348. */
  62349. export class ColorSplitterBlock extends NodeMaterialBlock {
  62350. /**
  62351. * Create a new ColorSplitterBlock
  62352. * @param name defines the block name
  62353. */
  62354. constructor(name: string);
  62355. /**
  62356. * Gets the current class name
  62357. * @returns the class name
  62358. */
  62359. getClassName(): string;
  62360. /**
  62361. * Gets the rgba component (input)
  62362. */
  62363. get rgba(): NodeMaterialConnectionPoint;
  62364. /**
  62365. * Gets the rgb component (input)
  62366. */
  62367. get rgbIn(): NodeMaterialConnectionPoint;
  62368. /**
  62369. * Gets the rgb component (output)
  62370. */
  62371. get rgbOut(): NodeMaterialConnectionPoint;
  62372. /**
  62373. * Gets the r component (output)
  62374. */
  62375. get r(): NodeMaterialConnectionPoint;
  62376. /**
  62377. * Gets the g component (output)
  62378. */
  62379. get g(): NodeMaterialConnectionPoint;
  62380. /**
  62381. * Gets the b component (output)
  62382. */
  62383. get b(): NodeMaterialConnectionPoint;
  62384. /**
  62385. * Gets the a component (output)
  62386. */
  62387. get a(): NodeMaterialConnectionPoint;
  62388. protected _inputRename(name: string): string;
  62389. protected _outputRename(name: string): string;
  62390. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62391. }
  62392. }
  62393. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62397. /**
  62398. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62399. */
  62400. export class VectorSplitterBlock extends NodeMaterialBlock {
  62401. /**
  62402. * Create a new VectorSplitterBlock
  62403. * @param name defines the block name
  62404. */
  62405. constructor(name: string);
  62406. /**
  62407. * Gets the current class name
  62408. * @returns the class name
  62409. */
  62410. getClassName(): string;
  62411. /**
  62412. * Gets the xyzw component (input)
  62413. */
  62414. get xyzw(): NodeMaterialConnectionPoint;
  62415. /**
  62416. * Gets the xyz component (input)
  62417. */
  62418. get xyzIn(): NodeMaterialConnectionPoint;
  62419. /**
  62420. * Gets the xy component (input)
  62421. */
  62422. get xyIn(): NodeMaterialConnectionPoint;
  62423. /**
  62424. * Gets the xyz component (output)
  62425. */
  62426. get xyzOut(): NodeMaterialConnectionPoint;
  62427. /**
  62428. * Gets the xy component (output)
  62429. */
  62430. get xyOut(): NodeMaterialConnectionPoint;
  62431. /**
  62432. * Gets the x component (output)
  62433. */
  62434. get x(): NodeMaterialConnectionPoint;
  62435. /**
  62436. * Gets the y component (output)
  62437. */
  62438. get y(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the z component (output)
  62441. */
  62442. get z(): NodeMaterialConnectionPoint;
  62443. /**
  62444. * Gets the w component (output)
  62445. */
  62446. get w(): NodeMaterialConnectionPoint;
  62447. protected _inputRename(name: string): string;
  62448. protected _outputRename(name: string): string;
  62449. protected _buildBlock(state: NodeMaterialBuildState): this;
  62450. }
  62451. }
  62452. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62456. /**
  62457. * Block used to lerp between 2 values
  62458. */
  62459. export class LerpBlock extends NodeMaterialBlock {
  62460. /**
  62461. * Creates a new LerpBlock
  62462. * @param name defines the block name
  62463. */
  62464. constructor(name: string);
  62465. /**
  62466. * Gets the current class name
  62467. * @returns the class name
  62468. */
  62469. getClassName(): string;
  62470. /**
  62471. * Gets the left operand input component
  62472. */
  62473. get left(): NodeMaterialConnectionPoint;
  62474. /**
  62475. * Gets the right operand input component
  62476. */
  62477. get right(): NodeMaterialConnectionPoint;
  62478. /**
  62479. * Gets the gradient operand input component
  62480. */
  62481. get gradient(): NodeMaterialConnectionPoint;
  62482. /**
  62483. * Gets the output component
  62484. */
  62485. get output(): NodeMaterialConnectionPoint;
  62486. protected _buildBlock(state: NodeMaterialBuildState): this;
  62487. }
  62488. }
  62489. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62493. /**
  62494. * Block used to divide 2 vectors
  62495. */
  62496. export class DivideBlock extends NodeMaterialBlock {
  62497. /**
  62498. * Creates a new DivideBlock
  62499. * @param name defines the block name
  62500. */
  62501. constructor(name: string);
  62502. /**
  62503. * Gets the current class name
  62504. * @returns the class name
  62505. */
  62506. getClassName(): string;
  62507. /**
  62508. * Gets the left operand input component
  62509. */
  62510. get left(): NodeMaterialConnectionPoint;
  62511. /**
  62512. * Gets the right operand input component
  62513. */
  62514. get right(): NodeMaterialConnectionPoint;
  62515. /**
  62516. * Gets the output component
  62517. */
  62518. get output(): NodeMaterialConnectionPoint;
  62519. protected _buildBlock(state: NodeMaterialBuildState): this;
  62520. }
  62521. }
  62522. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62526. /**
  62527. * Block used to subtract 2 vectors
  62528. */
  62529. export class SubtractBlock extends NodeMaterialBlock {
  62530. /**
  62531. * Creates a new SubtractBlock
  62532. * @param name defines the block name
  62533. */
  62534. constructor(name: string);
  62535. /**
  62536. * Gets the current class name
  62537. * @returns the class name
  62538. */
  62539. getClassName(): string;
  62540. /**
  62541. * Gets the left operand input component
  62542. */
  62543. get left(): NodeMaterialConnectionPoint;
  62544. /**
  62545. * Gets the right operand input component
  62546. */
  62547. get right(): NodeMaterialConnectionPoint;
  62548. /**
  62549. * Gets the output component
  62550. */
  62551. get output(): NodeMaterialConnectionPoint;
  62552. protected _buildBlock(state: NodeMaterialBuildState): this;
  62553. }
  62554. }
  62555. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62556. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62557. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62559. /**
  62560. * Block used to step a value
  62561. */
  62562. export class StepBlock extends NodeMaterialBlock {
  62563. /**
  62564. * Creates a new StepBlock
  62565. * @param name defines the block name
  62566. */
  62567. constructor(name: string);
  62568. /**
  62569. * Gets the current class name
  62570. * @returns the class name
  62571. */
  62572. getClassName(): string;
  62573. /**
  62574. * Gets the value operand input component
  62575. */
  62576. get value(): NodeMaterialConnectionPoint;
  62577. /**
  62578. * Gets the edge operand input component
  62579. */
  62580. get edge(): NodeMaterialConnectionPoint;
  62581. /**
  62582. * Gets the output component
  62583. */
  62584. get output(): NodeMaterialConnectionPoint;
  62585. protected _buildBlock(state: NodeMaterialBuildState): this;
  62586. }
  62587. }
  62588. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62592. /**
  62593. * Block used to get the opposite (1 - x) of a value
  62594. */
  62595. export class OneMinusBlock extends NodeMaterialBlock {
  62596. /**
  62597. * Creates a new OneMinusBlock
  62598. * @param name defines the block name
  62599. */
  62600. constructor(name: string);
  62601. /**
  62602. * Gets the current class name
  62603. * @returns the class name
  62604. */
  62605. getClassName(): string;
  62606. /**
  62607. * Gets the input component
  62608. */
  62609. get input(): 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/viewDirectionBlock" {
  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. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62622. /**
  62623. * Block used to get the view direction
  62624. */
  62625. export class ViewDirectionBlock extends NodeMaterialBlock {
  62626. /**
  62627. * Creates a new ViewDirectionBlock
  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 world position component
  62638. */
  62639. get worldPosition(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the camera position component
  62642. */
  62643. get cameraPosition(): NodeMaterialConnectionPoint;
  62644. /**
  62645. * Gets the output component
  62646. */
  62647. get output(): NodeMaterialConnectionPoint;
  62648. autoConfigure(material: NodeMaterial): void;
  62649. protected _buildBlock(state: NodeMaterialBuildState): this;
  62650. }
  62651. }
  62652. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62656. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62657. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62658. /**
  62659. * Block used to compute fresnel value
  62660. */
  62661. export class FresnelBlock extends NodeMaterialBlock {
  62662. /**
  62663. * Create a new FresnelBlock
  62664. * @param name defines the block name
  62665. */
  62666. constructor(name: string);
  62667. /**
  62668. * Gets the current class name
  62669. * @returns the class name
  62670. */
  62671. getClassName(): string;
  62672. /**
  62673. * Gets the world normal input component
  62674. */
  62675. get worldNormal(): NodeMaterialConnectionPoint;
  62676. /**
  62677. * Gets the view direction input component
  62678. */
  62679. get viewDirection(): NodeMaterialConnectionPoint;
  62680. /**
  62681. * Gets the bias input component
  62682. */
  62683. get bias(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the camera (or eye) position component
  62686. */
  62687. get power(): NodeMaterialConnectionPoint;
  62688. /**
  62689. * Gets the fresnel output component
  62690. */
  62691. get fresnel(): NodeMaterialConnectionPoint;
  62692. autoConfigure(material: NodeMaterial): void;
  62693. protected _buildBlock(state: NodeMaterialBuildState): this;
  62694. }
  62695. }
  62696. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62700. /**
  62701. * Block used to get the max of 2 values
  62702. */
  62703. export class MaxBlock extends NodeMaterialBlock {
  62704. /**
  62705. * Creates a new MaxBlock
  62706. * @param name defines the block name
  62707. */
  62708. constructor(name: string);
  62709. /**
  62710. * Gets the current class name
  62711. * @returns the class name
  62712. */
  62713. getClassName(): string;
  62714. /**
  62715. * Gets the left operand input component
  62716. */
  62717. get left(): NodeMaterialConnectionPoint;
  62718. /**
  62719. * Gets the right operand input component
  62720. */
  62721. get right(): NodeMaterialConnectionPoint;
  62722. /**
  62723. * Gets the output component
  62724. */
  62725. get output(): NodeMaterialConnectionPoint;
  62726. protected _buildBlock(state: NodeMaterialBuildState): this;
  62727. }
  62728. }
  62729. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62733. /**
  62734. * Block used to get the min of 2 values
  62735. */
  62736. export class MinBlock extends NodeMaterialBlock {
  62737. /**
  62738. * Creates a new MinBlock
  62739. * @param name defines the block name
  62740. */
  62741. constructor(name: string);
  62742. /**
  62743. * Gets the current class name
  62744. * @returns the class name
  62745. */
  62746. getClassName(): string;
  62747. /**
  62748. * Gets the left operand input component
  62749. */
  62750. get left(): NodeMaterialConnectionPoint;
  62751. /**
  62752. * Gets the right operand input component
  62753. */
  62754. get right(): NodeMaterialConnectionPoint;
  62755. /**
  62756. * Gets the output component
  62757. */
  62758. get output(): NodeMaterialConnectionPoint;
  62759. protected _buildBlock(state: NodeMaterialBuildState): this;
  62760. }
  62761. }
  62762. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62763. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62764. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62766. /**
  62767. * Block used to get the distance between 2 values
  62768. */
  62769. export class DistanceBlock extends NodeMaterialBlock {
  62770. /**
  62771. * Creates a new DistanceBlock
  62772. * @param name defines the block name
  62773. */
  62774. constructor(name: string);
  62775. /**
  62776. * Gets the current class name
  62777. * @returns the class name
  62778. */
  62779. getClassName(): string;
  62780. /**
  62781. * Gets the left operand input component
  62782. */
  62783. get left(): NodeMaterialConnectionPoint;
  62784. /**
  62785. * Gets the right operand input component
  62786. */
  62787. get right(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the output component
  62790. */
  62791. get output(): NodeMaterialConnectionPoint;
  62792. protected _buildBlock(state: NodeMaterialBuildState): this;
  62793. }
  62794. }
  62795. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62799. /**
  62800. * Block used to get the length of a vector
  62801. */
  62802. export class LengthBlock extends NodeMaterialBlock {
  62803. /**
  62804. * Creates a new LengthBlock
  62805. * @param name defines the block name
  62806. */
  62807. constructor(name: string);
  62808. /**
  62809. * Gets the current class name
  62810. * @returns the class name
  62811. */
  62812. getClassName(): string;
  62813. /**
  62814. * Gets the value input component
  62815. */
  62816. get value(): NodeMaterialConnectionPoint;
  62817. /**
  62818. * Gets the output component
  62819. */
  62820. get output(): NodeMaterialConnectionPoint;
  62821. protected _buildBlock(state: NodeMaterialBuildState): this;
  62822. }
  62823. }
  62824. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62825. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62826. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62827. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62828. /**
  62829. * Block used to get negative version of a value (i.e. x * -1)
  62830. */
  62831. export class NegateBlock extends NodeMaterialBlock {
  62832. /**
  62833. * Creates a new NegateBlock
  62834. * @param name defines the block name
  62835. */
  62836. constructor(name: string);
  62837. /**
  62838. * Gets the current class name
  62839. * @returns the class name
  62840. */
  62841. getClassName(): string;
  62842. /**
  62843. * Gets the value input component
  62844. */
  62845. get value(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the output component
  62848. */
  62849. get output(): NodeMaterialConnectionPoint;
  62850. protected _buildBlock(state: NodeMaterialBuildState): this;
  62851. }
  62852. }
  62853. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62854. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62855. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62856. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62857. /**
  62858. * Block used to get the value of the first parameter raised to the power of the second
  62859. */
  62860. export class PowBlock extends NodeMaterialBlock {
  62861. /**
  62862. * Creates a new PowBlock
  62863. * @param name defines the block name
  62864. */
  62865. constructor(name: string);
  62866. /**
  62867. * Gets the current class name
  62868. * @returns the class name
  62869. */
  62870. getClassName(): string;
  62871. /**
  62872. * Gets the value operand input component
  62873. */
  62874. get value(): NodeMaterialConnectionPoint;
  62875. /**
  62876. * Gets the power operand input component
  62877. */
  62878. get power(): NodeMaterialConnectionPoint;
  62879. /**
  62880. * Gets the output component
  62881. */
  62882. get output(): NodeMaterialConnectionPoint;
  62883. protected _buildBlock(state: NodeMaterialBuildState): this;
  62884. }
  62885. }
  62886. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62890. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62891. /**
  62892. * Block used to get a random number
  62893. */
  62894. export class RandomNumberBlock extends NodeMaterialBlock {
  62895. /**
  62896. * Creates a new RandomNumberBlock
  62897. * @param name defines the block name
  62898. */
  62899. constructor(name: string);
  62900. /**
  62901. * Gets the current class name
  62902. * @returns the class name
  62903. */
  62904. getClassName(): string;
  62905. /**
  62906. * Gets the seed input component
  62907. */
  62908. get seed(): NodeMaterialConnectionPoint;
  62909. /**
  62910. * Gets the output component
  62911. */
  62912. get output(): NodeMaterialConnectionPoint;
  62913. protected _buildBlock(state: NodeMaterialBuildState): this;
  62914. }
  62915. }
  62916. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62920. /**
  62921. * Block used to compute arc tangent of 2 values
  62922. */
  62923. export class ArcTan2Block extends NodeMaterialBlock {
  62924. /**
  62925. * Creates a new ArcTan2Block
  62926. * @param name defines the block name
  62927. */
  62928. constructor(name: string);
  62929. /**
  62930. * Gets the current class name
  62931. * @returns the class name
  62932. */
  62933. getClassName(): string;
  62934. /**
  62935. * Gets the x operand input component
  62936. */
  62937. get x(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the y operand input component
  62940. */
  62941. get y(): NodeMaterialConnectionPoint;
  62942. /**
  62943. * Gets the output component
  62944. */
  62945. get output(): NodeMaterialConnectionPoint;
  62946. protected _buildBlock(state: NodeMaterialBuildState): this;
  62947. }
  62948. }
  62949. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62953. /**
  62954. * Block used to smooth step a value
  62955. */
  62956. export class SmoothStepBlock extends NodeMaterialBlock {
  62957. /**
  62958. * Creates a new SmoothStepBlock
  62959. * @param name defines the block name
  62960. */
  62961. constructor(name: string);
  62962. /**
  62963. * Gets the current class name
  62964. * @returns the class name
  62965. */
  62966. getClassName(): string;
  62967. /**
  62968. * Gets the value operand input component
  62969. */
  62970. get value(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the first edge operand input component
  62973. */
  62974. get edge0(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the second edge operand input component
  62977. */
  62978. get edge1(): NodeMaterialConnectionPoint;
  62979. /**
  62980. * Gets the output component
  62981. */
  62982. get output(): NodeMaterialConnectionPoint;
  62983. protected _buildBlock(state: NodeMaterialBuildState): this;
  62984. }
  62985. }
  62986. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62990. /**
  62991. * Block used to get the reciprocal (1 / x) of a value
  62992. */
  62993. export class ReciprocalBlock extends NodeMaterialBlock {
  62994. /**
  62995. * Creates a new ReciprocalBlock
  62996. * @param name defines the block name
  62997. */
  62998. constructor(name: string);
  62999. /**
  63000. * Gets the current class name
  63001. * @returns the class name
  63002. */
  63003. getClassName(): string;
  63004. /**
  63005. * Gets the input component
  63006. */
  63007. get input(): NodeMaterialConnectionPoint;
  63008. /**
  63009. * Gets the output component
  63010. */
  63011. get output(): NodeMaterialConnectionPoint;
  63012. protected _buildBlock(state: NodeMaterialBuildState): this;
  63013. }
  63014. }
  63015. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63019. /**
  63020. * Block used to replace a color by another one
  63021. */
  63022. export class ReplaceColorBlock extends NodeMaterialBlock {
  63023. /**
  63024. * Creates a new ReplaceColorBlock
  63025. * @param name defines the block name
  63026. */
  63027. constructor(name: string);
  63028. /**
  63029. * Gets the current class name
  63030. * @returns the class name
  63031. */
  63032. getClassName(): string;
  63033. /**
  63034. * Gets the value input component
  63035. */
  63036. get value(): NodeMaterialConnectionPoint;
  63037. /**
  63038. * Gets the reference input component
  63039. */
  63040. get reference(): NodeMaterialConnectionPoint;
  63041. /**
  63042. * Gets the distance input component
  63043. */
  63044. get distance(): NodeMaterialConnectionPoint;
  63045. /**
  63046. * Gets the replacement input component
  63047. */
  63048. get replacement(): NodeMaterialConnectionPoint;
  63049. /**
  63050. * Gets the output component
  63051. */
  63052. get output(): NodeMaterialConnectionPoint;
  63053. protected _buildBlock(state: NodeMaterialBuildState): this;
  63054. }
  63055. }
  63056. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63060. /**
  63061. * Block used to posterize a value
  63062. * @see https://en.wikipedia.org/wiki/Posterization
  63063. */
  63064. export class PosterizeBlock extends NodeMaterialBlock {
  63065. /**
  63066. * Creates a new PosterizeBlock
  63067. * @param name defines the block name
  63068. */
  63069. constructor(name: string);
  63070. /**
  63071. * Gets the current class name
  63072. * @returns the class name
  63073. */
  63074. getClassName(): string;
  63075. /**
  63076. * Gets the value input component
  63077. */
  63078. get value(): NodeMaterialConnectionPoint;
  63079. /**
  63080. * Gets the steps input component
  63081. */
  63082. get steps(): NodeMaterialConnectionPoint;
  63083. /**
  63084. * Gets the output component
  63085. */
  63086. get output(): NodeMaterialConnectionPoint;
  63087. protected _buildBlock(state: NodeMaterialBuildState): this;
  63088. }
  63089. }
  63090. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63092. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63093. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63094. import { Scene } from "babylonjs/scene";
  63095. /**
  63096. * Operations supported by the Wave block
  63097. */
  63098. export enum WaveBlockKind {
  63099. /** SawTooth */
  63100. SawTooth = 0,
  63101. /** Square */
  63102. Square = 1,
  63103. /** Triangle */
  63104. Triangle = 2
  63105. }
  63106. /**
  63107. * Block used to apply wave operation to floats
  63108. */
  63109. export class WaveBlock extends NodeMaterialBlock {
  63110. /**
  63111. * Gets or sets the kibnd of wave to be applied by the block
  63112. */
  63113. kind: WaveBlockKind;
  63114. /**
  63115. * Creates a new WaveBlock
  63116. * @param name defines the block name
  63117. */
  63118. constructor(name: string);
  63119. /**
  63120. * Gets the current class name
  63121. * @returns the class name
  63122. */
  63123. getClassName(): string;
  63124. /**
  63125. * Gets the input component
  63126. */
  63127. get input(): NodeMaterialConnectionPoint;
  63128. /**
  63129. * Gets the output component
  63130. */
  63131. get output(): NodeMaterialConnectionPoint;
  63132. protected _buildBlock(state: NodeMaterialBuildState): this;
  63133. serialize(): any;
  63134. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63135. }
  63136. }
  63137. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63141. import { Color3 } from "babylonjs/Maths/math.color";
  63142. import { Scene } from "babylonjs/scene";
  63143. /**
  63144. * Class used to store a color step for the GradientBlock
  63145. */
  63146. export class GradientBlockColorStep {
  63147. /**
  63148. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63149. */
  63150. step: number;
  63151. /**
  63152. * Gets or sets the color associated with this step
  63153. */
  63154. color: Color3;
  63155. /**
  63156. * Creates a new GradientBlockColorStep
  63157. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63158. * @param color defines the color associated with this step
  63159. */
  63160. constructor(
  63161. /**
  63162. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63163. */
  63164. step: number,
  63165. /**
  63166. * Gets or sets the color associated with this step
  63167. */
  63168. color: Color3);
  63169. }
  63170. /**
  63171. * Block used to return a color from a gradient based on an input value between 0 and 1
  63172. */
  63173. export class GradientBlock extends NodeMaterialBlock {
  63174. /**
  63175. * Gets or sets the list of color steps
  63176. */
  63177. colorSteps: GradientBlockColorStep[];
  63178. /**
  63179. * Creates a new GradientBlock
  63180. * @param name defines the block name
  63181. */
  63182. constructor(name: string);
  63183. /**
  63184. * Gets the current class name
  63185. * @returns the class name
  63186. */
  63187. getClassName(): string;
  63188. /**
  63189. * Gets the gradient input component
  63190. */
  63191. get gradient(): NodeMaterialConnectionPoint;
  63192. /**
  63193. * Gets the output component
  63194. */
  63195. get output(): NodeMaterialConnectionPoint;
  63196. private _writeColorConstant;
  63197. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63198. serialize(): any;
  63199. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63200. protected _dumpPropertiesCode(): string;
  63201. }
  63202. }
  63203. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  63204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63205. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63207. /**
  63208. * Block used to normalize lerp between 2 values
  63209. */
  63210. export class NLerpBlock extends NodeMaterialBlock {
  63211. /**
  63212. * Creates a new NLerpBlock
  63213. * @param name defines the block name
  63214. */
  63215. constructor(name: string);
  63216. /**
  63217. * Gets the current class name
  63218. * @returns the class name
  63219. */
  63220. getClassName(): string;
  63221. /**
  63222. * Gets the left operand input component
  63223. */
  63224. get left(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the right operand input component
  63227. */
  63228. get right(): NodeMaterialConnectionPoint;
  63229. /**
  63230. * Gets the gradient operand input component
  63231. */
  63232. get gradient(): NodeMaterialConnectionPoint;
  63233. /**
  63234. * Gets the output component
  63235. */
  63236. get output(): NodeMaterialConnectionPoint;
  63237. protected _buildBlock(state: NodeMaterialBuildState): this;
  63238. }
  63239. }
  63240. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63244. import { Scene } from "babylonjs/scene";
  63245. /**
  63246. * block used to Generate a Worley Noise 3D Noise Pattern
  63247. */
  63248. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63249. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63250. manhattanDistance: boolean;
  63251. /**
  63252. * Creates a new WorleyNoise3DBlock
  63253. * @param name defines the block name
  63254. */
  63255. constructor(name: string);
  63256. /**
  63257. * Gets the current class name
  63258. * @returns the class name
  63259. */
  63260. getClassName(): string;
  63261. /**
  63262. * Gets the seed input component
  63263. */
  63264. get seed(): NodeMaterialConnectionPoint;
  63265. /**
  63266. * Gets the jitter input component
  63267. */
  63268. get jitter(): NodeMaterialConnectionPoint;
  63269. /**
  63270. * Gets the output component
  63271. */
  63272. get output(): NodeMaterialConnectionPoint;
  63273. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63274. /**
  63275. * Exposes the properties to the UI?
  63276. */
  63277. protected _dumpPropertiesCode(): string;
  63278. /**
  63279. * Exposes the properties to the Seralize?
  63280. */
  63281. serialize(): any;
  63282. /**
  63283. * Exposes the properties to the deseralize?
  63284. */
  63285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63286. }
  63287. }
  63288. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63289. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63290. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63291. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63292. /**
  63293. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63294. */
  63295. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63296. /**
  63297. * Creates a new SimplexPerlin3DBlock
  63298. * @param name defines the block name
  63299. */
  63300. constructor(name: string);
  63301. /**
  63302. * Gets the current class name
  63303. * @returns the class name
  63304. */
  63305. getClassName(): string;
  63306. /**
  63307. * Gets the seed operand input component
  63308. */
  63309. get seed(): NodeMaterialConnectionPoint;
  63310. /**
  63311. * Gets the output component
  63312. */
  63313. get output(): NodeMaterialConnectionPoint;
  63314. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63315. }
  63316. }
  63317. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63321. /**
  63322. * Block used to blend normals
  63323. */
  63324. export class NormalBlendBlock extends NodeMaterialBlock {
  63325. /**
  63326. * Creates a new NormalBlendBlock
  63327. * @param name defines the block name
  63328. */
  63329. constructor(name: string);
  63330. /**
  63331. * Gets the current class name
  63332. * @returns the class name
  63333. */
  63334. getClassName(): string;
  63335. /**
  63336. * Gets the first input component
  63337. */
  63338. get normalMap0(): NodeMaterialConnectionPoint;
  63339. /**
  63340. * Gets the second input component
  63341. */
  63342. get normalMap1(): NodeMaterialConnectionPoint;
  63343. /**
  63344. * Gets the output component
  63345. */
  63346. get output(): NodeMaterialConnectionPoint;
  63347. protected _buildBlock(state: NodeMaterialBuildState): this;
  63348. }
  63349. }
  63350. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63354. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63355. /**
  63356. * Block used to rotate a 2d vector by a given angle
  63357. */
  63358. export class Rotate2dBlock extends NodeMaterialBlock {
  63359. /**
  63360. * Creates a new Rotate2dBlock
  63361. * @param name defines the block name
  63362. */
  63363. constructor(name: string);
  63364. /**
  63365. * Gets the current class name
  63366. * @returns the class name
  63367. */
  63368. getClassName(): string;
  63369. /**
  63370. * Gets the input vector
  63371. */
  63372. get input(): NodeMaterialConnectionPoint;
  63373. /**
  63374. * Gets the input angle
  63375. */
  63376. get angle(): NodeMaterialConnectionPoint;
  63377. /**
  63378. * Gets the output component
  63379. */
  63380. get output(): NodeMaterialConnectionPoint;
  63381. autoConfigure(material: NodeMaterial): void;
  63382. protected _buildBlock(state: NodeMaterialBuildState): this;
  63383. }
  63384. }
  63385. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63387. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63388. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63389. /**
  63390. * Block used to get the reflected vector from a direction and a normal
  63391. */
  63392. export class ReflectBlock extends NodeMaterialBlock {
  63393. /**
  63394. * Creates a new ReflectBlock
  63395. * @param name defines the block name
  63396. */
  63397. constructor(name: string);
  63398. /**
  63399. * Gets the current class name
  63400. * @returns the class name
  63401. */
  63402. getClassName(): string;
  63403. /**
  63404. * Gets the incident component
  63405. */
  63406. get incident(): NodeMaterialConnectionPoint;
  63407. /**
  63408. * Gets the normal component
  63409. */
  63410. get normal(): NodeMaterialConnectionPoint;
  63411. /**
  63412. * Gets the output component
  63413. */
  63414. get output(): NodeMaterialConnectionPoint;
  63415. protected _buildBlock(state: NodeMaterialBuildState): this;
  63416. }
  63417. }
  63418. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63422. /**
  63423. * Block used to get the refracted vector from a direction and a normal
  63424. */
  63425. export class RefractBlock extends NodeMaterialBlock {
  63426. /**
  63427. * Creates a new RefractBlock
  63428. * @param name defines the block name
  63429. */
  63430. constructor(name: string);
  63431. /**
  63432. * Gets the current class name
  63433. * @returns the class name
  63434. */
  63435. getClassName(): string;
  63436. /**
  63437. * Gets the incident component
  63438. */
  63439. get incident(): NodeMaterialConnectionPoint;
  63440. /**
  63441. * Gets the normal component
  63442. */
  63443. get normal(): NodeMaterialConnectionPoint;
  63444. /**
  63445. * Gets the index of refraction component
  63446. */
  63447. get ior(): NodeMaterialConnectionPoint;
  63448. /**
  63449. * Gets the output component
  63450. */
  63451. get output(): NodeMaterialConnectionPoint;
  63452. protected _buildBlock(state: NodeMaterialBuildState): this;
  63453. }
  63454. }
  63455. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63459. /**
  63460. * Block used to desaturate a color
  63461. */
  63462. export class DesaturateBlock extends NodeMaterialBlock {
  63463. /**
  63464. * Creates a new DesaturateBlock
  63465. * @param name defines the block name
  63466. */
  63467. constructor(name: string);
  63468. /**
  63469. * Gets the current class name
  63470. * @returns the class name
  63471. */
  63472. getClassName(): string;
  63473. /**
  63474. * Gets the color operand input component
  63475. */
  63476. get color(): NodeMaterialConnectionPoint;
  63477. /**
  63478. * Gets the level operand input component
  63479. */
  63480. get level(): NodeMaterialConnectionPoint;
  63481. /**
  63482. * Gets the output component
  63483. */
  63484. get output(): NodeMaterialConnectionPoint;
  63485. protected _buildBlock(state: NodeMaterialBuildState): this;
  63486. }
  63487. }
  63488. declare module "babylonjs/Materials/Node/Blocks/index" {
  63489. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63490. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63491. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63492. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63493. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63494. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63495. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63496. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63497. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63498. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63499. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63500. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63501. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63502. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63503. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63504. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63505. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63506. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63507. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63508. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63509. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63510. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63511. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63512. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63513. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63514. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63515. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63516. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63517. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63518. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63519. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63520. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63521. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63522. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63523. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63524. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63525. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63526. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63527. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63528. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63529. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63530. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63531. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63532. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63533. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63534. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63535. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63536. }
  63537. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63538. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63539. }
  63540. declare module "babylonjs/Materials/Node/index" {
  63541. export * from "babylonjs/Materials/Node/Enums/index";
  63542. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63543. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63544. export * from "babylonjs/Materials/Node/nodeMaterial";
  63545. export * from "babylonjs/Materials/Node/Blocks/index";
  63546. export * from "babylonjs/Materials/Node/Optimizers/index";
  63547. }
  63548. declare module "babylonjs/Materials/effectRenderer" {
  63549. import { Nullable } from "babylonjs/types";
  63550. import { Texture } from "babylonjs/Materials/Textures/texture";
  63551. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63552. import { Viewport } from "babylonjs/Maths/math.viewport";
  63553. import { Observable } from "babylonjs/Misc/observable";
  63554. import { Effect } from "babylonjs/Materials/effect";
  63555. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63556. import "babylonjs/Shaders/postprocess.vertex";
  63557. /**
  63558. * Effect Render Options
  63559. */
  63560. export interface IEffectRendererOptions {
  63561. /**
  63562. * Defines the vertices positions.
  63563. */
  63564. positions?: number[];
  63565. /**
  63566. * Defines the indices.
  63567. */
  63568. indices?: number[];
  63569. }
  63570. /**
  63571. * Helper class to render one or more effects
  63572. */
  63573. export class EffectRenderer {
  63574. private engine;
  63575. private static _DefaultOptions;
  63576. private _vertexBuffers;
  63577. private _indexBuffer;
  63578. private _ringBufferIndex;
  63579. private _ringScreenBuffer;
  63580. private _fullscreenViewport;
  63581. private _getNextFrameBuffer;
  63582. /**
  63583. * Creates an effect renderer
  63584. * @param engine the engine to use for rendering
  63585. * @param options defines the options of the effect renderer
  63586. */
  63587. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63588. /**
  63589. * Sets the current viewport in normalized coordinates 0-1
  63590. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63591. */
  63592. setViewport(viewport?: Viewport): void;
  63593. /**
  63594. * Binds the embedded attributes buffer to the effect.
  63595. * @param effect Defines the effect to bind the attributes for
  63596. */
  63597. bindBuffers(effect: Effect): void;
  63598. /**
  63599. * Sets the current effect wrapper to use during draw.
  63600. * The effect needs to be ready before calling this api.
  63601. * This also sets the default full screen position attribute.
  63602. * @param effectWrapper Defines the effect to draw with
  63603. */
  63604. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63605. /**
  63606. * Draws a full screen quad.
  63607. */
  63608. draw(): void;
  63609. /**
  63610. * renders one or more effects to a specified texture
  63611. * @param effectWrappers list of effects to renderer
  63612. * @param outputTexture texture to draw to, if null it will render to the screen
  63613. */
  63614. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63615. /**
  63616. * Disposes of the effect renderer
  63617. */
  63618. dispose(): void;
  63619. }
  63620. /**
  63621. * Options to create an EffectWrapper
  63622. */
  63623. interface EffectWrapperCreationOptions {
  63624. /**
  63625. * Engine to use to create the effect
  63626. */
  63627. engine: ThinEngine;
  63628. /**
  63629. * Fragment shader for the effect
  63630. */
  63631. fragmentShader: string;
  63632. /**
  63633. * Vertex shader for the effect
  63634. */
  63635. vertexShader?: string;
  63636. /**
  63637. * Attributes to use in the shader
  63638. */
  63639. attributeNames?: Array<string>;
  63640. /**
  63641. * Uniforms to use in the shader
  63642. */
  63643. uniformNames?: Array<string>;
  63644. /**
  63645. * Texture sampler names to use in the shader
  63646. */
  63647. samplerNames?: Array<string>;
  63648. /**
  63649. * The friendly name of the effect displayed in Spector.
  63650. */
  63651. name?: string;
  63652. }
  63653. /**
  63654. * Wraps an effect to be used for rendering
  63655. */
  63656. export class EffectWrapper {
  63657. /**
  63658. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63659. */
  63660. onApplyObservable: Observable<{}>;
  63661. /**
  63662. * The underlying effect
  63663. */
  63664. effect: Effect;
  63665. /**
  63666. * Creates an effect to be renderer
  63667. * @param creationOptions options to create the effect
  63668. */
  63669. constructor(creationOptions: EffectWrapperCreationOptions);
  63670. /**
  63671. * Disposes of the effect wrapper
  63672. */
  63673. dispose(): void;
  63674. }
  63675. }
  63676. declare module "babylonjs/Materials/index" {
  63677. export * from "babylonjs/Materials/Background/index";
  63678. export * from "babylonjs/Materials/colorCurves";
  63679. export * from "babylonjs/Materials/iEffectFallbacks";
  63680. export * from "babylonjs/Materials/effectFallbacks";
  63681. export * from "babylonjs/Materials/effect";
  63682. export * from "babylonjs/Materials/fresnelParameters";
  63683. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63684. export * from "babylonjs/Materials/material";
  63685. export * from "babylonjs/Materials/materialDefines";
  63686. export * from "babylonjs/Materials/materialHelper";
  63687. export * from "babylonjs/Materials/multiMaterial";
  63688. export * from "babylonjs/Materials/PBR/index";
  63689. export * from "babylonjs/Materials/pushMaterial";
  63690. export * from "babylonjs/Materials/shaderMaterial";
  63691. export * from "babylonjs/Materials/standardMaterial";
  63692. export * from "babylonjs/Materials/Textures/index";
  63693. export * from "babylonjs/Materials/uniformBuffer";
  63694. export * from "babylonjs/Materials/materialFlags";
  63695. export * from "babylonjs/Materials/Node/index";
  63696. export * from "babylonjs/Materials/effectRenderer";
  63697. }
  63698. declare module "babylonjs/Maths/index" {
  63699. export * from "babylonjs/Maths/math.scalar";
  63700. export * from "babylonjs/Maths/math";
  63701. export * from "babylonjs/Maths/sphericalPolynomial";
  63702. }
  63703. declare module "babylonjs/Misc/workerPool" {
  63704. import { IDisposable } from "babylonjs/scene";
  63705. /**
  63706. * Helper class to push actions to a pool of workers.
  63707. */
  63708. export class WorkerPool implements IDisposable {
  63709. private _workerInfos;
  63710. private _pendingActions;
  63711. /**
  63712. * Constructor
  63713. * @param workers Array of workers to use for actions
  63714. */
  63715. constructor(workers: Array<Worker>);
  63716. /**
  63717. * Terminates all workers and clears any pending actions.
  63718. */
  63719. dispose(): void;
  63720. /**
  63721. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63722. * pended until a worker has completed its action.
  63723. * @param action The action to perform. Call onComplete when the action is complete.
  63724. */
  63725. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63726. private _execute;
  63727. }
  63728. }
  63729. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63730. import { IDisposable } from "babylonjs/scene";
  63731. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63732. /**
  63733. * Configuration for Draco compression
  63734. */
  63735. export interface IDracoCompressionConfiguration {
  63736. /**
  63737. * Configuration for the decoder.
  63738. */
  63739. decoder: {
  63740. /**
  63741. * The url to the WebAssembly module.
  63742. */
  63743. wasmUrl?: string;
  63744. /**
  63745. * The url to the WebAssembly binary.
  63746. */
  63747. wasmBinaryUrl?: string;
  63748. /**
  63749. * The url to the fallback JavaScript module.
  63750. */
  63751. fallbackUrl?: string;
  63752. };
  63753. }
  63754. /**
  63755. * Draco compression (https://google.github.io/draco/)
  63756. *
  63757. * This class wraps the Draco module.
  63758. *
  63759. * **Encoder**
  63760. *
  63761. * The encoder is not currently implemented.
  63762. *
  63763. * **Decoder**
  63764. *
  63765. * 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.
  63766. *
  63767. * To update the configuration, use the following code:
  63768. * ```javascript
  63769. * DracoCompression.Configuration = {
  63770. * decoder: {
  63771. * wasmUrl: "<url to the WebAssembly library>",
  63772. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63773. * fallbackUrl: "<url to the fallback JavaScript library>",
  63774. * }
  63775. * };
  63776. * ```
  63777. *
  63778. * 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.
  63779. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63780. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63781. *
  63782. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63783. * ```javascript
  63784. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63785. * ```
  63786. *
  63787. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63788. */
  63789. export class DracoCompression implements IDisposable {
  63790. private _workerPoolPromise?;
  63791. private _decoderModulePromise?;
  63792. /**
  63793. * The configuration. Defaults to the following urls:
  63794. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63795. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63796. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63797. */
  63798. static Configuration: IDracoCompressionConfiguration;
  63799. /**
  63800. * Returns true if the decoder configuration is available.
  63801. */
  63802. static get DecoderAvailable(): boolean;
  63803. /**
  63804. * Default number of workers to create when creating the draco compression object.
  63805. */
  63806. static DefaultNumWorkers: number;
  63807. private static GetDefaultNumWorkers;
  63808. private static _Default;
  63809. /**
  63810. * Default instance for the draco compression object.
  63811. */
  63812. static get Default(): DracoCompression;
  63813. /**
  63814. * Constructor
  63815. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63816. */
  63817. constructor(numWorkers?: number);
  63818. /**
  63819. * Stop all async operations and release resources.
  63820. */
  63821. dispose(): void;
  63822. /**
  63823. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63824. * @returns a promise that resolves when ready
  63825. */
  63826. whenReadyAsync(): Promise<void>;
  63827. /**
  63828. * Decode Draco compressed mesh data to vertex data.
  63829. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63830. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63831. * @returns A promise that resolves with the decoded vertex data
  63832. */
  63833. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63834. [kind: string]: number;
  63835. }): Promise<VertexData>;
  63836. }
  63837. }
  63838. declare module "babylonjs/Meshes/Compression/index" {
  63839. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63840. }
  63841. declare module "babylonjs/Meshes/csg" {
  63842. import { Nullable } from "babylonjs/types";
  63843. import { Scene } from "babylonjs/scene";
  63844. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63845. import { Mesh } from "babylonjs/Meshes/mesh";
  63846. import { Material } from "babylonjs/Materials/material";
  63847. /**
  63848. * Class for building Constructive Solid Geometry
  63849. */
  63850. export class CSG {
  63851. private polygons;
  63852. /**
  63853. * The world matrix
  63854. */
  63855. matrix: Matrix;
  63856. /**
  63857. * Stores the position
  63858. */
  63859. position: Vector3;
  63860. /**
  63861. * Stores the rotation
  63862. */
  63863. rotation: Vector3;
  63864. /**
  63865. * Stores the rotation quaternion
  63866. */
  63867. rotationQuaternion: Nullable<Quaternion>;
  63868. /**
  63869. * Stores the scaling vector
  63870. */
  63871. scaling: Vector3;
  63872. /**
  63873. * Convert the Mesh to CSG
  63874. * @param mesh The Mesh to convert to CSG
  63875. * @returns A new CSG from the Mesh
  63876. */
  63877. static FromMesh(mesh: Mesh): CSG;
  63878. /**
  63879. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63880. * @param polygons Polygons used to construct a CSG solid
  63881. */
  63882. private static FromPolygons;
  63883. /**
  63884. * Clones, or makes a deep copy, of the CSG
  63885. * @returns A new CSG
  63886. */
  63887. clone(): CSG;
  63888. /**
  63889. * Unions this CSG with another CSG
  63890. * @param csg The CSG to union against this CSG
  63891. * @returns The unioned CSG
  63892. */
  63893. union(csg: CSG): CSG;
  63894. /**
  63895. * Unions this CSG with another CSG in place
  63896. * @param csg The CSG to union against this CSG
  63897. */
  63898. unionInPlace(csg: CSG): void;
  63899. /**
  63900. * Subtracts this CSG with another CSG
  63901. * @param csg The CSG to subtract against this CSG
  63902. * @returns A new CSG
  63903. */
  63904. subtract(csg: CSG): CSG;
  63905. /**
  63906. * Subtracts this CSG with another CSG in place
  63907. * @param csg The CSG to subtact against this CSG
  63908. */
  63909. subtractInPlace(csg: CSG): void;
  63910. /**
  63911. * Intersect this CSG with another CSG
  63912. * @param csg The CSG to intersect against this CSG
  63913. * @returns A new CSG
  63914. */
  63915. intersect(csg: CSG): CSG;
  63916. /**
  63917. * Intersects this CSG with another CSG in place
  63918. * @param csg The CSG to intersect against this CSG
  63919. */
  63920. intersectInPlace(csg: CSG): void;
  63921. /**
  63922. * Return a new CSG solid with solid and empty space switched. This solid is
  63923. * not modified.
  63924. * @returns A new CSG solid with solid and empty space switched
  63925. */
  63926. inverse(): CSG;
  63927. /**
  63928. * Inverses the CSG in place
  63929. */
  63930. inverseInPlace(): void;
  63931. /**
  63932. * This is used to keep meshes transformations so they can be restored
  63933. * when we build back a Babylon Mesh
  63934. * NB : All CSG operations are performed in world coordinates
  63935. * @param csg The CSG to copy the transform attributes from
  63936. * @returns This CSG
  63937. */
  63938. copyTransformAttributes(csg: CSG): CSG;
  63939. /**
  63940. * Build Raw mesh from CSG
  63941. * Coordinates here are in world space
  63942. * @param name The name of the mesh geometry
  63943. * @param scene The Scene
  63944. * @param keepSubMeshes Specifies if the submeshes should be kept
  63945. * @returns A new Mesh
  63946. */
  63947. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63948. /**
  63949. * Build Mesh from CSG taking material and transforms into account
  63950. * @param name The name of the Mesh
  63951. * @param material The material of the Mesh
  63952. * @param scene The Scene
  63953. * @param keepSubMeshes Specifies if submeshes should be kept
  63954. * @returns The new Mesh
  63955. */
  63956. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63957. }
  63958. }
  63959. declare module "babylonjs/Meshes/trailMesh" {
  63960. import { Mesh } from "babylonjs/Meshes/mesh";
  63961. import { Scene } from "babylonjs/scene";
  63962. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63963. /**
  63964. * Class used to create a trail following a mesh
  63965. */
  63966. export class TrailMesh extends Mesh {
  63967. private _generator;
  63968. private _autoStart;
  63969. private _running;
  63970. private _diameter;
  63971. private _length;
  63972. private _sectionPolygonPointsCount;
  63973. private _sectionVectors;
  63974. private _sectionNormalVectors;
  63975. private _beforeRenderObserver;
  63976. /**
  63977. * @constructor
  63978. * @param name The value used by scene.getMeshByName() to do a lookup.
  63979. * @param generator The mesh or transform node to generate a trail.
  63980. * @param scene The scene to add this mesh to.
  63981. * @param diameter Diameter of trailing mesh. Default is 1.
  63982. * @param length Length of trailing mesh. Default is 60.
  63983. * @param autoStart Automatically start trailing mesh. Default true.
  63984. */
  63985. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63986. /**
  63987. * "TrailMesh"
  63988. * @returns "TrailMesh"
  63989. */
  63990. getClassName(): string;
  63991. private _createMesh;
  63992. /**
  63993. * Start trailing mesh.
  63994. */
  63995. start(): void;
  63996. /**
  63997. * Stop trailing mesh.
  63998. */
  63999. stop(): void;
  64000. /**
  64001. * Update trailing mesh geometry.
  64002. */
  64003. update(): void;
  64004. /**
  64005. * Returns a new TrailMesh object.
  64006. * @param name is a string, the name given to the new mesh
  64007. * @param newGenerator use new generator object for cloned trail mesh
  64008. * @returns a new mesh
  64009. */
  64010. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64011. /**
  64012. * Serializes this trail mesh
  64013. * @param serializationObject object to write serialization to
  64014. */
  64015. serialize(serializationObject: any): void;
  64016. /**
  64017. * Parses a serialized trail mesh
  64018. * @param parsedMesh the serialized mesh
  64019. * @param scene the scene to create the trail mesh in
  64020. * @returns the created trail mesh
  64021. */
  64022. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64023. }
  64024. }
  64025. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  64026. import { Nullable } from "babylonjs/types";
  64027. import { Scene } from "babylonjs/scene";
  64028. import { Vector4 } from "babylonjs/Maths/math.vector";
  64029. import { Color4 } from "babylonjs/Maths/math.color";
  64030. import { Mesh } from "babylonjs/Meshes/mesh";
  64031. /**
  64032. * Class containing static functions to help procedurally build meshes
  64033. */
  64034. export class TiledBoxBuilder {
  64035. /**
  64036. * Creates a box mesh
  64037. * 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)
  64038. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64042. * @param name defines the name of the mesh
  64043. * @param options defines the options used to create the mesh
  64044. * @param scene defines the hosting scene
  64045. * @returns the box mesh
  64046. */
  64047. static CreateTiledBox(name: string, options: {
  64048. pattern?: number;
  64049. width?: number;
  64050. height?: number;
  64051. depth?: number;
  64052. tileSize?: number;
  64053. tileWidth?: number;
  64054. tileHeight?: number;
  64055. alignHorizontal?: number;
  64056. alignVertical?: number;
  64057. faceUV?: Vector4[];
  64058. faceColors?: Color4[];
  64059. sideOrientation?: number;
  64060. updatable?: boolean;
  64061. }, scene?: Nullable<Scene>): Mesh;
  64062. }
  64063. }
  64064. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  64065. import { Vector4 } from "babylonjs/Maths/math.vector";
  64066. import { Mesh } from "babylonjs/Meshes/mesh";
  64067. /**
  64068. * Class containing static functions to help procedurally build meshes
  64069. */
  64070. export class TorusKnotBuilder {
  64071. /**
  64072. * Creates a torus knot mesh
  64073. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64074. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64075. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64076. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64080. * @param name defines the name of the mesh
  64081. * @param options defines the options used to create the mesh
  64082. * @param scene defines the hosting scene
  64083. * @returns the torus knot mesh
  64084. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64085. */
  64086. static CreateTorusKnot(name: string, options: {
  64087. radius?: number;
  64088. tube?: number;
  64089. radialSegments?: number;
  64090. tubularSegments?: number;
  64091. p?: number;
  64092. q?: number;
  64093. updatable?: boolean;
  64094. sideOrientation?: number;
  64095. frontUVs?: Vector4;
  64096. backUVs?: Vector4;
  64097. }, scene: any): Mesh;
  64098. }
  64099. }
  64100. declare module "babylonjs/Meshes/polygonMesh" {
  64101. import { Scene } from "babylonjs/scene";
  64102. import { Vector2 } from "babylonjs/Maths/math.vector";
  64103. import { Mesh } from "babylonjs/Meshes/mesh";
  64104. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  64105. import { Path2 } from "babylonjs/Maths/math.path";
  64106. /**
  64107. * Polygon
  64108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64109. */
  64110. export class Polygon {
  64111. /**
  64112. * Creates a rectangle
  64113. * @param xmin bottom X coord
  64114. * @param ymin bottom Y coord
  64115. * @param xmax top X coord
  64116. * @param ymax top Y coord
  64117. * @returns points that make the resulting rectation
  64118. */
  64119. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64120. /**
  64121. * Creates a circle
  64122. * @param radius radius of circle
  64123. * @param cx scale in x
  64124. * @param cy scale in y
  64125. * @param numberOfSides number of sides that make up the circle
  64126. * @returns points that make the resulting circle
  64127. */
  64128. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64129. /**
  64130. * Creates a polygon from input string
  64131. * @param input Input polygon data
  64132. * @returns the parsed points
  64133. */
  64134. static Parse(input: string): Vector2[];
  64135. /**
  64136. * Starts building a polygon from x and y coordinates
  64137. * @param x x coordinate
  64138. * @param y y coordinate
  64139. * @returns the started path2
  64140. */
  64141. static StartingAt(x: number, y: number): Path2;
  64142. }
  64143. /**
  64144. * Builds a polygon
  64145. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64146. */
  64147. export class PolygonMeshBuilder {
  64148. private _points;
  64149. private _outlinepoints;
  64150. private _holes;
  64151. private _name;
  64152. private _scene;
  64153. private _epoints;
  64154. private _eholes;
  64155. private _addToepoint;
  64156. /**
  64157. * Babylon reference to the earcut plugin.
  64158. */
  64159. bjsEarcut: any;
  64160. /**
  64161. * Creates a PolygonMeshBuilder
  64162. * @param name name of the builder
  64163. * @param contours Path of the polygon
  64164. * @param scene scene to add to when creating the mesh
  64165. * @param earcutInjection can be used to inject your own earcut reference
  64166. */
  64167. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64168. /**
  64169. * Adds a whole within the polygon
  64170. * @param hole Array of points defining the hole
  64171. * @returns this
  64172. */
  64173. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64174. /**
  64175. * Creates the polygon
  64176. * @param updatable If the mesh should be updatable
  64177. * @param depth The depth of the mesh created
  64178. * @returns the created mesh
  64179. */
  64180. build(updatable?: boolean, depth?: number): Mesh;
  64181. /**
  64182. * Creates the polygon
  64183. * @param depth The depth of the mesh created
  64184. * @returns the created VertexData
  64185. */
  64186. buildVertexData(depth?: number): VertexData;
  64187. /**
  64188. * Adds a side to the polygon
  64189. * @param positions points that make the polygon
  64190. * @param normals normals of the polygon
  64191. * @param uvs uvs of the polygon
  64192. * @param indices indices of the polygon
  64193. * @param bounds bounds of the polygon
  64194. * @param points points of the polygon
  64195. * @param depth depth of the polygon
  64196. * @param flip flip of the polygon
  64197. */
  64198. private addSide;
  64199. }
  64200. }
  64201. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  64202. import { Scene } from "babylonjs/scene";
  64203. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64204. import { Color4 } from "babylonjs/Maths/math.color";
  64205. import { Mesh } from "babylonjs/Meshes/mesh";
  64206. import { Nullable } from "babylonjs/types";
  64207. /**
  64208. * Class containing static functions to help procedurally build meshes
  64209. */
  64210. export class PolygonBuilder {
  64211. /**
  64212. * Creates a polygon mesh
  64213. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64214. * * 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
  64215. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64218. * * Remember you can only change the shape positions, not their number when updating a polygon
  64219. * @param name defines the name of the mesh
  64220. * @param options defines the options used to create the mesh
  64221. * @param scene defines the hosting scene
  64222. * @param earcutInjection can be used to inject your own earcut reference
  64223. * @returns the polygon mesh
  64224. */
  64225. static CreatePolygon(name: string, options: {
  64226. shape: Vector3[];
  64227. holes?: Vector3[][];
  64228. depth?: number;
  64229. faceUV?: Vector4[];
  64230. faceColors?: Color4[];
  64231. updatable?: boolean;
  64232. sideOrientation?: number;
  64233. frontUVs?: Vector4;
  64234. backUVs?: Vector4;
  64235. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64236. /**
  64237. * Creates an extruded polygon mesh, with depth in the Y direction.
  64238. * * 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)
  64239. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64240. * @param name defines the name of the mesh
  64241. * @param options defines the options used to create the mesh
  64242. * @param scene defines the hosting scene
  64243. * @param earcutInjection can be used to inject your own earcut reference
  64244. * @returns the polygon mesh
  64245. */
  64246. static ExtrudePolygon(name: string, options: {
  64247. shape: Vector3[];
  64248. holes?: Vector3[][];
  64249. depth?: number;
  64250. faceUV?: Vector4[];
  64251. faceColors?: Color4[];
  64252. updatable?: boolean;
  64253. sideOrientation?: number;
  64254. frontUVs?: Vector4;
  64255. backUVs?: Vector4;
  64256. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64257. }
  64258. }
  64259. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64260. import { Scene } from "babylonjs/scene";
  64261. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64262. import { Mesh } from "babylonjs/Meshes/mesh";
  64263. import { Nullable } from "babylonjs/types";
  64264. /**
  64265. * Class containing static functions to help procedurally build meshes
  64266. */
  64267. export class LatheBuilder {
  64268. /**
  64269. * Creates lathe mesh.
  64270. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64271. * * 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
  64272. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64273. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64274. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64275. * * 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
  64276. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64277. * * 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
  64278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64280. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64282. * @param name defines the name of the mesh
  64283. * @param options defines the options used to create the mesh
  64284. * @param scene defines the hosting scene
  64285. * @returns the lathe mesh
  64286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64287. */
  64288. static CreateLathe(name: string, options: {
  64289. shape: Vector3[];
  64290. radius?: number;
  64291. tessellation?: number;
  64292. clip?: number;
  64293. arc?: number;
  64294. closed?: boolean;
  64295. updatable?: boolean;
  64296. sideOrientation?: number;
  64297. frontUVs?: Vector4;
  64298. backUVs?: Vector4;
  64299. cap?: number;
  64300. invertUV?: boolean;
  64301. }, scene?: Nullable<Scene>): Mesh;
  64302. }
  64303. }
  64304. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64305. import { Nullable } from "babylonjs/types";
  64306. import { Scene } from "babylonjs/scene";
  64307. import { Vector4 } from "babylonjs/Maths/math.vector";
  64308. import { Mesh } from "babylonjs/Meshes/mesh";
  64309. /**
  64310. * Class containing static functions to help procedurally build meshes
  64311. */
  64312. export class TiledPlaneBuilder {
  64313. /**
  64314. * Creates a tiled plane mesh
  64315. * * The parameter `pattern` will, depending on value, do nothing or
  64316. * * * flip (reflect about central vertical) alternate tiles across and up
  64317. * * * flip every tile on alternate rows
  64318. * * * rotate (180 degs) alternate tiles across and up
  64319. * * * rotate every tile on alternate rows
  64320. * * * flip and rotate alternate tiles across and up
  64321. * * * flip and rotate every tile on alternate rows
  64322. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64323. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64326. * * 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)
  64327. * * 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)
  64328. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64329. * @param name defines the name of the mesh
  64330. * @param options defines the options used to create the mesh
  64331. * @param scene defines the hosting scene
  64332. * @returns the box mesh
  64333. */
  64334. static CreateTiledPlane(name: string, options: {
  64335. pattern?: number;
  64336. tileSize?: number;
  64337. tileWidth?: number;
  64338. tileHeight?: number;
  64339. size?: number;
  64340. width?: number;
  64341. height?: number;
  64342. alignHorizontal?: number;
  64343. alignVertical?: number;
  64344. sideOrientation?: number;
  64345. frontUVs?: Vector4;
  64346. backUVs?: Vector4;
  64347. updatable?: boolean;
  64348. }, scene?: Nullable<Scene>): Mesh;
  64349. }
  64350. }
  64351. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64352. import { Nullable } from "babylonjs/types";
  64353. import { Scene } from "babylonjs/scene";
  64354. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64355. import { Mesh } from "babylonjs/Meshes/mesh";
  64356. /**
  64357. * Class containing static functions to help procedurally build meshes
  64358. */
  64359. export class TubeBuilder {
  64360. /**
  64361. * Creates a tube mesh.
  64362. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64363. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64364. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64365. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64366. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64367. * * 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)
  64368. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64369. * * 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
  64370. * * 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
  64371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64375. * @param name defines the name of the mesh
  64376. * @param options defines the options used to create the mesh
  64377. * @param scene defines the hosting scene
  64378. * @returns the tube mesh
  64379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64380. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64381. */
  64382. static CreateTube(name: string, options: {
  64383. path: Vector3[];
  64384. radius?: number;
  64385. tessellation?: number;
  64386. radiusFunction?: {
  64387. (i: number, distance: number): number;
  64388. };
  64389. cap?: number;
  64390. arc?: number;
  64391. updatable?: boolean;
  64392. sideOrientation?: number;
  64393. frontUVs?: Vector4;
  64394. backUVs?: Vector4;
  64395. instance?: Mesh;
  64396. invertUV?: boolean;
  64397. }, scene?: Nullable<Scene>): Mesh;
  64398. }
  64399. }
  64400. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64401. import { Scene } from "babylonjs/scene";
  64402. import { Vector4 } from "babylonjs/Maths/math.vector";
  64403. import { Mesh } from "babylonjs/Meshes/mesh";
  64404. import { Nullable } from "babylonjs/types";
  64405. /**
  64406. * Class containing static functions to help procedurally build meshes
  64407. */
  64408. export class IcoSphereBuilder {
  64409. /**
  64410. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64411. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64412. * * 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`)
  64413. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64414. * * 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
  64415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64418. * @param name defines the name of the mesh
  64419. * @param options defines the options used to create the mesh
  64420. * @param scene defines the hosting scene
  64421. * @returns the icosahedron mesh
  64422. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64423. */
  64424. static CreateIcoSphere(name: string, options: {
  64425. radius?: number;
  64426. radiusX?: number;
  64427. radiusY?: number;
  64428. radiusZ?: number;
  64429. flat?: boolean;
  64430. subdivisions?: number;
  64431. sideOrientation?: number;
  64432. frontUVs?: Vector4;
  64433. backUVs?: Vector4;
  64434. updatable?: boolean;
  64435. }, scene?: Nullable<Scene>): Mesh;
  64436. }
  64437. }
  64438. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64439. import { Vector3 } from "babylonjs/Maths/math.vector";
  64440. import { Mesh } from "babylonjs/Meshes/mesh";
  64441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64442. /**
  64443. * Class containing static functions to help procedurally build meshes
  64444. */
  64445. export class DecalBuilder {
  64446. /**
  64447. * Creates a decal mesh.
  64448. * 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
  64449. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64450. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64451. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64452. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64453. * @param name defines the name of the mesh
  64454. * @param sourceMesh defines the mesh where the decal must be applied
  64455. * @param options defines the options used to create the mesh
  64456. * @param scene defines the hosting scene
  64457. * @returns the decal mesh
  64458. * @see https://doc.babylonjs.com/how_to/decals
  64459. */
  64460. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64461. position?: Vector3;
  64462. normal?: Vector3;
  64463. size?: Vector3;
  64464. angle?: number;
  64465. }): Mesh;
  64466. }
  64467. }
  64468. declare module "babylonjs/Meshes/meshBuilder" {
  64469. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64470. import { Nullable } from "babylonjs/types";
  64471. import { Scene } from "babylonjs/scene";
  64472. import { Mesh } from "babylonjs/Meshes/mesh";
  64473. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64474. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64476. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64477. import { Plane } from "babylonjs/Maths/math.plane";
  64478. /**
  64479. * Class containing static functions to help procedurally build meshes
  64480. */
  64481. export class MeshBuilder {
  64482. /**
  64483. * Creates a box mesh
  64484. * * The parameter `size` sets the size (float) of each box side (default 1)
  64485. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64486. * * 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)
  64487. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64491. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64492. * @param name defines the name of the mesh
  64493. * @param options defines the options used to create the mesh
  64494. * @param scene defines the hosting scene
  64495. * @returns the box mesh
  64496. */
  64497. static CreateBox(name: string, options: {
  64498. size?: number;
  64499. width?: number;
  64500. height?: number;
  64501. depth?: number;
  64502. faceUV?: Vector4[];
  64503. faceColors?: Color4[];
  64504. sideOrientation?: number;
  64505. frontUVs?: Vector4;
  64506. backUVs?: Vector4;
  64507. wrap?: boolean;
  64508. topBaseAt?: number;
  64509. bottomBaseAt?: number;
  64510. updatable?: boolean;
  64511. }, scene?: Nullable<Scene>): Mesh;
  64512. /**
  64513. * Creates a tiled box mesh
  64514. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64516. * @param name defines the name of the mesh
  64517. * @param options defines the options used to create the mesh
  64518. * @param scene defines the hosting scene
  64519. * @returns the tiled box mesh
  64520. */
  64521. static CreateTiledBox(name: string, options: {
  64522. pattern?: number;
  64523. size?: number;
  64524. width?: number;
  64525. height?: number;
  64526. depth: number;
  64527. tileSize?: number;
  64528. tileWidth?: number;
  64529. tileHeight?: number;
  64530. faceUV?: Vector4[];
  64531. faceColors?: Color4[];
  64532. alignHorizontal?: number;
  64533. alignVertical?: number;
  64534. sideOrientation?: number;
  64535. updatable?: boolean;
  64536. }, scene?: Nullable<Scene>): Mesh;
  64537. /**
  64538. * Creates a sphere mesh
  64539. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64540. * * 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`)
  64541. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64542. * * 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
  64543. * * 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)
  64544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64547. * @param name defines the name of the mesh
  64548. * @param options defines the options used to create the mesh
  64549. * @param scene defines the hosting scene
  64550. * @returns the sphere mesh
  64551. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64552. */
  64553. static CreateSphere(name: string, options: {
  64554. segments?: number;
  64555. diameter?: number;
  64556. diameterX?: number;
  64557. diameterY?: number;
  64558. diameterZ?: number;
  64559. arc?: number;
  64560. slice?: number;
  64561. sideOrientation?: number;
  64562. frontUVs?: Vector4;
  64563. backUVs?: Vector4;
  64564. updatable?: boolean;
  64565. }, scene?: Nullable<Scene>): Mesh;
  64566. /**
  64567. * Creates a plane polygonal mesh. By default, this is a disc
  64568. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64569. * * 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
  64570. * * 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
  64571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64574. * @param name defines the name of the mesh
  64575. * @param options defines the options used to create the mesh
  64576. * @param scene defines the hosting scene
  64577. * @returns the plane polygonal mesh
  64578. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64579. */
  64580. static CreateDisc(name: string, options: {
  64581. radius?: number;
  64582. tessellation?: number;
  64583. arc?: number;
  64584. updatable?: boolean;
  64585. sideOrientation?: number;
  64586. frontUVs?: Vector4;
  64587. backUVs?: Vector4;
  64588. }, scene?: Nullable<Scene>): Mesh;
  64589. /**
  64590. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64591. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64592. * * 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`)
  64593. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64594. * * 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
  64595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64598. * @param name defines the name of the mesh
  64599. * @param options defines the options used to create the mesh
  64600. * @param scene defines the hosting scene
  64601. * @returns the icosahedron mesh
  64602. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64603. */
  64604. static CreateIcoSphere(name: string, options: {
  64605. radius?: number;
  64606. radiusX?: number;
  64607. radiusY?: number;
  64608. radiusZ?: number;
  64609. flat?: boolean;
  64610. subdivisions?: number;
  64611. sideOrientation?: number;
  64612. frontUVs?: Vector4;
  64613. backUVs?: Vector4;
  64614. updatable?: boolean;
  64615. }, scene?: Nullable<Scene>): Mesh;
  64616. /**
  64617. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64618. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64619. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64620. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64621. * * 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
  64622. * * 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
  64623. * * 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
  64624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64626. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64627. * * 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
  64628. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64629. * * 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
  64630. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64632. * @param name defines the name of the mesh
  64633. * @param options defines the options used to create the mesh
  64634. * @param scene defines the hosting scene
  64635. * @returns the ribbon mesh
  64636. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64637. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64638. */
  64639. static CreateRibbon(name: string, options: {
  64640. pathArray: Vector3[][];
  64641. closeArray?: boolean;
  64642. closePath?: boolean;
  64643. offset?: number;
  64644. updatable?: boolean;
  64645. sideOrientation?: number;
  64646. frontUVs?: Vector4;
  64647. backUVs?: Vector4;
  64648. instance?: Mesh;
  64649. invertUV?: boolean;
  64650. uvs?: Vector2[];
  64651. colors?: Color4[];
  64652. }, scene?: Nullable<Scene>): Mesh;
  64653. /**
  64654. * Creates a cylinder or a cone mesh
  64655. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64656. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64657. * * 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.
  64658. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64659. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64660. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64661. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64662. * * 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).
  64663. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64664. * * 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).
  64665. * * 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
  64666. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64667. * * 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
  64668. * * 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.
  64669. * * If `enclose` is false, a ring surface is one element.
  64670. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64671. * * 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
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64675. * @param name defines the name of the mesh
  64676. * @param options defines the options used to create the mesh
  64677. * @param scene defines the hosting scene
  64678. * @returns the cylinder mesh
  64679. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64680. */
  64681. static CreateCylinder(name: string, options: {
  64682. height?: number;
  64683. diameterTop?: number;
  64684. diameterBottom?: number;
  64685. diameter?: number;
  64686. tessellation?: number;
  64687. subdivisions?: number;
  64688. arc?: number;
  64689. faceColors?: Color4[];
  64690. faceUV?: Vector4[];
  64691. updatable?: boolean;
  64692. hasRings?: boolean;
  64693. enclose?: boolean;
  64694. cap?: number;
  64695. sideOrientation?: number;
  64696. frontUVs?: Vector4;
  64697. backUVs?: Vector4;
  64698. }, scene?: Nullable<Scene>): Mesh;
  64699. /**
  64700. * Creates a torus mesh
  64701. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64702. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64703. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64707. * @param name defines the name of the mesh
  64708. * @param options defines the options used to create the mesh
  64709. * @param scene defines the hosting scene
  64710. * @returns the torus mesh
  64711. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64712. */
  64713. static CreateTorus(name: string, options: {
  64714. diameter?: number;
  64715. thickness?: number;
  64716. tessellation?: number;
  64717. updatable?: boolean;
  64718. sideOrientation?: number;
  64719. frontUVs?: Vector4;
  64720. backUVs?: Vector4;
  64721. }, scene?: Nullable<Scene>): Mesh;
  64722. /**
  64723. * Creates a torus knot mesh
  64724. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64725. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64726. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64727. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64731. * @param name defines the name of the mesh
  64732. * @param options defines the options used to create the mesh
  64733. * @param scene defines the hosting scene
  64734. * @returns the torus knot mesh
  64735. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64736. */
  64737. static CreateTorusKnot(name: string, options: {
  64738. radius?: number;
  64739. tube?: number;
  64740. radialSegments?: number;
  64741. tubularSegments?: number;
  64742. p?: number;
  64743. q?: number;
  64744. updatable?: boolean;
  64745. sideOrientation?: number;
  64746. frontUVs?: Vector4;
  64747. backUVs?: Vector4;
  64748. }, scene?: Nullable<Scene>): Mesh;
  64749. /**
  64750. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64751. * * 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
  64752. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64753. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64754. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64755. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64756. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64757. * * 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
  64758. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64761. * @param name defines the name of the new line system
  64762. * @param options defines the options used to create the line system
  64763. * @param scene defines the hosting scene
  64764. * @returns a new line system mesh
  64765. */
  64766. static CreateLineSystem(name: string, options: {
  64767. lines: Vector3[][];
  64768. updatable?: boolean;
  64769. instance?: Nullable<LinesMesh>;
  64770. colors?: Nullable<Color4[][]>;
  64771. useVertexAlpha?: boolean;
  64772. }, scene: Nullable<Scene>): LinesMesh;
  64773. /**
  64774. * Creates a line mesh
  64775. * 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
  64776. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64777. * * The parameter `points` is an array successive Vector3
  64778. * * 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
  64779. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64780. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64781. * * When updating an instance, remember that only point positions can change, not the number of points
  64782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64783. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64784. * @param name defines the name of the new line system
  64785. * @param options defines the options used to create the line system
  64786. * @param scene defines the hosting scene
  64787. * @returns a new line mesh
  64788. */
  64789. static CreateLines(name: string, options: {
  64790. points: Vector3[];
  64791. updatable?: boolean;
  64792. instance?: Nullable<LinesMesh>;
  64793. colors?: Color4[];
  64794. useVertexAlpha?: boolean;
  64795. }, scene?: Nullable<Scene>): LinesMesh;
  64796. /**
  64797. * Creates a dashed line mesh
  64798. * * 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
  64799. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64800. * * The parameter `points` is an array successive Vector3
  64801. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64802. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64803. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64804. * * 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
  64805. * * When updating an instance, remember that only point positions can change, not the number of points
  64806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64807. * @param name defines the name of the mesh
  64808. * @param options defines the options used to create the mesh
  64809. * @param scene defines the hosting scene
  64810. * @returns the dashed line mesh
  64811. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64812. */
  64813. static CreateDashedLines(name: string, options: {
  64814. points: Vector3[];
  64815. dashSize?: number;
  64816. gapSize?: number;
  64817. dashNb?: number;
  64818. updatable?: boolean;
  64819. instance?: LinesMesh;
  64820. }, scene?: Nullable<Scene>): LinesMesh;
  64821. /**
  64822. * 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.
  64823. * * 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.
  64824. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64825. * * 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.
  64826. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64827. * * 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
  64828. * * 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
  64829. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64832. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64834. * @param name defines the name of the mesh
  64835. * @param options defines the options used to create the mesh
  64836. * @param scene defines the hosting scene
  64837. * @returns the extruded shape mesh
  64838. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64840. */
  64841. static ExtrudeShape(name: string, options: {
  64842. shape: Vector3[];
  64843. path: Vector3[];
  64844. scale?: number;
  64845. rotation?: number;
  64846. cap?: number;
  64847. updatable?: boolean;
  64848. sideOrientation?: number;
  64849. frontUVs?: Vector4;
  64850. backUVs?: Vector4;
  64851. instance?: Mesh;
  64852. invertUV?: boolean;
  64853. }, scene?: Nullable<Scene>): Mesh;
  64854. /**
  64855. * Creates an custom extruded shape mesh.
  64856. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64857. * * 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.
  64858. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64859. * * 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
  64860. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64861. * * 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
  64862. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64863. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64864. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64865. * * 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
  64866. * * 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
  64867. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64872. * @param name defines the name of the mesh
  64873. * @param options defines the options used to create the mesh
  64874. * @param scene defines the hosting scene
  64875. * @returns the custom extruded shape mesh
  64876. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64877. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64879. */
  64880. static ExtrudeShapeCustom(name: string, options: {
  64881. shape: Vector3[];
  64882. path: Vector3[];
  64883. scaleFunction?: any;
  64884. rotationFunction?: any;
  64885. ribbonCloseArray?: boolean;
  64886. ribbonClosePath?: boolean;
  64887. cap?: number;
  64888. updatable?: boolean;
  64889. sideOrientation?: number;
  64890. frontUVs?: Vector4;
  64891. backUVs?: Vector4;
  64892. instance?: Mesh;
  64893. invertUV?: boolean;
  64894. }, scene?: Nullable<Scene>): Mesh;
  64895. /**
  64896. * Creates lathe mesh.
  64897. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64898. * * 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
  64899. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64900. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64901. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64902. * * 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
  64903. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64904. * * 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
  64905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64909. * @param name defines the name of the mesh
  64910. * @param options defines the options used to create the mesh
  64911. * @param scene defines the hosting scene
  64912. * @returns the lathe mesh
  64913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64914. */
  64915. static CreateLathe(name: string, options: {
  64916. shape: Vector3[];
  64917. radius?: number;
  64918. tessellation?: number;
  64919. clip?: number;
  64920. arc?: number;
  64921. closed?: boolean;
  64922. updatable?: boolean;
  64923. sideOrientation?: number;
  64924. frontUVs?: Vector4;
  64925. backUVs?: Vector4;
  64926. cap?: number;
  64927. invertUV?: boolean;
  64928. }, scene?: Nullable<Scene>): Mesh;
  64929. /**
  64930. * Creates a tiled plane mesh
  64931. * * You can set a limited pattern arrangement with the tiles
  64932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64935. * @param name defines the name of the mesh
  64936. * @param options defines the options used to create the mesh
  64937. * @param scene defines the hosting scene
  64938. * @returns the plane mesh
  64939. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64940. */
  64941. static CreateTiledPlane(name: string, options: {
  64942. pattern?: number;
  64943. tileSize?: number;
  64944. tileWidth?: number;
  64945. tileHeight?: number;
  64946. size?: number;
  64947. width?: number;
  64948. height?: number;
  64949. alignHorizontal?: number;
  64950. alignVertical?: number;
  64951. sideOrientation?: number;
  64952. frontUVs?: Vector4;
  64953. backUVs?: Vector4;
  64954. updatable?: boolean;
  64955. }, scene?: Nullable<Scene>): Mesh;
  64956. /**
  64957. * Creates a plane mesh
  64958. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64959. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64960. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64964. * @param name defines the name of the mesh
  64965. * @param options defines the options used to create the mesh
  64966. * @param scene defines the hosting scene
  64967. * @returns the plane mesh
  64968. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64969. */
  64970. static CreatePlane(name: string, options: {
  64971. size?: number;
  64972. width?: number;
  64973. height?: number;
  64974. sideOrientation?: number;
  64975. frontUVs?: Vector4;
  64976. backUVs?: Vector4;
  64977. updatable?: boolean;
  64978. sourcePlane?: Plane;
  64979. }, scene?: Nullable<Scene>): Mesh;
  64980. /**
  64981. * Creates a ground mesh
  64982. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64983. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64985. * @param name defines the name of the mesh
  64986. * @param options defines the options used to create the mesh
  64987. * @param scene defines the hosting scene
  64988. * @returns the ground mesh
  64989. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64990. */
  64991. static CreateGround(name: string, options: {
  64992. width?: number;
  64993. height?: number;
  64994. subdivisions?: number;
  64995. subdivisionsX?: number;
  64996. subdivisionsY?: number;
  64997. updatable?: boolean;
  64998. }, scene?: Nullable<Scene>): Mesh;
  64999. /**
  65000. * Creates a tiled ground mesh
  65001. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65002. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65003. * * 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
  65004. * * 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
  65005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65006. * @param name defines the name of the mesh
  65007. * @param options defines the options used to create the mesh
  65008. * @param scene defines the hosting scene
  65009. * @returns the tiled ground mesh
  65010. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65011. */
  65012. static CreateTiledGround(name: string, options: {
  65013. xmin: number;
  65014. zmin: number;
  65015. xmax: number;
  65016. zmax: number;
  65017. subdivisions?: {
  65018. w: number;
  65019. h: number;
  65020. };
  65021. precision?: {
  65022. w: number;
  65023. h: number;
  65024. };
  65025. updatable?: boolean;
  65026. }, scene?: Nullable<Scene>): Mesh;
  65027. /**
  65028. * Creates a ground mesh from a height map
  65029. * * The parameter `url` sets the URL of the height map image resource.
  65030. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65031. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65032. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65033. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65034. * * 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.
  65035. * * 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).
  65036. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65038. * @param name defines the name of the mesh
  65039. * @param url defines the url to the height map
  65040. * @param options defines the options used to create the mesh
  65041. * @param scene defines the hosting scene
  65042. * @returns the ground mesh
  65043. * @see https://doc.babylonjs.com/babylon101/height_map
  65044. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65045. */
  65046. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65047. width?: number;
  65048. height?: number;
  65049. subdivisions?: number;
  65050. minHeight?: number;
  65051. maxHeight?: number;
  65052. colorFilter?: Color3;
  65053. alphaFilter?: number;
  65054. updatable?: boolean;
  65055. onReady?: (mesh: GroundMesh) => void;
  65056. }, scene?: Nullable<Scene>): GroundMesh;
  65057. /**
  65058. * Creates a polygon mesh
  65059. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65060. * * 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
  65061. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65063. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65064. * * Remember you can only change the shape positions, not their number when updating a polygon
  65065. * @param name defines the name of the mesh
  65066. * @param options defines the options used to create the mesh
  65067. * @param scene defines the hosting scene
  65068. * @param earcutInjection can be used to inject your own earcut reference
  65069. * @returns the polygon mesh
  65070. */
  65071. static CreatePolygon(name: string, options: {
  65072. shape: Vector3[];
  65073. holes?: Vector3[][];
  65074. depth?: number;
  65075. faceUV?: Vector4[];
  65076. faceColors?: Color4[];
  65077. updatable?: boolean;
  65078. sideOrientation?: number;
  65079. frontUVs?: Vector4;
  65080. backUVs?: Vector4;
  65081. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65082. /**
  65083. * Creates an extruded polygon mesh, with depth in the Y direction.
  65084. * * 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)
  65085. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65086. * @param name defines the name of the mesh
  65087. * @param options defines the options used to create the mesh
  65088. * @param scene defines the hosting scene
  65089. * @param earcutInjection can be used to inject your own earcut reference
  65090. * @returns the polygon mesh
  65091. */
  65092. static ExtrudePolygon(name: string, options: {
  65093. shape: Vector3[];
  65094. holes?: Vector3[][];
  65095. depth?: number;
  65096. faceUV?: Vector4[];
  65097. faceColors?: Color4[];
  65098. updatable?: boolean;
  65099. sideOrientation?: number;
  65100. frontUVs?: Vector4;
  65101. backUVs?: Vector4;
  65102. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65103. /**
  65104. * Creates a tube mesh.
  65105. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65106. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65107. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65108. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65109. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65110. * * 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)
  65111. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65112. * * 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
  65113. * * 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
  65114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65118. * @param name defines the name of the mesh
  65119. * @param options defines the options used to create the mesh
  65120. * @param scene defines the hosting scene
  65121. * @returns the tube mesh
  65122. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65123. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65124. */
  65125. static CreateTube(name: string, options: {
  65126. path: Vector3[];
  65127. radius?: number;
  65128. tessellation?: number;
  65129. radiusFunction?: {
  65130. (i: number, distance: number): number;
  65131. };
  65132. cap?: number;
  65133. arc?: number;
  65134. updatable?: boolean;
  65135. sideOrientation?: number;
  65136. frontUVs?: Vector4;
  65137. backUVs?: Vector4;
  65138. instance?: Mesh;
  65139. invertUV?: boolean;
  65140. }, scene?: Nullable<Scene>): Mesh;
  65141. /**
  65142. * Creates a polyhedron mesh
  65143. * * 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
  65144. * * The parameter `size` (positive float, default 1) sets the polygon size
  65145. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65146. * * 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`
  65147. * * 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
  65148. * * 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)`)
  65149. * * 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
  65150. * * 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
  65151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65154. * @param name defines the name of the mesh
  65155. * @param options defines the options used to create the mesh
  65156. * @param scene defines the hosting scene
  65157. * @returns the polyhedron mesh
  65158. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65159. */
  65160. static CreatePolyhedron(name: string, options: {
  65161. type?: number;
  65162. size?: number;
  65163. sizeX?: number;
  65164. sizeY?: number;
  65165. sizeZ?: number;
  65166. custom?: any;
  65167. faceUV?: Vector4[];
  65168. faceColors?: Color4[];
  65169. flat?: boolean;
  65170. updatable?: boolean;
  65171. sideOrientation?: number;
  65172. frontUVs?: Vector4;
  65173. backUVs?: Vector4;
  65174. }, scene?: Nullable<Scene>): Mesh;
  65175. /**
  65176. * Creates a decal mesh.
  65177. * 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
  65178. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65179. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65180. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65181. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65182. * @param name defines the name of the mesh
  65183. * @param sourceMesh defines the mesh where the decal must be applied
  65184. * @param options defines the options used to create the mesh
  65185. * @param scene defines the hosting scene
  65186. * @returns the decal mesh
  65187. * @see https://doc.babylonjs.com/how_to/decals
  65188. */
  65189. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65190. position?: Vector3;
  65191. normal?: Vector3;
  65192. size?: Vector3;
  65193. angle?: number;
  65194. }): Mesh;
  65195. }
  65196. }
  65197. declare module "babylonjs/Meshes/meshSimplification" {
  65198. import { Mesh } from "babylonjs/Meshes/mesh";
  65199. /**
  65200. * A simplifier interface for future simplification implementations
  65201. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65202. */
  65203. export interface ISimplifier {
  65204. /**
  65205. * Simplification of a given mesh according to the given settings.
  65206. * Since this requires computation, it is assumed that the function runs async.
  65207. * @param settings The settings of the simplification, including quality and distance
  65208. * @param successCallback A callback that will be called after the mesh was simplified.
  65209. * @param errorCallback in case of an error, this callback will be called. optional.
  65210. */
  65211. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65212. }
  65213. /**
  65214. * Expected simplification settings.
  65215. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65216. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65217. */
  65218. export interface ISimplificationSettings {
  65219. /**
  65220. * Gets or sets the expected quality
  65221. */
  65222. quality: number;
  65223. /**
  65224. * Gets or sets the distance when this optimized version should be used
  65225. */
  65226. distance: number;
  65227. /**
  65228. * Gets an already optimized mesh
  65229. */
  65230. optimizeMesh?: boolean;
  65231. }
  65232. /**
  65233. * Class used to specify simplification options
  65234. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65235. */
  65236. export class SimplificationSettings implements ISimplificationSettings {
  65237. /** expected quality */
  65238. quality: number;
  65239. /** distance when this optimized version should be used */
  65240. distance: number;
  65241. /** already optimized mesh */
  65242. optimizeMesh?: boolean | undefined;
  65243. /**
  65244. * Creates a SimplificationSettings
  65245. * @param quality expected quality
  65246. * @param distance distance when this optimized version should be used
  65247. * @param optimizeMesh already optimized mesh
  65248. */
  65249. constructor(
  65250. /** expected quality */
  65251. quality: number,
  65252. /** distance when this optimized version should be used */
  65253. distance: number,
  65254. /** already optimized mesh */
  65255. optimizeMesh?: boolean | undefined);
  65256. }
  65257. /**
  65258. * Interface used to define a simplification task
  65259. */
  65260. export interface ISimplificationTask {
  65261. /**
  65262. * Array of settings
  65263. */
  65264. settings: Array<ISimplificationSettings>;
  65265. /**
  65266. * Simplification type
  65267. */
  65268. simplificationType: SimplificationType;
  65269. /**
  65270. * Mesh to simplify
  65271. */
  65272. mesh: Mesh;
  65273. /**
  65274. * Callback called on success
  65275. */
  65276. successCallback?: () => void;
  65277. /**
  65278. * Defines if parallel processing can be used
  65279. */
  65280. parallelProcessing: boolean;
  65281. }
  65282. /**
  65283. * Queue used to order the simplification tasks
  65284. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65285. */
  65286. export class SimplificationQueue {
  65287. private _simplificationArray;
  65288. /**
  65289. * Gets a boolean indicating that the process is still running
  65290. */
  65291. running: boolean;
  65292. /**
  65293. * Creates a new queue
  65294. */
  65295. constructor();
  65296. /**
  65297. * Adds a new simplification task
  65298. * @param task defines a task to add
  65299. */
  65300. addTask(task: ISimplificationTask): void;
  65301. /**
  65302. * Execute next task
  65303. */
  65304. executeNext(): void;
  65305. /**
  65306. * Execute a simplification task
  65307. * @param task defines the task to run
  65308. */
  65309. runSimplification(task: ISimplificationTask): void;
  65310. private getSimplifier;
  65311. }
  65312. /**
  65313. * The implemented types of simplification
  65314. * At the moment only Quadratic Error Decimation is implemented
  65315. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65316. */
  65317. export enum SimplificationType {
  65318. /** Quadratic error decimation */
  65319. QUADRATIC = 0
  65320. }
  65321. /**
  65322. * An implementation of the Quadratic Error simplification algorithm.
  65323. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65324. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65325. * @author RaananW
  65326. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65327. */
  65328. export class QuadraticErrorSimplification implements ISimplifier {
  65329. private _mesh;
  65330. private triangles;
  65331. private vertices;
  65332. private references;
  65333. private _reconstructedMesh;
  65334. /** Gets or sets the number pf sync interations */
  65335. syncIterations: number;
  65336. /** Gets or sets the aggressiveness of the simplifier */
  65337. aggressiveness: number;
  65338. /** Gets or sets the number of allowed iterations for decimation */
  65339. decimationIterations: number;
  65340. /** Gets or sets the espilon to use for bounding box computation */
  65341. boundingBoxEpsilon: number;
  65342. /**
  65343. * Creates a new QuadraticErrorSimplification
  65344. * @param _mesh defines the target mesh
  65345. */
  65346. constructor(_mesh: Mesh);
  65347. /**
  65348. * Simplification of a given mesh according to the given settings.
  65349. * Since this requires computation, it is assumed that the function runs async.
  65350. * @param settings The settings of the simplification, including quality and distance
  65351. * @param successCallback A callback that will be called after the mesh was simplified.
  65352. */
  65353. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65354. private runDecimation;
  65355. private initWithMesh;
  65356. private init;
  65357. private reconstructMesh;
  65358. private initDecimatedMesh;
  65359. private isFlipped;
  65360. private updateTriangles;
  65361. private identifyBorder;
  65362. private updateMesh;
  65363. private vertexError;
  65364. private calculateError;
  65365. }
  65366. }
  65367. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65368. import { Scene } from "babylonjs/scene";
  65369. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65370. import { ISceneComponent } from "babylonjs/sceneComponent";
  65371. module "babylonjs/scene" {
  65372. interface Scene {
  65373. /** @hidden (Backing field) */
  65374. _simplificationQueue: SimplificationQueue;
  65375. /**
  65376. * Gets or sets the simplification queue attached to the scene
  65377. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65378. */
  65379. simplificationQueue: SimplificationQueue;
  65380. }
  65381. }
  65382. module "babylonjs/Meshes/mesh" {
  65383. interface Mesh {
  65384. /**
  65385. * Simplify the mesh according to the given array of settings.
  65386. * Function will return immediately and will simplify async
  65387. * @param settings a collection of simplification settings
  65388. * @param parallelProcessing should all levels calculate parallel or one after the other
  65389. * @param simplificationType the type of simplification to run
  65390. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65391. * @returns the current mesh
  65392. */
  65393. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65394. }
  65395. }
  65396. /**
  65397. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65398. * created in a scene
  65399. */
  65400. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65401. /**
  65402. * The component name helpfull to identify the component in the list of scene components.
  65403. */
  65404. readonly name: string;
  65405. /**
  65406. * The scene the component belongs to.
  65407. */
  65408. scene: Scene;
  65409. /**
  65410. * Creates a new instance of the component for the given scene
  65411. * @param scene Defines the scene to register the component in
  65412. */
  65413. constructor(scene: Scene);
  65414. /**
  65415. * Registers the component in a given scene
  65416. */
  65417. register(): void;
  65418. /**
  65419. * Rebuilds the elements related to this component in case of
  65420. * context lost for instance.
  65421. */
  65422. rebuild(): void;
  65423. /**
  65424. * Disposes the component and the associated ressources
  65425. */
  65426. dispose(): void;
  65427. private _beforeCameraUpdate;
  65428. }
  65429. }
  65430. declare module "babylonjs/Meshes/Builders/index" {
  65431. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65432. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65433. export * from "babylonjs/Meshes/Builders/discBuilder";
  65434. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65435. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65436. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65437. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65438. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65439. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65440. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65441. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65442. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65443. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65444. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65445. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65446. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65447. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65448. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65449. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65450. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65451. }
  65452. declare module "babylonjs/Meshes/index" {
  65453. export * from "babylonjs/Meshes/abstractMesh";
  65454. export * from "babylonjs/Meshes/buffer";
  65455. export * from "babylonjs/Meshes/Compression/index";
  65456. export * from "babylonjs/Meshes/csg";
  65457. export * from "babylonjs/Meshes/geometry";
  65458. export * from "babylonjs/Meshes/groundMesh";
  65459. export * from "babylonjs/Meshes/trailMesh";
  65460. export * from "babylonjs/Meshes/instancedMesh";
  65461. export * from "babylonjs/Meshes/linesMesh";
  65462. export * from "babylonjs/Meshes/mesh";
  65463. export * from "babylonjs/Meshes/mesh.vertexData";
  65464. export * from "babylonjs/Meshes/meshBuilder";
  65465. export * from "babylonjs/Meshes/meshSimplification";
  65466. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65467. export * from "babylonjs/Meshes/polygonMesh";
  65468. export * from "babylonjs/Meshes/subMesh";
  65469. export * from "babylonjs/Meshes/meshLODLevel";
  65470. export * from "babylonjs/Meshes/transformNode";
  65471. export * from "babylonjs/Meshes/Builders/index";
  65472. export * from "babylonjs/Meshes/dataBuffer";
  65473. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65474. }
  65475. declare module "babylonjs/Morph/index" {
  65476. export * from "babylonjs/Morph/morphTarget";
  65477. export * from "babylonjs/Morph/morphTargetManager";
  65478. }
  65479. declare module "babylonjs/Navigation/INavigationEngine" {
  65480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65481. import { Vector3 } from "babylonjs/Maths/math";
  65482. import { Mesh } from "babylonjs/Meshes/mesh";
  65483. import { Scene } from "babylonjs/scene";
  65484. /**
  65485. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65486. */
  65487. export interface INavigationEnginePlugin {
  65488. /**
  65489. * plugin name
  65490. */
  65491. name: string;
  65492. /**
  65493. * Creates a navigation mesh
  65494. * @param meshes array of all the geometry used to compute the navigatio mesh
  65495. * @param parameters bunch of parameters used to filter geometry
  65496. */
  65497. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65498. /**
  65499. * Create a navigation mesh debug mesh
  65500. * @param scene is where the mesh will be added
  65501. * @returns debug display mesh
  65502. */
  65503. createDebugNavMesh(scene: Scene): Mesh;
  65504. /**
  65505. * Get a navigation mesh constrained position, closest to the parameter position
  65506. * @param position world position
  65507. * @returns the closest point to position constrained by the navigation mesh
  65508. */
  65509. getClosestPoint(position: Vector3): Vector3;
  65510. /**
  65511. * Get a navigation mesh constrained position, closest to the parameter position
  65512. * @param position world position
  65513. * @param result output the closest point to position constrained by the navigation mesh
  65514. */
  65515. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65516. /**
  65517. * Get a navigation mesh constrained position, within a particular radius
  65518. * @param position world position
  65519. * @param maxRadius the maximum distance to the constrained world position
  65520. * @returns the closest point to position constrained by the navigation mesh
  65521. */
  65522. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65523. /**
  65524. * Get a navigation mesh constrained position, within a particular radius
  65525. * @param position world position
  65526. * @param maxRadius the maximum distance to the constrained world position
  65527. * @param result output the closest point to position constrained by the navigation mesh
  65528. */
  65529. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65530. /**
  65531. * Compute the final position from a segment made of destination-position
  65532. * @param position world position
  65533. * @param destination world position
  65534. * @returns the resulting point along the navmesh
  65535. */
  65536. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65537. /**
  65538. * Compute the final position from a segment made of destination-position
  65539. * @param position world position
  65540. * @param destination world position
  65541. * @param result output the resulting point along the navmesh
  65542. */
  65543. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65544. /**
  65545. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65546. * @param start world position
  65547. * @param end world position
  65548. * @returns array containing world position composing the path
  65549. */
  65550. computePath(start: Vector3, end: Vector3): Vector3[];
  65551. /**
  65552. * If this plugin is supported
  65553. * @returns true if plugin is supported
  65554. */
  65555. isSupported(): boolean;
  65556. /**
  65557. * Create a new Crowd so you can add agents
  65558. * @param maxAgents the maximum agent count in the crowd
  65559. * @param maxAgentRadius the maximum radius an agent can have
  65560. * @param scene to attach the crowd to
  65561. * @returns the crowd you can add agents to
  65562. */
  65563. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65564. /**
  65565. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65566. * The queries will try to find a solution within those bounds
  65567. * default is (1,1,1)
  65568. * @param extent x,y,z value that define the extent around the queries point of reference
  65569. */
  65570. setDefaultQueryExtent(extent: Vector3): void;
  65571. /**
  65572. * Get the Bounding box extent specified by setDefaultQueryExtent
  65573. * @returns the box extent values
  65574. */
  65575. getDefaultQueryExtent(): Vector3;
  65576. /**
  65577. * build the navmesh from a previously saved state using getNavmeshData
  65578. * @param data the Uint8Array returned by getNavmeshData
  65579. */
  65580. buildFromNavmeshData(data: Uint8Array): void;
  65581. /**
  65582. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65583. * @returns data the Uint8Array that can be saved and reused
  65584. */
  65585. getNavmeshData(): Uint8Array;
  65586. /**
  65587. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65588. * @param result output the box extent values
  65589. */
  65590. getDefaultQueryExtentToRef(result: Vector3): void;
  65591. /**
  65592. * Release all resources
  65593. */
  65594. dispose(): void;
  65595. }
  65596. /**
  65597. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65598. */
  65599. export interface ICrowd {
  65600. /**
  65601. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65602. * You can attach anything to that node. The node position is updated in the scene update tick.
  65603. * @param pos world position that will be constrained by the navigation mesh
  65604. * @param parameters agent parameters
  65605. * @param transform hooked to the agent that will be update by the scene
  65606. * @returns agent index
  65607. */
  65608. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65609. /**
  65610. * Returns the agent position in world space
  65611. * @param index agent index returned by addAgent
  65612. * @returns world space position
  65613. */
  65614. getAgentPosition(index: number): Vector3;
  65615. /**
  65616. * Gets the agent position result in world space
  65617. * @param index agent index returned by addAgent
  65618. * @param result output world space position
  65619. */
  65620. getAgentPositionToRef(index: number, result: Vector3): void;
  65621. /**
  65622. * Gets the agent velocity in world space
  65623. * @param index agent index returned by addAgent
  65624. * @returns world space velocity
  65625. */
  65626. getAgentVelocity(index: number): Vector3;
  65627. /**
  65628. * Gets the agent velocity result in world space
  65629. * @param index agent index returned by addAgent
  65630. * @param result output world space velocity
  65631. */
  65632. getAgentVelocityToRef(index: number, result: Vector3): void;
  65633. /**
  65634. * remove a particular agent previously created
  65635. * @param index agent index returned by addAgent
  65636. */
  65637. removeAgent(index: number): void;
  65638. /**
  65639. * get the list of all agents attached to this crowd
  65640. * @returns list of agent indices
  65641. */
  65642. getAgents(): number[];
  65643. /**
  65644. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65645. * @param deltaTime in seconds
  65646. */
  65647. update(deltaTime: number): void;
  65648. /**
  65649. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65650. * @param index agent index returned by addAgent
  65651. * @param destination targeted world position
  65652. */
  65653. agentGoto(index: number, destination: Vector3): void;
  65654. /**
  65655. * Teleport the agent to a new position
  65656. * @param index agent index returned by addAgent
  65657. * @param destination targeted world position
  65658. */
  65659. agentTeleport(index: number, destination: Vector3): void;
  65660. /**
  65661. * Update agent parameters
  65662. * @param index agent index returned by addAgent
  65663. * @param parameters agent parameters
  65664. */
  65665. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65666. /**
  65667. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65668. * The queries will try to find a solution within those bounds
  65669. * default is (1,1,1)
  65670. * @param extent x,y,z value that define the extent around the queries point of reference
  65671. */
  65672. setDefaultQueryExtent(extent: Vector3): void;
  65673. /**
  65674. * Get the Bounding box extent specified by setDefaultQueryExtent
  65675. * @returns the box extent values
  65676. */
  65677. getDefaultQueryExtent(): Vector3;
  65678. /**
  65679. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65680. * @param result output the box extent values
  65681. */
  65682. getDefaultQueryExtentToRef(result: Vector3): void;
  65683. /**
  65684. * Release all resources
  65685. */
  65686. dispose(): void;
  65687. }
  65688. /**
  65689. * Configures an agent
  65690. */
  65691. export interface IAgentParameters {
  65692. /**
  65693. * Agent radius. [Limit: >= 0]
  65694. */
  65695. radius: number;
  65696. /**
  65697. * Agent height. [Limit: > 0]
  65698. */
  65699. height: number;
  65700. /**
  65701. * Maximum allowed acceleration. [Limit: >= 0]
  65702. */
  65703. maxAcceleration: number;
  65704. /**
  65705. * Maximum allowed speed. [Limit: >= 0]
  65706. */
  65707. maxSpeed: number;
  65708. /**
  65709. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65710. */
  65711. collisionQueryRange: number;
  65712. /**
  65713. * The path visibility optimization range. [Limit: > 0]
  65714. */
  65715. pathOptimizationRange: number;
  65716. /**
  65717. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65718. */
  65719. separationWeight: number;
  65720. }
  65721. /**
  65722. * Configures the navigation mesh creation
  65723. */
  65724. export interface INavMeshParameters {
  65725. /**
  65726. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65727. */
  65728. cs: number;
  65729. /**
  65730. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65731. */
  65732. ch: number;
  65733. /**
  65734. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65735. */
  65736. walkableSlopeAngle: number;
  65737. /**
  65738. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65739. * be considered walkable. [Limit: >= 3] [Units: vx]
  65740. */
  65741. walkableHeight: number;
  65742. /**
  65743. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65744. */
  65745. walkableClimb: number;
  65746. /**
  65747. * The distance to erode/shrink the walkable area of the heightfield away from
  65748. * obstructions. [Limit: >=0] [Units: vx]
  65749. */
  65750. walkableRadius: number;
  65751. /**
  65752. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65753. */
  65754. maxEdgeLen: number;
  65755. /**
  65756. * The maximum distance a simplfied contour's border edges should deviate
  65757. * the original raw contour. [Limit: >=0] [Units: vx]
  65758. */
  65759. maxSimplificationError: number;
  65760. /**
  65761. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65762. */
  65763. minRegionArea: number;
  65764. /**
  65765. * Any regions with a span count smaller than this value will, if possible,
  65766. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65767. */
  65768. mergeRegionArea: number;
  65769. /**
  65770. * The maximum number of vertices allowed for polygons generated during the
  65771. * contour to polygon conversion process. [Limit: >= 3]
  65772. */
  65773. maxVertsPerPoly: number;
  65774. /**
  65775. * Sets the sampling distance to use when generating the detail mesh.
  65776. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65777. */
  65778. detailSampleDist: number;
  65779. /**
  65780. * The maximum distance the detail mesh surface should deviate from heightfield
  65781. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65782. */
  65783. detailSampleMaxError: number;
  65784. }
  65785. }
  65786. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65787. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65788. import { Mesh } from "babylonjs/Meshes/mesh";
  65789. import { Scene } from "babylonjs/scene";
  65790. import { Vector3 } from "babylonjs/Maths/math";
  65791. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65792. /**
  65793. * RecastJS navigation plugin
  65794. */
  65795. export class RecastJSPlugin implements INavigationEnginePlugin {
  65796. /**
  65797. * Reference to the Recast library
  65798. */
  65799. bjsRECAST: any;
  65800. /**
  65801. * plugin name
  65802. */
  65803. name: string;
  65804. /**
  65805. * the first navmesh created. We might extend this to support multiple navmeshes
  65806. */
  65807. navMesh: any;
  65808. /**
  65809. * Initializes the recastJS plugin
  65810. * @param recastInjection can be used to inject your own recast reference
  65811. */
  65812. constructor(recastInjection?: any);
  65813. /**
  65814. * Creates a navigation mesh
  65815. * @param meshes array of all the geometry used to compute the navigatio mesh
  65816. * @param parameters bunch of parameters used to filter geometry
  65817. */
  65818. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65819. /**
  65820. * Create a navigation mesh debug mesh
  65821. * @param scene is where the mesh will be added
  65822. * @returns debug display mesh
  65823. */
  65824. createDebugNavMesh(scene: Scene): Mesh;
  65825. /**
  65826. * Get a navigation mesh constrained position, closest to the parameter position
  65827. * @param position world position
  65828. * @returns the closest point to position constrained by the navigation mesh
  65829. */
  65830. getClosestPoint(position: Vector3): Vector3;
  65831. /**
  65832. * Get a navigation mesh constrained position, closest to the parameter position
  65833. * @param position world position
  65834. * @param result output the closest point to position constrained by the navigation mesh
  65835. */
  65836. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65837. /**
  65838. * Get a navigation mesh constrained position, within a particular radius
  65839. * @param position world position
  65840. * @param maxRadius the maximum distance to the constrained world position
  65841. * @returns the closest point to position constrained by the navigation mesh
  65842. */
  65843. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65844. /**
  65845. * Get a navigation mesh constrained position, within a particular radius
  65846. * @param position world position
  65847. * @param maxRadius the maximum distance to the constrained world position
  65848. * @param result output the closest point to position constrained by the navigation mesh
  65849. */
  65850. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65851. /**
  65852. * Compute the final position from a segment made of destination-position
  65853. * @param position world position
  65854. * @param destination world position
  65855. * @returns the resulting point along the navmesh
  65856. */
  65857. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65858. /**
  65859. * Compute the final position from a segment made of destination-position
  65860. * @param position world position
  65861. * @param destination world position
  65862. * @param result output the resulting point along the navmesh
  65863. */
  65864. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65865. /**
  65866. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65867. * @param start world position
  65868. * @param end world position
  65869. * @returns array containing world position composing the path
  65870. */
  65871. computePath(start: Vector3, end: Vector3): Vector3[];
  65872. /**
  65873. * Create a new Crowd so you can add agents
  65874. * @param maxAgents the maximum agent count in the crowd
  65875. * @param maxAgentRadius the maximum radius an agent can have
  65876. * @param scene to attach the crowd to
  65877. * @returns the crowd you can add agents to
  65878. */
  65879. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65880. /**
  65881. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65882. * The queries will try to find a solution within those bounds
  65883. * default is (1,1,1)
  65884. * @param extent x,y,z value that define the extent around the queries point of reference
  65885. */
  65886. setDefaultQueryExtent(extent: Vector3): void;
  65887. /**
  65888. * Get the Bounding box extent specified by setDefaultQueryExtent
  65889. * @returns the box extent values
  65890. */
  65891. getDefaultQueryExtent(): Vector3;
  65892. /**
  65893. * build the navmesh from a previously saved state using getNavmeshData
  65894. * @param data the Uint8Array returned by getNavmeshData
  65895. */
  65896. buildFromNavmeshData(data: Uint8Array): void;
  65897. /**
  65898. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65899. * @returns data the Uint8Array that can be saved and reused
  65900. */
  65901. getNavmeshData(): Uint8Array;
  65902. /**
  65903. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65904. * @param result output the box extent values
  65905. */
  65906. getDefaultQueryExtentToRef(result: Vector3): void;
  65907. /**
  65908. * Disposes
  65909. */
  65910. dispose(): void;
  65911. /**
  65912. * If this plugin is supported
  65913. * @returns true if plugin is supported
  65914. */
  65915. isSupported(): boolean;
  65916. }
  65917. /**
  65918. * Recast detour crowd implementation
  65919. */
  65920. export class RecastJSCrowd implements ICrowd {
  65921. /**
  65922. * Recast/detour plugin
  65923. */
  65924. bjsRECASTPlugin: RecastJSPlugin;
  65925. /**
  65926. * Link to the detour crowd
  65927. */
  65928. recastCrowd: any;
  65929. /**
  65930. * One transform per agent
  65931. */
  65932. transforms: TransformNode[];
  65933. /**
  65934. * All agents created
  65935. */
  65936. agents: number[];
  65937. /**
  65938. * Link to the scene is kept to unregister the crowd from the scene
  65939. */
  65940. private _scene;
  65941. /**
  65942. * Observer for crowd updates
  65943. */
  65944. private _onBeforeAnimationsObserver;
  65945. /**
  65946. * Constructor
  65947. * @param plugin recastJS plugin
  65948. * @param maxAgents the maximum agent count in the crowd
  65949. * @param maxAgentRadius the maximum radius an agent can have
  65950. * @param scene to attach the crowd to
  65951. * @returns the crowd you can add agents to
  65952. */
  65953. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65954. /**
  65955. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65956. * You can attach anything to that node. The node position is updated in the scene update tick.
  65957. * @param pos world position that will be constrained by the navigation mesh
  65958. * @param parameters agent parameters
  65959. * @param transform hooked to the agent that will be update by the scene
  65960. * @returns agent index
  65961. */
  65962. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65963. /**
  65964. * Returns the agent position in world space
  65965. * @param index agent index returned by addAgent
  65966. * @returns world space position
  65967. */
  65968. getAgentPosition(index: number): Vector3;
  65969. /**
  65970. * Returns the agent position result in world space
  65971. * @param index agent index returned by addAgent
  65972. * @param result output world space position
  65973. */
  65974. getAgentPositionToRef(index: number, result: Vector3): void;
  65975. /**
  65976. * Returns the agent velocity in world space
  65977. * @param index agent index returned by addAgent
  65978. * @returns world space velocity
  65979. */
  65980. getAgentVelocity(index: number): Vector3;
  65981. /**
  65982. * Returns the agent velocity result in world space
  65983. * @param index agent index returned by addAgent
  65984. * @param result output world space velocity
  65985. */
  65986. getAgentVelocityToRef(index: number, result: Vector3): void;
  65987. /**
  65988. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65989. * @param index agent index returned by addAgent
  65990. * @param destination targeted world position
  65991. */
  65992. agentGoto(index: number, destination: Vector3): void;
  65993. /**
  65994. * Teleport the agent to a new position
  65995. * @param index agent index returned by addAgent
  65996. * @param destination targeted world position
  65997. */
  65998. agentTeleport(index: number, destination: Vector3): void;
  65999. /**
  66000. * Update agent parameters
  66001. * @param index agent index returned by addAgent
  66002. * @param parameters agent parameters
  66003. */
  66004. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66005. /**
  66006. * remove a particular agent previously created
  66007. * @param index agent index returned by addAgent
  66008. */
  66009. removeAgent(index: number): void;
  66010. /**
  66011. * get the list of all agents attached to this crowd
  66012. * @returns list of agent indices
  66013. */
  66014. getAgents(): number[];
  66015. /**
  66016. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66017. * @param deltaTime in seconds
  66018. */
  66019. update(deltaTime: number): void;
  66020. /**
  66021. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66022. * The queries will try to find a solution within those bounds
  66023. * default is (1,1,1)
  66024. * @param extent x,y,z value that define the extent around the queries point of reference
  66025. */
  66026. setDefaultQueryExtent(extent: Vector3): void;
  66027. /**
  66028. * Get the Bounding box extent specified by setDefaultQueryExtent
  66029. * @returns the box extent values
  66030. */
  66031. getDefaultQueryExtent(): Vector3;
  66032. /**
  66033. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66034. * @param result output the box extent values
  66035. */
  66036. getDefaultQueryExtentToRef(result: Vector3): void;
  66037. /**
  66038. * Release all resources
  66039. */
  66040. dispose(): void;
  66041. }
  66042. }
  66043. declare module "babylonjs/Navigation/Plugins/index" {
  66044. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  66045. }
  66046. declare module "babylonjs/Navigation/index" {
  66047. export * from "babylonjs/Navigation/INavigationEngine";
  66048. export * from "babylonjs/Navigation/Plugins/index";
  66049. }
  66050. declare module "babylonjs/Offline/database" {
  66051. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  66052. /**
  66053. * Class used to enable access to IndexedDB
  66054. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66055. */
  66056. export class Database implements IOfflineProvider {
  66057. private _callbackManifestChecked;
  66058. private _currentSceneUrl;
  66059. private _db;
  66060. private _enableSceneOffline;
  66061. private _enableTexturesOffline;
  66062. private _manifestVersionFound;
  66063. private _mustUpdateRessources;
  66064. private _hasReachedQuota;
  66065. private _isSupported;
  66066. private _idbFactory;
  66067. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66068. private static IsUASupportingBlobStorage;
  66069. /**
  66070. * Gets a boolean indicating if Database storate is enabled (off by default)
  66071. */
  66072. static IDBStorageEnabled: boolean;
  66073. /**
  66074. * Gets a boolean indicating if scene must be saved in the database
  66075. */
  66076. get enableSceneOffline(): boolean;
  66077. /**
  66078. * Gets a boolean indicating if textures must be saved in the database
  66079. */
  66080. get enableTexturesOffline(): boolean;
  66081. /**
  66082. * Creates a new Database
  66083. * @param urlToScene defines the url to load the scene
  66084. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66085. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66086. */
  66087. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66088. private static _ParseURL;
  66089. private static _ReturnFullUrlLocation;
  66090. private _checkManifestFile;
  66091. /**
  66092. * Open the database and make it available
  66093. * @param successCallback defines the callback to call on success
  66094. * @param errorCallback defines the callback to call on error
  66095. */
  66096. open(successCallback: () => void, errorCallback: () => void): void;
  66097. /**
  66098. * Loads an image from the database
  66099. * @param url defines the url to load from
  66100. * @param image defines the target DOM image
  66101. */
  66102. loadImage(url: string, image: HTMLImageElement): void;
  66103. private _loadImageFromDBAsync;
  66104. private _saveImageIntoDBAsync;
  66105. private _checkVersionFromDB;
  66106. private _loadVersionFromDBAsync;
  66107. private _saveVersionIntoDBAsync;
  66108. /**
  66109. * Loads a file from database
  66110. * @param url defines the URL to load from
  66111. * @param sceneLoaded defines a callback to call on success
  66112. * @param progressCallBack defines a callback to call when progress changed
  66113. * @param errorCallback defines a callback to call on error
  66114. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66115. */
  66116. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66117. private _loadFileAsync;
  66118. private _saveFileAsync;
  66119. /**
  66120. * Validates if xhr data is correct
  66121. * @param xhr defines the request to validate
  66122. * @param dataType defines the expected data type
  66123. * @returns true if data is correct
  66124. */
  66125. private static _ValidateXHRData;
  66126. }
  66127. }
  66128. declare module "babylonjs/Offline/index" {
  66129. export * from "babylonjs/Offline/database";
  66130. export * from "babylonjs/Offline/IOfflineProvider";
  66131. }
  66132. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  66133. /** @hidden */
  66134. export var gpuUpdateParticlesPixelShader: {
  66135. name: string;
  66136. shader: string;
  66137. };
  66138. }
  66139. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  66140. /** @hidden */
  66141. export var gpuUpdateParticlesVertexShader: {
  66142. name: string;
  66143. shader: string;
  66144. };
  66145. }
  66146. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  66147. /** @hidden */
  66148. export var clipPlaneFragmentDeclaration2: {
  66149. name: string;
  66150. shader: string;
  66151. };
  66152. }
  66153. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  66154. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  66155. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66156. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66157. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66158. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  66159. /** @hidden */
  66160. export var gpuRenderParticlesPixelShader: {
  66161. name: string;
  66162. shader: string;
  66163. };
  66164. }
  66165. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  66166. /** @hidden */
  66167. export var clipPlaneVertexDeclaration2: {
  66168. name: string;
  66169. shader: string;
  66170. };
  66171. }
  66172. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  66173. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  66174. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  66175. /** @hidden */
  66176. export var gpuRenderParticlesVertexShader: {
  66177. name: string;
  66178. shader: string;
  66179. };
  66180. }
  66181. declare module "babylonjs/Particles/gpuParticleSystem" {
  66182. import { Nullable } from "babylonjs/types";
  66183. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  66184. import { Observable } from "babylonjs/Misc/observable";
  66185. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66186. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66187. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  66188. import { Scene, IDisposable } from "babylonjs/scene";
  66189. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  66190. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66191. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  66192. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  66193. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  66194. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  66195. /**
  66196. * This represents a GPU particle system in Babylon
  66197. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66198. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66199. */
  66200. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66201. /**
  66202. * The layer mask we are rendering the particles through.
  66203. */
  66204. layerMask: number;
  66205. private _capacity;
  66206. private _activeCount;
  66207. private _currentActiveCount;
  66208. private _accumulatedCount;
  66209. private _renderEffect;
  66210. private _updateEffect;
  66211. private _buffer0;
  66212. private _buffer1;
  66213. private _spriteBuffer;
  66214. private _updateVAO;
  66215. private _renderVAO;
  66216. private _targetIndex;
  66217. private _sourceBuffer;
  66218. private _targetBuffer;
  66219. private _engine;
  66220. private _currentRenderId;
  66221. private _started;
  66222. private _stopped;
  66223. private _timeDelta;
  66224. private _randomTexture;
  66225. private _randomTexture2;
  66226. private _attributesStrideSize;
  66227. private _updateEffectOptions;
  66228. private _randomTextureSize;
  66229. private _actualFrame;
  66230. private readonly _rawTextureWidth;
  66231. /**
  66232. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66233. */
  66234. static get IsSupported(): boolean;
  66235. /**
  66236. * An event triggered when the system is disposed.
  66237. */
  66238. onDisposeObservable: Observable<GPUParticleSystem>;
  66239. /**
  66240. * Gets the maximum number of particles active at the same time.
  66241. * @returns The max number of active particles.
  66242. */
  66243. getCapacity(): number;
  66244. /**
  66245. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66246. * to override the particles.
  66247. */
  66248. forceDepthWrite: boolean;
  66249. /**
  66250. * Gets or set the number of active particles
  66251. */
  66252. get activeParticleCount(): number;
  66253. set activeParticleCount(value: number);
  66254. private _preWarmDone;
  66255. /**
  66256. * Specifies if the particles are updated in emitter local space or world space.
  66257. * This is always false for GPU particles
  66258. */
  66259. get isLocal(): boolean;
  66260. set isLocal(value: boolean);
  66261. /**
  66262. * Is this system ready to be used/rendered
  66263. * @return true if the system is ready
  66264. */
  66265. isReady(): boolean;
  66266. /**
  66267. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66268. * @returns True if it has been started, otherwise false.
  66269. */
  66270. isStarted(): boolean;
  66271. /**
  66272. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66273. * @returns True if it has been stopped, otherwise false.
  66274. */
  66275. isStopped(): boolean;
  66276. /**
  66277. * Gets a boolean indicating that the system is stopping
  66278. * @returns true if the system is currently stopping
  66279. */
  66280. isStopping(): boolean;
  66281. /**
  66282. * Gets the number of particles active at the same time.
  66283. * @returns The number of active particles.
  66284. */
  66285. getActiveCount(): number;
  66286. /**
  66287. * Starts the particle system and begins to emit
  66288. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66289. */
  66290. start(delay?: number): void;
  66291. /**
  66292. * Stops the particle system.
  66293. */
  66294. stop(): void;
  66295. /**
  66296. * Remove all active particles
  66297. */
  66298. reset(): void;
  66299. /**
  66300. * Returns the string "GPUParticleSystem"
  66301. * @returns a string containing the class name
  66302. */
  66303. getClassName(): string;
  66304. private _colorGradientsTexture;
  66305. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66306. /**
  66307. * Adds a new color gradient
  66308. * @param gradient defines the gradient to use (between 0 and 1)
  66309. * @param color1 defines the color to affect to the specified gradient
  66310. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66311. * @returns the current particle system
  66312. */
  66313. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66314. private _refreshColorGradient;
  66315. /** Force the system to rebuild all gradients */
  66316. forceRefreshGradients(): void;
  66317. /**
  66318. * Remove a specific color gradient
  66319. * @param gradient defines the gradient to remove
  66320. * @returns the current particle system
  66321. */
  66322. removeColorGradient(gradient: number): GPUParticleSystem;
  66323. private _angularSpeedGradientsTexture;
  66324. private _sizeGradientsTexture;
  66325. private _velocityGradientsTexture;
  66326. private _limitVelocityGradientsTexture;
  66327. private _dragGradientsTexture;
  66328. private _addFactorGradient;
  66329. /**
  66330. * Adds a new size gradient
  66331. * @param gradient defines the gradient to use (between 0 and 1)
  66332. * @param factor defines the size factor to affect to the specified gradient
  66333. * @returns the current particle system
  66334. */
  66335. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66336. /**
  66337. * Remove a specific size gradient
  66338. * @param gradient defines the gradient to remove
  66339. * @returns the current particle system
  66340. */
  66341. removeSizeGradient(gradient: number): GPUParticleSystem;
  66342. private _refreshFactorGradient;
  66343. /**
  66344. * Adds a new angular speed gradient
  66345. * @param gradient defines the gradient to use (between 0 and 1)
  66346. * @param factor defines the angular speed to affect to the specified gradient
  66347. * @returns the current particle system
  66348. */
  66349. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66350. /**
  66351. * Remove a specific angular speed gradient
  66352. * @param gradient defines the gradient to remove
  66353. * @returns the current particle system
  66354. */
  66355. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66356. /**
  66357. * Adds a new velocity gradient
  66358. * @param gradient defines the gradient to use (between 0 and 1)
  66359. * @param factor defines the velocity to affect to the specified gradient
  66360. * @returns the current particle system
  66361. */
  66362. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66363. /**
  66364. * Remove a specific velocity gradient
  66365. * @param gradient defines the gradient to remove
  66366. * @returns the current particle system
  66367. */
  66368. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66369. /**
  66370. * Adds a new limit velocity gradient
  66371. * @param gradient defines the gradient to use (between 0 and 1)
  66372. * @param factor defines the limit velocity value to affect to the specified gradient
  66373. * @returns the current particle system
  66374. */
  66375. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66376. /**
  66377. * Remove a specific limit velocity gradient
  66378. * @param gradient defines the gradient to remove
  66379. * @returns the current particle system
  66380. */
  66381. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66382. /**
  66383. * Adds a new drag gradient
  66384. * @param gradient defines the gradient to use (between 0 and 1)
  66385. * @param factor defines the drag value to affect to the specified gradient
  66386. * @returns the current particle system
  66387. */
  66388. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66389. /**
  66390. * Remove a specific drag gradient
  66391. * @param gradient defines the gradient to remove
  66392. * @returns the current particle system
  66393. */
  66394. removeDragGradient(gradient: number): GPUParticleSystem;
  66395. /**
  66396. * Not supported by GPUParticleSystem
  66397. * @param gradient defines the gradient to use (between 0 and 1)
  66398. * @param factor defines the emit rate value to affect to the specified gradient
  66399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66400. * @returns the current particle system
  66401. */
  66402. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66403. /**
  66404. * Not supported by GPUParticleSystem
  66405. * @param gradient defines the gradient to remove
  66406. * @returns the current particle system
  66407. */
  66408. removeEmitRateGradient(gradient: number): IParticleSystem;
  66409. /**
  66410. * Not supported by GPUParticleSystem
  66411. * @param gradient defines the gradient to use (between 0 and 1)
  66412. * @param factor defines the start size value to affect to the specified gradient
  66413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66414. * @returns the current particle system
  66415. */
  66416. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66417. /**
  66418. * Not supported by GPUParticleSystem
  66419. * @param gradient defines the gradient to remove
  66420. * @returns the current particle system
  66421. */
  66422. removeStartSizeGradient(gradient: number): IParticleSystem;
  66423. /**
  66424. * Not supported by GPUParticleSystem
  66425. * @param gradient defines the gradient to use (between 0 and 1)
  66426. * @param min defines the color remap minimal range
  66427. * @param max defines the color remap maximal range
  66428. * @returns the current particle system
  66429. */
  66430. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66431. /**
  66432. * Not supported by GPUParticleSystem
  66433. * @param gradient defines the gradient to remove
  66434. * @returns the current particle system
  66435. */
  66436. removeColorRemapGradient(): IParticleSystem;
  66437. /**
  66438. * Not supported by GPUParticleSystem
  66439. * @param gradient defines the gradient to use (between 0 and 1)
  66440. * @param min defines the alpha remap minimal range
  66441. * @param max defines the alpha remap maximal range
  66442. * @returns the current particle system
  66443. */
  66444. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66445. /**
  66446. * Not supported by GPUParticleSystem
  66447. * @param gradient defines the gradient to remove
  66448. * @returns the current particle system
  66449. */
  66450. removeAlphaRemapGradient(): IParticleSystem;
  66451. /**
  66452. * Not supported by GPUParticleSystem
  66453. * @param gradient defines the gradient to use (between 0 and 1)
  66454. * @param color defines the color to affect to the specified gradient
  66455. * @returns the current particle system
  66456. */
  66457. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66458. /**
  66459. * Not supported by GPUParticleSystem
  66460. * @param gradient defines the gradient to remove
  66461. * @returns the current particle system
  66462. */
  66463. removeRampGradient(): IParticleSystem;
  66464. /**
  66465. * Not supported by GPUParticleSystem
  66466. * @returns the list of ramp gradients
  66467. */
  66468. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66469. /**
  66470. * Not supported by GPUParticleSystem
  66471. * Gets or sets a boolean indicating that ramp gradients must be used
  66472. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66473. */
  66474. get useRampGradients(): boolean;
  66475. set useRampGradients(value: boolean);
  66476. /**
  66477. * Not supported by GPUParticleSystem
  66478. * @param gradient defines the gradient to use (between 0 and 1)
  66479. * @param factor defines the life time factor to affect to the specified gradient
  66480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66481. * @returns the current particle system
  66482. */
  66483. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66484. /**
  66485. * Not supported by GPUParticleSystem
  66486. * @param gradient defines the gradient to remove
  66487. * @returns the current particle system
  66488. */
  66489. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66490. /**
  66491. * Instantiates a GPU particle system.
  66492. * 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.
  66493. * @param name The name of the particle system
  66494. * @param options The options used to create the system
  66495. * @param scene The scene the particle system belongs to
  66496. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66497. */
  66498. constructor(name: string, options: Partial<{
  66499. capacity: number;
  66500. randomTextureSize: number;
  66501. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66502. protected _reset(): void;
  66503. private _createUpdateVAO;
  66504. private _createRenderVAO;
  66505. private _initialize;
  66506. /** @hidden */
  66507. _recreateUpdateEffect(): void;
  66508. /** @hidden */
  66509. _recreateRenderEffect(): void;
  66510. /**
  66511. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66512. * @param preWarm defines if we are in the pre-warmimg phase
  66513. */
  66514. animate(preWarm?: boolean): void;
  66515. private _createFactorGradientTexture;
  66516. private _createSizeGradientTexture;
  66517. private _createAngularSpeedGradientTexture;
  66518. private _createVelocityGradientTexture;
  66519. private _createLimitVelocityGradientTexture;
  66520. private _createDragGradientTexture;
  66521. private _createColorGradientTexture;
  66522. /**
  66523. * Renders the particle system in its current state
  66524. * @param preWarm defines if the system should only update the particles but not render them
  66525. * @returns the current number of particles
  66526. */
  66527. render(preWarm?: boolean): number;
  66528. /**
  66529. * Rebuilds the particle system
  66530. */
  66531. rebuild(): void;
  66532. private _releaseBuffers;
  66533. private _releaseVAOs;
  66534. /**
  66535. * Disposes the particle system and free the associated resources
  66536. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66537. */
  66538. dispose(disposeTexture?: boolean): void;
  66539. /**
  66540. * Clones the particle system.
  66541. * @param name The name of the cloned object
  66542. * @param newEmitter The new emitter to use
  66543. * @returns the cloned particle system
  66544. */
  66545. clone(name: string, newEmitter: any): GPUParticleSystem;
  66546. /**
  66547. * Serializes the particle system to a JSON object.
  66548. * @returns the JSON object
  66549. */
  66550. serialize(): any;
  66551. /**
  66552. * Parses a JSON object to create a GPU particle system.
  66553. * @param parsedParticleSystem The JSON object to parse
  66554. * @param scene The scene to create the particle system in
  66555. * @param rootUrl The root url to use to load external dependencies like texture
  66556. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66557. * @returns the parsed GPU particle system
  66558. */
  66559. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66560. }
  66561. }
  66562. declare module "babylonjs/Particles/particleSystemSet" {
  66563. import { Nullable } from "babylonjs/types";
  66564. import { Color3 } from "babylonjs/Maths/math.color";
  66565. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66567. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66568. import { Scene, IDisposable } from "babylonjs/scene";
  66569. /**
  66570. * Represents a set of particle systems working together to create a specific effect
  66571. */
  66572. export class ParticleSystemSet implements IDisposable {
  66573. /**
  66574. * Gets or sets base Assets URL
  66575. */
  66576. static BaseAssetsUrl: string;
  66577. private _emitterCreationOptions;
  66578. private _emitterNode;
  66579. /**
  66580. * Gets the particle system list
  66581. */
  66582. systems: IParticleSystem[];
  66583. /**
  66584. * Gets the emitter node used with this set
  66585. */
  66586. get emitterNode(): Nullable<TransformNode>;
  66587. /**
  66588. * Creates a new emitter mesh as a sphere
  66589. * @param options defines the options used to create the sphere
  66590. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66591. * @param scene defines the hosting scene
  66592. */
  66593. setEmitterAsSphere(options: {
  66594. diameter: number;
  66595. segments: number;
  66596. color: Color3;
  66597. }, renderingGroupId: number, scene: Scene): void;
  66598. /**
  66599. * Starts all particle systems of the set
  66600. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66601. */
  66602. start(emitter?: AbstractMesh): void;
  66603. /**
  66604. * Release all associated resources
  66605. */
  66606. dispose(): void;
  66607. /**
  66608. * Serialize the set into a JSON compatible object
  66609. * @returns a JSON compatible representation of the set
  66610. */
  66611. serialize(): any;
  66612. /**
  66613. * Parse a new ParticleSystemSet from a serialized source
  66614. * @param data defines a JSON compatible representation of the set
  66615. * @param scene defines the hosting scene
  66616. * @param gpu defines if we want GPU particles or CPU particles
  66617. * @returns a new ParticleSystemSet
  66618. */
  66619. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66620. }
  66621. }
  66622. declare module "babylonjs/Particles/particleHelper" {
  66623. import { Nullable } from "babylonjs/types";
  66624. import { Scene } from "babylonjs/scene";
  66625. import { Vector3 } from "babylonjs/Maths/math.vector";
  66626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66627. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66628. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66629. /**
  66630. * This class is made for on one-liner static method to help creating particle system set.
  66631. */
  66632. export class ParticleHelper {
  66633. /**
  66634. * Gets or sets base Assets URL
  66635. */
  66636. static BaseAssetsUrl: string;
  66637. /**
  66638. * Create a default particle system that you can tweak
  66639. * @param emitter defines the emitter to use
  66640. * @param capacity defines the system capacity (default is 500 particles)
  66641. * @param scene defines the hosting scene
  66642. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66643. * @returns the new Particle system
  66644. */
  66645. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66646. /**
  66647. * This is the main static method (one-liner) of this helper to create different particle systems
  66648. * @param type This string represents the type to the particle system to create
  66649. * @param scene The scene where the particle system should live
  66650. * @param gpu If the system will use gpu
  66651. * @returns the ParticleSystemSet created
  66652. */
  66653. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66654. /**
  66655. * Static function used to export a particle system to a ParticleSystemSet variable.
  66656. * Please note that the emitter shape is not exported
  66657. * @param systems defines the particle systems to export
  66658. * @returns the created particle system set
  66659. */
  66660. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66661. }
  66662. }
  66663. declare module "babylonjs/Particles/particleSystemComponent" {
  66664. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66665. import { Effect } from "babylonjs/Materials/effect";
  66666. import "babylonjs/Shaders/particles.vertex";
  66667. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66668. module "babylonjs/Engines/engine" {
  66669. interface Engine {
  66670. /**
  66671. * Create an effect to use with particle systems.
  66672. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66673. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66674. * @param uniformsNames defines a list of attribute names
  66675. * @param samplers defines an array of string used to represent textures
  66676. * @param defines defines the string containing the defines to use to compile the shaders
  66677. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66678. * @param onCompiled defines a function to call when the effect creation is successful
  66679. * @param onError defines a function to call when the effect creation has failed
  66680. * @returns the new Effect
  66681. */
  66682. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66683. }
  66684. }
  66685. module "babylonjs/Meshes/mesh" {
  66686. interface Mesh {
  66687. /**
  66688. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66689. * @returns an array of IParticleSystem
  66690. */
  66691. getEmittedParticleSystems(): IParticleSystem[];
  66692. /**
  66693. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66694. * @returns an array of IParticleSystem
  66695. */
  66696. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66697. }
  66698. }
  66699. /**
  66700. * @hidden
  66701. */
  66702. export var _IDoNeedToBeInTheBuild: number;
  66703. }
  66704. declare module "babylonjs/Particles/pointsCloudSystem" {
  66705. import { Color4 } from "babylonjs/Maths/math";
  66706. import { Mesh } from "babylonjs/Meshes/mesh";
  66707. import { Scene, IDisposable } from "babylonjs/scene";
  66708. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66709. /** Defines the 4 color options */
  66710. export enum PointColor {
  66711. /** color value */
  66712. Color = 2,
  66713. /** uv value */
  66714. UV = 1,
  66715. /** random value */
  66716. Random = 0,
  66717. /** stated value */
  66718. Stated = 3
  66719. }
  66720. /**
  66721. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66722. * 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.
  66723. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66724. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66725. *
  66726. * Full documentation here : TO BE ENTERED
  66727. */
  66728. export class PointsCloudSystem implements IDisposable {
  66729. /**
  66730. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66731. * Example : var p = SPS.particles[i];
  66732. */
  66733. particles: CloudPoint[];
  66734. /**
  66735. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66736. */
  66737. nbParticles: number;
  66738. /**
  66739. * This a counter for your own usage. It's not set by any SPS functions.
  66740. */
  66741. counter: number;
  66742. /**
  66743. * The PCS name. This name is also given to the underlying mesh.
  66744. */
  66745. name: string;
  66746. /**
  66747. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66748. */
  66749. mesh: Mesh;
  66750. /**
  66751. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66752. * Please read :
  66753. */
  66754. vars: any;
  66755. /**
  66756. * @hidden
  66757. */
  66758. _size: number;
  66759. private _scene;
  66760. private _promises;
  66761. private _positions;
  66762. private _indices;
  66763. private _normals;
  66764. private _colors;
  66765. private _uvs;
  66766. private _indices32;
  66767. private _positions32;
  66768. private _colors32;
  66769. private _uvs32;
  66770. private _updatable;
  66771. private _isVisibilityBoxLocked;
  66772. private _alwaysVisible;
  66773. private _groups;
  66774. private _groupCounter;
  66775. private _computeParticleColor;
  66776. private _computeParticleTexture;
  66777. private _computeParticleRotation;
  66778. private _computeBoundingBox;
  66779. private _isReady;
  66780. /**
  66781. * Creates a PCS (Points Cloud System) object
  66782. * @param name (String) is the PCS name, this will be the underlying mesh name
  66783. * @param pointSize (number) is the size for each point
  66784. * @param scene (Scene) is the scene in which the PCS is added
  66785. * @param options defines the options of the PCS e.g.
  66786. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66787. */
  66788. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66789. updatable?: boolean;
  66790. });
  66791. /**
  66792. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66793. * If no points were added to the PCS, the returned mesh is just a single point.
  66794. * @returns a promise for the created mesh
  66795. */
  66796. buildMeshAsync(): Promise<Mesh>;
  66797. /**
  66798. * @hidden
  66799. */
  66800. private _buildMesh;
  66801. private _addParticle;
  66802. private _randomUnitVector;
  66803. private _getColorIndicesForCoord;
  66804. private _setPointsColorOrUV;
  66805. private _colorFromTexture;
  66806. private _calculateDensity;
  66807. /**
  66808. * Adds points to the PCS in random positions within a unit sphere
  66809. * @param nb (positive integer) the number of particles to be created from this model
  66810. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66811. * @returns the number of groups in the system
  66812. */
  66813. addPoints(nb: number, pointFunction?: any): number;
  66814. /**
  66815. * Adds points to the PCS from the surface of the model shape
  66816. * @param mesh is any Mesh object that will be used as a surface model for the points
  66817. * @param nb (positive integer) the number of particles to be created from this model
  66818. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66819. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66820. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66821. * @returns the number of groups in the system
  66822. */
  66823. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66824. /**
  66825. * Adds points to the PCS inside the model shape
  66826. * @param mesh is any Mesh object that will be used as a surface model for the points
  66827. * @param nb (positive integer) the number of particles to be created from this model
  66828. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66829. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66830. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66831. * @returns the number of groups in the system
  66832. */
  66833. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66834. /**
  66835. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66836. * This method calls `updateParticle()` for each particle of the SPS.
  66837. * For an animated SPS, it is usually called within the render loop.
  66838. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66839. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66840. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66841. * @returns the PCS.
  66842. */
  66843. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66844. /**
  66845. * Disposes the PCS.
  66846. */
  66847. dispose(): void;
  66848. /**
  66849. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66850. * doc :
  66851. * @returns the PCS.
  66852. */
  66853. refreshVisibleSize(): PointsCloudSystem;
  66854. /**
  66855. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66856. * @param size the size (float) of the visibility box
  66857. * note : this doesn't lock the PCS mesh bounding box.
  66858. * doc :
  66859. */
  66860. setVisibilityBox(size: number): void;
  66861. /**
  66862. * Gets whether the PCS is always visible or not
  66863. * doc :
  66864. */
  66865. get isAlwaysVisible(): boolean;
  66866. /**
  66867. * Sets the PCS as always visible or not
  66868. * doc :
  66869. */
  66870. set isAlwaysVisible(val: boolean);
  66871. /**
  66872. * Tells to `setParticles()` to compute the particle rotations or not
  66873. * Default value : false. The PCS is faster when it's set to false
  66874. * Note : particle rotations are only applied to parent particles
  66875. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66876. */
  66877. set computeParticleRotation(val: boolean);
  66878. /**
  66879. * Tells to `setParticles()` to compute the particle colors or not.
  66880. * Default value : true. The PCS is faster when it's set to false.
  66881. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66882. */
  66883. set computeParticleColor(val: boolean);
  66884. set computeParticleTexture(val: boolean);
  66885. /**
  66886. * Gets if `setParticles()` computes the particle colors or not.
  66887. * Default value : false. The PCS is faster when it's set to false.
  66888. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66889. */
  66890. get computeParticleColor(): boolean;
  66891. /**
  66892. * Gets if `setParticles()` computes the particle textures or not.
  66893. * Default value : false. The PCS is faster when it's set to false.
  66894. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66895. */
  66896. get computeParticleTexture(): boolean;
  66897. /**
  66898. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66899. */
  66900. set computeBoundingBox(val: boolean);
  66901. /**
  66902. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66903. */
  66904. get computeBoundingBox(): boolean;
  66905. /**
  66906. * This function does nothing. It may be overwritten to set all the particle first values.
  66907. * The PCS doesn't call this function, you may have to call it by your own.
  66908. * doc :
  66909. */
  66910. initParticles(): void;
  66911. /**
  66912. * This function does nothing. It may be overwritten to recycle a particle
  66913. * The PCS doesn't call this function, you can to call it
  66914. * doc :
  66915. * @param particle The particle to recycle
  66916. * @returns the recycled particle
  66917. */
  66918. recycleParticle(particle: CloudPoint): CloudPoint;
  66919. /**
  66920. * Updates a particle : this function should be overwritten by the user.
  66921. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66922. * doc :
  66923. * @example : just set a particle position or velocity and recycle conditions
  66924. * @param particle The particle to update
  66925. * @returns the updated particle
  66926. */
  66927. updateParticle(particle: CloudPoint): CloudPoint;
  66928. /**
  66929. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66930. * This does nothing and may be overwritten by the user.
  66931. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66932. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66933. * @param update the boolean update value actually passed to setParticles()
  66934. */
  66935. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66936. /**
  66937. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66938. * This will be passed three parameters.
  66939. * This does nothing and may be overwritten by the user.
  66940. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66941. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66942. * @param update the boolean update value actually passed to setParticles()
  66943. */
  66944. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66945. }
  66946. }
  66947. declare module "babylonjs/Particles/cloudPoint" {
  66948. import { Nullable } from "babylonjs/types";
  66949. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66950. import { Mesh } from "babylonjs/Meshes/mesh";
  66951. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66952. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66953. /**
  66954. * Represents one particle of a points cloud system.
  66955. */
  66956. export class CloudPoint {
  66957. /**
  66958. * particle global index
  66959. */
  66960. idx: number;
  66961. /**
  66962. * The color of the particle
  66963. */
  66964. color: Nullable<Color4>;
  66965. /**
  66966. * The world space position of the particle.
  66967. */
  66968. position: Vector3;
  66969. /**
  66970. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66971. */
  66972. rotation: Vector3;
  66973. /**
  66974. * The world space rotation quaternion of the particle.
  66975. */
  66976. rotationQuaternion: Nullable<Quaternion>;
  66977. /**
  66978. * The uv of the particle.
  66979. */
  66980. uv: Nullable<Vector2>;
  66981. /**
  66982. * The current speed of the particle.
  66983. */
  66984. velocity: Vector3;
  66985. /**
  66986. * The pivot point in the particle local space.
  66987. */
  66988. pivot: Vector3;
  66989. /**
  66990. * Must the particle be translated from its pivot point in its local space ?
  66991. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66992. * Default : false
  66993. */
  66994. translateFromPivot: boolean;
  66995. /**
  66996. * Index of this particle in the global "positions" array (Internal use)
  66997. * @hidden
  66998. */
  66999. _pos: number;
  67000. /**
  67001. * @hidden Index of this particle in the global "indices" array (Internal use)
  67002. */
  67003. _ind: number;
  67004. /**
  67005. * Group this particle belongs to
  67006. */
  67007. _group: PointsGroup;
  67008. /**
  67009. * Group id of this particle
  67010. */
  67011. groupId: number;
  67012. /**
  67013. * Index of the particle in its group id (Internal use)
  67014. */
  67015. idxInGroup: number;
  67016. /**
  67017. * @hidden Particle BoundingInfo object (Internal use)
  67018. */
  67019. _boundingInfo: BoundingInfo;
  67020. /**
  67021. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67022. */
  67023. _pcs: PointsCloudSystem;
  67024. /**
  67025. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67026. */
  67027. _stillInvisible: boolean;
  67028. /**
  67029. * @hidden Last computed particle rotation matrix
  67030. */
  67031. _rotationMatrix: number[];
  67032. /**
  67033. * Parent particle Id, if any.
  67034. * Default null.
  67035. */
  67036. parentId: Nullable<number>;
  67037. /**
  67038. * @hidden Internal global position in the PCS.
  67039. */
  67040. _globalPosition: Vector3;
  67041. /**
  67042. * Creates a Point Cloud object.
  67043. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67044. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67045. * @param group (PointsGroup) is the group the particle belongs to
  67046. * @param groupId (integer) is the group identifier in the PCS.
  67047. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67048. * @param pcs defines the PCS it is associated to
  67049. */
  67050. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67051. /**
  67052. * get point size
  67053. */
  67054. get size(): Vector3;
  67055. /**
  67056. * Set point size
  67057. */
  67058. set size(scale: Vector3);
  67059. /**
  67060. * Legacy support, changed quaternion to rotationQuaternion
  67061. */
  67062. get quaternion(): Nullable<Quaternion>;
  67063. /**
  67064. * Legacy support, changed quaternion to rotationQuaternion
  67065. */
  67066. set quaternion(q: Nullable<Quaternion>);
  67067. /**
  67068. * Returns a boolean. True if the particle intersects a mesh, else false
  67069. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67070. * @param target is the object (point or mesh) what the intersection is computed against
  67071. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67072. * @returns true if it intersects
  67073. */
  67074. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67075. /**
  67076. * get the rotation matrix of the particle
  67077. * @hidden
  67078. */
  67079. getRotationMatrix(m: Matrix): void;
  67080. }
  67081. /**
  67082. * Represents a group of points in a points cloud system
  67083. * * PCS internal tool, don't use it manually.
  67084. */
  67085. export class PointsGroup {
  67086. /**
  67087. * The group id
  67088. * @hidden
  67089. */
  67090. groupID: number;
  67091. /**
  67092. * image data for group (internal use)
  67093. * @hidden
  67094. */
  67095. _groupImageData: Nullable<ArrayBufferView>;
  67096. /**
  67097. * Image Width (internal use)
  67098. * @hidden
  67099. */
  67100. _groupImgWidth: number;
  67101. /**
  67102. * Image Height (internal use)
  67103. * @hidden
  67104. */
  67105. _groupImgHeight: number;
  67106. /**
  67107. * Custom position function (internal use)
  67108. * @hidden
  67109. */
  67110. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67111. /**
  67112. * density per facet for surface points
  67113. * @hidden
  67114. */
  67115. _groupDensity: number[];
  67116. /**
  67117. * Only when points are colored by texture carries pointer to texture list array
  67118. * @hidden
  67119. */
  67120. _textureNb: number;
  67121. /**
  67122. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67123. * PCS internal tool, don't use it manually.
  67124. * @hidden
  67125. */
  67126. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67127. }
  67128. }
  67129. declare module "babylonjs/Particles/index" {
  67130. export * from "babylonjs/Particles/baseParticleSystem";
  67131. export * from "babylonjs/Particles/EmitterTypes/index";
  67132. export * from "babylonjs/Particles/gpuParticleSystem";
  67133. export * from "babylonjs/Particles/IParticleSystem";
  67134. export * from "babylonjs/Particles/particle";
  67135. export * from "babylonjs/Particles/particleHelper";
  67136. export * from "babylonjs/Particles/particleSystem";
  67137. export * from "babylonjs/Particles/particleSystemComponent";
  67138. export * from "babylonjs/Particles/particleSystemSet";
  67139. export * from "babylonjs/Particles/solidParticle";
  67140. export * from "babylonjs/Particles/solidParticleSystem";
  67141. export * from "babylonjs/Particles/cloudPoint";
  67142. export * from "babylonjs/Particles/pointsCloudSystem";
  67143. export * from "babylonjs/Particles/subEmitter";
  67144. }
  67145. declare module "babylonjs/Physics/physicsEngineComponent" {
  67146. import { Nullable } from "babylonjs/types";
  67147. import { Observable, Observer } from "babylonjs/Misc/observable";
  67148. import { Vector3 } from "babylonjs/Maths/math.vector";
  67149. import { Mesh } from "babylonjs/Meshes/mesh";
  67150. import { ISceneComponent } from "babylonjs/sceneComponent";
  67151. import { Scene } from "babylonjs/scene";
  67152. import { Node } from "babylonjs/node";
  67153. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67154. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67155. module "babylonjs/scene" {
  67156. interface Scene {
  67157. /** @hidden (Backing field) */
  67158. _physicsEngine: Nullable<IPhysicsEngine>;
  67159. /** @hidden */
  67160. _physicsTimeAccumulator: number;
  67161. /**
  67162. * Gets the current physics engine
  67163. * @returns a IPhysicsEngine or null if none attached
  67164. */
  67165. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67166. /**
  67167. * Enables physics to the current scene
  67168. * @param gravity defines the scene's gravity for the physics engine
  67169. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67170. * @return a boolean indicating if the physics engine was initialized
  67171. */
  67172. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67173. /**
  67174. * Disables and disposes the physics engine associated with the scene
  67175. */
  67176. disablePhysicsEngine(): void;
  67177. /**
  67178. * Gets a boolean indicating if there is an active physics engine
  67179. * @returns a boolean indicating if there is an active physics engine
  67180. */
  67181. isPhysicsEnabled(): boolean;
  67182. /**
  67183. * Deletes a physics compound impostor
  67184. * @param compound defines the compound to delete
  67185. */
  67186. deleteCompoundImpostor(compound: any): void;
  67187. /**
  67188. * An event triggered when physic simulation is about to be run
  67189. */
  67190. onBeforePhysicsObservable: Observable<Scene>;
  67191. /**
  67192. * An event triggered when physic simulation has been done
  67193. */
  67194. onAfterPhysicsObservable: Observable<Scene>;
  67195. }
  67196. }
  67197. module "babylonjs/Meshes/abstractMesh" {
  67198. interface AbstractMesh {
  67199. /** @hidden */
  67200. _physicsImpostor: Nullable<PhysicsImpostor>;
  67201. /**
  67202. * Gets or sets impostor used for physic simulation
  67203. * @see http://doc.babylonjs.com/features/physics_engine
  67204. */
  67205. physicsImpostor: Nullable<PhysicsImpostor>;
  67206. /**
  67207. * Gets the current physics impostor
  67208. * @see http://doc.babylonjs.com/features/physics_engine
  67209. * @returns a physics impostor or null
  67210. */
  67211. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67212. /** Apply a physic impulse to the mesh
  67213. * @param force defines the force to apply
  67214. * @param contactPoint defines where to apply the force
  67215. * @returns the current mesh
  67216. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67217. */
  67218. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67219. /**
  67220. * Creates a physic joint between two meshes
  67221. * @param otherMesh defines the other mesh to use
  67222. * @param pivot1 defines the pivot to use on this mesh
  67223. * @param pivot2 defines the pivot to use on the other mesh
  67224. * @param options defines additional options (can be plugin dependent)
  67225. * @returns the current mesh
  67226. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67227. */
  67228. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67229. /** @hidden */
  67230. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67231. }
  67232. }
  67233. /**
  67234. * Defines the physics engine scene component responsible to manage a physics engine
  67235. */
  67236. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67237. /**
  67238. * The component name helpful to identify the component in the list of scene components.
  67239. */
  67240. readonly name: string;
  67241. /**
  67242. * The scene the component belongs to.
  67243. */
  67244. scene: Scene;
  67245. /**
  67246. * Creates a new instance of the component for the given scene
  67247. * @param scene Defines the scene to register the component in
  67248. */
  67249. constructor(scene: Scene);
  67250. /**
  67251. * Registers the component in a given scene
  67252. */
  67253. register(): void;
  67254. /**
  67255. * Rebuilds the elements related to this component in case of
  67256. * context lost for instance.
  67257. */
  67258. rebuild(): void;
  67259. /**
  67260. * Disposes the component and the associated ressources
  67261. */
  67262. dispose(): void;
  67263. }
  67264. }
  67265. declare module "babylonjs/Physics/physicsHelper" {
  67266. import { Nullable } from "babylonjs/types";
  67267. import { Vector3 } from "babylonjs/Maths/math.vector";
  67268. import { Mesh } from "babylonjs/Meshes/mesh";
  67269. import { Scene } from "babylonjs/scene";
  67270. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67271. /**
  67272. * A helper for physics simulations
  67273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67274. */
  67275. export class PhysicsHelper {
  67276. private _scene;
  67277. private _physicsEngine;
  67278. /**
  67279. * Initializes the Physics helper
  67280. * @param scene Babylon.js scene
  67281. */
  67282. constructor(scene: Scene);
  67283. /**
  67284. * Applies a radial explosion impulse
  67285. * @param origin the origin of the explosion
  67286. * @param radiusOrEventOptions the radius or the options of radial explosion
  67287. * @param strength the explosion strength
  67288. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67289. * @returns A physics radial explosion event, or null
  67290. */
  67291. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67292. /**
  67293. * Applies a radial explosion force
  67294. * @param origin the origin of the explosion
  67295. * @param radiusOrEventOptions the radius or the options of radial explosion
  67296. * @param strength the explosion strength
  67297. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67298. * @returns A physics radial explosion event, or null
  67299. */
  67300. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67301. /**
  67302. * Creates a gravitational field
  67303. * @param origin the origin of the explosion
  67304. * @param radiusOrEventOptions the radius or the options of radial explosion
  67305. * @param strength the explosion strength
  67306. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67307. * @returns A physics gravitational field event, or null
  67308. */
  67309. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67310. /**
  67311. * Creates a physics updraft event
  67312. * @param origin the origin of the updraft
  67313. * @param radiusOrEventOptions the radius or the options of the updraft
  67314. * @param strength the strength of the updraft
  67315. * @param height the height of the updraft
  67316. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67317. * @returns A physics updraft event, or null
  67318. */
  67319. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67320. /**
  67321. * Creates a physics vortex event
  67322. * @param origin the of the vortex
  67323. * @param radiusOrEventOptions the radius or the options of the vortex
  67324. * @param strength the strength of the vortex
  67325. * @param height the height of the vortex
  67326. * @returns a Physics vortex event, or null
  67327. * A physics vortex event or null
  67328. */
  67329. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67330. }
  67331. /**
  67332. * Represents a physics radial explosion event
  67333. */
  67334. class PhysicsRadialExplosionEvent {
  67335. private _scene;
  67336. private _options;
  67337. private _sphere;
  67338. private _dataFetched;
  67339. /**
  67340. * Initializes a radial explosioin event
  67341. * @param _scene BabylonJS scene
  67342. * @param _options The options for the vortex event
  67343. */
  67344. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67345. /**
  67346. * Returns the data related to the radial explosion event (sphere).
  67347. * @returns The radial explosion event data
  67348. */
  67349. getData(): PhysicsRadialExplosionEventData;
  67350. /**
  67351. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67352. * @param impostor A physics imposter
  67353. * @param origin the origin of the explosion
  67354. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67355. */
  67356. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67357. /**
  67358. * Triggers affecterd impostors callbacks
  67359. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67360. */
  67361. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67362. /**
  67363. * Disposes the sphere.
  67364. * @param force Specifies if the sphere should be disposed by force
  67365. */
  67366. dispose(force?: boolean): void;
  67367. /*** Helpers ***/
  67368. private _prepareSphere;
  67369. private _intersectsWithSphere;
  67370. }
  67371. /**
  67372. * Represents a gravitational field event
  67373. */
  67374. class PhysicsGravitationalFieldEvent {
  67375. private _physicsHelper;
  67376. private _scene;
  67377. private _origin;
  67378. private _options;
  67379. private _tickCallback;
  67380. private _sphere;
  67381. private _dataFetched;
  67382. /**
  67383. * Initializes the physics gravitational field event
  67384. * @param _physicsHelper A physics helper
  67385. * @param _scene BabylonJS scene
  67386. * @param _origin The origin position of the gravitational field event
  67387. * @param _options The options for the vortex event
  67388. */
  67389. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67390. /**
  67391. * Returns the data related to the gravitational field event (sphere).
  67392. * @returns A gravitational field event
  67393. */
  67394. getData(): PhysicsGravitationalFieldEventData;
  67395. /**
  67396. * Enables the gravitational field.
  67397. */
  67398. enable(): void;
  67399. /**
  67400. * Disables the gravitational field.
  67401. */
  67402. disable(): void;
  67403. /**
  67404. * Disposes the sphere.
  67405. * @param force The force to dispose from the gravitational field event
  67406. */
  67407. dispose(force?: boolean): void;
  67408. private _tick;
  67409. }
  67410. /**
  67411. * Represents a physics updraft event
  67412. */
  67413. class PhysicsUpdraftEvent {
  67414. private _scene;
  67415. private _origin;
  67416. private _options;
  67417. private _physicsEngine;
  67418. private _originTop;
  67419. private _originDirection;
  67420. private _tickCallback;
  67421. private _cylinder;
  67422. private _cylinderPosition;
  67423. private _dataFetched;
  67424. /**
  67425. * Initializes the physics updraft event
  67426. * @param _scene BabylonJS scene
  67427. * @param _origin The origin position of the updraft
  67428. * @param _options The options for the updraft event
  67429. */
  67430. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67431. /**
  67432. * Returns the data related to the updraft event (cylinder).
  67433. * @returns A physics updraft event
  67434. */
  67435. getData(): PhysicsUpdraftEventData;
  67436. /**
  67437. * Enables the updraft.
  67438. */
  67439. enable(): void;
  67440. /**
  67441. * Disables the updraft.
  67442. */
  67443. disable(): void;
  67444. /**
  67445. * Disposes the cylinder.
  67446. * @param force Specifies if the updraft should be disposed by force
  67447. */
  67448. dispose(force?: boolean): void;
  67449. private getImpostorHitData;
  67450. private _tick;
  67451. /*** Helpers ***/
  67452. private _prepareCylinder;
  67453. private _intersectsWithCylinder;
  67454. }
  67455. /**
  67456. * Represents a physics vortex event
  67457. */
  67458. class PhysicsVortexEvent {
  67459. private _scene;
  67460. private _origin;
  67461. private _options;
  67462. private _physicsEngine;
  67463. private _originTop;
  67464. private _tickCallback;
  67465. private _cylinder;
  67466. private _cylinderPosition;
  67467. private _dataFetched;
  67468. /**
  67469. * Initializes the physics vortex event
  67470. * @param _scene The BabylonJS scene
  67471. * @param _origin The origin position of the vortex
  67472. * @param _options The options for the vortex event
  67473. */
  67474. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67475. /**
  67476. * Returns the data related to the vortex event (cylinder).
  67477. * @returns The physics vortex event data
  67478. */
  67479. getData(): PhysicsVortexEventData;
  67480. /**
  67481. * Enables the vortex.
  67482. */
  67483. enable(): void;
  67484. /**
  67485. * Disables the cortex.
  67486. */
  67487. disable(): void;
  67488. /**
  67489. * Disposes the sphere.
  67490. * @param force
  67491. */
  67492. dispose(force?: boolean): void;
  67493. private getImpostorHitData;
  67494. private _tick;
  67495. /*** Helpers ***/
  67496. private _prepareCylinder;
  67497. private _intersectsWithCylinder;
  67498. }
  67499. /**
  67500. * Options fot the radial explosion event
  67501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67502. */
  67503. export class PhysicsRadialExplosionEventOptions {
  67504. /**
  67505. * The radius of the sphere for the radial explosion.
  67506. */
  67507. radius: number;
  67508. /**
  67509. * The strenth of the explosion.
  67510. */
  67511. strength: number;
  67512. /**
  67513. * The strenght of the force in correspondence to the distance of the affected object
  67514. */
  67515. falloff: PhysicsRadialImpulseFalloff;
  67516. /**
  67517. * Sphere options for the radial explosion.
  67518. */
  67519. sphere: {
  67520. segments: number;
  67521. diameter: number;
  67522. };
  67523. /**
  67524. * Sphere options for the radial explosion.
  67525. */
  67526. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67527. }
  67528. /**
  67529. * Options fot the updraft event
  67530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67531. */
  67532. export class PhysicsUpdraftEventOptions {
  67533. /**
  67534. * The radius of the cylinder for the vortex
  67535. */
  67536. radius: number;
  67537. /**
  67538. * The strenth of the updraft.
  67539. */
  67540. strength: number;
  67541. /**
  67542. * The height of the cylinder for the updraft.
  67543. */
  67544. height: number;
  67545. /**
  67546. * The mode for the the updraft.
  67547. */
  67548. updraftMode: PhysicsUpdraftMode;
  67549. }
  67550. /**
  67551. * Options fot the vortex event
  67552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67553. */
  67554. export class PhysicsVortexEventOptions {
  67555. /**
  67556. * The radius of the cylinder for the vortex
  67557. */
  67558. radius: number;
  67559. /**
  67560. * The strenth of the vortex.
  67561. */
  67562. strength: number;
  67563. /**
  67564. * The height of the cylinder for the vortex.
  67565. */
  67566. height: number;
  67567. /**
  67568. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67569. */
  67570. centripetalForceThreshold: number;
  67571. /**
  67572. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67573. */
  67574. centripetalForceMultiplier: number;
  67575. /**
  67576. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67577. */
  67578. centrifugalForceMultiplier: number;
  67579. /**
  67580. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67581. */
  67582. updraftForceMultiplier: number;
  67583. }
  67584. /**
  67585. * The strenght of the force in correspondence to the distance of the affected object
  67586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67587. */
  67588. export enum PhysicsRadialImpulseFalloff {
  67589. /** Defines that impulse is constant in strength across it's whole radius */
  67590. Constant = 0,
  67591. /** Defines that impulse gets weaker if it's further from the origin */
  67592. Linear = 1
  67593. }
  67594. /**
  67595. * The strength of the force in correspondence to the distance of the affected object
  67596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67597. */
  67598. export enum PhysicsUpdraftMode {
  67599. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67600. Center = 0,
  67601. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67602. Perpendicular = 1
  67603. }
  67604. /**
  67605. * Interface for a physics hit data
  67606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67607. */
  67608. export interface PhysicsHitData {
  67609. /**
  67610. * The force applied at the contact point
  67611. */
  67612. force: Vector3;
  67613. /**
  67614. * The contact point
  67615. */
  67616. contactPoint: Vector3;
  67617. /**
  67618. * The distance from the origin to the contact point
  67619. */
  67620. distanceFromOrigin: number;
  67621. }
  67622. /**
  67623. * Interface for radial explosion event data
  67624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67625. */
  67626. export interface PhysicsRadialExplosionEventData {
  67627. /**
  67628. * A sphere used for the radial explosion event
  67629. */
  67630. sphere: Mesh;
  67631. }
  67632. /**
  67633. * Interface for gravitational field event data
  67634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67635. */
  67636. export interface PhysicsGravitationalFieldEventData {
  67637. /**
  67638. * A sphere mesh used for the gravitational field event
  67639. */
  67640. sphere: Mesh;
  67641. }
  67642. /**
  67643. * Interface for updraft event data
  67644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67645. */
  67646. export interface PhysicsUpdraftEventData {
  67647. /**
  67648. * A cylinder used for the updraft event
  67649. */
  67650. cylinder: Mesh;
  67651. }
  67652. /**
  67653. * Interface for vortex event data
  67654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67655. */
  67656. export interface PhysicsVortexEventData {
  67657. /**
  67658. * A cylinder used for the vortex event
  67659. */
  67660. cylinder: Mesh;
  67661. }
  67662. /**
  67663. * Interface for an affected physics impostor
  67664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67665. */
  67666. export interface PhysicsAffectedImpostorWithData {
  67667. /**
  67668. * The impostor affected by the effect
  67669. */
  67670. impostor: PhysicsImpostor;
  67671. /**
  67672. * The data about the hit/horce from the explosion
  67673. */
  67674. hitData: PhysicsHitData;
  67675. }
  67676. }
  67677. declare module "babylonjs/Physics/Plugins/index" {
  67678. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67679. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67680. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67681. }
  67682. declare module "babylonjs/Physics/index" {
  67683. export * from "babylonjs/Physics/IPhysicsEngine";
  67684. export * from "babylonjs/Physics/physicsEngine";
  67685. export * from "babylonjs/Physics/physicsEngineComponent";
  67686. export * from "babylonjs/Physics/physicsHelper";
  67687. export * from "babylonjs/Physics/physicsImpostor";
  67688. export * from "babylonjs/Physics/physicsJoint";
  67689. export * from "babylonjs/Physics/Plugins/index";
  67690. }
  67691. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67692. /** @hidden */
  67693. export var blackAndWhitePixelShader: {
  67694. name: string;
  67695. shader: string;
  67696. };
  67697. }
  67698. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67699. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67700. import { Camera } from "babylonjs/Cameras/camera";
  67701. import { Engine } from "babylonjs/Engines/engine";
  67702. import "babylonjs/Shaders/blackAndWhite.fragment";
  67703. /**
  67704. * Post process used to render in black and white
  67705. */
  67706. export class BlackAndWhitePostProcess extends PostProcess {
  67707. /**
  67708. * Linear about to convert he result to black and white (default: 1)
  67709. */
  67710. degree: number;
  67711. /**
  67712. * Creates a black and white post process
  67713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67714. * @param name The name of the effect.
  67715. * @param options The required width/height ratio to downsize to before computing the render pass.
  67716. * @param camera The camera to apply the render pass to.
  67717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67718. * @param engine The engine which the post process will be applied. (default: current engine)
  67719. * @param reusable If the post process can be reused on the same frame. (default: false)
  67720. */
  67721. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67722. }
  67723. }
  67724. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67725. import { Nullable } from "babylonjs/types";
  67726. import { Camera } from "babylonjs/Cameras/camera";
  67727. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67728. import { Engine } from "babylonjs/Engines/engine";
  67729. /**
  67730. * This represents a set of one or more post processes in Babylon.
  67731. * A post process can be used to apply a shader to a texture after it is rendered.
  67732. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67733. */
  67734. export class PostProcessRenderEffect {
  67735. private _postProcesses;
  67736. private _getPostProcesses;
  67737. private _singleInstance;
  67738. private _cameras;
  67739. private _indicesForCamera;
  67740. /**
  67741. * Name of the effect
  67742. * @hidden
  67743. */
  67744. _name: string;
  67745. /**
  67746. * Instantiates a post process render effect.
  67747. * A post process can be used to apply a shader to a texture after it is rendered.
  67748. * @param engine The engine the effect is tied to
  67749. * @param name The name of the effect
  67750. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67751. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67752. */
  67753. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67754. /**
  67755. * Checks if all the post processes in the effect are supported.
  67756. */
  67757. get isSupported(): boolean;
  67758. /**
  67759. * Updates the current state of the effect
  67760. * @hidden
  67761. */
  67762. _update(): void;
  67763. /**
  67764. * Attaches the effect on cameras
  67765. * @param cameras The camera to attach to.
  67766. * @hidden
  67767. */
  67768. _attachCameras(cameras: Camera): void;
  67769. /**
  67770. * Attaches the effect on cameras
  67771. * @param cameras The camera to attach to.
  67772. * @hidden
  67773. */
  67774. _attachCameras(cameras: Camera[]): void;
  67775. /**
  67776. * Detaches the effect on cameras
  67777. * @param cameras The camera to detatch from.
  67778. * @hidden
  67779. */
  67780. _detachCameras(cameras: Camera): void;
  67781. /**
  67782. * Detatches the effect on cameras
  67783. * @param cameras The camera to detatch from.
  67784. * @hidden
  67785. */
  67786. _detachCameras(cameras: Camera[]): void;
  67787. /**
  67788. * Enables the effect on given cameras
  67789. * @param cameras The camera to enable.
  67790. * @hidden
  67791. */
  67792. _enable(cameras: Camera): void;
  67793. /**
  67794. * Enables the effect on given cameras
  67795. * @param cameras The camera to enable.
  67796. * @hidden
  67797. */
  67798. _enable(cameras: Nullable<Camera[]>): void;
  67799. /**
  67800. * Disables the effect on the given cameras
  67801. * @param cameras The camera to disable.
  67802. * @hidden
  67803. */
  67804. _disable(cameras: Camera): void;
  67805. /**
  67806. * Disables the effect on the given cameras
  67807. * @param cameras The camera to disable.
  67808. * @hidden
  67809. */
  67810. _disable(cameras: Nullable<Camera[]>): void;
  67811. /**
  67812. * Gets a list of the post processes contained in the effect.
  67813. * @param camera The camera to get the post processes on.
  67814. * @returns The list of the post processes in the effect.
  67815. */
  67816. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67817. }
  67818. }
  67819. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67821. /** @hidden */
  67822. export var extractHighlightsPixelShader: {
  67823. name: string;
  67824. shader: string;
  67825. };
  67826. }
  67827. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67828. import { Nullable } from "babylonjs/types";
  67829. import { Camera } from "babylonjs/Cameras/camera";
  67830. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67831. import { Engine } from "babylonjs/Engines/engine";
  67832. import "babylonjs/Shaders/extractHighlights.fragment";
  67833. /**
  67834. * 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.
  67835. */
  67836. export class ExtractHighlightsPostProcess extends PostProcess {
  67837. /**
  67838. * The luminance threshold, pixels below this value will be set to black.
  67839. */
  67840. threshold: number;
  67841. /** @hidden */
  67842. _exposure: number;
  67843. /**
  67844. * Post process which has the input texture to be used when performing highlight extraction
  67845. * @hidden
  67846. */
  67847. _inputPostProcess: Nullable<PostProcess>;
  67848. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67849. }
  67850. }
  67851. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67852. /** @hidden */
  67853. export var bloomMergePixelShader: {
  67854. name: string;
  67855. shader: string;
  67856. };
  67857. }
  67858. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67859. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67860. import { Nullable } from "babylonjs/types";
  67861. import { Engine } from "babylonjs/Engines/engine";
  67862. import { Camera } from "babylonjs/Cameras/camera";
  67863. import "babylonjs/Shaders/bloomMerge.fragment";
  67864. /**
  67865. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67866. */
  67867. export class BloomMergePostProcess extends PostProcess {
  67868. /** Weight of the bloom to be added to the original input. */
  67869. weight: number;
  67870. /**
  67871. * Creates a new instance of @see BloomMergePostProcess
  67872. * @param name The name of the effect.
  67873. * @param originalFromInput Post process which's input will be used for the merge.
  67874. * @param blurred Blurred highlights post process which's output will be used.
  67875. * @param weight Weight of the bloom to be added to the original input.
  67876. * @param options The required width/height ratio to downsize to before computing the render pass.
  67877. * @param camera The camera to apply the render pass to.
  67878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67879. * @param engine The engine which the post process will be applied. (default: current engine)
  67880. * @param reusable If the post process can be reused on the same frame. (default: false)
  67881. * @param textureType Type of textures used when performing the post process. (default: 0)
  67882. * @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)
  67883. */
  67884. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67885. /** Weight of the bloom to be added to the original input. */
  67886. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67887. }
  67888. }
  67889. declare module "babylonjs/PostProcesses/bloomEffect" {
  67890. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67891. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67892. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67893. import { Camera } from "babylonjs/Cameras/camera";
  67894. import { Scene } from "babylonjs/scene";
  67895. /**
  67896. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67897. */
  67898. export class BloomEffect extends PostProcessRenderEffect {
  67899. private bloomScale;
  67900. /**
  67901. * @hidden Internal
  67902. */
  67903. _effects: Array<PostProcess>;
  67904. /**
  67905. * @hidden Internal
  67906. */
  67907. _downscale: ExtractHighlightsPostProcess;
  67908. private _blurX;
  67909. private _blurY;
  67910. private _merge;
  67911. /**
  67912. * The luminance threshold to find bright areas of the image to bloom.
  67913. */
  67914. get threshold(): number;
  67915. set threshold(value: number);
  67916. /**
  67917. * The strength of the bloom.
  67918. */
  67919. get weight(): number;
  67920. set weight(value: number);
  67921. /**
  67922. * Specifies the size of the bloom blur kernel, relative to the final output size
  67923. */
  67924. get kernel(): number;
  67925. set kernel(value: number);
  67926. /**
  67927. * Creates a new instance of @see BloomEffect
  67928. * @param scene The scene the effect belongs to.
  67929. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67930. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67931. * @param bloomWeight The the strength of bloom.
  67932. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67933. * @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)
  67934. */
  67935. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67936. /**
  67937. * Disposes each of the internal effects for a given camera.
  67938. * @param camera The camera to dispose the effect on.
  67939. */
  67940. disposeEffects(camera: Camera): void;
  67941. /**
  67942. * @hidden Internal
  67943. */
  67944. _updateEffects(): void;
  67945. /**
  67946. * Internal
  67947. * @returns if all the contained post processes are ready.
  67948. * @hidden
  67949. */
  67950. _isReady(): boolean;
  67951. }
  67952. }
  67953. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67954. /** @hidden */
  67955. export var chromaticAberrationPixelShader: {
  67956. name: string;
  67957. shader: string;
  67958. };
  67959. }
  67960. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67961. import { Vector2 } from "babylonjs/Maths/math.vector";
  67962. import { Nullable } from "babylonjs/types";
  67963. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67964. import { Camera } from "babylonjs/Cameras/camera";
  67965. import { Engine } from "babylonjs/Engines/engine";
  67966. import "babylonjs/Shaders/chromaticAberration.fragment";
  67967. /**
  67968. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67969. */
  67970. export class ChromaticAberrationPostProcess extends PostProcess {
  67971. /**
  67972. * The amount of seperation of rgb channels (default: 30)
  67973. */
  67974. aberrationAmount: number;
  67975. /**
  67976. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67977. */
  67978. radialIntensity: number;
  67979. /**
  67980. * 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))
  67981. */
  67982. direction: Vector2;
  67983. /**
  67984. * 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))
  67985. */
  67986. centerPosition: Vector2;
  67987. /**
  67988. * Creates a new instance ChromaticAberrationPostProcess
  67989. * @param name The name of the effect.
  67990. * @param screenWidth The width of the screen to apply the effect on.
  67991. * @param screenHeight The height of the screen to apply the effect on.
  67992. * @param options The required width/height ratio to downsize to before computing the render pass.
  67993. * @param camera The camera to apply the render pass to.
  67994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67995. * @param engine The engine which the post process will be applied. (default: current engine)
  67996. * @param reusable If the post process can be reused on the same frame. (default: false)
  67997. * @param textureType Type of textures used when performing the post process. (default: 0)
  67998. * @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)
  67999. */
  68000. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68001. }
  68002. }
  68003. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  68004. /** @hidden */
  68005. export var circleOfConfusionPixelShader: {
  68006. name: string;
  68007. shader: string;
  68008. };
  68009. }
  68010. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  68011. import { Nullable } from "babylonjs/types";
  68012. import { Engine } from "babylonjs/Engines/engine";
  68013. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68014. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68015. import { Camera } from "babylonjs/Cameras/camera";
  68016. import "babylonjs/Shaders/circleOfConfusion.fragment";
  68017. /**
  68018. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68019. */
  68020. export class CircleOfConfusionPostProcess extends PostProcess {
  68021. /**
  68022. * 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.
  68023. */
  68024. lensSize: number;
  68025. /**
  68026. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68027. */
  68028. fStop: number;
  68029. /**
  68030. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68031. */
  68032. focusDistance: number;
  68033. /**
  68034. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68035. */
  68036. focalLength: number;
  68037. private _depthTexture;
  68038. /**
  68039. * Creates a new instance CircleOfConfusionPostProcess
  68040. * @param name The name of the effect.
  68041. * @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.
  68042. * @param options The required width/height ratio to downsize to before computing the render pass.
  68043. * @param camera The camera to apply the render pass to.
  68044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68045. * @param engine The engine which the post process will be applied. (default: current engine)
  68046. * @param reusable If the post process can be reused on the same frame. (default: false)
  68047. * @param textureType Type of textures used when performing the post process. (default: 0)
  68048. * @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)
  68049. */
  68050. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68051. /**
  68052. * 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.
  68053. */
  68054. set depthTexture(value: RenderTargetTexture);
  68055. }
  68056. }
  68057. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  68058. /** @hidden */
  68059. export var colorCorrectionPixelShader: {
  68060. name: string;
  68061. shader: string;
  68062. };
  68063. }
  68064. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  68065. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68066. import { Engine } from "babylonjs/Engines/engine";
  68067. import { Camera } from "babylonjs/Cameras/camera";
  68068. import "babylonjs/Shaders/colorCorrection.fragment";
  68069. /**
  68070. *
  68071. * This post-process allows the modification of rendered colors by using
  68072. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68073. *
  68074. * The object needs to be provided an url to a texture containing the color
  68075. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68076. * Use an image editing software to tweak the LUT to match your needs.
  68077. *
  68078. * For an example of a color LUT, see here:
  68079. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68080. * For explanations on color grading, see here:
  68081. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68082. *
  68083. */
  68084. export class ColorCorrectionPostProcess extends PostProcess {
  68085. private _colorTableTexture;
  68086. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68087. }
  68088. }
  68089. declare module "babylonjs/Shaders/convolution.fragment" {
  68090. /** @hidden */
  68091. export var convolutionPixelShader: {
  68092. name: string;
  68093. shader: string;
  68094. };
  68095. }
  68096. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  68097. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68098. import { Nullable } from "babylonjs/types";
  68099. import { Camera } from "babylonjs/Cameras/camera";
  68100. import { Engine } from "babylonjs/Engines/engine";
  68101. import "babylonjs/Shaders/convolution.fragment";
  68102. /**
  68103. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68104. * input texture to perform effects such as edge detection or sharpening
  68105. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68106. */
  68107. export class ConvolutionPostProcess extends PostProcess {
  68108. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68109. kernel: number[];
  68110. /**
  68111. * Creates a new instance ConvolutionPostProcess
  68112. * @param name The name of the effect.
  68113. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68114. * @param options The required width/height ratio to downsize to before computing the render pass.
  68115. * @param camera The camera to apply the render pass to.
  68116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68117. * @param engine The engine which the post process will be applied. (default: current engine)
  68118. * @param reusable If the post process can be reused on the same frame. (default: false)
  68119. * @param textureType Type of textures used when performing the post process. (default: 0)
  68120. */
  68121. constructor(name: string,
  68122. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68123. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68124. /**
  68125. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68126. */
  68127. static EdgeDetect0Kernel: number[];
  68128. /**
  68129. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68130. */
  68131. static EdgeDetect1Kernel: number[];
  68132. /**
  68133. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68134. */
  68135. static EdgeDetect2Kernel: number[];
  68136. /**
  68137. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68138. */
  68139. static SharpenKernel: number[];
  68140. /**
  68141. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68142. */
  68143. static EmbossKernel: number[];
  68144. /**
  68145. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68146. */
  68147. static GaussianKernel: number[];
  68148. }
  68149. }
  68150. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  68151. import { Nullable } from "babylonjs/types";
  68152. import { Vector2 } from "babylonjs/Maths/math.vector";
  68153. import { Camera } from "babylonjs/Cameras/camera";
  68154. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68155. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68156. import { Engine } from "babylonjs/Engines/engine";
  68157. import { Scene } from "babylonjs/scene";
  68158. /**
  68159. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68160. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68161. * based on samples that have a large difference in distance than the center pixel.
  68162. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68163. */
  68164. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68165. direction: Vector2;
  68166. /**
  68167. * Creates a new instance CircleOfConfusionPostProcess
  68168. * @param name The name of the effect.
  68169. * @param scene The scene the effect belongs to.
  68170. * @param direction The direction the blur should be applied.
  68171. * @param kernel The size of the kernel used to blur.
  68172. * @param options The required width/height ratio to downsize to before computing the render pass.
  68173. * @param camera The camera to apply the render pass to.
  68174. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68175. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68177. * @param engine The engine which the post process will be applied. (default: current engine)
  68178. * @param reusable If the post process can be reused on the same frame. (default: false)
  68179. * @param textureType Type of textures used when performing the post process. (default: 0)
  68180. * @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)
  68181. */
  68182. 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);
  68183. }
  68184. }
  68185. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  68186. /** @hidden */
  68187. export var depthOfFieldMergePixelShader: {
  68188. name: string;
  68189. shader: string;
  68190. };
  68191. }
  68192. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  68193. import { Nullable } from "babylonjs/types";
  68194. import { Camera } from "babylonjs/Cameras/camera";
  68195. import { Effect } from "babylonjs/Materials/effect";
  68196. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68197. import { Engine } from "babylonjs/Engines/engine";
  68198. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  68199. /**
  68200. * Options to be set when merging outputs from the default pipeline.
  68201. */
  68202. export class DepthOfFieldMergePostProcessOptions {
  68203. /**
  68204. * The original image to merge on top of
  68205. */
  68206. originalFromInput: PostProcess;
  68207. /**
  68208. * Parameters to perform the merge of the depth of field effect
  68209. */
  68210. depthOfField?: {
  68211. circleOfConfusion: PostProcess;
  68212. blurSteps: Array<PostProcess>;
  68213. };
  68214. /**
  68215. * Parameters to perform the merge of bloom effect
  68216. */
  68217. bloom?: {
  68218. blurred: PostProcess;
  68219. weight: number;
  68220. };
  68221. }
  68222. /**
  68223. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68224. */
  68225. export class DepthOfFieldMergePostProcess extends PostProcess {
  68226. private blurSteps;
  68227. /**
  68228. * Creates a new instance of DepthOfFieldMergePostProcess
  68229. * @param name The name of the effect.
  68230. * @param originalFromInput Post process which's input will be used for the merge.
  68231. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68232. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68233. * @param options The required width/height ratio to downsize to before computing the render pass.
  68234. * @param camera The camera to apply the render pass to.
  68235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68236. * @param engine The engine which the post process will be applied. (default: current engine)
  68237. * @param reusable If the post process can be reused on the same frame. (default: false)
  68238. * @param textureType Type of textures used when performing the post process. (default: 0)
  68239. * @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)
  68240. */
  68241. 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);
  68242. /**
  68243. * Updates the effect with the current post process compile time values and recompiles the shader.
  68244. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68245. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68246. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68247. * @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
  68248. * @param onCompiled Called when the shader has been compiled.
  68249. * @param onError Called if there is an error when compiling a shader.
  68250. */
  68251. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68252. }
  68253. }
  68254. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  68255. import { Nullable } from "babylonjs/types";
  68256. import { Camera } from "babylonjs/Cameras/camera";
  68257. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68258. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68259. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68260. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68261. import { Scene } from "babylonjs/scene";
  68262. /**
  68263. * Specifies the level of max blur that should be applied when using the depth of field effect
  68264. */
  68265. export enum DepthOfFieldEffectBlurLevel {
  68266. /**
  68267. * Subtle blur
  68268. */
  68269. Low = 0,
  68270. /**
  68271. * Medium blur
  68272. */
  68273. Medium = 1,
  68274. /**
  68275. * Large blur
  68276. */
  68277. High = 2
  68278. }
  68279. /**
  68280. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68281. */
  68282. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68283. private _circleOfConfusion;
  68284. /**
  68285. * @hidden Internal, blurs from high to low
  68286. */
  68287. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68288. private _depthOfFieldBlurY;
  68289. private _dofMerge;
  68290. /**
  68291. * @hidden Internal post processes in depth of field effect
  68292. */
  68293. _effects: Array<PostProcess>;
  68294. /**
  68295. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68296. */
  68297. set focalLength(value: number);
  68298. get focalLength(): number;
  68299. /**
  68300. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68301. */
  68302. set fStop(value: number);
  68303. get fStop(): number;
  68304. /**
  68305. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68306. */
  68307. set focusDistance(value: number);
  68308. get focusDistance(): number;
  68309. /**
  68310. * 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.
  68311. */
  68312. set lensSize(value: number);
  68313. get lensSize(): number;
  68314. /**
  68315. * Creates a new instance DepthOfFieldEffect
  68316. * @param scene The scene the effect belongs to.
  68317. * @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.
  68318. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68319. * @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)
  68320. */
  68321. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68322. /**
  68323. * Get the current class name of the current effet
  68324. * @returns "DepthOfFieldEffect"
  68325. */
  68326. getClassName(): string;
  68327. /**
  68328. * 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.
  68329. */
  68330. set depthTexture(value: RenderTargetTexture);
  68331. /**
  68332. * Disposes each of the internal effects for a given camera.
  68333. * @param camera The camera to dispose the effect on.
  68334. */
  68335. disposeEffects(camera: Camera): void;
  68336. /**
  68337. * @hidden Internal
  68338. */
  68339. _updateEffects(): void;
  68340. /**
  68341. * Internal
  68342. * @returns if all the contained post processes are ready.
  68343. * @hidden
  68344. */
  68345. _isReady(): boolean;
  68346. }
  68347. }
  68348. declare module "babylonjs/Shaders/displayPass.fragment" {
  68349. /** @hidden */
  68350. export var displayPassPixelShader: {
  68351. name: string;
  68352. shader: string;
  68353. };
  68354. }
  68355. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68356. import { Nullable } from "babylonjs/types";
  68357. import { Camera } from "babylonjs/Cameras/camera";
  68358. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68359. import { Engine } from "babylonjs/Engines/engine";
  68360. import "babylonjs/Shaders/displayPass.fragment";
  68361. /**
  68362. * DisplayPassPostProcess which produces an output the same as it's input
  68363. */
  68364. export class DisplayPassPostProcess extends PostProcess {
  68365. /**
  68366. * Creates the DisplayPassPostProcess
  68367. * @param name The name of the effect.
  68368. * @param options The required width/height ratio to downsize to before computing the render pass.
  68369. * @param camera The camera to apply the render pass to.
  68370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68371. * @param engine The engine which the post process will be applied. (default: current engine)
  68372. * @param reusable If the post process can be reused on the same frame. (default: false)
  68373. */
  68374. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68375. }
  68376. }
  68377. declare module "babylonjs/Shaders/filter.fragment" {
  68378. /** @hidden */
  68379. export var filterPixelShader: {
  68380. name: string;
  68381. shader: string;
  68382. };
  68383. }
  68384. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68385. import { Nullable } from "babylonjs/types";
  68386. import { Matrix } from "babylonjs/Maths/math.vector";
  68387. import { Camera } from "babylonjs/Cameras/camera";
  68388. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68389. import { Engine } from "babylonjs/Engines/engine";
  68390. import "babylonjs/Shaders/filter.fragment";
  68391. /**
  68392. * Applies a kernel filter to the image
  68393. */
  68394. export class FilterPostProcess extends PostProcess {
  68395. /** The matrix to be applied to the image */
  68396. kernelMatrix: Matrix;
  68397. /**
  68398. *
  68399. * @param name The name of the effect.
  68400. * @param kernelMatrix The matrix to be applied to the image
  68401. * @param options The required width/height ratio to downsize to before computing the render pass.
  68402. * @param camera The camera to apply the render pass to.
  68403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68404. * @param engine The engine which the post process will be applied. (default: current engine)
  68405. * @param reusable If the post process can be reused on the same frame. (default: false)
  68406. */
  68407. constructor(name: string,
  68408. /** The matrix to be applied to the image */
  68409. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68410. }
  68411. }
  68412. declare module "babylonjs/Shaders/fxaa.fragment" {
  68413. /** @hidden */
  68414. export var fxaaPixelShader: {
  68415. name: string;
  68416. shader: string;
  68417. };
  68418. }
  68419. declare module "babylonjs/Shaders/fxaa.vertex" {
  68420. /** @hidden */
  68421. export var fxaaVertexShader: {
  68422. name: string;
  68423. shader: string;
  68424. };
  68425. }
  68426. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68427. import { Nullable } from "babylonjs/types";
  68428. import { Camera } from "babylonjs/Cameras/camera";
  68429. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68430. import { Engine } from "babylonjs/Engines/engine";
  68431. import "babylonjs/Shaders/fxaa.fragment";
  68432. import "babylonjs/Shaders/fxaa.vertex";
  68433. /**
  68434. * Fxaa post process
  68435. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68436. */
  68437. export class FxaaPostProcess extends PostProcess {
  68438. /** @hidden */
  68439. texelWidth: number;
  68440. /** @hidden */
  68441. texelHeight: number;
  68442. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68443. private _getDefines;
  68444. }
  68445. }
  68446. declare module "babylonjs/Shaders/grain.fragment" {
  68447. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68448. /** @hidden */
  68449. export var grainPixelShader: {
  68450. name: string;
  68451. shader: string;
  68452. };
  68453. }
  68454. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68455. import { Nullable } from "babylonjs/types";
  68456. import { Camera } from "babylonjs/Cameras/camera";
  68457. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68458. import { Engine } from "babylonjs/Engines/engine";
  68459. import "babylonjs/Shaders/grain.fragment";
  68460. /**
  68461. * The GrainPostProcess adds noise to the image at mid luminance levels
  68462. */
  68463. export class GrainPostProcess extends PostProcess {
  68464. /**
  68465. * The intensity of the grain added (default: 30)
  68466. */
  68467. intensity: number;
  68468. /**
  68469. * If the grain should be randomized on every frame
  68470. */
  68471. animated: boolean;
  68472. /**
  68473. * Creates a new instance of @see GrainPostProcess
  68474. * @param name The name of the effect.
  68475. * @param options The required width/height ratio to downsize to before computing the render pass.
  68476. * @param camera The camera to apply the render pass to.
  68477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68478. * @param engine The engine which the post process will be applied. (default: current engine)
  68479. * @param reusable If the post process can be reused on the same frame. (default: false)
  68480. * @param textureType Type of textures used when performing the post process. (default: 0)
  68481. * @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)
  68482. */
  68483. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68484. }
  68485. }
  68486. declare module "babylonjs/Shaders/highlights.fragment" {
  68487. /** @hidden */
  68488. export var highlightsPixelShader: {
  68489. name: string;
  68490. shader: string;
  68491. };
  68492. }
  68493. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68494. import { Nullable } from "babylonjs/types";
  68495. import { Camera } from "babylonjs/Cameras/camera";
  68496. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68497. import { Engine } from "babylonjs/Engines/engine";
  68498. import "babylonjs/Shaders/highlights.fragment";
  68499. /**
  68500. * Extracts highlights from the image
  68501. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68502. */
  68503. export class HighlightsPostProcess extends PostProcess {
  68504. /**
  68505. * Extracts highlights from the image
  68506. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68507. * @param name The name of the effect.
  68508. * @param options The required width/height ratio to downsize to before computing the render pass.
  68509. * @param camera The camera to apply the render pass to.
  68510. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68511. * @param engine The engine which the post process will be applied. (default: current engine)
  68512. * @param reusable If the post process can be reused on the same frame. (default: false)
  68513. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68514. */
  68515. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68516. }
  68517. }
  68518. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68519. /** @hidden */
  68520. export var mrtFragmentDeclaration: {
  68521. name: string;
  68522. shader: string;
  68523. };
  68524. }
  68525. declare module "babylonjs/Shaders/geometry.fragment" {
  68526. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68527. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68528. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68529. /** @hidden */
  68530. export var geometryPixelShader: {
  68531. name: string;
  68532. shader: string;
  68533. };
  68534. }
  68535. declare module "babylonjs/Shaders/geometry.vertex" {
  68536. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68537. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68538. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68539. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68540. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68541. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68542. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68543. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68544. /** @hidden */
  68545. export var geometryVertexShader: {
  68546. name: string;
  68547. shader: string;
  68548. };
  68549. }
  68550. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68551. import { Matrix } from "babylonjs/Maths/math.vector";
  68552. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68553. import { Mesh } from "babylonjs/Meshes/mesh";
  68554. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68555. import { Effect } from "babylonjs/Materials/effect";
  68556. import { Scene } from "babylonjs/scene";
  68557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68558. import "babylonjs/Shaders/geometry.fragment";
  68559. import "babylonjs/Shaders/geometry.vertex";
  68560. /** @hidden */
  68561. interface ISavedTransformationMatrix {
  68562. world: Matrix;
  68563. viewProjection: Matrix;
  68564. }
  68565. /**
  68566. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68567. */
  68568. export class GeometryBufferRenderer {
  68569. /**
  68570. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68571. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68572. */
  68573. static readonly POSITION_TEXTURE_TYPE: number;
  68574. /**
  68575. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68576. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68577. */
  68578. static readonly VELOCITY_TEXTURE_TYPE: number;
  68579. /**
  68580. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68581. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68582. */
  68583. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68584. /**
  68585. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68586. * in order to compute objects velocities when enableVelocity is set to "true"
  68587. * @hidden
  68588. */
  68589. _previousTransformationMatrices: {
  68590. [index: number]: ISavedTransformationMatrix;
  68591. };
  68592. /**
  68593. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68594. * in order to compute objects velocities when enableVelocity is set to "true"
  68595. * @hidden
  68596. */
  68597. _previousBonesTransformationMatrices: {
  68598. [index: number]: Float32Array;
  68599. };
  68600. /**
  68601. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68602. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68603. */
  68604. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68605. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68606. renderTransparentMeshes: boolean;
  68607. private _scene;
  68608. private _multiRenderTarget;
  68609. private _ratio;
  68610. private _enablePosition;
  68611. private _enableVelocity;
  68612. private _enableReflectivity;
  68613. private _positionIndex;
  68614. private _velocityIndex;
  68615. private _reflectivityIndex;
  68616. protected _effect: Effect;
  68617. protected _cachedDefines: string;
  68618. /**
  68619. * Set the render list (meshes to be rendered) used in the G buffer.
  68620. */
  68621. set renderList(meshes: Mesh[]);
  68622. /**
  68623. * Gets wether or not G buffer are supported by the running hardware.
  68624. * This requires draw buffer supports
  68625. */
  68626. get isSupported(): boolean;
  68627. /**
  68628. * Returns the index of the given texture type in the G-Buffer textures array
  68629. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68630. * @returns the index of the given texture type in the G-Buffer textures array
  68631. */
  68632. getTextureIndex(textureType: number): number;
  68633. /**
  68634. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68635. */
  68636. get enablePosition(): boolean;
  68637. /**
  68638. * Sets whether or not objects positions are enabled for the G buffer.
  68639. */
  68640. set enablePosition(enable: boolean);
  68641. /**
  68642. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68643. */
  68644. get enableVelocity(): boolean;
  68645. /**
  68646. * Sets wether or not objects velocities are enabled for the G buffer.
  68647. */
  68648. set enableVelocity(enable: boolean);
  68649. /**
  68650. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68651. */
  68652. get enableReflectivity(): boolean;
  68653. /**
  68654. * Sets wether or not objects roughness are enabled for the G buffer.
  68655. */
  68656. set enableReflectivity(enable: boolean);
  68657. /**
  68658. * Gets the scene associated with the buffer.
  68659. */
  68660. get scene(): Scene;
  68661. /**
  68662. * Gets the ratio used by the buffer during its creation.
  68663. * How big is the buffer related to the main canvas.
  68664. */
  68665. get ratio(): number;
  68666. /** @hidden */
  68667. static _SceneComponentInitialization: (scene: Scene) => void;
  68668. /**
  68669. * Creates a new G Buffer for the scene
  68670. * @param scene The scene the buffer belongs to
  68671. * @param ratio How big is the buffer related to the main canvas.
  68672. */
  68673. constructor(scene: Scene, ratio?: number);
  68674. /**
  68675. * Checks wether everything is ready to render a submesh to the G buffer.
  68676. * @param subMesh the submesh to check readiness for
  68677. * @param useInstances is the mesh drawn using instance or not
  68678. * @returns true if ready otherwise false
  68679. */
  68680. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68681. /**
  68682. * Gets the current underlying G Buffer.
  68683. * @returns the buffer
  68684. */
  68685. getGBuffer(): MultiRenderTarget;
  68686. /**
  68687. * Gets the number of samples used to render the buffer (anti aliasing).
  68688. */
  68689. get samples(): number;
  68690. /**
  68691. * Sets the number of samples used to render the buffer (anti aliasing).
  68692. */
  68693. set samples(value: number);
  68694. /**
  68695. * Disposes the renderer and frees up associated resources.
  68696. */
  68697. dispose(): void;
  68698. protected _createRenderTargets(): void;
  68699. private _copyBonesTransformationMatrices;
  68700. }
  68701. }
  68702. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68703. import { Nullable } from "babylonjs/types";
  68704. import { Scene } from "babylonjs/scene";
  68705. import { ISceneComponent } from "babylonjs/sceneComponent";
  68706. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68707. module "babylonjs/scene" {
  68708. interface Scene {
  68709. /** @hidden (Backing field) */
  68710. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68711. /**
  68712. * Gets or Sets the current geometry buffer associated to the scene.
  68713. */
  68714. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68715. /**
  68716. * Enables a GeometryBufferRender and associates it with the scene
  68717. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68718. * @returns the GeometryBufferRenderer
  68719. */
  68720. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68721. /**
  68722. * Disables the GeometryBufferRender associated with the scene
  68723. */
  68724. disableGeometryBufferRenderer(): void;
  68725. }
  68726. }
  68727. /**
  68728. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68729. * in several rendering techniques.
  68730. */
  68731. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68732. /**
  68733. * The component name helpful to identify the component in the list of scene components.
  68734. */
  68735. readonly name: string;
  68736. /**
  68737. * The scene the component belongs to.
  68738. */
  68739. scene: Scene;
  68740. /**
  68741. * Creates a new instance of the component for the given scene
  68742. * @param scene Defines the scene to register the component in
  68743. */
  68744. constructor(scene: Scene);
  68745. /**
  68746. * Registers the component in a given scene
  68747. */
  68748. register(): void;
  68749. /**
  68750. * Rebuilds the elements related to this component in case of
  68751. * context lost for instance.
  68752. */
  68753. rebuild(): void;
  68754. /**
  68755. * Disposes the component and the associated ressources
  68756. */
  68757. dispose(): void;
  68758. private _gatherRenderTargets;
  68759. }
  68760. }
  68761. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68762. /** @hidden */
  68763. export var motionBlurPixelShader: {
  68764. name: string;
  68765. shader: string;
  68766. };
  68767. }
  68768. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68769. import { Nullable } from "babylonjs/types";
  68770. import { Camera } from "babylonjs/Cameras/camera";
  68771. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68772. import { Scene } from "babylonjs/scene";
  68773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68774. import "babylonjs/Animations/animatable";
  68775. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68776. import "babylonjs/Shaders/motionBlur.fragment";
  68777. import { Engine } from "babylonjs/Engines/engine";
  68778. /**
  68779. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68780. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68781. * As an example, all you have to do is to create the post-process:
  68782. * var mb = new BABYLON.MotionBlurPostProcess(
  68783. * 'mb', // The name of the effect.
  68784. * scene, // The scene containing the objects to blur according to their velocity.
  68785. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68786. * camera // The camera to apply the render pass to.
  68787. * );
  68788. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68789. */
  68790. export class MotionBlurPostProcess extends PostProcess {
  68791. /**
  68792. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68793. */
  68794. motionStrength: number;
  68795. /**
  68796. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68797. */
  68798. get motionBlurSamples(): number;
  68799. /**
  68800. * Sets the number of iterations to be used for motion blur quality
  68801. */
  68802. set motionBlurSamples(samples: number);
  68803. private _motionBlurSamples;
  68804. private _geometryBufferRenderer;
  68805. /**
  68806. * Creates a new instance MotionBlurPostProcess
  68807. * @param name The name of the effect.
  68808. * @param scene The scene containing the objects to blur according to their velocity.
  68809. * @param options The required width/height ratio to downsize to before computing the render pass.
  68810. * @param camera The camera to apply the render pass to.
  68811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68812. * @param engine The engine which the post process will be applied. (default: current engine)
  68813. * @param reusable If the post process can be reused on the same frame. (default: false)
  68814. * @param textureType Type of textures used when performing the post process. (default: 0)
  68815. * @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)
  68816. */
  68817. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68818. /**
  68819. * Excludes the given skinned mesh from computing bones velocities.
  68820. * 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.
  68821. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68822. */
  68823. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68824. /**
  68825. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68826. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68827. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68828. */
  68829. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68830. /**
  68831. * Disposes the post process.
  68832. * @param camera The camera to dispose the post process on.
  68833. */
  68834. dispose(camera?: Camera): void;
  68835. }
  68836. }
  68837. declare module "babylonjs/Shaders/refraction.fragment" {
  68838. /** @hidden */
  68839. export var refractionPixelShader: {
  68840. name: string;
  68841. shader: string;
  68842. };
  68843. }
  68844. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68845. import { Color3 } from "babylonjs/Maths/math.color";
  68846. import { Camera } from "babylonjs/Cameras/camera";
  68847. import { Texture } from "babylonjs/Materials/Textures/texture";
  68848. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68849. import { Engine } from "babylonjs/Engines/engine";
  68850. import "babylonjs/Shaders/refraction.fragment";
  68851. /**
  68852. * Post process which applies a refractin texture
  68853. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68854. */
  68855. export class RefractionPostProcess extends PostProcess {
  68856. /** the base color of the refraction (used to taint the rendering) */
  68857. color: Color3;
  68858. /** simulated refraction depth */
  68859. depth: number;
  68860. /** the coefficient of the base color (0 to remove base color tainting) */
  68861. colorLevel: number;
  68862. private _refTexture;
  68863. private _ownRefractionTexture;
  68864. /**
  68865. * Gets or sets the refraction texture
  68866. * Please note that you are responsible for disposing the texture if you set it manually
  68867. */
  68868. get refractionTexture(): Texture;
  68869. set refractionTexture(value: Texture);
  68870. /**
  68871. * Initializes the RefractionPostProcess
  68872. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68873. * @param name The name of the effect.
  68874. * @param refractionTextureUrl Url of the refraction texture to use
  68875. * @param color the base color of the refraction (used to taint the rendering)
  68876. * @param depth simulated refraction depth
  68877. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68878. * @param camera The camera to apply the render pass to.
  68879. * @param options The required width/height ratio to downsize to before computing the render pass.
  68880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68881. * @param engine The engine which the post process will be applied. (default: current engine)
  68882. * @param reusable If the post process can be reused on the same frame. (default: false)
  68883. */
  68884. constructor(name: string, refractionTextureUrl: string,
  68885. /** the base color of the refraction (used to taint the rendering) */
  68886. color: Color3,
  68887. /** simulated refraction depth */
  68888. depth: number,
  68889. /** the coefficient of the base color (0 to remove base color tainting) */
  68890. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68891. /**
  68892. * Disposes of the post process
  68893. * @param camera Camera to dispose post process on
  68894. */
  68895. dispose(camera: Camera): void;
  68896. }
  68897. }
  68898. declare module "babylonjs/Shaders/sharpen.fragment" {
  68899. /** @hidden */
  68900. export var sharpenPixelShader: {
  68901. name: string;
  68902. shader: string;
  68903. };
  68904. }
  68905. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68906. import { Nullable } from "babylonjs/types";
  68907. import { Camera } from "babylonjs/Cameras/camera";
  68908. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68909. import "babylonjs/Shaders/sharpen.fragment";
  68910. import { Engine } from "babylonjs/Engines/engine";
  68911. /**
  68912. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68913. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68914. */
  68915. export class SharpenPostProcess extends PostProcess {
  68916. /**
  68917. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68918. */
  68919. colorAmount: number;
  68920. /**
  68921. * How much sharpness should be applied (default: 0.3)
  68922. */
  68923. edgeAmount: number;
  68924. /**
  68925. * Creates a new instance ConvolutionPostProcess
  68926. * @param name The name of the effect.
  68927. * @param options The required width/height ratio to downsize to before computing the render pass.
  68928. * @param camera The camera to apply the render pass to.
  68929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68930. * @param engine The engine which the post process will be applied. (default: current engine)
  68931. * @param reusable If the post process can be reused on the same frame. (default: false)
  68932. * @param textureType Type of textures used when performing the post process. (default: 0)
  68933. * @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)
  68934. */
  68935. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68936. }
  68937. }
  68938. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68939. import { Nullable } from "babylonjs/types";
  68940. import { Camera } from "babylonjs/Cameras/camera";
  68941. import { Engine } from "babylonjs/Engines/engine";
  68942. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68943. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68944. /**
  68945. * PostProcessRenderPipeline
  68946. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68947. */
  68948. export class PostProcessRenderPipeline {
  68949. private engine;
  68950. private _renderEffects;
  68951. private _renderEffectsForIsolatedPass;
  68952. /**
  68953. * List of inspectable custom properties (used by the Inspector)
  68954. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68955. */
  68956. inspectableCustomProperties: IInspectable[];
  68957. /**
  68958. * @hidden
  68959. */
  68960. protected _cameras: Camera[];
  68961. /** @hidden */
  68962. _name: string;
  68963. /**
  68964. * Gets pipeline name
  68965. */
  68966. get name(): string;
  68967. /** Gets the list of attached cameras */
  68968. get cameras(): Camera[];
  68969. /**
  68970. * Initializes a PostProcessRenderPipeline
  68971. * @param engine engine to add the pipeline to
  68972. * @param name name of the pipeline
  68973. */
  68974. constructor(engine: Engine, name: string);
  68975. /**
  68976. * Gets the class name
  68977. * @returns "PostProcessRenderPipeline"
  68978. */
  68979. getClassName(): string;
  68980. /**
  68981. * If all the render effects in the pipeline are supported
  68982. */
  68983. get isSupported(): boolean;
  68984. /**
  68985. * Adds an effect to the pipeline
  68986. * @param renderEffect the effect to add
  68987. */
  68988. addEffect(renderEffect: PostProcessRenderEffect): void;
  68989. /** @hidden */
  68990. _rebuild(): void;
  68991. /** @hidden */
  68992. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68993. /** @hidden */
  68994. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68995. /** @hidden */
  68996. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68997. /** @hidden */
  68998. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68999. /** @hidden */
  69000. _attachCameras(cameras: Camera, unique: boolean): void;
  69001. /** @hidden */
  69002. _attachCameras(cameras: Camera[], unique: boolean): void;
  69003. /** @hidden */
  69004. _detachCameras(cameras: Camera): void;
  69005. /** @hidden */
  69006. _detachCameras(cameras: Nullable<Camera[]>): void;
  69007. /** @hidden */
  69008. _update(): void;
  69009. /** @hidden */
  69010. _reset(): void;
  69011. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69012. /**
  69013. * Disposes of the pipeline
  69014. */
  69015. dispose(): void;
  69016. }
  69017. }
  69018. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  69019. import { Camera } from "babylonjs/Cameras/camera";
  69020. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69021. /**
  69022. * PostProcessRenderPipelineManager class
  69023. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69024. */
  69025. export class PostProcessRenderPipelineManager {
  69026. private _renderPipelines;
  69027. /**
  69028. * Initializes a PostProcessRenderPipelineManager
  69029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69030. */
  69031. constructor();
  69032. /**
  69033. * Gets the list of supported render pipelines
  69034. */
  69035. get supportedPipelines(): PostProcessRenderPipeline[];
  69036. /**
  69037. * Adds a pipeline to the manager
  69038. * @param renderPipeline The pipeline to add
  69039. */
  69040. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69041. /**
  69042. * Attaches a camera to the pipeline
  69043. * @param renderPipelineName The name of the pipeline to attach to
  69044. * @param cameras the camera to attach
  69045. * @param unique if the camera can be attached multiple times to the pipeline
  69046. */
  69047. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69048. /**
  69049. * Detaches a camera from the pipeline
  69050. * @param renderPipelineName The name of the pipeline to detach from
  69051. * @param cameras the camera to detach
  69052. */
  69053. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69054. /**
  69055. * Enables an effect by name on a pipeline
  69056. * @param renderPipelineName the name of the pipeline to enable the effect in
  69057. * @param renderEffectName the name of the effect to enable
  69058. * @param cameras the cameras that the effect should be enabled on
  69059. */
  69060. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69061. /**
  69062. * Disables an effect by name on a pipeline
  69063. * @param renderPipelineName the name of the pipeline to disable the effect in
  69064. * @param renderEffectName the name of the effect to disable
  69065. * @param cameras the cameras that the effect should be disabled on
  69066. */
  69067. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69068. /**
  69069. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69070. */
  69071. update(): void;
  69072. /** @hidden */
  69073. _rebuild(): void;
  69074. /**
  69075. * Disposes of the manager and pipelines
  69076. */
  69077. dispose(): void;
  69078. }
  69079. }
  69080. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  69081. import { ISceneComponent } from "babylonjs/sceneComponent";
  69082. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69083. import { Scene } from "babylonjs/scene";
  69084. module "babylonjs/scene" {
  69085. interface Scene {
  69086. /** @hidden (Backing field) */
  69087. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69088. /**
  69089. * Gets the postprocess render pipeline manager
  69090. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69091. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69092. */
  69093. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69094. }
  69095. }
  69096. /**
  69097. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69098. */
  69099. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69100. /**
  69101. * The component name helpfull to identify the component in the list of scene components.
  69102. */
  69103. readonly name: string;
  69104. /**
  69105. * The scene the component belongs to.
  69106. */
  69107. scene: Scene;
  69108. /**
  69109. * Creates a new instance of the component for the given scene
  69110. * @param scene Defines the scene to register the component in
  69111. */
  69112. constructor(scene: Scene);
  69113. /**
  69114. * Registers the component in a given scene
  69115. */
  69116. register(): void;
  69117. /**
  69118. * Rebuilds the elements related to this component in case of
  69119. * context lost for instance.
  69120. */
  69121. rebuild(): void;
  69122. /**
  69123. * Disposes the component and the associated ressources
  69124. */
  69125. dispose(): void;
  69126. private _gatherRenderTargets;
  69127. }
  69128. }
  69129. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  69130. import { Nullable } from "babylonjs/types";
  69131. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69132. import { Camera } from "babylonjs/Cameras/camera";
  69133. import { IDisposable } from "babylonjs/scene";
  69134. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  69135. import { Scene } from "babylonjs/scene";
  69136. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  69137. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69138. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69139. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  69140. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69141. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69142. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  69143. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69144. import { Animation } from "babylonjs/Animations/animation";
  69145. /**
  69146. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69147. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69148. */
  69149. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69150. private _scene;
  69151. private _camerasToBeAttached;
  69152. /**
  69153. * ID of the sharpen post process,
  69154. */
  69155. private readonly SharpenPostProcessId;
  69156. /**
  69157. * @ignore
  69158. * ID of the image processing post process;
  69159. */
  69160. readonly ImageProcessingPostProcessId: string;
  69161. /**
  69162. * @ignore
  69163. * ID of the Fast Approximate Anti-Aliasing post process;
  69164. */
  69165. readonly FxaaPostProcessId: string;
  69166. /**
  69167. * ID of the chromatic aberration post process,
  69168. */
  69169. private readonly ChromaticAberrationPostProcessId;
  69170. /**
  69171. * ID of the grain post process
  69172. */
  69173. private readonly GrainPostProcessId;
  69174. /**
  69175. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69176. */
  69177. sharpen: SharpenPostProcess;
  69178. private _sharpenEffect;
  69179. private bloom;
  69180. /**
  69181. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69182. */
  69183. depthOfField: DepthOfFieldEffect;
  69184. /**
  69185. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69186. */
  69187. fxaa: FxaaPostProcess;
  69188. /**
  69189. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69190. */
  69191. imageProcessing: ImageProcessingPostProcess;
  69192. /**
  69193. * Chromatic aberration post process which will shift rgb colors in the image
  69194. */
  69195. chromaticAberration: ChromaticAberrationPostProcess;
  69196. private _chromaticAberrationEffect;
  69197. /**
  69198. * Grain post process which add noise to the image
  69199. */
  69200. grain: GrainPostProcess;
  69201. private _grainEffect;
  69202. /**
  69203. * Glow post process which adds a glow to emissive areas of the image
  69204. */
  69205. private _glowLayer;
  69206. /**
  69207. * Animations which can be used to tweak settings over a period of time
  69208. */
  69209. animations: Animation[];
  69210. private _imageProcessingConfigurationObserver;
  69211. private _sharpenEnabled;
  69212. private _bloomEnabled;
  69213. private _depthOfFieldEnabled;
  69214. private _depthOfFieldBlurLevel;
  69215. private _fxaaEnabled;
  69216. private _imageProcessingEnabled;
  69217. private _defaultPipelineTextureType;
  69218. private _bloomScale;
  69219. private _chromaticAberrationEnabled;
  69220. private _grainEnabled;
  69221. private _buildAllowed;
  69222. /**
  69223. * Gets active scene
  69224. */
  69225. get scene(): Scene;
  69226. /**
  69227. * Enable or disable the sharpen process from the pipeline
  69228. */
  69229. set sharpenEnabled(enabled: boolean);
  69230. get sharpenEnabled(): boolean;
  69231. private _resizeObserver;
  69232. private _hardwareScaleLevel;
  69233. private _bloomKernel;
  69234. /**
  69235. * Specifies the size of the bloom blur kernel, relative to the final output size
  69236. */
  69237. get bloomKernel(): number;
  69238. set bloomKernel(value: number);
  69239. /**
  69240. * Specifies the weight of the bloom in the final rendering
  69241. */
  69242. private _bloomWeight;
  69243. /**
  69244. * Specifies the luma threshold for the area that will be blurred by the bloom
  69245. */
  69246. private _bloomThreshold;
  69247. private _hdr;
  69248. /**
  69249. * The strength of the bloom.
  69250. */
  69251. set bloomWeight(value: number);
  69252. get bloomWeight(): number;
  69253. /**
  69254. * The strength of the bloom.
  69255. */
  69256. set bloomThreshold(value: number);
  69257. get bloomThreshold(): number;
  69258. /**
  69259. * The scale of the bloom, lower value will provide better performance.
  69260. */
  69261. set bloomScale(value: number);
  69262. get bloomScale(): number;
  69263. /**
  69264. * Enable or disable the bloom from the pipeline
  69265. */
  69266. set bloomEnabled(enabled: boolean);
  69267. get bloomEnabled(): boolean;
  69268. private _rebuildBloom;
  69269. /**
  69270. * If the depth of field is enabled.
  69271. */
  69272. get depthOfFieldEnabled(): boolean;
  69273. set depthOfFieldEnabled(enabled: boolean);
  69274. /**
  69275. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69276. */
  69277. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69278. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69279. /**
  69280. * If the anti aliasing is enabled.
  69281. */
  69282. set fxaaEnabled(enabled: boolean);
  69283. get fxaaEnabled(): boolean;
  69284. private _samples;
  69285. /**
  69286. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69287. */
  69288. set samples(sampleCount: number);
  69289. get samples(): number;
  69290. /**
  69291. * If image processing is enabled.
  69292. */
  69293. set imageProcessingEnabled(enabled: boolean);
  69294. get imageProcessingEnabled(): boolean;
  69295. /**
  69296. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69297. */
  69298. set glowLayerEnabled(enabled: boolean);
  69299. get glowLayerEnabled(): boolean;
  69300. /**
  69301. * Gets the glow layer (or null if not defined)
  69302. */
  69303. get glowLayer(): Nullable<GlowLayer>;
  69304. /**
  69305. * Enable or disable the chromaticAberration process from the pipeline
  69306. */
  69307. set chromaticAberrationEnabled(enabled: boolean);
  69308. get chromaticAberrationEnabled(): boolean;
  69309. /**
  69310. * Enable or disable the grain process from the pipeline
  69311. */
  69312. set grainEnabled(enabled: boolean);
  69313. get grainEnabled(): boolean;
  69314. /**
  69315. * @constructor
  69316. * @param name - The rendering pipeline name (default: "")
  69317. * @param hdr - If high dynamic range textures should be used (default: true)
  69318. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69319. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69320. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69321. */
  69322. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69323. /**
  69324. * Get the class name
  69325. * @returns "DefaultRenderingPipeline"
  69326. */
  69327. getClassName(): string;
  69328. /**
  69329. * Force the compilation of the entire pipeline.
  69330. */
  69331. prepare(): void;
  69332. private _hasCleared;
  69333. private _prevPostProcess;
  69334. private _prevPrevPostProcess;
  69335. private _setAutoClearAndTextureSharing;
  69336. private _depthOfFieldSceneObserver;
  69337. private _buildPipeline;
  69338. private _disposePostProcesses;
  69339. /**
  69340. * Adds a camera to the pipeline
  69341. * @param camera the camera to be added
  69342. */
  69343. addCamera(camera: Camera): void;
  69344. /**
  69345. * Removes a camera from the pipeline
  69346. * @param camera the camera to remove
  69347. */
  69348. removeCamera(camera: Camera): void;
  69349. /**
  69350. * Dispose of the pipeline and stop all post processes
  69351. */
  69352. dispose(): void;
  69353. /**
  69354. * Serialize the rendering pipeline (Used when exporting)
  69355. * @returns the serialized object
  69356. */
  69357. serialize(): any;
  69358. /**
  69359. * Parse the serialized pipeline
  69360. * @param source Source pipeline.
  69361. * @param scene The scene to load the pipeline to.
  69362. * @param rootUrl The URL of the serialized pipeline.
  69363. * @returns An instantiated pipeline from the serialized object.
  69364. */
  69365. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69366. }
  69367. }
  69368. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69369. /** @hidden */
  69370. export var lensHighlightsPixelShader: {
  69371. name: string;
  69372. shader: string;
  69373. };
  69374. }
  69375. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69376. /** @hidden */
  69377. export var depthOfFieldPixelShader: {
  69378. name: string;
  69379. shader: string;
  69380. };
  69381. }
  69382. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69383. import { Camera } from "babylonjs/Cameras/camera";
  69384. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69385. import { Scene } from "babylonjs/scene";
  69386. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69387. import "babylonjs/Shaders/chromaticAberration.fragment";
  69388. import "babylonjs/Shaders/lensHighlights.fragment";
  69389. import "babylonjs/Shaders/depthOfField.fragment";
  69390. /**
  69391. * BABYLON.JS Chromatic Aberration GLSL Shader
  69392. * Author: Olivier Guyot
  69393. * Separates very slightly R, G and B colors on the edges of the screen
  69394. * Inspired by Francois Tarlier & Martins Upitis
  69395. */
  69396. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69397. /**
  69398. * @ignore
  69399. * The chromatic aberration PostProcess id in the pipeline
  69400. */
  69401. LensChromaticAberrationEffect: string;
  69402. /**
  69403. * @ignore
  69404. * The highlights enhancing PostProcess id in the pipeline
  69405. */
  69406. HighlightsEnhancingEffect: string;
  69407. /**
  69408. * @ignore
  69409. * The depth-of-field PostProcess id in the pipeline
  69410. */
  69411. LensDepthOfFieldEffect: string;
  69412. private _scene;
  69413. private _depthTexture;
  69414. private _grainTexture;
  69415. private _chromaticAberrationPostProcess;
  69416. private _highlightsPostProcess;
  69417. private _depthOfFieldPostProcess;
  69418. private _edgeBlur;
  69419. private _grainAmount;
  69420. private _chromaticAberration;
  69421. private _distortion;
  69422. private _highlightsGain;
  69423. private _highlightsThreshold;
  69424. private _dofDistance;
  69425. private _dofAperture;
  69426. private _dofDarken;
  69427. private _dofPentagon;
  69428. private _blurNoise;
  69429. /**
  69430. * @constructor
  69431. *
  69432. * Effect parameters are as follow:
  69433. * {
  69434. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69435. * edge_blur: number; // from 0 to x (1 for realism)
  69436. * distortion: number; // from 0 to x (1 for realism)
  69437. * grain_amount: number; // from 0 to 1
  69438. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69439. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69440. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69441. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69442. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69443. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69444. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69445. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69446. * }
  69447. * Note: if an effect parameter is unset, effect is disabled
  69448. *
  69449. * @param name The rendering pipeline name
  69450. * @param parameters - An object containing all parameters (see above)
  69451. * @param scene The scene linked to this pipeline
  69452. * @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)
  69453. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69454. */
  69455. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69456. /**
  69457. * Get the class name
  69458. * @returns "LensRenderingPipeline"
  69459. */
  69460. getClassName(): string;
  69461. /**
  69462. * Gets associated scene
  69463. */
  69464. get scene(): Scene;
  69465. /**
  69466. * Gets or sets the edge blur
  69467. */
  69468. get edgeBlur(): number;
  69469. set edgeBlur(value: number);
  69470. /**
  69471. * Gets or sets the grain amount
  69472. */
  69473. get grainAmount(): number;
  69474. set grainAmount(value: number);
  69475. /**
  69476. * Gets or sets the chromatic aberration amount
  69477. */
  69478. get chromaticAberration(): number;
  69479. set chromaticAberration(value: number);
  69480. /**
  69481. * Gets or sets the depth of field aperture
  69482. */
  69483. get dofAperture(): number;
  69484. set dofAperture(value: number);
  69485. /**
  69486. * Gets or sets the edge distortion
  69487. */
  69488. get edgeDistortion(): number;
  69489. set edgeDistortion(value: number);
  69490. /**
  69491. * Gets or sets the depth of field distortion
  69492. */
  69493. get dofDistortion(): number;
  69494. set dofDistortion(value: number);
  69495. /**
  69496. * Gets or sets the darken out of focus amount
  69497. */
  69498. get darkenOutOfFocus(): number;
  69499. set darkenOutOfFocus(value: number);
  69500. /**
  69501. * Gets or sets a boolean indicating if blur noise is enabled
  69502. */
  69503. get blurNoise(): boolean;
  69504. set blurNoise(value: boolean);
  69505. /**
  69506. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69507. */
  69508. get pentagonBokeh(): boolean;
  69509. set pentagonBokeh(value: boolean);
  69510. /**
  69511. * Gets or sets the highlight grain amount
  69512. */
  69513. get highlightsGain(): number;
  69514. set highlightsGain(value: number);
  69515. /**
  69516. * Gets or sets the highlight threshold
  69517. */
  69518. get highlightsThreshold(): number;
  69519. set highlightsThreshold(value: number);
  69520. /**
  69521. * Sets the amount of blur at the edges
  69522. * @param amount blur amount
  69523. */
  69524. setEdgeBlur(amount: number): void;
  69525. /**
  69526. * Sets edge blur to 0
  69527. */
  69528. disableEdgeBlur(): void;
  69529. /**
  69530. * Sets the amout of grain
  69531. * @param amount Amount of grain
  69532. */
  69533. setGrainAmount(amount: number): void;
  69534. /**
  69535. * Set grain amount to 0
  69536. */
  69537. disableGrain(): void;
  69538. /**
  69539. * Sets the chromatic aberration amount
  69540. * @param amount amount of chromatic aberration
  69541. */
  69542. setChromaticAberration(amount: number): void;
  69543. /**
  69544. * Sets chromatic aberration amount to 0
  69545. */
  69546. disableChromaticAberration(): void;
  69547. /**
  69548. * Sets the EdgeDistortion amount
  69549. * @param amount amount of EdgeDistortion
  69550. */
  69551. setEdgeDistortion(amount: number): void;
  69552. /**
  69553. * Sets edge distortion to 0
  69554. */
  69555. disableEdgeDistortion(): void;
  69556. /**
  69557. * Sets the FocusDistance amount
  69558. * @param amount amount of FocusDistance
  69559. */
  69560. setFocusDistance(amount: number): void;
  69561. /**
  69562. * Disables depth of field
  69563. */
  69564. disableDepthOfField(): void;
  69565. /**
  69566. * Sets the Aperture amount
  69567. * @param amount amount of Aperture
  69568. */
  69569. setAperture(amount: number): void;
  69570. /**
  69571. * Sets the DarkenOutOfFocus amount
  69572. * @param amount amount of DarkenOutOfFocus
  69573. */
  69574. setDarkenOutOfFocus(amount: number): void;
  69575. private _pentagonBokehIsEnabled;
  69576. /**
  69577. * Creates a pentagon bokeh effect
  69578. */
  69579. enablePentagonBokeh(): void;
  69580. /**
  69581. * Disables the pentagon bokeh effect
  69582. */
  69583. disablePentagonBokeh(): void;
  69584. /**
  69585. * Enables noise blur
  69586. */
  69587. enableNoiseBlur(): void;
  69588. /**
  69589. * Disables noise blur
  69590. */
  69591. disableNoiseBlur(): void;
  69592. /**
  69593. * Sets the HighlightsGain amount
  69594. * @param amount amount of HighlightsGain
  69595. */
  69596. setHighlightsGain(amount: number): void;
  69597. /**
  69598. * Sets the HighlightsThreshold amount
  69599. * @param amount amount of HighlightsThreshold
  69600. */
  69601. setHighlightsThreshold(amount: number): void;
  69602. /**
  69603. * Disables highlights
  69604. */
  69605. disableHighlights(): void;
  69606. /**
  69607. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69608. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69609. */
  69610. dispose(disableDepthRender?: boolean): void;
  69611. private _createChromaticAberrationPostProcess;
  69612. private _createHighlightsPostProcess;
  69613. private _createDepthOfFieldPostProcess;
  69614. private _createGrainTexture;
  69615. }
  69616. }
  69617. declare module "babylonjs/Shaders/ssao2.fragment" {
  69618. /** @hidden */
  69619. export var ssao2PixelShader: {
  69620. name: string;
  69621. shader: string;
  69622. };
  69623. }
  69624. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69625. /** @hidden */
  69626. export var ssaoCombinePixelShader: {
  69627. name: string;
  69628. shader: string;
  69629. };
  69630. }
  69631. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69632. import { Camera } from "babylonjs/Cameras/camera";
  69633. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69634. import { Scene } from "babylonjs/scene";
  69635. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69636. import "babylonjs/Shaders/ssao2.fragment";
  69637. import "babylonjs/Shaders/ssaoCombine.fragment";
  69638. /**
  69639. * Render pipeline to produce ssao effect
  69640. */
  69641. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69642. /**
  69643. * @ignore
  69644. * The PassPostProcess id in the pipeline that contains the original scene color
  69645. */
  69646. SSAOOriginalSceneColorEffect: string;
  69647. /**
  69648. * @ignore
  69649. * The SSAO PostProcess id in the pipeline
  69650. */
  69651. SSAORenderEffect: string;
  69652. /**
  69653. * @ignore
  69654. * The horizontal blur PostProcess id in the pipeline
  69655. */
  69656. SSAOBlurHRenderEffect: string;
  69657. /**
  69658. * @ignore
  69659. * The vertical blur PostProcess id in the pipeline
  69660. */
  69661. SSAOBlurVRenderEffect: string;
  69662. /**
  69663. * @ignore
  69664. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69665. */
  69666. SSAOCombineRenderEffect: string;
  69667. /**
  69668. * The output strength of the SSAO post-process. Default value is 1.0.
  69669. */
  69670. totalStrength: number;
  69671. /**
  69672. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69673. */
  69674. maxZ: number;
  69675. /**
  69676. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69677. */
  69678. minZAspect: number;
  69679. private _samples;
  69680. /**
  69681. * Number of samples used for the SSAO calculations. Default value is 8
  69682. */
  69683. set samples(n: number);
  69684. get samples(): number;
  69685. private _textureSamples;
  69686. /**
  69687. * Number of samples to use for antialiasing
  69688. */
  69689. set textureSamples(n: number);
  69690. get textureSamples(): number;
  69691. /**
  69692. * Ratio object used for SSAO ratio and blur ratio
  69693. */
  69694. private _ratio;
  69695. /**
  69696. * Dynamically generated sphere sampler.
  69697. */
  69698. private _sampleSphere;
  69699. /**
  69700. * Blur filter offsets
  69701. */
  69702. private _samplerOffsets;
  69703. private _expensiveBlur;
  69704. /**
  69705. * If bilateral blur should be used
  69706. */
  69707. set expensiveBlur(b: boolean);
  69708. get expensiveBlur(): boolean;
  69709. /**
  69710. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69711. */
  69712. radius: number;
  69713. /**
  69714. * The base color of the SSAO post-process
  69715. * The final result is "base + ssao" between [0, 1]
  69716. */
  69717. base: number;
  69718. /**
  69719. * Support test.
  69720. */
  69721. static get IsSupported(): boolean;
  69722. private _scene;
  69723. private _depthTexture;
  69724. private _normalTexture;
  69725. private _randomTexture;
  69726. private _originalColorPostProcess;
  69727. private _ssaoPostProcess;
  69728. private _blurHPostProcess;
  69729. private _blurVPostProcess;
  69730. private _ssaoCombinePostProcess;
  69731. /**
  69732. * Gets active scene
  69733. */
  69734. get scene(): Scene;
  69735. /**
  69736. * @constructor
  69737. * @param name The rendering pipeline name
  69738. * @param scene The scene linked to this pipeline
  69739. * @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 }
  69740. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69741. */
  69742. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69743. /**
  69744. * Get the class name
  69745. * @returns "SSAO2RenderingPipeline"
  69746. */
  69747. getClassName(): string;
  69748. /**
  69749. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69750. */
  69751. dispose(disableGeometryBufferRenderer?: boolean): void;
  69752. private _createBlurPostProcess;
  69753. /** @hidden */
  69754. _rebuild(): void;
  69755. private _bits;
  69756. private _radicalInverse_VdC;
  69757. private _hammersley;
  69758. private _hemisphereSample_uniform;
  69759. private _generateHemisphere;
  69760. private _createSSAOPostProcess;
  69761. private _createSSAOCombinePostProcess;
  69762. private _createRandomTexture;
  69763. /**
  69764. * Serialize the rendering pipeline (Used when exporting)
  69765. * @returns the serialized object
  69766. */
  69767. serialize(): any;
  69768. /**
  69769. * Parse the serialized pipeline
  69770. * @param source Source pipeline.
  69771. * @param scene The scene to load the pipeline to.
  69772. * @param rootUrl The URL of the serialized pipeline.
  69773. * @returns An instantiated pipeline from the serialized object.
  69774. */
  69775. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69776. }
  69777. }
  69778. declare module "babylonjs/Shaders/ssao.fragment" {
  69779. /** @hidden */
  69780. export var ssaoPixelShader: {
  69781. name: string;
  69782. shader: string;
  69783. };
  69784. }
  69785. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69786. import { Camera } from "babylonjs/Cameras/camera";
  69787. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69788. import { Scene } from "babylonjs/scene";
  69789. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69790. import "babylonjs/Shaders/ssao.fragment";
  69791. import "babylonjs/Shaders/ssaoCombine.fragment";
  69792. /**
  69793. * Render pipeline to produce ssao effect
  69794. */
  69795. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69796. /**
  69797. * @ignore
  69798. * The PassPostProcess id in the pipeline that contains the original scene color
  69799. */
  69800. SSAOOriginalSceneColorEffect: string;
  69801. /**
  69802. * @ignore
  69803. * The SSAO PostProcess id in the pipeline
  69804. */
  69805. SSAORenderEffect: string;
  69806. /**
  69807. * @ignore
  69808. * The horizontal blur PostProcess id in the pipeline
  69809. */
  69810. SSAOBlurHRenderEffect: string;
  69811. /**
  69812. * @ignore
  69813. * The vertical blur PostProcess id in the pipeline
  69814. */
  69815. SSAOBlurVRenderEffect: string;
  69816. /**
  69817. * @ignore
  69818. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69819. */
  69820. SSAOCombineRenderEffect: string;
  69821. /**
  69822. * The output strength of the SSAO post-process. Default value is 1.0.
  69823. */
  69824. totalStrength: number;
  69825. /**
  69826. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69827. */
  69828. radius: number;
  69829. /**
  69830. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69831. * Must not be equal to fallOff and superior to fallOff.
  69832. * Default value is 0.0075
  69833. */
  69834. area: number;
  69835. /**
  69836. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69837. * Must not be equal to area and inferior to area.
  69838. * Default value is 0.000001
  69839. */
  69840. fallOff: number;
  69841. /**
  69842. * The base color of the SSAO post-process
  69843. * The final result is "base + ssao" between [0, 1]
  69844. */
  69845. base: number;
  69846. private _scene;
  69847. private _depthTexture;
  69848. private _randomTexture;
  69849. private _originalColorPostProcess;
  69850. private _ssaoPostProcess;
  69851. private _blurHPostProcess;
  69852. private _blurVPostProcess;
  69853. private _ssaoCombinePostProcess;
  69854. private _firstUpdate;
  69855. /**
  69856. * Gets active scene
  69857. */
  69858. get scene(): Scene;
  69859. /**
  69860. * @constructor
  69861. * @param name - The rendering pipeline name
  69862. * @param scene - The scene linked to this pipeline
  69863. * @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 }
  69864. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69865. */
  69866. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69867. /**
  69868. * Get the class name
  69869. * @returns "SSAORenderingPipeline"
  69870. */
  69871. getClassName(): string;
  69872. /**
  69873. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69874. */
  69875. dispose(disableDepthRender?: boolean): void;
  69876. private _createBlurPostProcess;
  69877. /** @hidden */
  69878. _rebuild(): void;
  69879. private _createSSAOPostProcess;
  69880. private _createSSAOCombinePostProcess;
  69881. private _createRandomTexture;
  69882. }
  69883. }
  69884. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69885. /** @hidden */
  69886. export var screenSpaceReflectionPixelShader: {
  69887. name: string;
  69888. shader: string;
  69889. };
  69890. }
  69891. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69892. import { Nullable } from "babylonjs/types";
  69893. import { Camera } from "babylonjs/Cameras/camera";
  69894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69895. import { Scene } from "babylonjs/scene";
  69896. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69897. import { Engine } from "babylonjs/Engines/engine";
  69898. /**
  69899. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69900. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69901. */
  69902. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69903. /**
  69904. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69905. */
  69906. threshold: number;
  69907. /**
  69908. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69909. */
  69910. strength: number;
  69911. /**
  69912. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69913. */
  69914. reflectionSpecularFalloffExponent: number;
  69915. /**
  69916. * 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]
  69917. */
  69918. step: number;
  69919. /**
  69920. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69921. */
  69922. roughnessFactor: number;
  69923. private _geometryBufferRenderer;
  69924. private _enableSmoothReflections;
  69925. private _reflectionSamples;
  69926. private _smoothSteps;
  69927. /**
  69928. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69929. * @param name The name of the effect.
  69930. * @param scene The scene containing the objects to calculate reflections.
  69931. * @param options The required width/height ratio to downsize to before computing the render pass.
  69932. * @param camera The camera to apply the render pass to.
  69933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69934. * @param engine The engine which the post process will be applied. (default: current engine)
  69935. * @param reusable If the post process can be reused on the same frame. (default: false)
  69936. * @param textureType Type of textures used when performing the post process. (default: 0)
  69937. * @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)
  69938. */
  69939. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69940. /**
  69941. * Gets wether or not smoothing reflections is enabled.
  69942. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69943. */
  69944. get enableSmoothReflections(): boolean;
  69945. /**
  69946. * Sets wether or not smoothing reflections is enabled.
  69947. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69948. */
  69949. set enableSmoothReflections(enabled: boolean);
  69950. /**
  69951. * Gets the number of samples taken while computing reflections. More samples count is high,
  69952. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69953. */
  69954. get reflectionSamples(): number;
  69955. /**
  69956. * Sets the number of samples taken while computing reflections. More samples count is high,
  69957. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69958. */
  69959. set reflectionSamples(samples: number);
  69960. /**
  69961. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69962. * more the post-process will require GPU power and can generate a drop in FPS.
  69963. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69964. */
  69965. get smoothSteps(): number;
  69966. set smoothSteps(steps: number);
  69967. private _updateEffectDefines;
  69968. }
  69969. }
  69970. declare module "babylonjs/Shaders/standard.fragment" {
  69971. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69972. /** @hidden */
  69973. export var standardPixelShader: {
  69974. name: string;
  69975. shader: string;
  69976. };
  69977. }
  69978. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69979. import { Nullable } from "babylonjs/types";
  69980. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69981. import { Camera } from "babylonjs/Cameras/camera";
  69982. import { Texture } from "babylonjs/Materials/Textures/texture";
  69983. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69984. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69985. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69986. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69987. import { IDisposable } from "babylonjs/scene";
  69988. import { SpotLight } from "babylonjs/Lights/spotLight";
  69989. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69990. import { Scene } from "babylonjs/scene";
  69991. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69992. import { Animation } from "babylonjs/Animations/animation";
  69993. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69994. import "babylonjs/Shaders/standard.fragment";
  69995. /**
  69996. * Standard rendering pipeline
  69997. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69998. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69999. */
  70000. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70001. /**
  70002. * Public members
  70003. */
  70004. /**
  70005. * Post-process which contains the original scene color before the pipeline applies all the effects
  70006. */
  70007. originalPostProcess: Nullable<PostProcess>;
  70008. /**
  70009. * Post-process used to down scale an image x4
  70010. */
  70011. downSampleX4PostProcess: Nullable<PostProcess>;
  70012. /**
  70013. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70014. */
  70015. brightPassPostProcess: Nullable<PostProcess>;
  70016. /**
  70017. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70018. */
  70019. blurHPostProcesses: PostProcess[];
  70020. /**
  70021. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70022. */
  70023. blurVPostProcesses: PostProcess[];
  70024. /**
  70025. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70026. */
  70027. textureAdderPostProcess: Nullable<PostProcess>;
  70028. /**
  70029. * Post-process used to create volumetric lighting effect
  70030. */
  70031. volumetricLightPostProcess: Nullable<PostProcess>;
  70032. /**
  70033. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70034. */
  70035. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70036. /**
  70037. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70038. */
  70039. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70040. /**
  70041. * Post-process used to merge the volumetric light effect and the real scene color
  70042. */
  70043. volumetricLightMergePostProces: Nullable<PostProcess>;
  70044. /**
  70045. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70046. */
  70047. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70048. /**
  70049. * Base post-process used to calculate the average luminance of the final image for HDR
  70050. */
  70051. luminancePostProcess: Nullable<PostProcess>;
  70052. /**
  70053. * Post-processes used to create down sample post-processes in order to get
  70054. * the average luminance of the final image for HDR
  70055. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70056. */
  70057. luminanceDownSamplePostProcesses: PostProcess[];
  70058. /**
  70059. * Post-process used to create a HDR effect (light adaptation)
  70060. */
  70061. hdrPostProcess: Nullable<PostProcess>;
  70062. /**
  70063. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70064. */
  70065. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70066. /**
  70067. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70068. */
  70069. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70070. /**
  70071. * Post-process used to merge the final HDR post-process and the real scene color
  70072. */
  70073. hdrFinalPostProcess: Nullable<PostProcess>;
  70074. /**
  70075. * Post-process used to create a lens flare effect
  70076. */
  70077. lensFlarePostProcess: Nullable<PostProcess>;
  70078. /**
  70079. * Post-process that merges the result of the lens flare post-process and the real scene color
  70080. */
  70081. lensFlareComposePostProcess: Nullable<PostProcess>;
  70082. /**
  70083. * Post-process used to create a motion blur effect
  70084. */
  70085. motionBlurPostProcess: Nullable<PostProcess>;
  70086. /**
  70087. * Post-process used to create a depth of field effect
  70088. */
  70089. depthOfFieldPostProcess: Nullable<PostProcess>;
  70090. /**
  70091. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70092. */
  70093. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70094. /**
  70095. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70096. */
  70097. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70098. /**
  70099. * Represents the brightness threshold in order to configure the illuminated surfaces
  70100. */
  70101. brightThreshold: number;
  70102. /**
  70103. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70104. */
  70105. blurWidth: number;
  70106. /**
  70107. * Sets if the blur for highlighted surfaces must be only horizontal
  70108. */
  70109. horizontalBlur: boolean;
  70110. /**
  70111. * Gets the overall exposure used by the pipeline
  70112. */
  70113. get exposure(): number;
  70114. /**
  70115. * Sets the overall exposure used by the pipeline
  70116. */
  70117. set exposure(value: number);
  70118. /**
  70119. * Texture used typically to simulate "dirty" on camera lens
  70120. */
  70121. lensTexture: Nullable<Texture>;
  70122. /**
  70123. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70124. */
  70125. volumetricLightCoefficient: number;
  70126. /**
  70127. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70128. */
  70129. volumetricLightPower: number;
  70130. /**
  70131. * Used the set the blur intensity to smooth the volumetric lights
  70132. */
  70133. volumetricLightBlurScale: number;
  70134. /**
  70135. * Light (spot or directional) used to generate the volumetric lights rays
  70136. * The source light must have a shadow generate so the pipeline can get its
  70137. * depth map
  70138. */
  70139. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70140. /**
  70141. * For eye adaptation, represents the minimum luminance the eye can see
  70142. */
  70143. hdrMinimumLuminance: number;
  70144. /**
  70145. * For eye adaptation, represents the decrease luminance speed
  70146. */
  70147. hdrDecreaseRate: number;
  70148. /**
  70149. * For eye adaptation, represents the increase luminance speed
  70150. */
  70151. hdrIncreaseRate: number;
  70152. /**
  70153. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70154. */
  70155. get hdrAutoExposure(): boolean;
  70156. /**
  70157. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70158. */
  70159. set hdrAutoExposure(value: boolean);
  70160. /**
  70161. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70162. */
  70163. lensColorTexture: Nullable<Texture>;
  70164. /**
  70165. * The overall strengh for the lens flare effect
  70166. */
  70167. lensFlareStrength: number;
  70168. /**
  70169. * Dispersion coefficient for lens flare ghosts
  70170. */
  70171. lensFlareGhostDispersal: number;
  70172. /**
  70173. * Main lens flare halo width
  70174. */
  70175. lensFlareHaloWidth: number;
  70176. /**
  70177. * Based on the lens distortion effect, defines how much the lens flare result
  70178. * is distorted
  70179. */
  70180. lensFlareDistortionStrength: number;
  70181. /**
  70182. * Configures the blur intensity used for for lens flare (halo)
  70183. */
  70184. lensFlareBlurWidth: number;
  70185. /**
  70186. * Lens star texture must be used to simulate rays on the flares and is available
  70187. * in the documentation
  70188. */
  70189. lensStarTexture: Nullable<Texture>;
  70190. /**
  70191. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70192. * flare effect by taking account of the dirt texture
  70193. */
  70194. lensFlareDirtTexture: Nullable<Texture>;
  70195. /**
  70196. * Represents the focal length for the depth of field effect
  70197. */
  70198. depthOfFieldDistance: number;
  70199. /**
  70200. * Represents the blur intensity for the blurred part of the depth of field effect
  70201. */
  70202. depthOfFieldBlurWidth: number;
  70203. /**
  70204. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70205. */
  70206. get motionStrength(): number;
  70207. /**
  70208. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70209. */
  70210. set motionStrength(strength: number);
  70211. /**
  70212. * Gets wether or not the motion blur post-process is object based or screen based.
  70213. */
  70214. get objectBasedMotionBlur(): boolean;
  70215. /**
  70216. * Sets wether or not the motion blur post-process should be object based or screen based
  70217. */
  70218. set objectBasedMotionBlur(value: boolean);
  70219. /**
  70220. * List of animations for the pipeline (IAnimatable implementation)
  70221. */
  70222. animations: Animation[];
  70223. /**
  70224. * Private members
  70225. */
  70226. private _scene;
  70227. private _currentDepthOfFieldSource;
  70228. private _basePostProcess;
  70229. private _fixedExposure;
  70230. private _currentExposure;
  70231. private _hdrAutoExposure;
  70232. private _hdrCurrentLuminance;
  70233. private _motionStrength;
  70234. private _isObjectBasedMotionBlur;
  70235. private _floatTextureType;
  70236. private _camerasToBeAttached;
  70237. private _ratio;
  70238. private _bloomEnabled;
  70239. private _depthOfFieldEnabled;
  70240. private _vlsEnabled;
  70241. private _lensFlareEnabled;
  70242. private _hdrEnabled;
  70243. private _motionBlurEnabled;
  70244. private _fxaaEnabled;
  70245. private _screenSpaceReflectionsEnabled;
  70246. private _motionBlurSamples;
  70247. private _volumetricLightStepsCount;
  70248. private _samples;
  70249. /**
  70250. * @ignore
  70251. * Specifies if the bloom pipeline is enabled
  70252. */
  70253. get BloomEnabled(): boolean;
  70254. set BloomEnabled(enabled: boolean);
  70255. /**
  70256. * @ignore
  70257. * Specifies if the depth of field pipeline is enabed
  70258. */
  70259. get DepthOfFieldEnabled(): boolean;
  70260. set DepthOfFieldEnabled(enabled: boolean);
  70261. /**
  70262. * @ignore
  70263. * Specifies if the lens flare pipeline is enabed
  70264. */
  70265. get LensFlareEnabled(): boolean;
  70266. set LensFlareEnabled(enabled: boolean);
  70267. /**
  70268. * @ignore
  70269. * Specifies if the HDR pipeline is enabled
  70270. */
  70271. get HDREnabled(): boolean;
  70272. set HDREnabled(enabled: boolean);
  70273. /**
  70274. * @ignore
  70275. * Specifies if the volumetric lights scattering effect is enabled
  70276. */
  70277. get VLSEnabled(): boolean;
  70278. set VLSEnabled(enabled: boolean);
  70279. /**
  70280. * @ignore
  70281. * Specifies if the motion blur effect is enabled
  70282. */
  70283. get MotionBlurEnabled(): boolean;
  70284. set MotionBlurEnabled(enabled: boolean);
  70285. /**
  70286. * Specifies if anti-aliasing is enabled
  70287. */
  70288. get fxaaEnabled(): boolean;
  70289. set fxaaEnabled(enabled: boolean);
  70290. /**
  70291. * Specifies if screen space reflections are enabled.
  70292. */
  70293. get screenSpaceReflectionsEnabled(): boolean;
  70294. set screenSpaceReflectionsEnabled(enabled: boolean);
  70295. /**
  70296. * Specifies the number of steps used to calculate the volumetric lights
  70297. * Typically in interval [50, 200]
  70298. */
  70299. get volumetricLightStepsCount(): number;
  70300. set volumetricLightStepsCount(count: number);
  70301. /**
  70302. * Specifies the number of samples used for the motion blur effect
  70303. * Typically in interval [16, 64]
  70304. */
  70305. get motionBlurSamples(): number;
  70306. set motionBlurSamples(samples: number);
  70307. /**
  70308. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70309. */
  70310. get samples(): number;
  70311. set samples(sampleCount: number);
  70312. /**
  70313. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70314. * @constructor
  70315. * @param name The rendering pipeline name
  70316. * @param scene The scene linked to this pipeline
  70317. * @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)
  70318. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70319. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70320. */
  70321. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70322. private _buildPipeline;
  70323. private _createDownSampleX4PostProcess;
  70324. private _createBrightPassPostProcess;
  70325. private _createBlurPostProcesses;
  70326. private _createTextureAdderPostProcess;
  70327. private _createVolumetricLightPostProcess;
  70328. private _createLuminancePostProcesses;
  70329. private _createHdrPostProcess;
  70330. private _createLensFlarePostProcess;
  70331. private _createDepthOfFieldPostProcess;
  70332. private _createMotionBlurPostProcess;
  70333. private _getDepthTexture;
  70334. private _disposePostProcesses;
  70335. /**
  70336. * Dispose of the pipeline and stop all post processes
  70337. */
  70338. dispose(): void;
  70339. /**
  70340. * Serialize the rendering pipeline (Used when exporting)
  70341. * @returns the serialized object
  70342. */
  70343. serialize(): any;
  70344. /**
  70345. * Parse the serialized pipeline
  70346. * @param source Source pipeline.
  70347. * @param scene The scene to load the pipeline to.
  70348. * @param rootUrl The URL of the serialized pipeline.
  70349. * @returns An instantiated pipeline from the serialized object.
  70350. */
  70351. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70352. /**
  70353. * Luminance steps
  70354. */
  70355. static LuminanceSteps: number;
  70356. }
  70357. }
  70358. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70359. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70360. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70361. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70362. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70363. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70364. }
  70365. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70366. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70367. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70368. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70369. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70370. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70371. }
  70372. declare module "babylonjs/Shaders/tonemap.fragment" {
  70373. /** @hidden */
  70374. export var tonemapPixelShader: {
  70375. name: string;
  70376. shader: string;
  70377. };
  70378. }
  70379. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70380. import { Camera } from "babylonjs/Cameras/camera";
  70381. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70382. import "babylonjs/Shaders/tonemap.fragment";
  70383. import { Engine } from "babylonjs/Engines/engine";
  70384. /** Defines operator used for tonemapping */
  70385. export enum TonemappingOperator {
  70386. /** Hable */
  70387. Hable = 0,
  70388. /** Reinhard */
  70389. Reinhard = 1,
  70390. /** HejiDawson */
  70391. HejiDawson = 2,
  70392. /** Photographic */
  70393. Photographic = 3
  70394. }
  70395. /**
  70396. * Defines a post process to apply tone mapping
  70397. */
  70398. export class TonemapPostProcess extends PostProcess {
  70399. private _operator;
  70400. /** Defines the required exposure adjustement */
  70401. exposureAdjustment: number;
  70402. /**
  70403. * Creates a new TonemapPostProcess
  70404. * @param name defines the name of the postprocess
  70405. * @param _operator defines the operator to use
  70406. * @param exposureAdjustment defines the required exposure adjustement
  70407. * @param camera defines the camera to use (can be null)
  70408. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70409. * @param engine defines the hosting engine (can be ignore if camera is set)
  70410. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70411. */
  70412. constructor(name: string, _operator: TonemappingOperator,
  70413. /** Defines the required exposure adjustement */
  70414. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70415. }
  70416. }
  70417. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70418. /** @hidden */
  70419. export var volumetricLightScatteringPixelShader: {
  70420. name: string;
  70421. shader: string;
  70422. };
  70423. }
  70424. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70425. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70427. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70428. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70429. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70430. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70431. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70432. /** @hidden */
  70433. export var volumetricLightScatteringPassVertexShader: {
  70434. name: string;
  70435. shader: string;
  70436. };
  70437. }
  70438. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70439. /** @hidden */
  70440. export var volumetricLightScatteringPassPixelShader: {
  70441. name: string;
  70442. shader: string;
  70443. };
  70444. }
  70445. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70446. import { Vector3 } from "babylonjs/Maths/math.vector";
  70447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70448. import { Mesh } from "babylonjs/Meshes/mesh";
  70449. import { Camera } from "babylonjs/Cameras/camera";
  70450. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70451. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70452. import { Scene } from "babylonjs/scene";
  70453. import "babylonjs/Meshes/Builders/planeBuilder";
  70454. import "babylonjs/Shaders/depth.vertex";
  70455. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70456. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70457. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70458. import { Engine } from "babylonjs/Engines/engine";
  70459. /**
  70460. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70461. */
  70462. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70463. private _volumetricLightScatteringPass;
  70464. private _volumetricLightScatteringRTT;
  70465. private _viewPort;
  70466. private _screenCoordinates;
  70467. private _cachedDefines;
  70468. /**
  70469. * If not undefined, the mesh position is computed from the attached node position
  70470. */
  70471. attachedNode: {
  70472. position: Vector3;
  70473. };
  70474. /**
  70475. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70476. */
  70477. customMeshPosition: Vector3;
  70478. /**
  70479. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70480. */
  70481. useCustomMeshPosition: boolean;
  70482. /**
  70483. * If the post-process should inverse the light scattering direction
  70484. */
  70485. invert: boolean;
  70486. /**
  70487. * The internal mesh used by the post-process
  70488. */
  70489. mesh: Mesh;
  70490. /**
  70491. * @hidden
  70492. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70493. */
  70494. get useDiffuseColor(): boolean;
  70495. set useDiffuseColor(useDiffuseColor: boolean);
  70496. /**
  70497. * Array containing the excluded meshes not rendered in the internal pass
  70498. */
  70499. excludedMeshes: AbstractMesh[];
  70500. /**
  70501. * Controls the overall intensity of the post-process
  70502. */
  70503. exposure: number;
  70504. /**
  70505. * Dissipates each sample's contribution in range [0, 1]
  70506. */
  70507. decay: number;
  70508. /**
  70509. * Controls the overall intensity of each sample
  70510. */
  70511. weight: number;
  70512. /**
  70513. * Controls the density of each sample
  70514. */
  70515. density: number;
  70516. /**
  70517. * @constructor
  70518. * @param name The post-process name
  70519. * @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)
  70520. * @param camera The camera that the post-process will be attached to
  70521. * @param mesh The mesh used to create the light scattering
  70522. * @param samples The post-process quality, default 100
  70523. * @param samplingModeThe post-process filtering mode
  70524. * @param engine The babylon engine
  70525. * @param reusable If the post-process is reusable
  70526. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70527. */
  70528. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70529. /**
  70530. * Returns the string "VolumetricLightScatteringPostProcess"
  70531. * @returns "VolumetricLightScatteringPostProcess"
  70532. */
  70533. getClassName(): string;
  70534. private _isReady;
  70535. /**
  70536. * Sets the new light position for light scattering effect
  70537. * @param position The new custom light position
  70538. */
  70539. setCustomMeshPosition(position: Vector3): void;
  70540. /**
  70541. * Returns the light position for light scattering effect
  70542. * @return Vector3 The custom light position
  70543. */
  70544. getCustomMeshPosition(): Vector3;
  70545. /**
  70546. * Disposes the internal assets and detaches the post-process from the camera
  70547. */
  70548. dispose(camera: Camera): void;
  70549. /**
  70550. * Returns the render target texture used by the post-process
  70551. * @return the render target texture used by the post-process
  70552. */
  70553. getPass(): RenderTargetTexture;
  70554. private _meshExcluded;
  70555. private _createPass;
  70556. private _updateMeshScreenCoordinates;
  70557. /**
  70558. * Creates a default mesh for the Volumeric Light Scattering post-process
  70559. * @param name The mesh name
  70560. * @param scene The scene where to create the mesh
  70561. * @return the default mesh
  70562. */
  70563. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70564. }
  70565. }
  70566. declare module "babylonjs/PostProcesses/index" {
  70567. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70568. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70569. export * from "babylonjs/PostProcesses/bloomEffect";
  70570. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70571. export * from "babylonjs/PostProcesses/blurPostProcess";
  70572. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70573. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70574. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70575. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70576. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70577. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70578. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70579. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70580. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70581. export * from "babylonjs/PostProcesses/filterPostProcess";
  70582. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70583. export * from "babylonjs/PostProcesses/grainPostProcess";
  70584. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70585. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70586. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70587. export * from "babylonjs/PostProcesses/passPostProcess";
  70588. export * from "babylonjs/PostProcesses/postProcess";
  70589. export * from "babylonjs/PostProcesses/postProcessManager";
  70590. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70591. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70592. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70593. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70594. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70595. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70596. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70597. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70598. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70599. }
  70600. declare module "babylonjs/Probes/index" {
  70601. export * from "babylonjs/Probes/reflectionProbe";
  70602. }
  70603. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70604. import { Scene } from "babylonjs/scene";
  70605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70606. import { SmartArray } from "babylonjs/Misc/smartArray";
  70607. import { ISceneComponent } from "babylonjs/sceneComponent";
  70608. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70609. import "babylonjs/Meshes/Builders/boxBuilder";
  70610. import "babylonjs/Shaders/color.fragment";
  70611. import "babylonjs/Shaders/color.vertex";
  70612. import { Color3 } from "babylonjs/Maths/math.color";
  70613. module "babylonjs/scene" {
  70614. interface Scene {
  70615. /** @hidden (Backing field) */
  70616. _boundingBoxRenderer: BoundingBoxRenderer;
  70617. /** @hidden (Backing field) */
  70618. _forceShowBoundingBoxes: boolean;
  70619. /**
  70620. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70621. */
  70622. forceShowBoundingBoxes: boolean;
  70623. /**
  70624. * Gets the bounding box renderer associated with the scene
  70625. * @returns a BoundingBoxRenderer
  70626. */
  70627. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70628. }
  70629. }
  70630. module "babylonjs/Meshes/abstractMesh" {
  70631. interface AbstractMesh {
  70632. /** @hidden (Backing field) */
  70633. _showBoundingBox: boolean;
  70634. /**
  70635. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70636. */
  70637. showBoundingBox: boolean;
  70638. }
  70639. }
  70640. /**
  70641. * Component responsible of rendering the bounding box of the meshes in a scene.
  70642. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70643. */
  70644. export class BoundingBoxRenderer implements ISceneComponent {
  70645. /**
  70646. * The component name helpfull to identify the component in the list of scene components.
  70647. */
  70648. readonly name: string;
  70649. /**
  70650. * The scene the component belongs to.
  70651. */
  70652. scene: Scene;
  70653. /**
  70654. * Color of the bounding box lines placed in front of an object
  70655. */
  70656. frontColor: Color3;
  70657. /**
  70658. * Color of the bounding box lines placed behind an object
  70659. */
  70660. backColor: Color3;
  70661. /**
  70662. * Defines if the renderer should show the back lines or not
  70663. */
  70664. showBackLines: boolean;
  70665. /**
  70666. * @hidden
  70667. */
  70668. renderList: SmartArray<BoundingBox>;
  70669. private _colorShader;
  70670. private _vertexBuffers;
  70671. private _indexBuffer;
  70672. private _fillIndexBuffer;
  70673. private _fillIndexData;
  70674. /**
  70675. * Instantiates a new bounding box renderer in a scene.
  70676. * @param scene the scene the renderer renders in
  70677. */
  70678. constructor(scene: Scene);
  70679. /**
  70680. * Registers the component in a given scene
  70681. */
  70682. register(): void;
  70683. private _evaluateSubMesh;
  70684. private _activeMesh;
  70685. private _prepareRessources;
  70686. private _createIndexBuffer;
  70687. /**
  70688. * Rebuilds the elements related to this component in case of
  70689. * context lost for instance.
  70690. */
  70691. rebuild(): void;
  70692. /**
  70693. * @hidden
  70694. */
  70695. reset(): void;
  70696. /**
  70697. * Render the bounding boxes of a specific rendering group
  70698. * @param renderingGroupId defines the rendering group to render
  70699. */
  70700. render(renderingGroupId: number): void;
  70701. /**
  70702. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70703. * @param mesh Define the mesh to render the occlusion bounding box for
  70704. */
  70705. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70706. /**
  70707. * Dispose and release the resources attached to this renderer.
  70708. */
  70709. dispose(): void;
  70710. }
  70711. }
  70712. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70713. import { Nullable } from "babylonjs/types";
  70714. import { Scene } from "babylonjs/scene";
  70715. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70716. import { Camera } from "babylonjs/Cameras/camera";
  70717. import { ISceneComponent } from "babylonjs/sceneComponent";
  70718. module "babylonjs/scene" {
  70719. interface Scene {
  70720. /** @hidden (Backing field) */
  70721. _depthRenderer: {
  70722. [id: string]: DepthRenderer;
  70723. };
  70724. /**
  70725. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70726. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70727. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70728. * @returns the created depth renderer
  70729. */
  70730. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70731. /**
  70732. * Disables a depth renderer for a given camera
  70733. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70734. */
  70735. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70736. }
  70737. }
  70738. /**
  70739. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70740. * in several rendering techniques.
  70741. */
  70742. export class DepthRendererSceneComponent implements ISceneComponent {
  70743. /**
  70744. * The component name helpfull to identify the component in the list of scene components.
  70745. */
  70746. readonly name: string;
  70747. /**
  70748. * The scene the component belongs to.
  70749. */
  70750. scene: Scene;
  70751. /**
  70752. * Creates a new instance of the component for the given scene
  70753. * @param scene Defines the scene to register the component in
  70754. */
  70755. constructor(scene: Scene);
  70756. /**
  70757. * Registers the component in a given scene
  70758. */
  70759. register(): void;
  70760. /**
  70761. * Rebuilds the elements related to this component in case of
  70762. * context lost for instance.
  70763. */
  70764. rebuild(): void;
  70765. /**
  70766. * Disposes the component and the associated ressources
  70767. */
  70768. dispose(): void;
  70769. private _gatherRenderTargets;
  70770. private _gatherActiveCameraRenderTargets;
  70771. }
  70772. }
  70773. declare module "babylonjs/Shaders/outline.fragment" {
  70774. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70775. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70776. /** @hidden */
  70777. export var outlinePixelShader: {
  70778. name: string;
  70779. shader: string;
  70780. };
  70781. }
  70782. declare module "babylonjs/Shaders/outline.vertex" {
  70783. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70784. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70785. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70786. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70787. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70788. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70789. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70790. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70791. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70792. /** @hidden */
  70793. export var outlineVertexShader: {
  70794. name: string;
  70795. shader: string;
  70796. };
  70797. }
  70798. declare module "babylonjs/Rendering/outlineRenderer" {
  70799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70800. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70801. import { Scene } from "babylonjs/scene";
  70802. import { ISceneComponent } from "babylonjs/sceneComponent";
  70803. import "babylonjs/Shaders/outline.fragment";
  70804. import "babylonjs/Shaders/outline.vertex";
  70805. module "babylonjs/scene" {
  70806. interface Scene {
  70807. /** @hidden */
  70808. _outlineRenderer: OutlineRenderer;
  70809. /**
  70810. * Gets the outline renderer associated with the scene
  70811. * @returns a OutlineRenderer
  70812. */
  70813. getOutlineRenderer(): OutlineRenderer;
  70814. }
  70815. }
  70816. module "babylonjs/Meshes/abstractMesh" {
  70817. interface AbstractMesh {
  70818. /** @hidden (Backing field) */
  70819. _renderOutline: boolean;
  70820. /**
  70821. * Gets or sets a boolean indicating if the outline must be rendered as well
  70822. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70823. */
  70824. renderOutline: boolean;
  70825. /** @hidden (Backing field) */
  70826. _renderOverlay: boolean;
  70827. /**
  70828. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70829. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70830. */
  70831. renderOverlay: boolean;
  70832. }
  70833. }
  70834. /**
  70835. * This class is responsible to draw bothe outline/overlay of meshes.
  70836. * It should not be used directly but through the available method on mesh.
  70837. */
  70838. export class OutlineRenderer implements ISceneComponent {
  70839. /**
  70840. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70841. */
  70842. private static _StencilReference;
  70843. /**
  70844. * The name of the component. Each component must have a unique name.
  70845. */
  70846. name: string;
  70847. /**
  70848. * The scene the component belongs to.
  70849. */
  70850. scene: Scene;
  70851. /**
  70852. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70853. */
  70854. zOffset: number;
  70855. private _engine;
  70856. private _effect;
  70857. private _cachedDefines;
  70858. private _savedDepthWrite;
  70859. /**
  70860. * Instantiates a new outline renderer. (There could be only one per scene).
  70861. * @param scene Defines the scene it belongs to
  70862. */
  70863. constructor(scene: Scene);
  70864. /**
  70865. * Register the component to one instance of a scene.
  70866. */
  70867. register(): void;
  70868. /**
  70869. * Rebuilds the elements related to this component in case of
  70870. * context lost for instance.
  70871. */
  70872. rebuild(): void;
  70873. /**
  70874. * Disposes the component and the associated ressources.
  70875. */
  70876. dispose(): void;
  70877. /**
  70878. * Renders the outline in the canvas.
  70879. * @param subMesh Defines the sumesh to render
  70880. * @param batch Defines the batch of meshes in case of instances
  70881. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70882. */
  70883. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70884. /**
  70885. * Returns whether or not the outline renderer is ready for a given submesh.
  70886. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70887. * @param subMesh Defines the submesh to check readyness for
  70888. * @param useInstances Defines wheter wee are trying to render instances or not
  70889. * @returns true if ready otherwise false
  70890. */
  70891. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70892. private _beforeRenderingMesh;
  70893. private _afterRenderingMesh;
  70894. }
  70895. }
  70896. declare module "babylonjs/Rendering/index" {
  70897. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70898. export * from "babylonjs/Rendering/depthRenderer";
  70899. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70900. export * from "babylonjs/Rendering/edgesRenderer";
  70901. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70902. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70903. export * from "babylonjs/Rendering/outlineRenderer";
  70904. export * from "babylonjs/Rendering/renderingGroup";
  70905. export * from "babylonjs/Rendering/renderingManager";
  70906. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70907. }
  70908. declare module "babylonjs/Sprites/ISprites" {
  70909. /**
  70910. * Defines the basic options interface of a Sprite Frame Source Size.
  70911. */
  70912. export interface ISpriteJSONSpriteSourceSize {
  70913. /**
  70914. * number of the original width of the Frame
  70915. */
  70916. w: number;
  70917. /**
  70918. * number of the original height of the Frame
  70919. */
  70920. h: number;
  70921. }
  70922. /**
  70923. * Defines the basic options interface of a Sprite Frame Data.
  70924. */
  70925. export interface ISpriteJSONSpriteFrameData {
  70926. /**
  70927. * number of the x offset of the Frame
  70928. */
  70929. x: number;
  70930. /**
  70931. * number of the y offset of the Frame
  70932. */
  70933. y: number;
  70934. /**
  70935. * number of the width of the Frame
  70936. */
  70937. w: number;
  70938. /**
  70939. * number of the height of the Frame
  70940. */
  70941. h: number;
  70942. }
  70943. /**
  70944. * Defines the basic options interface of a JSON Sprite.
  70945. */
  70946. export interface ISpriteJSONSprite {
  70947. /**
  70948. * string name of the Frame
  70949. */
  70950. filename: string;
  70951. /**
  70952. * ISpriteJSONSpriteFrame basic object of the frame data
  70953. */
  70954. frame: ISpriteJSONSpriteFrameData;
  70955. /**
  70956. * boolean to flag is the frame was rotated.
  70957. */
  70958. rotated: boolean;
  70959. /**
  70960. * boolean to flag is the frame was trimmed.
  70961. */
  70962. trimmed: boolean;
  70963. /**
  70964. * ISpriteJSONSpriteFrame basic object of the source data
  70965. */
  70966. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70967. /**
  70968. * ISpriteJSONSpriteFrame basic object of the source data
  70969. */
  70970. sourceSize: ISpriteJSONSpriteSourceSize;
  70971. }
  70972. /**
  70973. * Defines the basic options interface of a JSON atlas.
  70974. */
  70975. export interface ISpriteJSONAtlas {
  70976. /**
  70977. * Array of objects that contain the frame data.
  70978. */
  70979. frames: Array<ISpriteJSONSprite>;
  70980. /**
  70981. * object basic object containing the sprite meta data.
  70982. */
  70983. meta?: object;
  70984. }
  70985. }
  70986. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70987. /** @hidden */
  70988. export var spriteMapPixelShader: {
  70989. name: string;
  70990. shader: string;
  70991. };
  70992. }
  70993. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70994. /** @hidden */
  70995. export var spriteMapVertexShader: {
  70996. name: string;
  70997. shader: string;
  70998. };
  70999. }
  71000. declare module "babylonjs/Sprites/spriteMap" {
  71001. import { IDisposable, Scene } from "babylonjs/scene";
  71002. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  71003. import { Texture } from "babylonjs/Materials/Textures/texture";
  71004. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71005. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  71006. import "babylonjs/Meshes/Builders/planeBuilder";
  71007. import "babylonjs/Shaders/spriteMap.fragment";
  71008. import "babylonjs/Shaders/spriteMap.vertex";
  71009. /**
  71010. * Defines the basic options interface of a SpriteMap
  71011. */
  71012. export interface ISpriteMapOptions {
  71013. /**
  71014. * Vector2 of the number of cells in the grid.
  71015. */
  71016. stageSize?: Vector2;
  71017. /**
  71018. * Vector2 of the size of the output plane in World Units.
  71019. */
  71020. outputSize?: Vector2;
  71021. /**
  71022. * Vector3 of the position of the output plane in World Units.
  71023. */
  71024. outputPosition?: Vector3;
  71025. /**
  71026. * Vector3 of the rotation of the output plane.
  71027. */
  71028. outputRotation?: Vector3;
  71029. /**
  71030. * number of layers that the system will reserve in resources.
  71031. */
  71032. layerCount?: number;
  71033. /**
  71034. * number of max animation frames a single cell will reserve in resources.
  71035. */
  71036. maxAnimationFrames?: number;
  71037. /**
  71038. * number cell index of the base tile when the system compiles.
  71039. */
  71040. baseTile?: number;
  71041. /**
  71042. * boolean flip the sprite after its been repositioned by the framing data.
  71043. */
  71044. flipU?: boolean;
  71045. /**
  71046. * Vector3 scalar of the global RGB values of the SpriteMap.
  71047. */
  71048. colorMultiply?: Vector3;
  71049. }
  71050. /**
  71051. * Defines the IDisposable interface in order to be cleanable from resources.
  71052. */
  71053. export interface ISpriteMap extends IDisposable {
  71054. /**
  71055. * String name of the SpriteMap.
  71056. */
  71057. name: string;
  71058. /**
  71059. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71060. */
  71061. atlasJSON: ISpriteJSONAtlas;
  71062. /**
  71063. * Texture of the SpriteMap.
  71064. */
  71065. spriteSheet: Texture;
  71066. /**
  71067. * The parameters to initialize the SpriteMap with.
  71068. */
  71069. options: ISpriteMapOptions;
  71070. }
  71071. /**
  71072. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71073. */
  71074. export class SpriteMap implements ISpriteMap {
  71075. /** The Name of the spriteMap */
  71076. name: string;
  71077. /** The JSON file with the frame and meta data */
  71078. atlasJSON: ISpriteJSONAtlas;
  71079. /** The systems Sprite Sheet Texture */
  71080. spriteSheet: Texture;
  71081. /** Arguments passed with the Constructor */
  71082. options: ISpriteMapOptions;
  71083. /** Public Sprite Storage array, parsed from atlasJSON */
  71084. sprites: Array<ISpriteJSONSprite>;
  71085. /** Returns the Number of Sprites in the System */
  71086. get spriteCount(): number;
  71087. /** Returns the Position of Output Plane*/
  71088. get position(): Vector3;
  71089. /** Returns the Position of Output Plane*/
  71090. set position(v: Vector3);
  71091. /** Returns the Rotation of Output Plane*/
  71092. get rotation(): Vector3;
  71093. /** Returns the Rotation of Output Plane*/
  71094. set rotation(v: Vector3);
  71095. /** Sets the AnimationMap*/
  71096. get animationMap(): RawTexture;
  71097. /** Sets the AnimationMap*/
  71098. set animationMap(v: RawTexture);
  71099. /** Scene that the SpriteMap was created in */
  71100. private _scene;
  71101. /** Texture Buffer of Float32 that holds tile frame data*/
  71102. private _frameMap;
  71103. /** Texture Buffers of Float32 that holds tileMap data*/
  71104. private _tileMaps;
  71105. /** Texture Buffer of Float32 that holds Animation Data*/
  71106. private _animationMap;
  71107. /** Custom ShaderMaterial Central to the System*/
  71108. private _material;
  71109. /** Custom ShaderMaterial Central to the System*/
  71110. private _output;
  71111. /** Systems Time Ticker*/
  71112. private _time;
  71113. /**
  71114. * Creates a new SpriteMap
  71115. * @param name defines the SpriteMaps Name
  71116. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71117. * @param spriteSheet is the Texture that the Sprites are on.
  71118. * @param options a basic deployment configuration
  71119. * @param scene The Scene that the map is deployed on
  71120. */
  71121. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71122. /**
  71123. * Returns tileID location
  71124. * @returns Vector2 the cell position ID
  71125. */
  71126. getTileID(): Vector2;
  71127. /**
  71128. * Gets the UV location of the mouse over the SpriteMap.
  71129. * @returns Vector2 the UV position of the mouse interaction
  71130. */
  71131. getMousePosition(): Vector2;
  71132. /**
  71133. * Creates the "frame" texture Buffer
  71134. * -------------------------------------
  71135. * Structure of frames
  71136. * "filename": "Falling-Water-2.png",
  71137. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71138. * "rotated": true,
  71139. * "trimmed": true,
  71140. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71141. * "sourceSize": {"w":32,"h":32}
  71142. * @returns RawTexture of the frameMap
  71143. */
  71144. private _createFrameBuffer;
  71145. /**
  71146. * Creates the tileMap texture Buffer
  71147. * @param buffer normally and array of numbers, or a false to generate from scratch
  71148. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71149. * @returns RawTexture of the tileMap
  71150. */
  71151. private _createTileBuffer;
  71152. /**
  71153. * Modifies the data of the tileMaps
  71154. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71155. * @param pos is the iVector2 Coordinates of the Tile
  71156. * @param tile The SpriteIndex of the new Tile
  71157. */
  71158. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71159. /**
  71160. * Creates the animationMap texture Buffer
  71161. * @param buffer normally and array of numbers, or a false to generate from scratch
  71162. * @returns RawTexture of the animationMap
  71163. */
  71164. private _createTileAnimationBuffer;
  71165. /**
  71166. * Modifies the data of the animationMap
  71167. * @param cellID is the Index of the Sprite
  71168. * @param _frame is the target Animation frame
  71169. * @param toCell is the Target Index of the next frame of the animation
  71170. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71171. * @param speed is a global scalar of the time variable on the map.
  71172. */
  71173. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71174. /**
  71175. * Exports the .tilemaps file
  71176. */
  71177. saveTileMaps(): void;
  71178. /**
  71179. * Imports the .tilemaps file
  71180. * @param url of the .tilemaps file
  71181. */
  71182. loadTileMaps(url: string): void;
  71183. /**
  71184. * Release associated resources
  71185. */
  71186. dispose(): void;
  71187. }
  71188. }
  71189. declare module "babylonjs/Sprites/spritePackedManager" {
  71190. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  71191. import { Scene } from "babylonjs/scene";
  71192. /**
  71193. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71194. * @see http://doc.babylonjs.com/babylon101/sprites
  71195. */
  71196. export class SpritePackedManager extends SpriteManager {
  71197. /** defines the packed manager's name */
  71198. name: string;
  71199. /**
  71200. * Creates a new sprite manager from a packed sprite sheet
  71201. * @param name defines the manager's name
  71202. * @param imgUrl defines the sprite sheet url
  71203. * @param capacity defines the maximum allowed number of sprites
  71204. * @param scene defines the hosting scene
  71205. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71206. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71207. * @param samplingMode defines the smapling mode to use with spritesheet
  71208. * @param fromPacked set to true; do not alter
  71209. */
  71210. constructor(
  71211. /** defines the packed manager's name */
  71212. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71213. }
  71214. }
  71215. declare module "babylonjs/Sprites/index" {
  71216. export * from "babylonjs/Sprites/sprite";
  71217. export * from "babylonjs/Sprites/ISprites";
  71218. export * from "babylonjs/Sprites/spriteManager";
  71219. export * from "babylonjs/Sprites/spriteMap";
  71220. export * from "babylonjs/Sprites/spritePackedManager";
  71221. export * from "babylonjs/Sprites/spriteSceneComponent";
  71222. }
  71223. declare module "babylonjs/States/index" {
  71224. export * from "babylonjs/States/alphaCullingState";
  71225. export * from "babylonjs/States/depthCullingState";
  71226. export * from "babylonjs/States/stencilState";
  71227. }
  71228. declare module "babylonjs/Misc/assetsManager" {
  71229. import { Scene } from "babylonjs/scene";
  71230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71231. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71232. import { Skeleton } from "babylonjs/Bones/skeleton";
  71233. import { Observable } from "babylonjs/Misc/observable";
  71234. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71235. import { Texture } from "babylonjs/Materials/Textures/texture";
  71236. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  71237. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  71238. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  71239. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  71240. /**
  71241. * Defines the list of states available for a task inside a AssetsManager
  71242. */
  71243. export enum AssetTaskState {
  71244. /**
  71245. * Initialization
  71246. */
  71247. INIT = 0,
  71248. /**
  71249. * Running
  71250. */
  71251. RUNNING = 1,
  71252. /**
  71253. * Done
  71254. */
  71255. DONE = 2,
  71256. /**
  71257. * Error
  71258. */
  71259. ERROR = 3
  71260. }
  71261. /**
  71262. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71263. */
  71264. export abstract class AbstractAssetTask {
  71265. /**
  71266. * Task name
  71267. */ name: string;
  71268. /**
  71269. * Callback called when the task is successful
  71270. */
  71271. onSuccess: (task: any) => void;
  71272. /**
  71273. * Callback called when the task is not successful
  71274. */
  71275. onError: (task: any, message?: string, exception?: any) => void;
  71276. /**
  71277. * Creates a new AssetsManager
  71278. * @param name defines the name of the task
  71279. */
  71280. constructor(
  71281. /**
  71282. * Task name
  71283. */ name: string);
  71284. private _isCompleted;
  71285. private _taskState;
  71286. private _errorObject;
  71287. /**
  71288. * Get if the task is completed
  71289. */
  71290. get isCompleted(): boolean;
  71291. /**
  71292. * Gets the current state of the task
  71293. */
  71294. get taskState(): AssetTaskState;
  71295. /**
  71296. * Gets the current error object (if task is in error)
  71297. */
  71298. get errorObject(): {
  71299. message?: string;
  71300. exception?: any;
  71301. };
  71302. /**
  71303. * Internal only
  71304. * @hidden
  71305. */
  71306. _setErrorObject(message?: string, exception?: any): void;
  71307. /**
  71308. * Execute the current task
  71309. * @param scene defines the scene where you want your assets to be loaded
  71310. * @param onSuccess is a callback called when the task is successfully executed
  71311. * @param onError is a callback called if an error occurs
  71312. */
  71313. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71314. /**
  71315. * Execute the current task
  71316. * @param scene defines the scene where you want your assets to be loaded
  71317. * @param onSuccess is a callback called when the task is successfully executed
  71318. * @param onError is a callback called if an error occurs
  71319. */
  71320. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71321. /**
  71322. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71323. * This can be used with failed tasks that have the reason for failure fixed.
  71324. */
  71325. reset(): void;
  71326. private onErrorCallback;
  71327. private onDoneCallback;
  71328. }
  71329. /**
  71330. * Define the interface used by progress events raised during assets loading
  71331. */
  71332. export interface IAssetsProgressEvent {
  71333. /**
  71334. * Defines the number of remaining tasks to process
  71335. */
  71336. remainingCount: number;
  71337. /**
  71338. * Defines the total number of tasks
  71339. */
  71340. totalCount: number;
  71341. /**
  71342. * Defines the task that was just processed
  71343. */
  71344. task: AbstractAssetTask;
  71345. }
  71346. /**
  71347. * Class used to share progress information about assets loading
  71348. */
  71349. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71350. /**
  71351. * Defines the number of remaining tasks to process
  71352. */
  71353. remainingCount: number;
  71354. /**
  71355. * Defines the total number of tasks
  71356. */
  71357. totalCount: number;
  71358. /**
  71359. * Defines the task that was just processed
  71360. */
  71361. task: AbstractAssetTask;
  71362. /**
  71363. * Creates a AssetsProgressEvent
  71364. * @param remainingCount defines the number of remaining tasks to process
  71365. * @param totalCount defines the total number of tasks
  71366. * @param task defines the task that was just processed
  71367. */
  71368. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71369. }
  71370. /**
  71371. * Define a task used by AssetsManager to load meshes
  71372. */
  71373. export class MeshAssetTask extends AbstractAssetTask {
  71374. /**
  71375. * Defines the name of the task
  71376. */
  71377. name: string;
  71378. /**
  71379. * Defines the list of mesh's names you want to load
  71380. */
  71381. meshesNames: any;
  71382. /**
  71383. * Defines the root url to use as a base to load your meshes and associated resources
  71384. */
  71385. rootUrl: string;
  71386. /**
  71387. * Defines the filename of the scene to load from
  71388. */
  71389. sceneFilename: string;
  71390. /**
  71391. * Gets the list of loaded meshes
  71392. */
  71393. loadedMeshes: Array<AbstractMesh>;
  71394. /**
  71395. * Gets the list of loaded particle systems
  71396. */
  71397. loadedParticleSystems: Array<IParticleSystem>;
  71398. /**
  71399. * Gets the list of loaded skeletons
  71400. */
  71401. loadedSkeletons: Array<Skeleton>;
  71402. /**
  71403. * Gets the list of loaded animation groups
  71404. */
  71405. loadedAnimationGroups: Array<AnimationGroup>;
  71406. /**
  71407. * Callback called when the task is successful
  71408. */
  71409. onSuccess: (task: MeshAssetTask) => void;
  71410. /**
  71411. * Callback called when the task is successful
  71412. */
  71413. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71414. /**
  71415. * Creates a new MeshAssetTask
  71416. * @param name defines the name of the task
  71417. * @param meshesNames defines the list of mesh's names you want to load
  71418. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71419. * @param sceneFilename defines the filename of the scene to load from
  71420. */
  71421. constructor(
  71422. /**
  71423. * Defines the name of the task
  71424. */
  71425. name: string,
  71426. /**
  71427. * Defines the list of mesh's names you want to load
  71428. */
  71429. meshesNames: any,
  71430. /**
  71431. * Defines the root url to use as a base to load your meshes and associated resources
  71432. */
  71433. rootUrl: string,
  71434. /**
  71435. * Defines the filename of the scene to load from
  71436. */
  71437. sceneFilename: string);
  71438. /**
  71439. * Execute the current task
  71440. * @param scene defines the scene where you want your assets to be loaded
  71441. * @param onSuccess is a callback called when the task is successfully executed
  71442. * @param onError is a callback called if an error occurs
  71443. */
  71444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71445. }
  71446. /**
  71447. * Define a task used by AssetsManager to load text content
  71448. */
  71449. export class TextFileAssetTask extends AbstractAssetTask {
  71450. /**
  71451. * Defines the name of the task
  71452. */
  71453. name: string;
  71454. /**
  71455. * Defines the location of the file to load
  71456. */
  71457. url: string;
  71458. /**
  71459. * Gets the loaded text string
  71460. */
  71461. text: string;
  71462. /**
  71463. * Callback called when the task is successful
  71464. */
  71465. onSuccess: (task: TextFileAssetTask) => void;
  71466. /**
  71467. * Callback called when the task is successful
  71468. */
  71469. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71470. /**
  71471. * Creates a new TextFileAssetTask object
  71472. * @param name defines the name of the task
  71473. * @param url defines the location of the file to load
  71474. */
  71475. constructor(
  71476. /**
  71477. * Defines the name of the task
  71478. */
  71479. name: string,
  71480. /**
  71481. * Defines the location of the file to load
  71482. */
  71483. url: string);
  71484. /**
  71485. * Execute the current task
  71486. * @param scene defines the scene where you want your assets to be loaded
  71487. * @param onSuccess is a callback called when the task is successfully executed
  71488. * @param onError is a callback called if an error occurs
  71489. */
  71490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71491. }
  71492. /**
  71493. * Define a task used by AssetsManager to load binary data
  71494. */
  71495. export class BinaryFileAssetTask extends AbstractAssetTask {
  71496. /**
  71497. * Defines the name of the task
  71498. */
  71499. name: string;
  71500. /**
  71501. * Defines the location of the file to load
  71502. */
  71503. url: string;
  71504. /**
  71505. * Gets the lodaded data (as an array buffer)
  71506. */
  71507. data: ArrayBuffer;
  71508. /**
  71509. * Callback called when the task is successful
  71510. */
  71511. onSuccess: (task: BinaryFileAssetTask) => void;
  71512. /**
  71513. * Callback called when the task is successful
  71514. */
  71515. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71516. /**
  71517. * Creates a new BinaryFileAssetTask object
  71518. * @param name defines the name of the new task
  71519. * @param url defines the location of the file to load
  71520. */
  71521. constructor(
  71522. /**
  71523. * Defines the name of the task
  71524. */
  71525. name: string,
  71526. /**
  71527. * Defines the location of the file to load
  71528. */
  71529. url: string);
  71530. /**
  71531. * Execute the current task
  71532. * @param scene defines the scene where you want your assets to be loaded
  71533. * @param onSuccess is a callback called when the task is successfully executed
  71534. * @param onError is a callback called if an error occurs
  71535. */
  71536. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71537. }
  71538. /**
  71539. * Define a task used by AssetsManager to load images
  71540. */
  71541. export class ImageAssetTask extends AbstractAssetTask {
  71542. /**
  71543. * Defines the name of the task
  71544. */
  71545. name: string;
  71546. /**
  71547. * Defines the location of the image to load
  71548. */
  71549. url: string;
  71550. /**
  71551. * Gets the loaded images
  71552. */
  71553. image: HTMLImageElement;
  71554. /**
  71555. * Callback called when the task is successful
  71556. */
  71557. onSuccess: (task: ImageAssetTask) => void;
  71558. /**
  71559. * Callback called when the task is successful
  71560. */
  71561. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71562. /**
  71563. * Creates a new ImageAssetTask
  71564. * @param name defines the name of the task
  71565. * @param url defines the location of the image to load
  71566. */
  71567. constructor(
  71568. /**
  71569. * Defines the name of the task
  71570. */
  71571. name: string,
  71572. /**
  71573. * Defines the location of the image to load
  71574. */
  71575. url: string);
  71576. /**
  71577. * Execute the current task
  71578. * @param scene defines the scene where you want your assets to be loaded
  71579. * @param onSuccess is a callback called when the task is successfully executed
  71580. * @param onError is a callback called if an error occurs
  71581. */
  71582. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71583. }
  71584. /**
  71585. * Defines the interface used by texture loading tasks
  71586. */
  71587. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71588. /**
  71589. * Gets the loaded texture
  71590. */
  71591. texture: TEX;
  71592. }
  71593. /**
  71594. * Define a task used by AssetsManager to load 2D textures
  71595. */
  71596. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71597. /**
  71598. * Defines the name of the task
  71599. */
  71600. name: string;
  71601. /**
  71602. * Defines the location of the file to load
  71603. */
  71604. url: string;
  71605. /**
  71606. * Defines if mipmap should not be generated (default is false)
  71607. */
  71608. noMipmap?: boolean | undefined;
  71609. /**
  71610. * Defines if texture must be inverted on Y axis (default is false)
  71611. */
  71612. invertY?: boolean | undefined;
  71613. /**
  71614. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71615. */
  71616. samplingMode: number;
  71617. /**
  71618. * Gets the loaded texture
  71619. */
  71620. texture: Texture;
  71621. /**
  71622. * Callback called when the task is successful
  71623. */
  71624. onSuccess: (task: TextureAssetTask) => void;
  71625. /**
  71626. * Callback called when the task is successful
  71627. */
  71628. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71629. /**
  71630. * Creates a new TextureAssetTask object
  71631. * @param name defines the name of the task
  71632. * @param url defines the location of the file to load
  71633. * @param noMipmap defines if mipmap should not be generated (default is false)
  71634. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71635. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71636. */
  71637. constructor(
  71638. /**
  71639. * Defines the name of the task
  71640. */
  71641. name: string,
  71642. /**
  71643. * Defines the location of the file to load
  71644. */
  71645. url: string,
  71646. /**
  71647. * Defines if mipmap should not be generated (default is false)
  71648. */
  71649. noMipmap?: boolean | undefined,
  71650. /**
  71651. * Defines if texture must be inverted on Y axis (default is false)
  71652. */
  71653. invertY?: boolean | undefined,
  71654. /**
  71655. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71656. */
  71657. samplingMode?: number);
  71658. /**
  71659. * Execute the current task
  71660. * @param scene defines the scene where you want your assets to be loaded
  71661. * @param onSuccess is a callback called when the task is successfully executed
  71662. * @param onError is a callback called if an error occurs
  71663. */
  71664. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71665. }
  71666. /**
  71667. * Define a task used by AssetsManager to load cube textures
  71668. */
  71669. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71670. /**
  71671. * Defines the name of the task
  71672. */
  71673. name: string;
  71674. /**
  71675. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71676. */
  71677. url: string;
  71678. /**
  71679. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71680. */
  71681. extensions?: string[] | undefined;
  71682. /**
  71683. * Defines if mipmaps should not be generated (default is false)
  71684. */
  71685. noMipmap?: boolean | undefined;
  71686. /**
  71687. * Defines the explicit list of files (undefined by default)
  71688. */
  71689. files?: string[] | undefined;
  71690. /**
  71691. * Gets the loaded texture
  71692. */
  71693. texture: CubeTexture;
  71694. /**
  71695. * Callback called when the task is successful
  71696. */
  71697. onSuccess: (task: CubeTextureAssetTask) => void;
  71698. /**
  71699. * Callback called when the task is successful
  71700. */
  71701. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71702. /**
  71703. * Creates a new CubeTextureAssetTask
  71704. * @param name defines the name of the task
  71705. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71706. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71707. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71708. * @param files defines the explicit list of files (undefined by default)
  71709. */
  71710. constructor(
  71711. /**
  71712. * Defines the name of the task
  71713. */
  71714. name: string,
  71715. /**
  71716. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71717. */
  71718. url: string,
  71719. /**
  71720. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71721. */
  71722. extensions?: string[] | undefined,
  71723. /**
  71724. * Defines if mipmaps should not be generated (default is false)
  71725. */
  71726. noMipmap?: boolean | undefined,
  71727. /**
  71728. * Defines the explicit list of files (undefined by default)
  71729. */
  71730. files?: string[] | undefined);
  71731. /**
  71732. * Execute the current task
  71733. * @param scene defines the scene where you want your assets to be loaded
  71734. * @param onSuccess is a callback called when the task is successfully executed
  71735. * @param onError is a callback called if an error occurs
  71736. */
  71737. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71738. }
  71739. /**
  71740. * Define a task used by AssetsManager to load HDR cube textures
  71741. */
  71742. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71743. /**
  71744. * Defines the name of the task
  71745. */
  71746. name: string;
  71747. /**
  71748. * Defines the location of the file to load
  71749. */
  71750. url: string;
  71751. /**
  71752. * Defines the desired size (the more it increases the longer the generation will be)
  71753. */
  71754. size: number;
  71755. /**
  71756. * Defines if mipmaps should not be generated (default is false)
  71757. */
  71758. noMipmap: boolean;
  71759. /**
  71760. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71761. */
  71762. generateHarmonics: boolean;
  71763. /**
  71764. * 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)
  71765. */
  71766. gammaSpace: boolean;
  71767. /**
  71768. * Internal Use Only
  71769. */
  71770. reserved: boolean;
  71771. /**
  71772. * Gets the loaded texture
  71773. */
  71774. texture: HDRCubeTexture;
  71775. /**
  71776. * Callback called when the task is successful
  71777. */
  71778. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71779. /**
  71780. * Callback called when the task is successful
  71781. */
  71782. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71783. /**
  71784. * Creates a new HDRCubeTextureAssetTask object
  71785. * @param name defines the name of the task
  71786. * @param url defines the location of the file to load
  71787. * @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.
  71788. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71789. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71790. * @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)
  71791. * @param reserved Internal use only
  71792. */
  71793. constructor(
  71794. /**
  71795. * Defines the name of the task
  71796. */
  71797. name: string,
  71798. /**
  71799. * Defines the location of the file to load
  71800. */
  71801. url: string,
  71802. /**
  71803. * Defines the desired size (the more it increases the longer the generation will be)
  71804. */
  71805. size: number,
  71806. /**
  71807. * Defines if mipmaps should not be generated (default is false)
  71808. */
  71809. noMipmap?: boolean,
  71810. /**
  71811. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71812. */
  71813. generateHarmonics?: boolean,
  71814. /**
  71815. * 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)
  71816. */
  71817. gammaSpace?: boolean,
  71818. /**
  71819. * Internal Use Only
  71820. */
  71821. reserved?: boolean);
  71822. /**
  71823. * Execute the current task
  71824. * @param scene defines the scene where you want your assets to be loaded
  71825. * @param onSuccess is a callback called when the task is successfully executed
  71826. * @param onError is a callback called if an error occurs
  71827. */
  71828. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71829. }
  71830. /**
  71831. * Define a task used by AssetsManager to load Equirectangular cube textures
  71832. */
  71833. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71834. /**
  71835. * Defines the name of the task
  71836. */
  71837. name: string;
  71838. /**
  71839. * Defines the location of the file to load
  71840. */
  71841. url: string;
  71842. /**
  71843. * Defines the desired size (the more it increases the longer the generation will be)
  71844. */
  71845. size: number;
  71846. /**
  71847. * Defines if mipmaps should not be generated (default is false)
  71848. */
  71849. noMipmap: boolean;
  71850. /**
  71851. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71852. * but the standard material would require them in Gamma space) (default is true)
  71853. */
  71854. gammaSpace: boolean;
  71855. /**
  71856. * Gets the loaded texture
  71857. */
  71858. texture: EquiRectangularCubeTexture;
  71859. /**
  71860. * Callback called when the task is successful
  71861. */
  71862. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71863. /**
  71864. * Callback called when the task is successful
  71865. */
  71866. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71867. /**
  71868. * Creates a new EquiRectangularCubeTextureAssetTask object
  71869. * @param name defines the name of the task
  71870. * @param url defines the location of the file to load
  71871. * @param size defines the desired size (the more it increases the longer the generation will be)
  71872. * If the size is omitted this implies you are using a preprocessed cubemap.
  71873. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71874. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71875. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71876. * (default is true)
  71877. */
  71878. constructor(
  71879. /**
  71880. * Defines the name of the task
  71881. */
  71882. name: string,
  71883. /**
  71884. * Defines the location of the file to load
  71885. */
  71886. url: string,
  71887. /**
  71888. * Defines the desired size (the more it increases the longer the generation will be)
  71889. */
  71890. size: number,
  71891. /**
  71892. * Defines if mipmaps should not be generated (default is false)
  71893. */
  71894. noMipmap?: boolean,
  71895. /**
  71896. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71897. * but the standard material would require them in Gamma space) (default is true)
  71898. */
  71899. gammaSpace?: boolean);
  71900. /**
  71901. * Execute the current task
  71902. * @param scene defines the scene where you want your assets to be loaded
  71903. * @param onSuccess is a callback called when the task is successfully executed
  71904. * @param onError is a callback called if an error occurs
  71905. */
  71906. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71907. }
  71908. /**
  71909. * This class can be used to easily import assets into a scene
  71910. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71911. */
  71912. export class AssetsManager {
  71913. private _scene;
  71914. private _isLoading;
  71915. protected _tasks: AbstractAssetTask[];
  71916. protected _waitingTasksCount: number;
  71917. protected _totalTasksCount: number;
  71918. /**
  71919. * Callback called when all tasks are processed
  71920. */
  71921. onFinish: (tasks: AbstractAssetTask[]) => void;
  71922. /**
  71923. * Callback called when a task is successful
  71924. */
  71925. onTaskSuccess: (task: AbstractAssetTask) => void;
  71926. /**
  71927. * Callback called when a task had an error
  71928. */
  71929. onTaskError: (task: AbstractAssetTask) => void;
  71930. /**
  71931. * Callback called when a task is done (whatever the result is)
  71932. */
  71933. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71934. /**
  71935. * Observable called when all tasks are processed
  71936. */
  71937. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71938. /**
  71939. * Observable called when a task had an error
  71940. */
  71941. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71942. /**
  71943. * Observable called when all tasks were executed
  71944. */
  71945. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71946. /**
  71947. * Observable called when a task is done (whatever the result is)
  71948. */
  71949. onProgressObservable: Observable<IAssetsProgressEvent>;
  71950. /**
  71951. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71952. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71953. */
  71954. useDefaultLoadingScreen: boolean;
  71955. /**
  71956. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71957. * when all assets have been downloaded.
  71958. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71959. */
  71960. autoHideLoadingUI: boolean;
  71961. /**
  71962. * Creates a new AssetsManager
  71963. * @param scene defines the scene to work on
  71964. */
  71965. constructor(scene: Scene);
  71966. /**
  71967. * Add a MeshAssetTask to the list of active tasks
  71968. * @param taskName defines the name of the new task
  71969. * @param meshesNames defines the name of meshes to load
  71970. * @param rootUrl defines the root url to use to locate files
  71971. * @param sceneFilename defines the filename of the scene file
  71972. * @returns a new MeshAssetTask object
  71973. */
  71974. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71975. /**
  71976. * Add a TextFileAssetTask to the list of active tasks
  71977. * @param taskName defines the name of the new task
  71978. * @param url defines the url of the file to load
  71979. * @returns a new TextFileAssetTask object
  71980. */
  71981. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71982. /**
  71983. * Add a BinaryFileAssetTask to the list of active tasks
  71984. * @param taskName defines the name of the new task
  71985. * @param url defines the url of the file to load
  71986. * @returns a new BinaryFileAssetTask object
  71987. */
  71988. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71989. /**
  71990. * Add a ImageAssetTask to the list of active tasks
  71991. * @param taskName defines the name of the new task
  71992. * @param url defines the url of the file to load
  71993. * @returns a new ImageAssetTask object
  71994. */
  71995. addImageTask(taskName: string, url: string): ImageAssetTask;
  71996. /**
  71997. * Add a TextureAssetTask to the list of active tasks
  71998. * @param taskName defines the name of the new task
  71999. * @param url defines the url of the file to load
  72000. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72001. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72002. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72003. * @returns a new TextureAssetTask object
  72004. */
  72005. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72006. /**
  72007. * Add a CubeTextureAssetTask to the list of active tasks
  72008. * @param taskName defines the name of the new task
  72009. * @param url defines the url of the file to load
  72010. * @param extensions defines the extension to use to load the cube map (can be null)
  72011. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72012. * @param files defines the list of files to load (can be null)
  72013. * @returns a new CubeTextureAssetTask object
  72014. */
  72015. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72016. /**
  72017. *
  72018. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72019. * @param taskName defines the name of the new task
  72020. * @param url defines the url of the file to load
  72021. * @param size defines the size you want for the cubemap (can be null)
  72022. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72023. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72024. * @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)
  72025. * @param reserved Internal use only
  72026. * @returns a new HDRCubeTextureAssetTask object
  72027. */
  72028. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72029. /**
  72030. *
  72031. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72032. * @param taskName defines the name of the new task
  72033. * @param url defines the url of the file to load
  72034. * @param size defines the size you want for the cubemap (can be null)
  72035. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72036. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72037. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72038. * @returns a new EquiRectangularCubeTextureAssetTask object
  72039. */
  72040. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72041. /**
  72042. * Remove a task from the assets manager.
  72043. * @param task the task to remove
  72044. */
  72045. removeTask(task: AbstractAssetTask): void;
  72046. private _decreaseWaitingTasksCount;
  72047. private _runTask;
  72048. /**
  72049. * Reset the AssetsManager and remove all tasks
  72050. * @return the current instance of the AssetsManager
  72051. */
  72052. reset(): AssetsManager;
  72053. /**
  72054. * Start the loading process
  72055. * @return the current instance of the AssetsManager
  72056. */
  72057. load(): AssetsManager;
  72058. /**
  72059. * Start the loading process as an async operation
  72060. * @return a promise returning the list of failed tasks
  72061. */
  72062. loadAsync(): Promise<void>;
  72063. }
  72064. }
  72065. declare module "babylonjs/Misc/deferred" {
  72066. /**
  72067. * Wrapper class for promise with external resolve and reject.
  72068. */
  72069. export class Deferred<T> {
  72070. /**
  72071. * The promise associated with this deferred object.
  72072. */
  72073. readonly promise: Promise<T>;
  72074. private _resolve;
  72075. private _reject;
  72076. /**
  72077. * The resolve method of the promise associated with this deferred object.
  72078. */
  72079. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72080. /**
  72081. * The reject method of the promise associated with this deferred object.
  72082. */
  72083. get reject(): (reason?: any) => void;
  72084. /**
  72085. * Constructor for this deferred object.
  72086. */
  72087. constructor();
  72088. }
  72089. }
  72090. declare module "babylonjs/Misc/meshExploder" {
  72091. import { Mesh } from "babylonjs/Meshes/mesh";
  72092. /**
  72093. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72094. */
  72095. export class MeshExploder {
  72096. private _centerMesh;
  72097. private _meshes;
  72098. private _meshesOrigins;
  72099. private _toCenterVectors;
  72100. private _scaledDirection;
  72101. private _newPosition;
  72102. private _centerPosition;
  72103. /**
  72104. * Explodes meshes from a center mesh.
  72105. * @param meshes The meshes to explode.
  72106. * @param centerMesh The mesh to be center of explosion.
  72107. */
  72108. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72109. private _setCenterMesh;
  72110. /**
  72111. * Get class name
  72112. * @returns "MeshExploder"
  72113. */
  72114. getClassName(): string;
  72115. /**
  72116. * "Exploded meshes"
  72117. * @returns Array of meshes with the centerMesh at index 0.
  72118. */
  72119. getMeshes(): Array<Mesh>;
  72120. /**
  72121. * Explodes meshes giving a specific direction
  72122. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72123. */
  72124. explode(direction?: number): void;
  72125. }
  72126. }
  72127. declare module "babylonjs/Misc/filesInput" {
  72128. import { Engine } from "babylonjs/Engines/engine";
  72129. import { Scene } from "babylonjs/scene";
  72130. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  72131. /**
  72132. * Class used to help managing file picking and drag'n'drop
  72133. */
  72134. export class FilesInput {
  72135. /**
  72136. * List of files ready to be loaded
  72137. */
  72138. static get FilesToLoad(): {
  72139. [key: string]: File;
  72140. };
  72141. /**
  72142. * Callback called when a file is processed
  72143. */
  72144. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  72145. private _engine;
  72146. private _currentScene;
  72147. private _sceneLoadedCallback;
  72148. private _progressCallback;
  72149. private _additionalRenderLoopLogicCallback;
  72150. private _textureLoadingCallback;
  72151. private _startingProcessingFilesCallback;
  72152. private _onReloadCallback;
  72153. private _errorCallback;
  72154. private _elementToMonitor;
  72155. private _sceneFileToLoad;
  72156. private _filesToLoad;
  72157. /**
  72158. * Creates a new FilesInput
  72159. * @param engine defines the rendering engine
  72160. * @param scene defines the hosting scene
  72161. * @param sceneLoadedCallback callback called when scene is loaded
  72162. * @param progressCallback callback called to track progress
  72163. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72164. * @param textureLoadingCallback callback called when a texture is loading
  72165. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72166. * @param onReloadCallback callback called when a reload is requested
  72167. * @param errorCallback callback call if an error occurs
  72168. */
  72169. 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);
  72170. private _dragEnterHandler;
  72171. private _dragOverHandler;
  72172. private _dropHandler;
  72173. /**
  72174. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72175. * @param elementToMonitor defines the DOM element to track
  72176. */
  72177. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72178. /**
  72179. * Release all associated resources
  72180. */
  72181. dispose(): void;
  72182. private renderFunction;
  72183. private drag;
  72184. private drop;
  72185. private _traverseFolder;
  72186. private _processFiles;
  72187. /**
  72188. * Load files from a drop event
  72189. * @param event defines the drop event to use as source
  72190. */
  72191. loadFiles(event: any): void;
  72192. private _processReload;
  72193. /**
  72194. * Reload the current scene from the loaded files
  72195. */
  72196. reload(): void;
  72197. }
  72198. }
  72199. declare module "babylonjs/Misc/HighDynamicRange/index" {
  72200. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  72201. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  72202. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  72203. }
  72204. declare module "babylonjs/Misc/sceneOptimizer" {
  72205. import { Scene, IDisposable } from "babylonjs/scene";
  72206. import { Observable } from "babylonjs/Misc/observable";
  72207. /**
  72208. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72209. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72210. */
  72211. export class SceneOptimization {
  72212. /**
  72213. * Defines the priority of this optimization (0 by default which means first in the list)
  72214. */
  72215. priority: number;
  72216. /**
  72217. * Gets a string describing the action executed by the current optimization
  72218. * @returns description string
  72219. */
  72220. getDescription(): string;
  72221. /**
  72222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72223. * @param scene defines the current scene where to apply this optimization
  72224. * @param optimizer defines the current optimizer
  72225. * @returns true if everything that can be done was applied
  72226. */
  72227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72228. /**
  72229. * Creates the SceneOptimization object
  72230. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72231. * @param desc defines the description associated with the optimization
  72232. */
  72233. constructor(
  72234. /**
  72235. * Defines the priority of this optimization (0 by default which means first in the list)
  72236. */
  72237. priority?: number);
  72238. }
  72239. /**
  72240. * Defines an optimization used to reduce the size of render target textures
  72241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72242. */
  72243. export class TextureOptimization extends SceneOptimization {
  72244. /**
  72245. * Defines the priority of this optimization (0 by default which means first in the list)
  72246. */
  72247. priority: number;
  72248. /**
  72249. * 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
  72250. */
  72251. maximumSize: number;
  72252. /**
  72253. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72254. */
  72255. step: number;
  72256. /**
  72257. * Gets a string describing the action executed by the current optimization
  72258. * @returns description string
  72259. */
  72260. getDescription(): string;
  72261. /**
  72262. * Creates the TextureOptimization object
  72263. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72264. * @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
  72265. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72266. */
  72267. constructor(
  72268. /**
  72269. * Defines the priority of this optimization (0 by default which means first in the list)
  72270. */
  72271. priority?: number,
  72272. /**
  72273. * 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
  72274. */
  72275. maximumSize?: number,
  72276. /**
  72277. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72278. */
  72279. step?: number);
  72280. /**
  72281. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72282. * @param scene defines the current scene where to apply this optimization
  72283. * @param optimizer defines the current optimizer
  72284. * @returns true if everything that can be done was applied
  72285. */
  72286. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72287. }
  72288. /**
  72289. * Defines an optimization used to increase or decrease the rendering resolution
  72290. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72291. */
  72292. export class HardwareScalingOptimization extends SceneOptimization {
  72293. /**
  72294. * Defines the priority of this optimization (0 by default which means first in the list)
  72295. */
  72296. priority: number;
  72297. /**
  72298. * Defines the maximum scale to use (2 by default)
  72299. */
  72300. maximumScale: number;
  72301. /**
  72302. * Defines the step to use between two passes (0.5 by default)
  72303. */
  72304. step: number;
  72305. private _currentScale;
  72306. private _directionOffset;
  72307. /**
  72308. * Gets a string describing the action executed by the current optimization
  72309. * @return description string
  72310. */
  72311. getDescription(): string;
  72312. /**
  72313. * Creates the HardwareScalingOptimization object
  72314. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72315. * @param maximumScale defines the maximum scale to use (2 by default)
  72316. * @param step defines the step to use between two passes (0.5 by default)
  72317. */
  72318. constructor(
  72319. /**
  72320. * Defines the priority of this optimization (0 by default which means first in the list)
  72321. */
  72322. priority?: number,
  72323. /**
  72324. * Defines the maximum scale to use (2 by default)
  72325. */
  72326. maximumScale?: number,
  72327. /**
  72328. * Defines the step to use between two passes (0.5 by default)
  72329. */
  72330. step?: number);
  72331. /**
  72332. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72333. * @param scene defines the current scene where to apply this optimization
  72334. * @param optimizer defines the current optimizer
  72335. * @returns true if everything that can be done was applied
  72336. */
  72337. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72338. }
  72339. /**
  72340. * Defines an optimization used to remove shadows
  72341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72342. */
  72343. export class ShadowsOptimization extends SceneOptimization {
  72344. /**
  72345. * Gets a string describing the action executed by the current optimization
  72346. * @return description string
  72347. */
  72348. getDescription(): string;
  72349. /**
  72350. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72351. * @param scene defines the current scene where to apply this optimization
  72352. * @param optimizer defines the current optimizer
  72353. * @returns true if everything that can be done was applied
  72354. */
  72355. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72356. }
  72357. /**
  72358. * Defines an optimization used to turn post-processes off
  72359. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72360. */
  72361. export class PostProcessesOptimization extends SceneOptimization {
  72362. /**
  72363. * Gets a string describing the action executed by the current optimization
  72364. * @return description string
  72365. */
  72366. getDescription(): string;
  72367. /**
  72368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72369. * @param scene defines the current scene where to apply this optimization
  72370. * @param optimizer defines the current optimizer
  72371. * @returns true if everything that can be done was applied
  72372. */
  72373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72374. }
  72375. /**
  72376. * Defines an optimization used to turn lens flares off
  72377. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72378. */
  72379. export class LensFlaresOptimization extends SceneOptimization {
  72380. /**
  72381. * Gets a string describing the action executed by the current optimization
  72382. * @return description string
  72383. */
  72384. getDescription(): string;
  72385. /**
  72386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72387. * @param scene defines the current scene where to apply this optimization
  72388. * @param optimizer defines the current optimizer
  72389. * @returns true if everything that can be done was applied
  72390. */
  72391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72392. }
  72393. /**
  72394. * Defines an optimization based on user defined callback.
  72395. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72396. */
  72397. export class CustomOptimization extends SceneOptimization {
  72398. /**
  72399. * Callback called to apply the custom optimization.
  72400. */
  72401. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72402. /**
  72403. * Callback called to get custom description
  72404. */
  72405. onGetDescription: () => string;
  72406. /**
  72407. * Gets a string describing the action executed by the current optimization
  72408. * @returns description string
  72409. */
  72410. getDescription(): string;
  72411. /**
  72412. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72413. * @param scene defines the current scene where to apply this optimization
  72414. * @param optimizer defines the current optimizer
  72415. * @returns true if everything that can be done was applied
  72416. */
  72417. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72418. }
  72419. /**
  72420. * Defines an optimization used to turn particles off
  72421. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72422. */
  72423. export class ParticlesOptimization extends SceneOptimization {
  72424. /**
  72425. * Gets a string describing the action executed by the current optimization
  72426. * @return description string
  72427. */
  72428. getDescription(): string;
  72429. /**
  72430. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72431. * @param scene defines the current scene where to apply this optimization
  72432. * @param optimizer defines the current optimizer
  72433. * @returns true if everything that can be done was applied
  72434. */
  72435. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72436. }
  72437. /**
  72438. * Defines an optimization used to turn render targets off
  72439. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72440. */
  72441. export class RenderTargetsOptimization extends SceneOptimization {
  72442. /**
  72443. * Gets a string describing the action executed by the current optimization
  72444. * @return description string
  72445. */
  72446. getDescription(): string;
  72447. /**
  72448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72449. * @param scene defines the current scene where to apply this optimization
  72450. * @param optimizer defines the current optimizer
  72451. * @returns true if everything that can be done was applied
  72452. */
  72453. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72454. }
  72455. /**
  72456. * Defines an optimization used to merge meshes with compatible materials
  72457. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72458. */
  72459. export class MergeMeshesOptimization extends SceneOptimization {
  72460. private static _UpdateSelectionTree;
  72461. /**
  72462. * Gets or sets a boolean which defines if optimization octree has to be updated
  72463. */
  72464. static get UpdateSelectionTree(): boolean;
  72465. /**
  72466. * Gets or sets a boolean which defines if optimization octree has to be updated
  72467. */
  72468. static set UpdateSelectionTree(value: boolean);
  72469. /**
  72470. * Gets a string describing the action executed by the current optimization
  72471. * @return description string
  72472. */
  72473. getDescription(): string;
  72474. private _canBeMerged;
  72475. /**
  72476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72477. * @param scene defines the current scene where to apply this optimization
  72478. * @param optimizer defines the current optimizer
  72479. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72480. * @returns true if everything that can be done was applied
  72481. */
  72482. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72483. }
  72484. /**
  72485. * Defines a list of options used by SceneOptimizer
  72486. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72487. */
  72488. export class SceneOptimizerOptions {
  72489. /**
  72490. * Defines the target frame rate to reach (60 by default)
  72491. */
  72492. targetFrameRate: number;
  72493. /**
  72494. * Defines the interval between two checkes (2000ms by default)
  72495. */
  72496. trackerDuration: number;
  72497. /**
  72498. * Gets the list of optimizations to apply
  72499. */
  72500. optimizations: SceneOptimization[];
  72501. /**
  72502. * Creates a new list of options used by SceneOptimizer
  72503. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72504. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72505. */
  72506. constructor(
  72507. /**
  72508. * Defines the target frame rate to reach (60 by default)
  72509. */
  72510. targetFrameRate?: number,
  72511. /**
  72512. * Defines the interval between two checkes (2000ms by default)
  72513. */
  72514. trackerDuration?: number);
  72515. /**
  72516. * Add a new optimization
  72517. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72518. * @returns the current SceneOptimizerOptions
  72519. */
  72520. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72521. /**
  72522. * Add a new custom optimization
  72523. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72524. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72525. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72526. * @returns the current SceneOptimizerOptions
  72527. */
  72528. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72529. /**
  72530. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72531. * @param targetFrameRate defines the target frame rate (60 by default)
  72532. * @returns a SceneOptimizerOptions object
  72533. */
  72534. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72535. /**
  72536. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72537. * @param targetFrameRate defines the target frame rate (60 by default)
  72538. * @returns a SceneOptimizerOptions object
  72539. */
  72540. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72541. /**
  72542. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72543. * @param targetFrameRate defines the target frame rate (60 by default)
  72544. * @returns a SceneOptimizerOptions object
  72545. */
  72546. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72547. }
  72548. /**
  72549. * Class used to run optimizations in order to reach a target frame rate
  72550. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72551. */
  72552. export class SceneOptimizer implements IDisposable {
  72553. private _isRunning;
  72554. private _options;
  72555. private _scene;
  72556. private _currentPriorityLevel;
  72557. private _targetFrameRate;
  72558. private _trackerDuration;
  72559. private _currentFrameRate;
  72560. private _sceneDisposeObserver;
  72561. private _improvementMode;
  72562. /**
  72563. * Defines an observable called when the optimizer reaches the target frame rate
  72564. */
  72565. onSuccessObservable: Observable<SceneOptimizer>;
  72566. /**
  72567. * Defines an observable called when the optimizer enables an optimization
  72568. */
  72569. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72570. /**
  72571. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72572. */
  72573. onFailureObservable: Observable<SceneOptimizer>;
  72574. /**
  72575. * Gets a boolean indicating if the optimizer is in improvement mode
  72576. */
  72577. get isInImprovementMode(): boolean;
  72578. /**
  72579. * Gets the current priority level (0 at start)
  72580. */
  72581. get currentPriorityLevel(): number;
  72582. /**
  72583. * Gets the current frame rate checked by the SceneOptimizer
  72584. */
  72585. get currentFrameRate(): number;
  72586. /**
  72587. * Gets or sets the current target frame rate (60 by default)
  72588. */
  72589. get targetFrameRate(): number;
  72590. /**
  72591. * Gets or sets the current target frame rate (60 by default)
  72592. */
  72593. set targetFrameRate(value: number);
  72594. /**
  72595. * Gets or sets the current interval between two checks (every 2000ms by default)
  72596. */
  72597. get trackerDuration(): number;
  72598. /**
  72599. * Gets or sets the current interval between two checks (every 2000ms by default)
  72600. */
  72601. set trackerDuration(value: number);
  72602. /**
  72603. * Gets the list of active optimizations
  72604. */
  72605. get optimizations(): SceneOptimization[];
  72606. /**
  72607. * Creates a new SceneOptimizer
  72608. * @param scene defines the scene to work on
  72609. * @param options defines the options to use with the SceneOptimizer
  72610. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72611. * @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)
  72612. */
  72613. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72614. /**
  72615. * Stops the current optimizer
  72616. */
  72617. stop(): void;
  72618. /**
  72619. * Reset the optimizer to initial step (current priority level = 0)
  72620. */
  72621. reset(): void;
  72622. /**
  72623. * Start the optimizer. By default it will try to reach a specific framerate
  72624. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72625. */
  72626. start(): void;
  72627. private _checkCurrentState;
  72628. /**
  72629. * Release all resources
  72630. */
  72631. dispose(): void;
  72632. /**
  72633. * Helper function to create a SceneOptimizer with one single line of code
  72634. * @param scene defines the scene to work on
  72635. * @param options defines the options to use with the SceneOptimizer
  72636. * @param onSuccess defines a callback to call on success
  72637. * @param onFailure defines a callback to call on failure
  72638. * @returns the new SceneOptimizer object
  72639. */
  72640. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72641. }
  72642. }
  72643. declare module "babylonjs/Misc/sceneSerializer" {
  72644. import { Scene } from "babylonjs/scene";
  72645. /**
  72646. * Class used to serialize a scene into a string
  72647. */
  72648. export class SceneSerializer {
  72649. /**
  72650. * Clear cache used by a previous serialization
  72651. */
  72652. static ClearCache(): void;
  72653. /**
  72654. * Serialize a scene into a JSON compatible object
  72655. * @param scene defines the scene to serialize
  72656. * @returns a JSON compatible object
  72657. */
  72658. static Serialize(scene: Scene): any;
  72659. /**
  72660. * Serialize a mesh into a JSON compatible object
  72661. * @param toSerialize defines the mesh to serialize
  72662. * @param withParents defines if parents must be serialized as well
  72663. * @param withChildren defines if children must be serialized as well
  72664. * @returns a JSON compatible object
  72665. */
  72666. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72667. }
  72668. }
  72669. declare module "babylonjs/Misc/textureTools" {
  72670. import { Texture } from "babylonjs/Materials/Textures/texture";
  72671. /**
  72672. * Class used to host texture specific utilities
  72673. */
  72674. export class TextureTools {
  72675. /**
  72676. * Uses the GPU to create a copy texture rescaled at a given size
  72677. * @param texture Texture to copy from
  72678. * @param width defines the desired width
  72679. * @param height defines the desired height
  72680. * @param useBilinearMode defines if bilinear mode has to be used
  72681. * @return the generated texture
  72682. */
  72683. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72684. }
  72685. }
  72686. declare module "babylonjs/Misc/videoRecorder" {
  72687. import { Nullable } from "babylonjs/types";
  72688. import { Engine } from "babylonjs/Engines/engine";
  72689. /**
  72690. * This represents the different options available for the video capture.
  72691. */
  72692. export interface VideoRecorderOptions {
  72693. /** Defines the mime type of the video. */
  72694. mimeType: string;
  72695. /** Defines the FPS the video should be recorded at. */
  72696. fps: number;
  72697. /** Defines the chunk size for the recording data. */
  72698. recordChunckSize: number;
  72699. /** The audio tracks to attach to the recording. */
  72700. audioTracks?: MediaStreamTrack[];
  72701. }
  72702. /**
  72703. * This can help with recording videos from BabylonJS.
  72704. * This is based on the available WebRTC functionalities of the browser.
  72705. *
  72706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72707. */
  72708. export class VideoRecorder {
  72709. private static readonly _defaultOptions;
  72710. /**
  72711. * Returns whether or not the VideoRecorder is available in your browser.
  72712. * @param engine Defines the Babylon Engine.
  72713. * @returns true if supported otherwise false.
  72714. */
  72715. static IsSupported(engine: Engine): boolean;
  72716. private readonly _options;
  72717. private _canvas;
  72718. private _mediaRecorder;
  72719. private _recordedChunks;
  72720. private _fileName;
  72721. private _resolve;
  72722. private _reject;
  72723. /**
  72724. * True when a recording is already in progress.
  72725. */
  72726. get isRecording(): boolean;
  72727. /**
  72728. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72729. * @param engine Defines the BabylonJS Engine you wish to record.
  72730. * @param options Defines options that can be used to customize the capture.
  72731. */
  72732. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72733. /**
  72734. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72735. */
  72736. stopRecording(): void;
  72737. /**
  72738. * Starts recording the canvas for a max duration specified in parameters.
  72739. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72740. * If null no automatic download will start and you can rely on the promise to get the data back.
  72741. * @param maxDuration Defines the maximum recording time in seconds.
  72742. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72743. * @return A promise callback at the end of the recording with the video data in Blob.
  72744. */
  72745. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72746. /**
  72747. * Releases internal resources used during the recording.
  72748. */
  72749. dispose(): void;
  72750. private _handleDataAvailable;
  72751. private _handleError;
  72752. private _handleStop;
  72753. }
  72754. }
  72755. declare module "babylonjs/Misc/screenshotTools" {
  72756. import { Camera } from "babylonjs/Cameras/camera";
  72757. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72758. import { Engine } from "babylonjs/Engines/engine";
  72759. /**
  72760. * Class containing a set of static utilities functions for screenshots
  72761. */
  72762. export class ScreenshotTools {
  72763. /**
  72764. * Captures a screenshot of the current rendering
  72765. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72766. * @param engine defines the rendering engine
  72767. * @param camera defines the source camera
  72768. * @param size This parameter can be set to a single number or to an object with the
  72769. * following (optional) properties: precision, width, height. If a single number is passed,
  72770. * it will be used for both width and height. If an object is passed, the screenshot size
  72771. * will be derived from the parameters. The precision property is a multiplier allowing
  72772. * rendering at a higher or lower resolution
  72773. * @param successCallback defines the callback receives a single parameter which contains the
  72774. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72775. * src parameter of an <img> to display it
  72776. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72777. * Check your browser for supported MIME types
  72778. */
  72779. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72780. /**
  72781. * Captures a screenshot of the current rendering
  72782. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72783. * @param engine defines the rendering engine
  72784. * @param camera defines the source camera
  72785. * @param size This parameter can be set to a single number or to an object with the
  72786. * following (optional) properties: precision, width, height. If a single number is passed,
  72787. * it will be used for both width and height. If an object is passed, the screenshot size
  72788. * will be derived from the parameters. The precision property is a multiplier allowing
  72789. * rendering at a higher or lower resolution
  72790. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72791. * Check your browser for supported MIME types
  72792. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72793. * to the src parameter of an <img> to display it
  72794. */
  72795. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72796. /**
  72797. * Generates an image screenshot from the specified camera.
  72798. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72799. * @param engine The engine to use for rendering
  72800. * @param camera The camera to use for rendering
  72801. * @param size This parameter can be set to a single number or to an object with the
  72802. * following (optional) properties: precision, width, height. If a single number is passed,
  72803. * it will be used for both width and height. If an object is passed, the screenshot size
  72804. * will be derived from the parameters. The precision property is a multiplier allowing
  72805. * rendering at a higher or lower resolution
  72806. * @param successCallback The callback receives a single parameter which contains the
  72807. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72808. * src parameter of an <img> to display it
  72809. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72810. * Check your browser for supported MIME types
  72811. * @param samples Texture samples (default: 1)
  72812. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72813. * @param fileName A name for for the downloaded file.
  72814. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72815. */
  72816. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72817. /**
  72818. * Generates an image screenshot from the specified camera.
  72819. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72820. * @param engine The engine to use for rendering
  72821. * @param camera The camera to use for rendering
  72822. * @param size This parameter can be set to a single number or to an object with the
  72823. * following (optional) properties: precision, width, height. If a single number is passed,
  72824. * it will be used for both width and height. If an object is passed, the screenshot size
  72825. * will be derived from the parameters. The precision property is a multiplier allowing
  72826. * rendering at a higher or lower resolution
  72827. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72828. * Check your browser for supported MIME types
  72829. * @param samples Texture samples (default: 1)
  72830. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72831. * @param fileName A name for for the downloaded file.
  72832. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72833. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72834. * to the src parameter of an <img> to display it
  72835. */
  72836. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72837. /**
  72838. * Gets height and width for screenshot size
  72839. * @private
  72840. */
  72841. private static _getScreenshotSize;
  72842. }
  72843. }
  72844. declare module "babylonjs/Misc/dataReader" {
  72845. /**
  72846. * Interface for a data buffer
  72847. */
  72848. export interface IDataBuffer {
  72849. /**
  72850. * Reads bytes from the data buffer.
  72851. * @param byteOffset The byte offset to read
  72852. * @param byteLength The byte length to read
  72853. * @returns A promise that resolves when the bytes are read
  72854. */
  72855. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72856. /**
  72857. * The byte length of the buffer.
  72858. */
  72859. readonly byteLength: number;
  72860. }
  72861. /**
  72862. * Utility class for reading from a data buffer
  72863. */
  72864. export class DataReader {
  72865. /**
  72866. * The data buffer associated with this data reader.
  72867. */
  72868. readonly buffer: IDataBuffer;
  72869. /**
  72870. * The current byte offset from the beginning of the data buffer.
  72871. */
  72872. byteOffset: number;
  72873. private _dataView;
  72874. private _dataByteOffset;
  72875. /**
  72876. * Constructor
  72877. * @param buffer The buffer to read
  72878. */
  72879. constructor(buffer: IDataBuffer);
  72880. /**
  72881. * Loads the given byte length.
  72882. * @param byteLength The byte length to load
  72883. * @returns A promise that resolves when the load is complete
  72884. */
  72885. loadAsync(byteLength: number): Promise<void>;
  72886. /**
  72887. * Read a unsigned 32-bit integer from the currently loaded data range.
  72888. * @returns The 32-bit integer read
  72889. */
  72890. readUint32(): number;
  72891. /**
  72892. * Read a byte array from the currently loaded data range.
  72893. * @param byteLength The byte length to read
  72894. * @returns The byte array read
  72895. */
  72896. readUint8Array(byteLength: number): Uint8Array;
  72897. /**
  72898. * Read a string from the currently loaded data range.
  72899. * @param byteLength The byte length to read
  72900. * @returns The string read
  72901. */
  72902. readString(byteLength: number): string;
  72903. /**
  72904. * Skips the given byte length the currently loaded data range.
  72905. * @param byteLength The byte length to skip
  72906. */
  72907. skipBytes(byteLength: number): void;
  72908. }
  72909. }
  72910. declare module "babylonjs/Misc/dataStorage" {
  72911. /**
  72912. * Class for storing data to local storage if available or in-memory storage otherwise
  72913. */
  72914. export class DataStorage {
  72915. private static _Storage;
  72916. private static _GetStorage;
  72917. /**
  72918. * Reads a string from the data storage
  72919. * @param key The key to read
  72920. * @param defaultValue The value if the key doesn't exist
  72921. * @returns The string value
  72922. */
  72923. static ReadString(key: string, defaultValue: string): string;
  72924. /**
  72925. * Writes a string to the data storage
  72926. * @param key The key to write
  72927. * @param value The value to write
  72928. */
  72929. static WriteString(key: string, value: string): void;
  72930. /**
  72931. * Reads a boolean from the data storage
  72932. * @param key The key to read
  72933. * @param defaultValue The value if the key doesn't exist
  72934. * @returns The boolean value
  72935. */
  72936. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72937. /**
  72938. * Writes a boolean to the data storage
  72939. * @param key The key to write
  72940. * @param value The value to write
  72941. */
  72942. static WriteBoolean(key: string, value: boolean): void;
  72943. /**
  72944. * Reads a number from the data storage
  72945. * @param key The key to read
  72946. * @param defaultValue The value if the key doesn't exist
  72947. * @returns The number value
  72948. */
  72949. static ReadNumber(key: string, defaultValue: number): number;
  72950. /**
  72951. * Writes a number to the data storage
  72952. * @param key The key to write
  72953. * @param value The value to write
  72954. */
  72955. static WriteNumber(key: string, value: number): void;
  72956. }
  72957. }
  72958. declare module "babylonjs/Misc/index" {
  72959. export * from "babylonjs/Misc/andOrNotEvaluator";
  72960. export * from "babylonjs/Misc/assetsManager";
  72961. export * from "babylonjs/Misc/basis";
  72962. export * from "babylonjs/Misc/dds";
  72963. export * from "babylonjs/Misc/decorators";
  72964. export * from "babylonjs/Misc/deferred";
  72965. export * from "babylonjs/Misc/environmentTextureTools";
  72966. export * from "babylonjs/Misc/meshExploder";
  72967. export * from "babylonjs/Misc/filesInput";
  72968. export * from "babylonjs/Misc/HighDynamicRange/index";
  72969. export * from "babylonjs/Misc/khronosTextureContainer";
  72970. export * from "babylonjs/Misc/observable";
  72971. export * from "babylonjs/Misc/performanceMonitor";
  72972. export * from "babylonjs/Misc/promise";
  72973. export * from "babylonjs/Misc/sceneOptimizer";
  72974. export * from "babylonjs/Misc/sceneSerializer";
  72975. export * from "babylonjs/Misc/smartArray";
  72976. export * from "babylonjs/Misc/stringDictionary";
  72977. export * from "babylonjs/Misc/tags";
  72978. export * from "babylonjs/Misc/textureTools";
  72979. export * from "babylonjs/Misc/tga";
  72980. export * from "babylonjs/Misc/tools";
  72981. export * from "babylonjs/Misc/videoRecorder";
  72982. export * from "babylonjs/Misc/virtualJoystick";
  72983. export * from "babylonjs/Misc/workerPool";
  72984. export * from "babylonjs/Misc/logger";
  72985. export * from "babylonjs/Misc/typeStore";
  72986. export * from "babylonjs/Misc/filesInputStore";
  72987. export * from "babylonjs/Misc/deepCopier";
  72988. export * from "babylonjs/Misc/pivotTools";
  72989. export * from "babylonjs/Misc/precisionDate";
  72990. export * from "babylonjs/Misc/screenshotTools";
  72991. export * from "babylonjs/Misc/typeStore";
  72992. export * from "babylonjs/Misc/webRequest";
  72993. export * from "babylonjs/Misc/iInspectable";
  72994. export * from "babylonjs/Misc/brdfTextureTools";
  72995. export * from "babylonjs/Misc/rgbdTextureTools";
  72996. export * from "babylonjs/Misc/gradients";
  72997. export * from "babylonjs/Misc/perfCounter";
  72998. export * from "babylonjs/Misc/fileRequest";
  72999. export * from "babylonjs/Misc/customAnimationFrameRequester";
  73000. export * from "babylonjs/Misc/retryStrategy";
  73001. export * from "babylonjs/Misc/interfaces/screenshotSize";
  73002. export * from "babylonjs/Misc/canvasGenerator";
  73003. export * from "babylonjs/Misc/fileTools";
  73004. export * from "babylonjs/Misc/stringTools";
  73005. export * from "babylonjs/Misc/dataReader";
  73006. export * from "babylonjs/Misc/minMaxReducer";
  73007. export * from "babylonjs/Misc/depthReducer";
  73008. export * from "babylonjs/Misc/dataStorage";
  73009. }
  73010. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  73011. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73012. import { Observable } from "babylonjs/Misc/observable";
  73013. import { Matrix } from "babylonjs/Maths/math.vector";
  73014. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73015. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73016. /**
  73017. * Options used for hit testing
  73018. */
  73019. export interface IWebXRLegacyHitTestOptions {
  73020. /**
  73021. * Only test when user interacted with the scene. Default - hit test every frame
  73022. */
  73023. testOnPointerDownOnly?: boolean;
  73024. /**
  73025. * The node to use to transform the local results to world coordinates
  73026. */
  73027. worldParentNode?: TransformNode;
  73028. }
  73029. /**
  73030. * Interface defining the babylon result of raycasting/hit-test
  73031. */
  73032. export interface IWebXRLegacyHitResult {
  73033. /**
  73034. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73035. */
  73036. transformationMatrix: Matrix;
  73037. /**
  73038. * The native hit test result
  73039. */
  73040. xrHitResult: XRHitResult | XRHitTestResult;
  73041. }
  73042. /**
  73043. * The currently-working hit-test module.
  73044. * Hit test (or Ray-casting) is used to interact with the real world.
  73045. * For further information read here - https://github.com/immersive-web/hit-test
  73046. */
  73047. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  73048. /**
  73049. * options to use when constructing this feature
  73050. */
  73051. readonly options: IWebXRLegacyHitTestOptions;
  73052. private _direction;
  73053. private _mat;
  73054. private _onSelectEnabled;
  73055. private _origin;
  73056. /**
  73057. * The module's name
  73058. */
  73059. static readonly Name: string;
  73060. /**
  73061. * The (Babylon) version of this module.
  73062. * This is an integer representing the implementation version.
  73063. * This number does not correspond to the WebXR specs version
  73064. */
  73065. static readonly Version: number;
  73066. /**
  73067. * Populated with the last native XR Hit Results
  73068. */
  73069. lastNativeXRHitResults: XRHitResult[];
  73070. /**
  73071. * Triggered when new babylon (transformed) hit test results are available
  73072. */
  73073. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73074. /**
  73075. * Creates a new instance of the (legacy version) hit test feature
  73076. * @param _xrSessionManager an instance of WebXRSessionManager
  73077. * @param options options to use when constructing this feature
  73078. */
  73079. constructor(_xrSessionManager: WebXRSessionManager,
  73080. /**
  73081. * options to use when constructing this feature
  73082. */
  73083. options?: IWebXRLegacyHitTestOptions);
  73084. /**
  73085. * execute a hit test with an XR Ray
  73086. *
  73087. * @param xrSession a native xrSession that will execute this hit test
  73088. * @param xrRay the ray (position and direction) to use for ray-casting
  73089. * @param referenceSpace native XR reference space to use for the hit-test
  73090. * @param filter filter function that will filter the results
  73091. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73092. */
  73093. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73094. /**
  73095. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73096. * @param event the (select) event to use to select with
  73097. * @param referenceSpace the reference space to use for this hit test
  73098. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73099. */
  73100. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73101. /**
  73102. * attach this feature
  73103. * Will usually be called by the features manager
  73104. *
  73105. * @returns true if successful.
  73106. */
  73107. attach(): boolean;
  73108. /**
  73109. * detach this feature.
  73110. * Will usually be called by the features manager
  73111. *
  73112. * @returns true if successful.
  73113. */
  73114. detach(): boolean;
  73115. /**
  73116. * Dispose this feature and all of the resources attached
  73117. */
  73118. dispose(): void;
  73119. protected _onXRFrame(frame: XRFrame): void;
  73120. private _onHitTestResults;
  73121. private _onSelect;
  73122. }
  73123. }
  73124. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  73125. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73126. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73127. import { Observable } from "babylonjs/Misc/observable";
  73128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  73129. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73130. /**
  73131. * Options used in the plane detector module
  73132. */
  73133. export interface IWebXRPlaneDetectorOptions {
  73134. /**
  73135. * The node to use to transform the local results to world coordinates
  73136. */
  73137. worldParentNode?: TransformNode;
  73138. }
  73139. /**
  73140. * A babylon interface for a WebXR plane.
  73141. * A Plane is actually a polygon, built from N points in space
  73142. *
  73143. * Supported in chrome 79, not supported in canary 81 ATM
  73144. */
  73145. export interface IWebXRPlane {
  73146. /**
  73147. * a babylon-assigned ID for this polygon
  73148. */
  73149. id: number;
  73150. /**
  73151. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73152. */
  73153. polygonDefinition: Array<Vector3>;
  73154. /**
  73155. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73156. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73157. */
  73158. transformationMatrix: Matrix;
  73159. /**
  73160. * the native xr-plane object
  73161. */
  73162. xrPlane: XRPlane;
  73163. }
  73164. /**
  73165. * The plane detector is used to detect planes in the real world when in AR
  73166. * For more information see https://github.com/immersive-web/real-world-geometry/
  73167. */
  73168. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73169. private _options;
  73170. private _detectedPlanes;
  73171. private _enabled;
  73172. private _lastFrameDetected;
  73173. /**
  73174. * The module's name
  73175. */
  73176. static readonly Name: string;
  73177. /**
  73178. * The (Babylon) version of this module.
  73179. * This is an integer representing the implementation version.
  73180. * This number does not correspond to the WebXR specs version
  73181. */
  73182. static readonly Version: number;
  73183. /**
  73184. * Observers registered here will be executed when a new plane was added to the session
  73185. */
  73186. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73187. /**
  73188. * Observers registered here will be executed when a plane is no longer detected in the session
  73189. */
  73190. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73191. /**
  73192. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73193. * This can execute N times every frame
  73194. */
  73195. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73196. /**
  73197. * construct a new Plane Detector
  73198. * @param _xrSessionManager an instance of xr Session manager
  73199. * @param _options configuration to use when constructing this feature
  73200. */
  73201. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73202. /**
  73203. * Dispose this feature and all of the resources attached
  73204. */
  73205. dispose(): void;
  73206. protected _onXRFrame(frame: XRFrame): void;
  73207. private _init;
  73208. private _updatePlaneWithXRPlane;
  73209. /**
  73210. * avoiding using Array.find for global support.
  73211. * @param xrPlane the plane to find in the array
  73212. */
  73213. private findIndexInPlaneArray;
  73214. }
  73215. }
  73216. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  73217. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73218. import { Observable } from "babylonjs/Misc/observable";
  73219. import { Matrix } from "babylonjs/Maths/math.vector";
  73220. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73221. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  73222. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73223. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73224. /**
  73225. * Configuration options of the anchor system
  73226. */
  73227. export interface IWebXRAnchorSystemOptions {
  73228. /**
  73229. * Should a new anchor be added every time a select event is triggered
  73230. */
  73231. addAnchorOnSelect?: boolean;
  73232. /**
  73233. * should the anchor system use plane detection.
  73234. * If set to true, the plane-detection feature should be set using setPlaneDetector
  73235. */
  73236. usePlaneDetection?: boolean;
  73237. /**
  73238. * a node that will be used to convert local to world coordinates
  73239. */
  73240. worldParentNode?: TransformNode;
  73241. }
  73242. /**
  73243. * A babylon container for an XR Anchor
  73244. */
  73245. export interface IWebXRAnchor {
  73246. /**
  73247. * A babylon-assigned ID for this anchor
  73248. */
  73249. id: number;
  73250. /**
  73251. * Transformation matrix to apply to an object attached to this anchor
  73252. */
  73253. transformationMatrix: Matrix;
  73254. /**
  73255. * The native anchor object
  73256. */
  73257. xrAnchor: XRAnchor;
  73258. }
  73259. /**
  73260. * An implementation of the anchor system of WebXR.
  73261. * Note that the current documented implementation is not available in any browser. Future implementations
  73262. * will use the frame to create an anchor and not the session or a detected plane
  73263. * For further information see https://github.com/immersive-web/anchors/
  73264. */
  73265. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73266. private _options;
  73267. private _enabled;
  73268. private _hitTestModule;
  73269. private _lastFrameDetected;
  73270. private _onSelect;
  73271. private _planeDetector;
  73272. private _trackedAnchors;
  73273. /**
  73274. * The module's name
  73275. */
  73276. static readonly Name: string;
  73277. /**
  73278. * The (Babylon) version of this module.
  73279. * This is an integer representing the implementation version.
  73280. * This number does not correspond to the WebXR specs version
  73281. */
  73282. static readonly Version: number;
  73283. /**
  73284. * Observers registered here will be executed when a new anchor was added to the session
  73285. */
  73286. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73287. /**
  73288. * Observers registered here will be executed when an anchor was removed from the session
  73289. */
  73290. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73291. /**
  73292. * Observers registered here will be executed when an existing anchor updates
  73293. * This can execute N times every frame
  73294. */
  73295. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73296. /**
  73297. * constructs a new anchor system
  73298. * @param _xrSessionManager an instance of WebXRSessionManager
  73299. * @param _options configuration object for this feature
  73300. */
  73301. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73302. /**
  73303. * Add anchor at a specific XR point.
  73304. *
  73305. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  73306. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  73307. * @returns a promise the fulfills when the anchor was created
  73308. */
  73309. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  73310. /**
  73311. * attach this feature
  73312. * Will usually be called by the features manager
  73313. *
  73314. * @returns true if successful.
  73315. */
  73316. attach(): boolean;
  73317. /**
  73318. * detach this feature.
  73319. * Will usually be called by the features manager
  73320. *
  73321. * @returns true if successful.
  73322. */
  73323. detach(): boolean;
  73324. /**
  73325. * Dispose this feature and all of the resources attached
  73326. */
  73327. dispose(): void;
  73328. /**
  73329. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  73330. * @param hitTestModule the hit-test module to use.
  73331. */
  73332. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  73333. /**
  73334. * set the plane detector to use in order to create anchors from frames
  73335. * @param planeDetector the plane-detector module to use
  73336. * @param enable enable plane-anchors. default is true
  73337. */
  73338. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  73339. protected _onXRFrame(frame: XRFrame): void;
  73340. /**
  73341. * avoiding using Array.find for global support.
  73342. * @param xrAnchor the plane to find in the array
  73343. */
  73344. private _findIndexInAnchorArray;
  73345. private _updateAnchorWithXRFrame;
  73346. }
  73347. }
  73348. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  73349. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73351. import { Observable } from "babylonjs/Misc/observable";
  73352. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73353. /**
  73354. * Options interface for the background remover plugin
  73355. */
  73356. export interface IWebXRBackgroundRemoverOptions {
  73357. /**
  73358. * Further background meshes to disable when entering AR
  73359. */
  73360. backgroundMeshes?: AbstractMesh[];
  73361. /**
  73362. * flags to configure the removal of the environment helper.
  73363. * If not set, the entire background will be removed. If set, flags should be set as well.
  73364. */
  73365. environmentHelperRemovalFlags?: {
  73366. /**
  73367. * Should the skybox be removed (default false)
  73368. */
  73369. skyBox?: boolean;
  73370. /**
  73371. * Should the ground be removed (default false)
  73372. */
  73373. ground?: boolean;
  73374. };
  73375. /**
  73376. * don't disable the environment helper
  73377. */
  73378. ignoreEnvironmentHelper?: boolean;
  73379. }
  73380. /**
  73381. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73382. */
  73383. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73384. /**
  73385. * read-only options to be used in this module
  73386. */
  73387. readonly options: IWebXRBackgroundRemoverOptions;
  73388. /**
  73389. * The module's name
  73390. */
  73391. static readonly Name: string;
  73392. /**
  73393. * The (Babylon) version of this module.
  73394. * This is an integer representing the implementation version.
  73395. * This number does not correspond to the WebXR specs version
  73396. */
  73397. static readonly Version: number;
  73398. /**
  73399. * registered observers will be triggered when the background state changes
  73400. */
  73401. onBackgroundStateChangedObservable: Observable<boolean>;
  73402. /**
  73403. * constructs a new background remover module
  73404. * @param _xrSessionManager the session manager for this module
  73405. * @param options read-only options to be used in this module
  73406. */
  73407. constructor(_xrSessionManager: WebXRSessionManager,
  73408. /**
  73409. * read-only options to be used in this module
  73410. */
  73411. options?: IWebXRBackgroundRemoverOptions);
  73412. /**
  73413. * attach this feature
  73414. * Will usually be called by the features manager
  73415. *
  73416. * @returns true if successful.
  73417. */
  73418. attach(): boolean;
  73419. /**
  73420. * detach this feature.
  73421. * Will usually be called by the features manager
  73422. *
  73423. * @returns true if successful.
  73424. */
  73425. detach(): boolean;
  73426. /**
  73427. * Dispose this feature and all of the resources attached
  73428. */
  73429. dispose(): void;
  73430. protected _onXRFrame(_xrFrame: XRFrame): void;
  73431. private _setBackgroundState;
  73432. }
  73433. }
  73434. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73435. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73436. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73437. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73438. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73439. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73440. import { Nullable } from "babylonjs/types";
  73441. /**
  73442. * Options for the controller physics feature
  73443. */
  73444. export class IWebXRControllerPhysicsOptions {
  73445. /**
  73446. * Should the headset get its own impostor
  73447. */
  73448. enableHeadsetImpostor?: boolean;
  73449. /**
  73450. * Optional parameters for the headset impostor
  73451. */
  73452. headsetImpostorParams?: {
  73453. /**
  73454. * The type of impostor to create. Default is sphere
  73455. */
  73456. impostorType: number;
  73457. /**
  73458. * the size of the impostor. Defaults to 10cm
  73459. */
  73460. impostorSize?: number | {
  73461. width: number;
  73462. height: number;
  73463. depth: number;
  73464. };
  73465. /**
  73466. * Friction definitions
  73467. */
  73468. friction?: number;
  73469. /**
  73470. * Restitution
  73471. */
  73472. restitution?: number;
  73473. };
  73474. /**
  73475. * The physics properties of the future impostors
  73476. */
  73477. physicsProperties?: {
  73478. /**
  73479. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73480. * Note that this requires a physics engine that supports mesh impostors!
  73481. */
  73482. useControllerMesh?: boolean;
  73483. /**
  73484. * The type of impostor to create. Default is sphere
  73485. */
  73486. impostorType?: number;
  73487. /**
  73488. * the size of the impostor. Defaults to 10cm
  73489. */
  73490. impostorSize?: number | {
  73491. width: number;
  73492. height: number;
  73493. depth: number;
  73494. };
  73495. /**
  73496. * Friction definitions
  73497. */
  73498. friction?: number;
  73499. /**
  73500. * Restitution
  73501. */
  73502. restitution?: number;
  73503. };
  73504. /**
  73505. * the xr input to use with this pointer selection
  73506. */
  73507. xrInput: WebXRInput;
  73508. }
  73509. /**
  73510. * Add physics impostor to your webxr controllers,
  73511. * including naive calculation of their linear and angular velocity
  73512. */
  73513. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73514. private readonly _options;
  73515. private _attachController;
  73516. private _controllers;
  73517. private _debugMode;
  73518. private _delta;
  73519. private _headsetImpostor?;
  73520. private _headsetMesh?;
  73521. private _lastTimestamp;
  73522. private _tmpQuaternion;
  73523. private _tmpVector;
  73524. /**
  73525. * The module's name
  73526. */
  73527. static readonly Name: string;
  73528. /**
  73529. * The (Babylon) version of this module.
  73530. * This is an integer representing the implementation version.
  73531. * This number does not correspond to the webxr specs version
  73532. */
  73533. static readonly Version: number;
  73534. /**
  73535. * Construct a new Controller Physics Feature
  73536. * @param _xrSessionManager the corresponding xr session manager
  73537. * @param _options options to create this feature with
  73538. */
  73539. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73540. /**
  73541. * @hidden
  73542. * enable debugging - will show console outputs and the impostor mesh
  73543. */
  73544. _enablePhysicsDebug(): void;
  73545. /**
  73546. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73547. * @param xrController the controller to add
  73548. */
  73549. addController(xrController: WebXRInputSource): void;
  73550. /**
  73551. * attach this feature
  73552. * Will usually be called by the features manager
  73553. *
  73554. * @returns true if successful.
  73555. */
  73556. attach(): boolean;
  73557. /**
  73558. * detach this feature.
  73559. * Will usually be called by the features manager
  73560. *
  73561. * @returns true if successful.
  73562. */
  73563. detach(): boolean;
  73564. /**
  73565. * Get the headset impostor, if enabled
  73566. * @returns the impostor
  73567. */
  73568. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73569. /**
  73570. * Get the physics impostor of a specific controller.
  73571. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73572. * @param controller the controller or the controller id of which to get the impostor
  73573. * @returns the impostor or null
  73574. */
  73575. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73576. /**
  73577. * Update the physics properties provided in the constructor
  73578. * @param newProperties the new properties object
  73579. */
  73580. setPhysicsProperties(newProperties: {
  73581. impostorType?: number;
  73582. impostorSize?: number | {
  73583. width: number;
  73584. height: number;
  73585. depth: number;
  73586. };
  73587. friction?: number;
  73588. restitution?: number;
  73589. }): void;
  73590. protected _onXRFrame(_xrFrame: any): void;
  73591. private _detachController;
  73592. }
  73593. }
  73594. declare module "babylonjs/XR/features/WebXRHitTest" {
  73595. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73596. import { Observable } from "babylonjs/Misc/observable";
  73597. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  73598. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73599. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73600. /**
  73601. * Options used for hit testing (version 2)
  73602. */
  73603. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73604. /**
  73605. * Do not create a permanent hit test. Will usually be used when only
  73606. * transient inputs are needed.
  73607. */
  73608. disablePermanentHitTest?: boolean;
  73609. /**
  73610. * Enable transient (for example touch-based) hit test inspections
  73611. */
  73612. enableTransientHitTest?: boolean;
  73613. /**
  73614. * Offset ray for the permanent hit test
  73615. */
  73616. offsetRay?: Vector3;
  73617. /**
  73618. * Offset ray for the transient hit test
  73619. */
  73620. transientOffsetRay?: Vector3;
  73621. /**
  73622. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73623. */
  73624. useReferenceSpace?: boolean;
  73625. }
  73626. /**
  73627. * Interface defining the babylon result of hit-test
  73628. */
  73629. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73630. /**
  73631. * The input source that generated this hit test (if transient)
  73632. */
  73633. inputSource?: XRInputSource;
  73634. /**
  73635. * Is this a transient hit test
  73636. */
  73637. isTransient?: boolean;
  73638. /**
  73639. * Position of the hit test result
  73640. */
  73641. position: Vector3;
  73642. /**
  73643. * Rotation of the hit test result
  73644. */
  73645. rotationQuaternion: Quaternion;
  73646. }
  73647. /**
  73648. * The currently-working hit-test module.
  73649. * Hit test (or Ray-casting) is used to interact with the real world.
  73650. * For further information read here - https://github.com/immersive-web/hit-test
  73651. *
  73652. * Tested on chrome (mobile) 80.
  73653. */
  73654. export class WebXRHitTest extends WebXRAbstractFeature {
  73655. /**
  73656. * options to use when constructing this feature
  73657. */
  73658. readonly options: IWebXRHitTestOptions;
  73659. private _tmpMat;
  73660. private _tmpPos;
  73661. private _tmpQuat;
  73662. private _transientXrHitTestSource;
  73663. private _xrHitTestSource;
  73664. private initHitTestSource;
  73665. /**
  73666. * The module's name
  73667. */
  73668. static readonly Name: string;
  73669. /**
  73670. * The (Babylon) version of this module.
  73671. * This is an integer representing the implementation version.
  73672. * This number does not correspond to the WebXR specs version
  73673. */
  73674. static readonly Version: number;
  73675. /**
  73676. * When set to true, each hit test will have its own position/rotation objects
  73677. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73678. * the developers will clone them or copy them as they see fit.
  73679. */
  73680. autoCloneTransformation: boolean;
  73681. /**
  73682. * Populated with the last native XR Hit Results
  73683. */
  73684. lastNativeXRHitResults: XRHitResult[];
  73685. /**
  73686. * Triggered when new babylon (transformed) hit test results are available
  73687. */
  73688. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73689. /**
  73690. * Use this to temporarily pause hit test checks.
  73691. */
  73692. paused: boolean;
  73693. /**
  73694. * Creates a new instance of the hit test feature
  73695. * @param _xrSessionManager an instance of WebXRSessionManager
  73696. * @param options options to use when constructing this feature
  73697. */
  73698. constructor(_xrSessionManager: WebXRSessionManager,
  73699. /**
  73700. * options to use when constructing this feature
  73701. */
  73702. options?: IWebXRHitTestOptions);
  73703. /**
  73704. * attach this feature
  73705. * Will usually be called by the features manager
  73706. *
  73707. * @returns true if successful.
  73708. */
  73709. attach(): boolean;
  73710. /**
  73711. * detach this feature.
  73712. * Will usually be called by the features manager
  73713. *
  73714. * @returns true if successful.
  73715. */
  73716. detach(): boolean;
  73717. /**
  73718. * Dispose this feature and all of the resources attached
  73719. */
  73720. dispose(): void;
  73721. protected _onXRFrame(frame: XRFrame): void;
  73722. private _processWebXRHitTestResult;
  73723. }
  73724. }
  73725. declare module "babylonjs/XR/features/index" {
  73726. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73727. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73728. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73729. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73730. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73731. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73732. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73733. export * from "babylonjs/XR/features/WebXRHitTest";
  73734. }
  73735. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73736. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73738. import { Scene } from "babylonjs/scene";
  73739. /**
  73740. * The motion controller class for all microsoft mixed reality controllers
  73741. */
  73742. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73743. protected readonly _mapping: {
  73744. defaultButton: {
  73745. "valueNodeName": string;
  73746. "unpressedNodeName": string;
  73747. "pressedNodeName": string;
  73748. };
  73749. defaultAxis: {
  73750. "valueNodeName": string;
  73751. "minNodeName": string;
  73752. "maxNodeName": string;
  73753. };
  73754. buttons: {
  73755. "xr-standard-trigger": {
  73756. "rootNodeName": string;
  73757. "componentProperty": string;
  73758. "states": string[];
  73759. };
  73760. "xr-standard-squeeze": {
  73761. "rootNodeName": string;
  73762. "componentProperty": string;
  73763. "states": string[];
  73764. };
  73765. "xr-standard-touchpad": {
  73766. "rootNodeName": string;
  73767. "labelAnchorNodeName": string;
  73768. "touchPointNodeName": string;
  73769. };
  73770. "xr-standard-thumbstick": {
  73771. "rootNodeName": string;
  73772. "componentProperty": string;
  73773. "states": string[];
  73774. };
  73775. };
  73776. axes: {
  73777. "xr-standard-touchpad": {
  73778. "x-axis": {
  73779. "rootNodeName": string;
  73780. };
  73781. "y-axis": {
  73782. "rootNodeName": string;
  73783. };
  73784. };
  73785. "xr-standard-thumbstick": {
  73786. "x-axis": {
  73787. "rootNodeName": string;
  73788. };
  73789. "y-axis": {
  73790. "rootNodeName": string;
  73791. };
  73792. };
  73793. };
  73794. };
  73795. /**
  73796. * The base url used to load the left and right controller models
  73797. */
  73798. static MODEL_BASE_URL: string;
  73799. /**
  73800. * The name of the left controller model file
  73801. */
  73802. static MODEL_LEFT_FILENAME: string;
  73803. /**
  73804. * The name of the right controller model file
  73805. */
  73806. static MODEL_RIGHT_FILENAME: string;
  73807. profileId: string;
  73808. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73809. protected _getFilenameAndPath(): {
  73810. filename: string;
  73811. path: string;
  73812. };
  73813. protected _getModelLoadingConstraints(): boolean;
  73814. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73815. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73816. protected _updateModel(): void;
  73817. }
  73818. }
  73819. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73820. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73822. import { Scene } from "babylonjs/scene";
  73823. /**
  73824. * The motion controller class for oculus touch (quest, rift).
  73825. * This class supports legacy mapping as well the standard xr mapping
  73826. */
  73827. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73828. private _forceLegacyControllers;
  73829. private _modelRootNode;
  73830. /**
  73831. * The base url used to load the left and right controller models
  73832. */
  73833. static MODEL_BASE_URL: string;
  73834. /**
  73835. * The name of the left controller model file
  73836. */
  73837. static MODEL_LEFT_FILENAME: string;
  73838. /**
  73839. * The name of the right controller model file
  73840. */
  73841. static MODEL_RIGHT_FILENAME: string;
  73842. /**
  73843. * Base Url for the Quest controller model.
  73844. */
  73845. static QUEST_MODEL_BASE_URL: string;
  73846. profileId: string;
  73847. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73848. protected _getFilenameAndPath(): {
  73849. filename: string;
  73850. path: string;
  73851. };
  73852. protected _getModelLoadingConstraints(): boolean;
  73853. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73854. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73855. protected _updateModel(): void;
  73856. /**
  73857. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73858. * between the touch and touch 2.
  73859. */
  73860. private _isQuest;
  73861. }
  73862. }
  73863. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73864. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73865. import { Scene } from "babylonjs/scene";
  73866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73867. /**
  73868. * The motion controller class for the standard HTC-Vive controllers
  73869. */
  73870. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73871. private _modelRootNode;
  73872. /**
  73873. * The base url used to load the left and right controller models
  73874. */
  73875. static MODEL_BASE_URL: string;
  73876. /**
  73877. * File name for the controller model.
  73878. */
  73879. static MODEL_FILENAME: string;
  73880. profileId: string;
  73881. /**
  73882. * Create a new Vive motion controller object
  73883. * @param scene the scene to use to create this controller
  73884. * @param gamepadObject the corresponding gamepad object
  73885. * @param handness the handness of the controller
  73886. */
  73887. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73888. protected _getFilenameAndPath(): {
  73889. filename: string;
  73890. path: string;
  73891. };
  73892. protected _getModelLoadingConstraints(): boolean;
  73893. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73894. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73895. protected _updateModel(): void;
  73896. }
  73897. }
  73898. declare module "babylonjs/XR/motionController/index" {
  73899. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73900. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73901. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73902. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73903. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73904. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73905. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73906. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73907. }
  73908. declare module "babylonjs/XR/index" {
  73909. export * from "babylonjs/XR/webXRCamera";
  73910. export * from "babylonjs/XR/webXREnterExitUI";
  73911. export * from "babylonjs/XR/webXRExperienceHelper";
  73912. export * from "babylonjs/XR/webXRInput";
  73913. export * from "babylonjs/XR/webXRInputSource";
  73914. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73915. export * from "babylonjs/XR/webXRTypes";
  73916. export * from "babylonjs/XR/webXRSessionManager";
  73917. export * from "babylonjs/XR/webXRDefaultExperience";
  73918. export * from "babylonjs/XR/webXRFeaturesManager";
  73919. export * from "babylonjs/XR/features/index";
  73920. export * from "babylonjs/XR/motionController/index";
  73921. }
  73922. declare module "babylonjs/index" {
  73923. export * from "babylonjs/abstractScene";
  73924. export * from "babylonjs/Actions/index";
  73925. export * from "babylonjs/Animations/index";
  73926. export * from "babylonjs/assetContainer";
  73927. export * from "babylonjs/Audio/index";
  73928. export * from "babylonjs/Behaviors/index";
  73929. export * from "babylonjs/Bones/index";
  73930. export * from "babylonjs/Cameras/index";
  73931. export * from "babylonjs/Collisions/index";
  73932. export * from "babylonjs/Culling/index";
  73933. export * from "babylonjs/Debug/index";
  73934. export * from "babylonjs/Engines/index";
  73935. export * from "babylonjs/Events/index";
  73936. export * from "babylonjs/Gamepads/index";
  73937. export * from "babylonjs/Gizmos/index";
  73938. export * from "babylonjs/Helpers/index";
  73939. export * from "babylonjs/Instrumentation/index";
  73940. export * from "babylonjs/Layers/index";
  73941. export * from "babylonjs/LensFlares/index";
  73942. export * from "babylonjs/Lights/index";
  73943. export * from "babylonjs/Loading/index";
  73944. export * from "babylonjs/Materials/index";
  73945. export * from "babylonjs/Maths/index";
  73946. export * from "babylonjs/Meshes/index";
  73947. export * from "babylonjs/Morph/index";
  73948. export * from "babylonjs/Navigation/index";
  73949. export * from "babylonjs/node";
  73950. export * from "babylonjs/Offline/index";
  73951. export * from "babylonjs/Particles/index";
  73952. export * from "babylonjs/Physics/index";
  73953. export * from "babylonjs/PostProcesses/index";
  73954. export * from "babylonjs/Probes/index";
  73955. export * from "babylonjs/Rendering/index";
  73956. export * from "babylonjs/scene";
  73957. export * from "babylonjs/sceneComponent";
  73958. export * from "babylonjs/Sprites/index";
  73959. export * from "babylonjs/States/index";
  73960. export * from "babylonjs/Misc/index";
  73961. export * from "babylonjs/XR/index";
  73962. export * from "babylonjs/types";
  73963. }
  73964. declare module "babylonjs/Animations/pathCursor" {
  73965. import { Vector3 } from "babylonjs/Maths/math.vector";
  73966. import { Path2 } from "babylonjs/Maths/math.path";
  73967. /**
  73968. * A cursor which tracks a point on a path
  73969. */
  73970. export class PathCursor {
  73971. private path;
  73972. /**
  73973. * Stores path cursor callbacks for when an onchange event is triggered
  73974. */
  73975. private _onchange;
  73976. /**
  73977. * The value of the path cursor
  73978. */
  73979. value: number;
  73980. /**
  73981. * The animation array of the path cursor
  73982. */
  73983. animations: Animation[];
  73984. /**
  73985. * Initializes the path cursor
  73986. * @param path The path to track
  73987. */
  73988. constructor(path: Path2);
  73989. /**
  73990. * Gets the cursor point on the path
  73991. * @returns A point on the path cursor at the cursor location
  73992. */
  73993. getPoint(): Vector3;
  73994. /**
  73995. * Moves the cursor ahead by the step amount
  73996. * @param step The amount to move the cursor forward
  73997. * @returns This path cursor
  73998. */
  73999. moveAhead(step?: number): PathCursor;
  74000. /**
  74001. * Moves the cursor behind by the step amount
  74002. * @param step The amount to move the cursor back
  74003. * @returns This path cursor
  74004. */
  74005. moveBack(step?: number): PathCursor;
  74006. /**
  74007. * Moves the cursor by the step amount
  74008. * If the step amount is greater than one, an exception is thrown
  74009. * @param step The amount to move the cursor
  74010. * @returns This path cursor
  74011. */
  74012. move(step: number): PathCursor;
  74013. /**
  74014. * Ensures that the value is limited between zero and one
  74015. * @returns This path cursor
  74016. */
  74017. private ensureLimits;
  74018. /**
  74019. * Runs onchange callbacks on change (used by the animation engine)
  74020. * @returns This path cursor
  74021. */
  74022. private raiseOnChange;
  74023. /**
  74024. * Executes a function on change
  74025. * @param f A path cursor onchange callback
  74026. * @returns This path cursor
  74027. */
  74028. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74029. }
  74030. }
  74031. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  74032. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  74033. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  74034. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  74035. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  74036. }
  74037. declare module "babylonjs/Engines/Processors/Expressions/index" {
  74038. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  74039. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  74040. }
  74041. declare module "babylonjs/Engines/Processors/index" {
  74042. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  74043. export * from "babylonjs/Engines/Processors/Expressions/index";
  74044. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  74045. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  74046. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  74047. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  74048. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  74049. export * from "babylonjs/Engines/Processors/shaderProcessor";
  74050. }
  74051. declare module "babylonjs/Legacy/legacy" {
  74052. import * as Babylon from "babylonjs/index";
  74053. export * from "babylonjs/index";
  74054. }
  74055. declare module "babylonjs/Shaders/blur.fragment" {
  74056. /** @hidden */
  74057. export var blurPixelShader: {
  74058. name: string;
  74059. shader: string;
  74060. };
  74061. }
  74062. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  74063. /** @hidden */
  74064. export var pointCloudVertexDeclaration: {
  74065. name: string;
  74066. shader: string;
  74067. };
  74068. }
  74069. declare module "babylonjs" {
  74070. export * from "babylonjs/Legacy/legacy";
  74071. }
  74072. declare module BABYLON {
  74073. /** Alias type for value that can be null */
  74074. export type Nullable<T> = T | null;
  74075. /**
  74076. * Alias type for number that are floats
  74077. * @ignorenaming
  74078. */
  74079. export type float = number;
  74080. /**
  74081. * Alias type for number that are doubles.
  74082. * @ignorenaming
  74083. */
  74084. export type double = number;
  74085. /**
  74086. * Alias type for number that are integer
  74087. * @ignorenaming
  74088. */
  74089. export type int = number;
  74090. /** Alias type for number array or Float32Array */
  74091. export type FloatArray = number[] | Float32Array;
  74092. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  74093. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  74094. /**
  74095. * Alias for types that can be used by a Buffer or VertexBuffer.
  74096. */
  74097. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  74098. /**
  74099. * Alias type for primitive types
  74100. * @ignorenaming
  74101. */
  74102. type Primitive = undefined | null | boolean | string | number | Function;
  74103. /**
  74104. * Type modifier to make all the properties of an object Readonly
  74105. */
  74106. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  74107. /**
  74108. * Type modifier to make all the properties of an object Readonly recursively
  74109. */
  74110. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  74111. /**
  74112. * Type modifier to make object properties readonly.
  74113. */
  74114. export type DeepImmutableObject<T> = {
  74115. readonly [K in keyof T]: DeepImmutable<T[K]>;
  74116. };
  74117. /** @hidden */
  74118. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  74119. }
  74120. }
  74121. declare module BABYLON {
  74122. /**
  74123. * A class serves as a medium between the observable and its observers
  74124. */
  74125. export class EventState {
  74126. /**
  74127. * Create a new EventState
  74128. * @param mask defines the mask associated with this state
  74129. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74130. * @param target defines the original target of the state
  74131. * @param currentTarget defines the current target of the state
  74132. */
  74133. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  74134. /**
  74135. * Initialize the current event state
  74136. * @param mask defines the mask associated with this state
  74137. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74138. * @param target defines the original target of the state
  74139. * @param currentTarget defines the current target of the state
  74140. * @returns the current event state
  74141. */
  74142. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  74143. /**
  74144. * An Observer can set this property to true to prevent subsequent observers of being notified
  74145. */
  74146. skipNextObservers: boolean;
  74147. /**
  74148. * Get the mask value that were used to trigger the event corresponding to this EventState object
  74149. */
  74150. mask: number;
  74151. /**
  74152. * The object that originally notified the event
  74153. */
  74154. target?: any;
  74155. /**
  74156. * The current object in the bubbling phase
  74157. */
  74158. currentTarget?: any;
  74159. /**
  74160. * This will be populated with the return value of the last function that was executed.
  74161. * If it is the first function in the callback chain it will be the event data.
  74162. */
  74163. lastReturnValue?: any;
  74164. }
  74165. /**
  74166. * Represent an Observer registered to a given Observable object.
  74167. */
  74168. export class Observer<T> {
  74169. /**
  74170. * Defines the callback to call when the observer is notified
  74171. */
  74172. callback: (eventData: T, eventState: EventState) => void;
  74173. /**
  74174. * Defines the mask of the observer (used to filter notifications)
  74175. */
  74176. mask: number;
  74177. /**
  74178. * Defines the current scope used to restore the JS context
  74179. */
  74180. scope: any;
  74181. /** @hidden */
  74182. _willBeUnregistered: boolean;
  74183. /**
  74184. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  74185. */
  74186. unregisterOnNextCall: boolean;
  74187. /**
  74188. * Creates a new observer
  74189. * @param callback defines the callback to call when the observer is notified
  74190. * @param mask defines the mask of the observer (used to filter notifications)
  74191. * @param scope defines the current scope used to restore the JS context
  74192. */
  74193. constructor(
  74194. /**
  74195. * Defines the callback to call when the observer is notified
  74196. */
  74197. callback: (eventData: T, eventState: EventState) => void,
  74198. /**
  74199. * Defines the mask of the observer (used to filter notifications)
  74200. */
  74201. mask: number,
  74202. /**
  74203. * Defines the current scope used to restore the JS context
  74204. */
  74205. scope?: any);
  74206. }
  74207. /**
  74208. * Represent a list of observers registered to multiple Observables object.
  74209. */
  74210. export class MultiObserver<T> {
  74211. private _observers;
  74212. private _observables;
  74213. /**
  74214. * Release associated resources
  74215. */
  74216. dispose(): void;
  74217. /**
  74218. * Raise a callback when one of the observable will notify
  74219. * @param observables defines a list of observables to watch
  74220. * @param callback defines the callback to call on notification
  74221. * @param mask defines the mask used to filter notifications
  74222. * @param scope defines the current scope used to restore the JS context
  74223. * @returns the new MultiObserver
  74224. */
  74225. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  74226. }
  74227. /**
  74228. * The Observable class is a simple implementation of the Observable pattern.
  74229. *
  74230. * 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.
  74231. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  74232. * 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).
  74233. * 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.
  74234. */
  74235. export class Observable<T> {
  74236. private _observers;
  74237. private _eventState;
  74238. private _onObserverAdded;
  74239. /**
  74240. * Gets the list of observers
  74241. */
  74242. get observers(): Array<Observer<T>>;
  74243. /**
  74244. * Creates a new observable
  74245. * @param onObserverAdded defines a callback to call when a new observer is added
  74246. */
  74247. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  74248. /**
  74249. * Create a new Observer with the specified callback
  74250. * @param callback the callback that will be executed for that Observer
  74251. * @param mask the mask used to filter observers
  74252. * @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.
  74253. * @param scope optional scope for the callback to be called from
  74254. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  74255. * @returns the new observer created for the callback
  74256. */
  74257. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  74258. /**
  74259. * Create a new Observer with the specified callback and unregisters after the next notification
  74260. * @param callback the callback that will be executed for that Observer
  74261. * @returns the new observer created for the callback
  74262. */
  74263. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  74264. /**
  74265. * Remove an Observer from the Observable object
  74266. * @param observer the instance of the Observer to remove
  74267. * @returns false if it doesn't belong to this Observable
  74268. */
  74269. remove(observer: Nullable<Observer<T>>): boolean;
  74270. /**
  74271. * Remove a callback from the Observable object
  74272. * @param callback the callback to remove
  74273. * @param scope optional scope. If used only the callbacks with this scope will be removed
  74274. * @returns false if it doesn't belong to this Observable
  74275. */
  74276. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  74277. private _deferUnregister;
  74278. private _remove;
  74279. /**
  74280. * Moves the observable to the top of the observer list making it get called first when notified
  74281. * @param observer the observer to move
  74282. */
  74283. makeObserverTopPriority(observer: Observer<T>): void;
  74284. /**
  74285. * Moves the observable to the bottom of the observer list making it get called last when notified
  74286. * @param observer the observer to move
  74287. */
  74288. makeObserverBottomPriority(observer: Observer<T>): void;
  74289. /**
  74290. * Notify all Observers by calling their respective callback with the given data
  74291. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  74292. * @param eventData defines the data to send to all observers
  74293. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  74294. * @param target defines the original target of the state
  74295. * @param currentTarget defines the current target of the state
  74296. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  74297. */
  74298. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  74299. /**
  74300. * Calling this will execute each callback, expecting it to be a promise or return a value.
  74301. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  74302. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  74303. * and it is crucial that all callbacks will be executed.
  74304. * The order of the callbacks is kept, callbacks are not executed parallel.
  74305. *
  74306. * @param eventData The data to be sent to each callback
  74307. * @param mask is used to filter observers defaults to -1
  74308. * @param target defines the callback target (see EventState)
  74309. * @param currentTarget defines he current object in the bubbling phase
  74310. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  74311. */
  74312. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  74313. /**
  74314. * Notify a specific observer
  74315. * @param observer defines the observer to notify
  74316. * @param eventData defines the data to be sent to each callback
  74317. * @param mask is used to filter observers defaults to -1
  74318. */
  74319. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  74320. /**
  74321. * Gets a boolean indicating if the observable has at least one observer
  74322. * @returns true is the Observable has at least one Observer registered
  74323. */
  74324. hasObservers(): boolean;
  74325. /**
  74326. * Clear the list of observers
  74327. */
  74328. clear(): void;
  74329. /**
  74330. * Clone the current observable
  74331. * @returns a new observable
  74332. */
  74333. clone(): Observable<T>;
  74334. /**
  74335. * Does this observable handles observer registered with a given mask
  74336. * @param mask defines the mask to be tested
  74337. * @return whether or not one observer registered with the given mask is handeled
  74338. **/
  74339. hasSpecificMask(mask?: number): boolean;
  74340. }
  74341. }
  74342. declare module BABYLON {
  74343. /**
  74344. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  74345. * Babylon.js
  74346. */
  74347. export class DomManagement {
  74348. /**
  74349. * Checks if the window object exists
  74350. * @returns true if the window object exists
  74351. */
  74352. static IsWindowObjectExist(): boolean;
  74353. /**
  74354. * Checks if the navigator object exists
  74355. * @returns true if the navigator object exists
  74356. */
  74357. static IsNavigatorAvailable(): boolean;
  74358. /**
  74359. * Extracts text content from a DOM element hierarchy
  74360. * @param element defines the root element
  74361. * @returns a string
  74362. */
  74363. static GetDOMTextContent(element: HTMLElement): string;
  74364. }
  74365. }
  74366. declare module BABYLON {
  74367. /**
  74368. * Logger used througouht the application to allow configuration of
  74369. * the log level required for the messages.
  74370. */
  74371. export class Logger {
  74372. /**
  74373. * No log
  74374. */
  74375. static readonly NoneLogLevel: number;
  74376. /**
  74377. * Only message logs
  74378. */
  74379. static readonly MessageLogLevel: number;
  74380. /**
  74381. * Only warning logs
  74382. */
  74383. static readonly WarningLogLevel: number;
  74384. /**
  74385. * Only error logs
  74386. */
  74387. static readonly ErrorLogLevel: number;
  74388. /**
  74389. * All logs
  74390. */
  74391. static readonly AllLogLevel: number;
  74392. private static _LogCache;
  74393. /**
  74394. * Gets a value indicating the number of loading errors
  74395. * @ignorenaming
  74396. */
  74397. static errorsCount: number;
  74398. /**
  74399. * Callback called when a new log is added
  74400. */
  74401. static OnNewCacheEntry: (entry: string) => void;
  74402. private static _AddLogEntry;
  74403. private static _FormatMessage;
  74404. private static _LogDisabled;
  74405. private static _LogEnabled;
  74406. private static _WarnDisabled;
  74407. private static _WarnEnabled;
  74408. private static _ErrorDisabled;
  74409. private static _ErrorEnabled;
  74410. /**
  74411. * Log a message to the console
  74412. */
  74413. static Log: (message: string) => void;
  74414. /**
  74415. * Write a warning message to the console
  74416. */
  74417. static Warn: (message: string) => void;
  74418. /**
  74419. * Write an error message to the console
  74420. */
  74421. static Error: (message: string) => void;
  74422. /**
  74423. * Gets current log cache (list of logs)
  74424. */
  74425. static get LogCache(): string;
  74426. /**
  74427. * Clears the log cache
  74428. */
  74429. static ClearLogCache(): void;
  74430. /**
  74431. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  74432. */
  74433. static set LogLevels(level: number);
  74434. }
  74435. }
  74436. declare module BABYLON {
  74437. /** @hidden */
  74438. export class _TypeStore {
  74439. /** @hidden */
  74440. static RegisteredTypes: {
  74441. [key: string]: Object;
  74442. };
  74443. /** @hidden */
  74444. static GetClass(fqdn: string): any;
  74445. }
  74446. }
  74447. declare module BABYLON {
  74448. /**
  74449. * Helper to manipulate strings
  74450. */
  74451. export class StringTools {
  74452. /**
  74453. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  74454. * @param str Source string
  74455. * @param suffix Suffix to search for in the source string
  74456. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74457. */
  74458. static EndsWith(str: string, suffix: string): boolean;
  74459. /**
  74460. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  74461. * @param str Source string
  74462. * @param suffix Suffix to search for in the source string
  74463. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74464. */
  74465. static StartsWith(str: string, suffix: string): boolean;
  74466. /**
  74467. * Decodes a buffer into a string
  74468. * @param buffer The buffer to decode
  74469. * @returns The decoded string
  74470. */
  74471. static Decode(buffer: Uint8Array | Uint16Array): string;
  74472. /**
  74473. * Encode a buffer to a base64 string
  74474. * @param buffer defines the buffer to encode
  74475. * @returns the encoded string
  74476. */
  74477. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  74478. /**
  74479. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  74480. * @param num the number to convert and pad
  74481. * @param length the expected length of the string
  74482. * @returns the padded string
  74483. */
  74484. static PadNumber(num: number, length: number): string;
  74485. }
  74486. }
  74487. declare module BABYLON {
  74488. /**
  74489. * Class containing a set of static utilities functions for deep copy.
  74490. */
  74491. export class DeepCopier {
  74492. /**
  74493. * Tries to copy an object by duplicating every property
  74494. * @param source defines the source object
  74495. * @param destination defines the target object
  74496. * @param doNotCopyList defines a list of properties to avoid
  74497. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74498. */
  74499. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74500. }
  74501. }
  74502. declare module BABYLON {
  74503. /**
  74504. * Class containing a set of static utilities functions for precision date
  74505. */
  74506. export class PrecisionDate {
  74507. /**
  74508. * Gets either window.performance.now() if supported or Date.now() else
  74509. */
  74510. static get Now(): number;
  74511. }
  74512. }
  74513. declare module BABYLON {
  74514. /** @hidden */
  74515. export class _DevTools {
  74516. static WarnImport(name: string): string;
  74517. }
  74518. }
  74519. declare module BABYLON {
  74520. /**
  74521. * Interface used to define the mechanism to get data from the network
  74522. */
  74523. export interface IWebRequest {
  74524. /**
  74525. * Returns client's response url
  74526. */
  74527. responseURL: string;
  74528. /**
  74529. * Returns client's status
  74530. */
  74531. status: number;
  74532. /**
  74533. * Returns client's status as a text
  74534. */
  74535. statusText: string;
  74536. }
  74537. }
  74538. declare module BABYLON {
  74539. /**
  74540. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74541. */
  74542. export class WebRequest implements IWebRequest {
  74543. private _xhr;
  74544. /**
  74545. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74546. * i.e. when loading files, where the server/service expects an Authorization header
  74547. */
  74548. static CustomRequestHeaders: {
  74549. [key: string]: string;
  74550. };
  74551. /**
  74552. * Add callback functions in this array to update all the requests before they get sent to the network
  74553. */
  74554. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74555. private _injectCustomRequestHeaders;
  74556. /**
  74557. * Gets or sets a function to be called when loading progress changes
  74558. */
  74559. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74560. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74561. /**
  74562. * Returns client's state
  74563. */
  74564. get readyState(): number;
  74565. /**
  74566. * Returns client's status
  74567. */
  74568. get status(): number;
  74569. /**
  74570. * Returns client's status as a text
  74571. */
  74572. get statusText(): string;
  74573. /**
  74574. * Returns client's response
  74575. */
  74576. get response(): any;
  74577. /**
  74578. * Returns client's response url
  74579. */
  74580. get responseURL(): string;
  74581. /**
  74582. * Returns client's response as text
  74583. */
  74584. get responseText(): string;
  74585. /**
  74586. * Gets or sets the expected response type
  74587. */
  74588. get responseType(): XMLHttpRequestResponseType;
  74589. set responseType(value: XMLHttpRequestResponseType);
  74590. /** @hidden */
  74591. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74592. /** @hidden */
  74593. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74594. /**
  74595. * Cancels any network activity
  74596. */
  74597. abort(): void;
  74598. /**
  74599. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74600. * @param body defines an optional request body
  74601. */
  74602. send(body?: Document | BodyInit | null): void;
  74603. /**
  74604. * Sets the request method, request URL
  74605. * @param method defines the method to use (GET, POST, etc..)
  74606. * @param url defines the url to connect with
  74607. */
  74608. open(method: string, url: string): void;
  74609. /**
  74610. * Sets the value of a request header.
  74611. * @param name The name of the header whose value is to be set
  74612. * @param value The value to set as the body of the header
  74613. */
  74614. setRequestHeader(name: string, value: string): void;
  74615. /**
  74616. * Get the string containing the text of a particular header's value.
  74617. * @param name The name of the header
  74618. * @returns The string containing the text of the given header name
  74619. */
  74620. getResponseHeader(name: string): Nullable<string>;
  74621. }
  74622. }
  74623. declare module BABYLON {
  74624. /**
  74625. * File request interface
  74626. */
  74627. export interface IFileRequest {
  74628. /**
  74629. * Raised when the request is complete (success or error).
  74630. */
  74631. onCompleteObservable: Observable<IFileRequest>;
  74632. /**
  74633. * Aborts the request for a file.
  74634. */
  74635. abort: () => void;
  74636. }
  74637. }
  74638. declare module BABYLON {
  74639. /**
  74640. * Define options used to create a render target texture
  74641. */
  74642. export class RenderTargetCreationOptions {
  74643. /**
  74644. * Specifies is mipmaps must be generated
  74645. */
  74646. generateMipMaps?: boolean;
  74647. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74648. generateDepthBuffer?: boolean;
  74649. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74650. generateStencilBuffer?: boolean;
  74651. /** Defines texture type (int by default) */
  74652. type?: number;
  74653. /** Defines sampling mode (trilinear by default) */
  74654. samplingMode?: number;
  74655. /** Defines format (RGBA by default) */
  74656. format?: number;
  74657. }
  74658. }
  74659. declare module BABYLON {
  74660. /** Defines the cross module used constants to avoid circular dependncies */
  74661. export class Constants {
  74662. /** Defines that alpha blending is disabled */
  74663. static readonly ALPHA_DISABLE: number;
  74664. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74665. static readonly ALPHA_ADD: number;
  74666. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74667. static readonly ALPHA_COMBINE: number;
  74668. /** Defines that alpha blending is DEST - SRC * DEST */
  74669. static readonly ALPHA_SUBTRACT: number;
  74670. /** Defines that alpha blending is SRC * DEST */
  74671. static readonly ALPHA_MULTIPLY: number;
  74672. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74673. static readonly ALPHA_MAXIMIZED: number;
  74674. /** Defines that alpha blending is SRC + DEST */
  74675. static readonly ALPHA_ONEONE: number;
  74676. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74677. static readonly ALPHA_PREMULTIPLIED: number;
  74678. /**
  74679. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74680. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74681. */
  74682. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74683. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74684. static readonly ALPHA_INTERPOLATE: number;
  74685. /**
  74686. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74687. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74688. */
  74689. static readonly ALPHA_SCREENMODE: number;
  74690. /**
  74691. * Defines that alpha blending is SRC + DST
  74692. * Alpha will be set to SRC ALPHA + DST ALPHA
  74693. */
  74694. static readonly ALPHA_ONEONE_ONEONE: number;
  74695. /**
  74696. * Defines that alpha blending is SRC * DST ALPHA + DST
  74697. * Alpha will be set to 0
  74698. */
  74699. static readonly ALPHA_ALPHATOCOLOR: number;
  74700. /**
  74701. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74702. */
  74703. static readonly ALPHA_REVERSEONEMINUS: number;
  74704. /**
  74705. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74706. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74707. */
  74708. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74709. /**
  74710. * Defines that alpha blending is SRC + DST
  74711. * Alpha will be set to SRC ALPHA
  74712. */
  74713. static readonly ALPHA_ONEONE_ONEZERO: number;
  74714. /**
  74715. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74716. * Alpha will be set to DST ALPHA
  74717. */
  74718. static readonly ALPHA_EXCLUSION: number;
  74719. /** Defines that alpha blending equation a SUM */
  74720. static readonly ALPHA_EQUATION_ADD: number;
  74721. /** Defines that alpha blending equation a SUBSTRACTION */
  74722. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74723. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74724. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74725. /** Defines that alpha blending equation a MAX operation */
  74726. static readonly ALPHA_EQUATION_MAX: number;
  74727. /** Defines that alpha blending equation a MIN operation */
  74728. static readonly ALPHA_EQUATION_MIN: number;
  74729. /**
  74730. * Defines that alpha blending equation a DARKEN operation:
  74731. * It takes the min of the src and sums the alpha channels.
  74732. */
  74733. static readonly ALPHA_EQUATION_DARKEN: number;
  74734. /** Defines that the ressource is not delayed*/
  74735. static readonly DELAYLOADSTATE_NONE: number;
  74736. /** Defines that the ressource was successfully delay loaded */
  74737. static readonly DELAYLOADSTATE_LOADED: number;
  74738. /** Defines that the ressource is currently delay loading */
  74739. static readonly DELAYLOADSTATE_LOADING: number;
  74740. /** Defines that the ressource is delayed and has not started loading */
  74741. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74742. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74743. static readonly NEVER: number;
  74744. /** 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 */
  74745. static readonly ALWAYS: number;
  74746. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74747. static readonly LESS: number;
  74748. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74749. static readonly EQUAL: number;
  74750. /** 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 */
  74751. static readonly LEQUAL: number;
  74752. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74753. static readonly GREATER: number;
  74754. /** 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 */
  74755. static readonly GEQUAL: number;
  74756. /** 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 */
  74757. static readonly NOTEQUAL: number;
  74758. /** Passed to stencilOperation to specify that stencil value must be kept */
  74759. static readonly KEEP: number;
  74760. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74761. static readonly REPLACE: number;
  74762. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74763. static readonly INCR: number;
  74764. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74765. static readonly DECR: number;
  74766. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74767. static readonly INVERT: number;
  74768. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74769. static readonly INCR_WRAP: number;
  74770. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74771. static readonly DECR_WRAP: number;
  74772. /** Texture is not repeating outside of 0..1 UVs */
  74773. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74774. /** Texture is repeating outside of 0..1 UVs */
  74775. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74776. /** Texture is repeating and mirrored */
  74777. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74778. /** ALPHA */
  74779. static readonly TEXTUREFORMAT_ALPHA: number;
  74780. /** LUMINANCE */
  74781. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74782. /** LUMINANCE_ALPHA */
  74783. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74784. /** RGB */
  74785. static readonly TEXTUREFORMAT_RGB: number;
  74786. /** RGBA */
  74787. static readonly TEXTUREFORMAT_RGBA: number;
  74788. /** RED */
  74789. static readonly TEXTUREFORMAT_RED: number;
  74790. /** RED (2nd reference) */
  74791. static readonly TEXTUREFORMAT_R: number;
  74792. /** RG */
  74793. static readonly TEXTUREFORMAT_RG: number;
  74794. /** RED_INTEGER */
  74795. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74796. /** RED_INTEGER (2nd reference) */
  74797. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74798. /** RG_INTEGER */
  74799. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74800. /** RGB_INTEGER */
  74801. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74802. /** RGBA_INTEGER */
  74803. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74804. /** UNSIGNED_BYTE */
  74805. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74806. /** UNSIGNED_BYTE (2nd reference) */
  74807. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74808. /** FLOAT */
  74809. static readonly TEXTURETYPE_FLOAT: number;
  74810. /** HALF_FLOAT */
  74811. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74812. /** BYTE */
  74813. static readonly TEXTURETYPE_BYTE: number;
  74814. /** SHORT */
  74815. static readonly TEXTURETYPE_SHORT: number;
  74816. /** UNSIGNED_SHORT */
  74817. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74818. /** INT */
  74819. static readonly TEXTURETYPE_INT: number;
  74820. /** UNSIGNED_INT */
  74821. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74822. /** UNSIGNED_SHORT_4_4_4_4 */
  74823. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74824. /** UNSIGNED_SHORT_5_5_5_1 */
  74825. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74826. /** UNSIGNED_SHORT_5_6_5 */
  74827. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74828. /** UNSIGNED_INT_2_10_10_10_REV */
  74829. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74830. /** UNSIGNED_INT_24_8 */
  74831. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74832. /** UNSIGNED_INT_10F_11F_11F_REV */
  74833. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74834. /** UNSIGNED_INT_5_9_9_9_REV */
  74835. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74836. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74837. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74838. /** nearest is mag = nearest and min = nearest and no mip */
  74839. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74840. /** mag = nearest and min = nearest and mip = none */
  74841. static readonly TEXTURE_NEAREST_NEAREST: number;
  74842. /** Bilinear is mag = linear and min = linear and no mip */
  74843. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74844. /** mag = linear and min = linear and mip = none */
  74845. static readonly TEXTURE_LINEAR_LINEAR: number;
  74846. /** Trilinear is mag = linear and min = linear and mip = linear */
  74847. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74848. /** Trilinear is mag = linear and min = linear and mip = linear */
  74849. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74850. /** mag = nearest and min = nearest and mip = nearest */
  74851. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74852. /** mag = nearest and min = linear and mip = nearest */
  74853. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74854. /** mag = nearest and min = linear and mip = linear */
  74855. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74856. /** mag = nearest and min = linear and mip = none */
  74857. static readonly TEXTURE_NEAREST_LINEAR: number;
  74858. /** nearest is mag = nearest and min = nearest and mip = linear */
  74859. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74860. /** mag = linear and min = nearest and mip = nearest */
  74861. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74862. /** mag = linear and min = nearest and mip = linear */
  74863. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74864. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74865. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74866. /** mag = linear and min = nearest and mip = none */
  74867. static readonly TEXTURE_LINEAR_NEAREST: number;
  74868. /** Explicit coordinates mode */
  74869. static readonly TEXTURE_EXPLICIT_MODE: number;
  74870. /** Spherical coordinates mode */
  74871. static readonly TEXTURE_SPHERICAL_MODE: number;
  74872. /** Planar coordinates mode */
  74873. static readonly TEXTURE_PLANAR_MODE: number;
  74874. /** Cubic coordinates mode */
  74875. static readonly TEXTURE_CUBIC_MODE: number;
  74876. /** Projection coordinates mode */
  74877. static readonly TEXTURE_PROJECTION_MODE: number;
  74878. /** Skybox coordinates mode */
  74879. static readonly TEXTURE_SKYBOX_MODE: number;
  74880. /** Inverse Cubic coordinates mode */
  74881. static readonly TEXTURE_INVCUBIC_MODE: number;
  74882. /** Equirectangular coordinates mode */
  74883. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74884. /** Equirectangular Fixed coordinates mode */
  74885. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74886. /** Equirectangular Fixed Mirrored coordinates mode */
  74887. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74888. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74889. static readonly SCALEMODE_FLOOR: number;
  74890. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74891. static readonly SCALEMODE_NEAREST: number;
  74892. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74893. static readonly SCALEMODE_CEILING: number;
  74894. /**
  74895. * The dirty texture flag value
  74896. */
  74897. static readonly MATERIAL_TextureDirtyFlag: number;
  74898. /**
  74899. * The dirty light flag value
  74900. */
  74901. static readonly MATERIAL_LightDirtyFlag: number;
  74902. /**
  74903. * The dirty fresnel flag value
  74904. */
  74905. static readonly MATERIAL_FresnelDirtyFlag: number;
  74906. /**
  74907. * The dirty attribute flag value
  74908. */
  74909. static readonly MATERIAL_AttributesDirtyFlag: number;
  74910. /**
  74911. * The dirty misc flag value
  74912. */
  74913. static readonly MATERIAL_MiscDirtyFlag: number;
  74914. /**
  74915. * The all dirty flag value
  74916. */
  74917. static readonly MATERIAL_AllDirtyFlag: number;
  74918. /**
  74919. * Returns the triangle fill mode
  74920. */
  74921. static readonly MATERIAL_TriangleFillMode: number;
  74922. /**
  74923. * Returns the wireframe mode
  74924. */
  74925. static readonly MATERIAL_WireFrameFillMode: number;
  74926. /**
  74927. * Returns the point fill mode
  74928. */
  74929. static readonly MATERIAL_PointFillMode: number;
  74930. /**
  74931. * Returns the point list draw mode
  74932. */
  74933. static readonly MATERIAL_PointListDrawMode: number;
  74934. /**
  74935. * Returns the line list draw mode
  74936. */
  74937. static readonly MATERIAL_LineListDrawMode: number;
  74938. /**
  74939. * Returns the line loop draw mode
  74940. */
  74941. static readonly MATERIAL_LineLoopDrawMode: number;
  74942. /**
  74943. * Returns the line strip draw mode
  74944. */
  74945. static readonly MATERIAL_LineStripDrawMode: number;
  74946. /**
  74947. * Returns the triangle strip draw mode
  74948. */
  74949. static readonly MATERIAL_TriangleStripDrawMode: number;
  74950. /**
  74951. * Returns the triangle fan draw mode
  74952. */
  74953. static readonly MATERIAL_TriangleFanDrawMode: number;
  74954. /**
  74955. * Stores the clock-wise side orientation
  74956. */
  74957. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74958. /**
  74959. * Stores the counter clock-wise side orientation
  74960. */
  74961. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74962. /**
  74963. * Nothing
  74964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74965. */
  74966. static readonly ACTION_NothingTrigger: number;
  74967. /**
  74968. * On pick
  74969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74970. */
  74971. static readonly ACTION_OnPickTrigger: number;
  74972. /**
  74973. * On left pick
  74974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74975. */
  74976. static readonly ACTION_OnLeftPickTrigger: number;
  74977. /**
  74978. * On right pick
  74979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74980. */
  74981. static readonly ACTION_OnRightPickTrigger: number;
  74982. /**
  74983. * On center pick
  74984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74985. */
  74986. static readonly ACTION_OnCenterPickTrigger: number;
  74987. /**
  74988. * On pick down
  74989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74990. */
  74991. static readonly ACTION_OnPickDownTrigger: number;
  74992. /**
  74993. * On double pick
  74994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74995. */
  74996. static readonly ACTION_OnDoublePickTrigger: number;
  74997. /**
  74998. * On pick up
  74999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75000. */
  75001. static readonly ACTION_OnPickUpTrigger: number;
  75002. /**
  75003. * On pick out.
  75004. * This trigger will only be raised if you also declared a OnPickDown
  75005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75006. */
  75007. static readonly ACTION_OnPickOutTrigger: number;
  75008. /**
  75009. * On long press
  75010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75011. */
  75012. static readonly ACTION_OnLongPressTrigger: number;
  75013. /**
  75014. * On pointer over
  75015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75016. */
  75017. static readonly ACTION_OnPointerOverTrigger: number;
  75018. /**
  75019. * On pointer out
  75020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75021. */
  75022. static readonly ACTION_OnPointerOutTrigger: number;
  75023. /**
  75024. * On every frame
  75025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75026. */
  75027. static readonly ACTION_OnEveryFrameTrigger: number;
  75028. /**
  75029. * On intersection enter
  75030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75031. */
  75032. static readonly ACTION_OnIntersectionEnterTrigger: number;
  75033. /**
  75034. * On intersection exit
  75035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75036. */
  75037. static readonly ACTION_OnIntersectionExitTrigger: number;
  75038. /**
  75039. * On key down
  75040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75041. */
  75042. static readonly ACTION_OnKeyDownTrigger: number;
  75043. /**
  75044. * On key up
  75045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75046. */
  75047. static readonly ACTION_OnKeyUpTrigger: number;
  75048. /**
  75049. * Billboard mode will only apply to Y axis
  75050. */
  75051. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  75052. /**
  75053. * Billboard mode will apply to all axes
  75054. */
  75055. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  75056. /**
  75057. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75058. */
  75059. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  75060. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  75061. * Test order :
  75062. * Is the bounding sphere outside the frustum ?
  75063. * If not, are the bounding box vertices outside the frustum ?
  75064. * It not, then the cullable object is in the frustum.
  75065. */
  75066. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  75067. /** Culling strategy : Bounding Sphere Only.
  75068. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  75069. * It's also less accurate than the standard because some not visible objects can still be selected.
  75070. * Test : is the bounding sphere outside the frustum ?
  75071. * If not, then the cullable object is in the frustum.
  75072. */
  75073. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  75074. /** Culling strategy : Optimistic Inclusion.
  75075. * This in an inclusion test first, then the standard exclusion test.
  75076. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  75077. * 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.
  75078. * Anyway, it's as accurate as the standard strategy.
  75079. * Test :
  75080. * Is the cullable object bounding sphere center in the frustum ?
  75081. * If not, apply the default culling strategy.
  75082. */
  75083. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  75084. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  75085. * This in an inclusion test first, then the bounding sphere only exclusion test.
  75086. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  75087. * 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.
  75088. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  75089. * Test :
  75090. * Is the cullable object bounding sphere center in the frustum ?
  75091. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  75092. */
  75093. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  75094. /**
  75095. * No logging while loading
  75096. */
  75097. static readonly SCENELOADER_NO_LOGGING: number;
  75098. /**
  75099. * Minimal logging while loading
  75100. */
  75101. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  75102. /**
  75103. * Summary logging while loading
  75104. */
  75105. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  75106. /**
  75107. * Detailled logging while loading
  75108. */
  75109. static readonly SCENELOADER_DETAILED_LOGGING: number;
  75110. }
  75111. }
  75112. declare module BABYLON {
  75113. /**
  75114. * This represents the required contract to create a new type of texture loader.
  75115. */
  75116. export interface IInternalTextureLoader {
  75117. /**
  75118. * Defines wether the loader supports cascade loading the different faces.
  75119. */
  75120. supportCascades: boolean;
  75121. /**
  75122. * This returns if the loader support the current file information.
  75123. * @param extension defines the file extension of the file being loaded
  75124. * @returns true if the loader can load the specified file
  75125. */
  75126. canLoad(extension: string): boolean;
  75127. /**
  75128. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  75129. * @param data contains the texture data
  75130. * @param texture defines the BabylonJS internal texture
  75131. * @param createPolynomials will be true if polynomials have been requested
  75132. * @param onLoad defines the callback to trigger once the texture is ready
  75133. * @param onError defines the callback to trigger in case of error
  75134. */
  75135. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  75136. /**
  75137. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  75138. * @param data contains the texture data
  75139. * @param texture defines the BabylonJS internal texture
  75140. * @param callback defines the method to call once ready to upload
  75141. */
  75142. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  75143. }
  75144. }
  75145. declare module BABYLON {
  75146. /**
  75147. * Class used to store and describe the pipeline context associated with an effect
  75148. */
  75149. export interface IPipelineContext {
  75150. /**
  75151. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  75152. */
  75153. isAsync: boolean;
  75154. /**
  75155. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  75156. */
  75157. isReady: boolean;
  75158. /** @hidden */
  75159. _getVertexShaderCode(): string | null;
  75160. /** @hidden */
  75161. _getFragmentShaderCode(): string | null;
  75162. /** @hidden */
  75163. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  75164. }
  75165. }
  75166. declare module BABYLON {
  75167. /**
  75168. * Class used to store gfx data (like WebGLBuffer)
  75169. */
  75170. export class DataBuffer {
  75171. /**
  75172. * Gets or sets the number of objects referencing this buffer
  75173. */
  75174. references: number;
  75175. /** Gets or sets the size of the underlying buffer */
  75176. capacity: number;
  75177. /**
  75178. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  75179. */
  75180. is32Bits: boolean;
  75181. /**
  75182. * Gets the underlying buffer
  75183. */
  75184. get underlyingResource(): any;
  75185. }
  75186. }
  75187. declare module BABYLON {
  75188. /** @hidden */
  75189. export interface IShaderProcessor {
  75190. attributeProcessor?: (attribute: string) => string;
  75191. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  75192. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  75193. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  75194. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  75195. lineProcessor?: (line: string, isFragment: boolean) => string;
  75196. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75197. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75198. }
  75199. }
  75200. declare module BABYLON {
  75201. /** @hidden */
  75202. export interface ProcessingOptions {
  75203. defines: string[];
  75204. indexParameters: any;
  75205. isFragment: boolean;
  75206. shouldUseHighPrecisionShader: boolean;
  75207. supportsUniformBuffers: boolean;
  75208. shadersRepository: string;
  75209. includesShadersStore: {
  75210. [key: string]: string;
  75211. };
  75212. processor?: IShaderProcessor;
  75213. version: string;
  75214. platformName: string;
  75215. lookForClosingBracketForUniformBuffer?: boolean;
  75216. }
  75217. }
  75218. declare module BABYLON {
  75219. /** @hidden */
  75220. export class ShaderCodeNode {
  75221. line: string;
  75222. children: ShaderCodeNode[];
  75223. additionalDefineKey?: string;
  75224. additionalDefineValue?: string;
  75225. isValid(preprocessors: {
  75226. [key: string]: string;
  75227. }): boolean;
  75228. process(preprocessors: {
  75229. [key: string]: string;
  75230. }, options: ProcessingOptions): string;
  75231. }
  75232. }
  75233. declare module BABYLON {
  75234. /** @hidden */
  75235. export class ShaderCodeCursor {
  75236. private _lines;
  75237. lineIndex: number;
  75238. get currentLine(): string;
  75239. get canRead(): boolean;
  75240. set lines(value: string[]);
  75241. }
  75242. }
  75243. declare module BABYLON {
  75244. /** @hidden */
  75245. export class ShaderCodeConditionNode extends ShaderCodeNode {
  75246. process(preprocessors: {
  75247. [key: string]: string;
  75248. }, options: ProcessingOptions): string;
  75249. }
  75250. }
  75251. declare module BABYLON {
  75252. /** @hidden */
  75253. export class ShaderDefineExpression {
  75254. isTrue(preprocessors: {
  75255. [key: string]: string;
  75256. }): boolean;
  75257. }
  75258. }
  75259. declare module BABYLON {
  75260. /** @hidden */
  75261. export class ShaderCodeTestNode extends ShaderCodeNode {
  75262. testExpression: ShaderDefineExpression;
  75263. isValid(preprocessors: {
  75264. [key: string]: string;
  75265. }): boolean;
  75266. }
  75267. }
  75268. declare module BABYLON {
  75269. /** @hidden */
  75270. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  75271. define: string;
  75272. not: boolean;
  75273. constructor(define: string, not?: boolean);
  75274. isTrue(preprocessors: {
  75275. [key: string]: string;
  75276. }): boolean;
  75277. }
  75278. }
  75279. declare module BABYLON {
  75280. /** @hidden */
  75281. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  75282. leftOperand: ShaderDefineExpression;
  75283. rightOperand: ShaderDefineExpression;
  75284. isTrue(preprocessors: {
  75285. [key: string]: string;
  75286. }): boolean;
  75287. }
  75288. }
  75289. declare module BABYLON {
  75290. /** @hidden */
  75291. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  75292. leftOperand: ShaderDefineExpression;
  75293. rightOperand: ShaderDefineExpression;
  75294. isTrue(preprocessors: {
  75295. [key: string]: string;
  75296. }): boolean;
  75297. }
  75298. }
  75299. declare module BABYLON {
  75300. /** @hidden */
  75301. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  75302. define: string;
  75303. operand: string;
  75304. testValue: string;
  75305. constructor(define: string, operand: string, testValue: string);
  75306. isTrue(preprocessors: {
  75307. [key: string]: string;
  75308. }): boolean;
  75309. }
  75310. }
  75311. declare module BABYLON {
  75312. /**
  75313. * Class used to enable access to offline support
  75314. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75315. */
  75316. export interface IOfflineProvider {
  75317. /**
  75318. * Gets a boolean indicating if scene must be saved in the database
  75319. */
  75320. enableSceneOffline: boolean;
  75321. /**
  75322. * Gets a boolean indicating if textures must be saved in the database
  75323. */
  75324. enableTexturesOffline: boolean;
  75325. /**
  75326. * Open the offline support and make it available
  75327. * @param successCallback defines the callback to call on success
  75328. * @param errorCallback defines the callback to call on error
  75329. */
  75330. open(successCallback: () => void, errorCallback: () => void): void;
  75331. /**
  75332. * Loads an image from the offline support
  75333. * @param url defines the url to load from
  75334. * @param image defines the target DOM image
  75335. */
  75336. loadImage(url: string, image: HTMLImageElement): void;
  75337. /**
  75338. * Loads a file from offline support
  75339. * @param url defines the URL to load from
  75340. * @param sceneLoaded defines a callback to call on success
  75341. * @param progressCallBack defines a callback to call when progress changed
  75342. * @param errorCallback defines a callback to call on error
  75343. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75344. */
  75345. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75346. }
  75347. }
  75348. declare module BABYLON {
  75349. /**
  75350. * Class used to help managing file picking and drag'n'drop
  75351. * File Storage
  75352. */
  75353. export class FilesInputStore {
  75354. /**
  75355. * List of files ready to be loaded
  75356. */
  75357. static FilesToLoad: {
  75358. [key: string]: File;
  75359. };
  75360. }
  75361. }
  75362. declare module BABYLON {
  75363. /**
  75364. * Class used to define a retry strategy when error happens while loading assets
  75365. */
  75366. export class RetryStrategy {
  75367. /**
  75368. * Function used to defines an exponential back off strategy
  75369. * @param maxRetries defines the maximum number of retries (3 by default)
  75370. * @param baseInterval defines the interval between retries
  75371. * @returns the strategy function to use
  75372. */
  75373. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  75374. }
  75375. }
  75376. declare module BABYLON {
  75377. /**
  75378. * @ignore
  75379. * Application error to support additional information when loading a file
  75380. */
  75381. export abstract class BaseError extends Error {
  75382. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  75383. }
  75384. }
  75385. declare module BABYLON {
  75386. /** @ignore */
  75387. export class LoadFileError extends BaseError {
  75388. request?: WebRequest;
  75389. file?: File;
  75390. /**
  75391. * Creates a new LoadFileError
  75392. * @param message defines the message of the error
  75393. * @param request defines the optional web request
  75394. * @param file defines the optional file
  75395. */
  75396. constructor(message: string, object?: WebRequest | File);
  75397. }
  75398. /** @ignore */
  75399. export class RequestFileError extends BaseError {
  75400. request: WebRequest;
  75401. /**
  75402. * Creates a new LoadFileError
  75403. * @param message defines the message of the error
  75404. * @param request defines the optional web request
  75405. */
  75406. constructor(message: string, request: WebRequest);
  75407. }
  75408. /** @ignore */
  75409. export class ReadFileError extends BaseError {
  75410. file: File;
  75411. /**
  75412. * Creates a new ReadFileError
  75413. * @param message defines the message of the error
  75414. * @param file defines the optional file
  75415. */
  75416. constructor(message: string, file: File);
  75417. }
  75418. /**
  75419. * @hidden
  75420. */
  75421. export class FileTools {
  75422. /**
  75423. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  75424. */
  75425. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  75426. /**
  75427. * Gets or sets the base URL to use to load assets
  75428. */
  75429. static BaseUrl: string;
  75430. /**
  75431. * Default behaviour for cors in the application.
  75432. * It can be a string if the expected behavior is identical in the entire app.
  75433. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  75434. */
  75435. static CorsBehavior: string | ((url: string | string[]) => string);
  75436. /**
  75437. * Gets or sets a function used to pre-process url before using them to load assets
  75438. */
  75439. static PreprocessUrl: (url: string) => string;
  75440. /**
  75441. * Removes unwanted characters from an url
  75442. * @param url defines the url to clean
  75443. * @returns the cleaned url
  75444. */
  75445. private static _CleanUrl;
  75446. /**
  75447. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  75448. * @param url define the url we are trying
  75449. * @param element define the dom element where to configure the cors policy
  75450. */
  75451. static SetCorsBehavior(url: string | string[], element: {
  75452. crossOrigin: string | null;
  75453. }): void;
  75454. /**
  75455. * Loads an image as an HTMLImageElement.
  75456. * @param input url string, ArrayBuffer, or Blob to load
  75457. * @param onLoad callback called when the image successfully loads
  75458. * @param onError callback called when the image fails to load
  75459. * @param offlineProvider offline provider for caching
  75460. * @param mimeType optional mime type
  75461. * @returns the HTMLImageElement of the loaded image
  75462. */
  75463. 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>;
  75464. /**
  75465. * Reads a file from a File object
  75466. * @param file defines the file to load
  75467. * @param onSuccess defines the callback to call when data is loaded
  75468. * @param onProgress defines the callback to call during loading process
  75469. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  75470. * @param onError defines the callback to call when an error occurs
  75471. * @returns a file request object
  75472. */
  75473. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  75474. /**
  75475. * Loads a file from a url
  75476. * @param url url to load
  75477. * @param onSuccess callback called when the file successfully loads
  75478. * @param onProgress callback called while file is loading (if the server supports this mode)
  75479. * @param offlineProvider defines the offline provider for caching
  75480. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75481. * @param onError callback called when the file fails to load
  75482. * @returns a file request object
  75483. */
  75484. 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;
  75485. /**
  75486. * Loads a file
  75487. * @param url url to load
  75488. * @param onSuccess callback called when the file successfully loads
  75489. * @param onProgress callback called while file is loading (if the server supports this mode)
  75490. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75491. * @param onError callback called when the file fails to load
  75492. * @param onOpened callback called when the web request is opened
  75493. * @returns a file request object
  75494. */
  75495. 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;
  75496. /**
  75497. * Checks if the loaded document was accessed via `file:`-Protocol.
  75498. * @returns boolean
  75499. */
  75500. static IsFileURL(): boolean;
  75501. }
  75502. }
  75503. declare module BABYLON {
  75504. /** @hidden */
  75505. export class ShaderProcessor {
  75506. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75507. private static _ProcessPrecision;
  75508. private static _ExtractOperation;
  75509. private static _BuildSubExpression;
  75510. private static _BuildExpression;
  75511. private static _MoveCursorWithinIf;
  75512. private static _MoveCursor;
  75513. private static _EvaluatePreProcessors;
  75514. private static _PreparePreProcessors;
  75515. private static _ProcessShaderConversion;
  75516. private static _ProcessIncludes;
  75517. /**
  75518. * Loads a file from a url
  75519. * @param url url to load
  75520. * @param onSuccess callback called when the file successfully loads
  75521. * @param onProgress callback called while file is loading (if the server supports this mode)
  75522. * @param offlineProvider defines the offline provider for caching
  75523. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75524. * @param onError callback called when the file fails to load
  75525. * @returns a file request object
  75526. * @hidden
  75527. */
  75528. 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;
  75529. }
  75530. }
  75531. declare module BABYLON {
  75532. /**
  75533. * @hidden
  75534. */
  75535. export interface IColor4Like {
  75536. r: float;
  75537. g: float;
  75538. b: float;
  75539. a: float;
  75540. }
  75541. /**
  75542. * @hidden
  75543. */
  75544. export interface IColor3Like {
  75545. r: float;
  75546. g: float;
  75547. b: float;
  75548. }
  75549. /**
  75550. * @hidden
  75551. */
  75552. export interface IVector4Like {
  75553. x: float;
  75554. y: float;
  75555. z: float;
  75556. w: float;
  75557. }
  75558. /**
  75559. * @hidden
  75560. */
  75561. export interface IVector3Like {
  75562. x: float;
  75563. y: float;
  75564. z: float;
  75565. }
  75566. /**
  75567. * @hidden
  75568. */
  75569. export interface IVector2Like {
  75570. x: float;
  75571. y: float;
  75572. }
  75573. /**
  75574. * @hidden
  75575. */
  75576. export interface IMatrixLike {
  75577. toArray(): DeepImmutable<Float32Array>;
  75578. updateFlag: int;
  75579. }
  75580. /**
  75581. * @hidden
  75582. */
  75583. export interface IViewportLike {
  75584. x: float;
  75585. y: float;
  75586. width: float;
  75587. height: float;
  75588. }
  75589. /**
  75590. * @hidden
  75591. */
  75592. export interface IPlaneLike {
  75593. normal: IVector3Like;
  75594. d: float;
  75595. normalize(): void;
  75596. }
  75597. }
  75598. declare module BABYLON {
  75599. /**
  75600. * Interface used to define common properties for effect fallbacks
  75601. */
  75602. export interface IEffectFallbacks {
  75603. /**
  75604. * Removes the defines that should be removed when falling back.
  75605. * @param currentDefines defines the current define statements for the shader.
  75606. * @param effect defines the current effect we try to compile
  75607. * @returns The resulting defines with defines of the current rank removed.
  75608. */
  75609. reduce(currentDefines: string, effect: Effect): string;
  75610. /**
  75611. * Removes the fallback from the bound mesh.
  75612. */
  75613. unBindMesh(): void;
  75614. /**
  75615. * Checks to see if more fallbacks are still availible.
  75616. */
  75617. hasMoreFallbacks: boolean;
  75618. }
  75619. }
  75620. declare module BABYLON {
  75621. /**
  75622. * Class used to evalaute queries containing `and` and `or` operators
  75623. */
  75624. export class AndOrNotEvaluator {
  75625. /**
  75626. * Evaluate a query
  75627. * @param query defines the query to evaluate
  75628. * @param evaluateCallback defines the callback used to filter result
  75629. * @returns true if the query matches
  75630. */
  75631. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75632. private static _HandleParenthesisContent;
  75633. private static _SimplifyNegation;
  75634. }
  75635. }
  75636. declare module BABYLON {
  75637. /**
  75638. * Class used to store custom tags
  75639. */
  75640. export class Tags {
  75641. /**
  75642. * Adds support for tags on the given object
  75643. * @param obj defines the object to use
  75644. */
  75645. static EnableFor(obj: any): void;
  75646. /**
  75647. * Removes tags support
  75648. * @param obj defines the object to use
  75649. */
  75650. static DisableFor(obj: any): void;
  75651. /**
  75652. * Gets a boolean indicating if the given object has tags
  75653. * @param obj defines the object to use
  75654. * @returns a boolean
  75655. */
  75656. static HasTags(obj: any): boolean;
  75657. /**
  75658. * Gets the tags available on a given object
  75659. * @param obj defines the object to use
  75660. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75661. * @returns the tags
  75662. */
  75663. static GetTags(obj: any, asString?: boolean): any;
  75664. /**
  75665. * Adds tags to an object
  75666. * @param obj defines the object to use
  75667. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75668. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75669. */
  75670. static AddTagsTo(obj: any, tagsString: string): void;
  75671. /**
  75672. * @hidden
  75673. */
  75674. static _AddTagTo(obj: any, tag: string): void;
  75675. /**
  75676. * Removes specific tags from a specific object
  75677. * @param obj defines the object to use
  75678. * @param tagsString defines the tags to remove
  75679. */
  75680. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75681. /**
  75682. * @hidden
  75683. */
  75684. static _RemoveTagFrom(obj: any, tag: string): void;
  75685. /**
  75686. * Defines if tags hosted on an object match a given query
  75687. * @param obj defines the object to use
  75688. * @param tagsQuery defines the tag query
  75689. * @returns a boolean
  75690. */
  75691. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75692. }
  75693. }
  75694. declare module BABYLON {
  75695. /**
  75696. * Scalar computation library
  75697. */
  75698. export class Scalar {
  75699. /**
  75700. * Two pi constants convenient for computation.
  75701. */
  75702. static TwoPi: number;
  75703. /**
  75704. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75705. * @param a number
  75706. * @param b number
  75707. * @param epsilon (default = 1.401298E-45)
  75708. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75709. */
  75710. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75711. /**
  75712. * Returns a string : the upper case translation of the number i to hexadecimal.
  75713. * @param i number
  75714. * @returns the upper case translation of the number i to hexadecimal.
  75715. */
  75716. static ToHex(i: number): string;
  75717. /**
  75718. * Returns -1 if value is negative and +1 is value is positive.
  75719. * @param value the value
  75720. * @returns the value itself if it's equal to zero.
  75721. */
  75722. static Sign(value: number): number;
  75723. /**
  75724. * Returns the value itself if it's between min and max.
  75725. * Returns min if the value is lower than min.
  75726. * Returns max if the value is greater than max.
  75727. * @param value the value to clmap
  75728. * @param min the min value to clamp to (default: 0)
  75729. * @param max the max value to clamp to (default: 1)
  75730. * @returns the clamped value
  75731. */
  75732. static Clamp(value: number, min?: number, max?: number): number;
  75733. /**
  75734. * the log2 of value.
  75735. * @param value the value to compute log2 of
  75736. * @returns the log2 of value.
  75737. */
  75738. static Log2(value: number): number;
  75739. /**
  75740. * Loops the value, so that it is never larger than length and never smaller than 0.
  75741. *
  75742. * This is similar to the modulo operator but it works with floating point numbers.
  75743. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75744. * With t = 5 and length = 2.5, the result would be 0.0.
  75745. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75746. * @param value the value
  75747. * @param length the length
  75748. * @returns the looped value
  75749. */
  75750. static Repeat(value: number, length: number): number;
  75751. /**
  75752. * Normalize the value between 0.0 and 1.0 using min and max values
  75753. * @param value value to normalize
  75754. * @param min max to normalize between
  75755. * @param max min to normalize between
  75756. * @returns the normalized value
  75757. */
  75758. static Normalize(value: number, min: number, max: number): number;
  75759. /**
  75760. * Denormalize the value from 0.0 and 1.0 using min and max values
  75761. * @param normalized value to denormalize
  75762. * @param min max to denormalize between
  75763. * @param max min to denormalize between
  75764. * @returns the denormalized value
  75765. */
  75766. static Denormalize(normalized: number, min: number, max: number): number;
  75767. /**
  75768. * Calculates the shortest difference between two given angles given in degrees.
  75769. * @param current current angle in degrees
  75770. * @param target target angle in degrees
  75771. * @returns the delta
  75772. */
  75773. static DeltaAngle(current: number, target: number): number;
  75774. /**
  75775. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75776. * @param tx value
  75777. * @param length length
  75778. * @returns The returned value will move back and forth between 0 and length
  75779. */
  75780. static PingPong(tx: number, length: number): number;
  75781. /**
  75782. * Interpolates between min and max with smoothing at the limits.
  75783. *
  75784. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75785. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75786. * @param from from
  75787. * @param to to
  75788. * @param tx value
  75789. * @returns the smooth stepped value
  75790. */
  75791. static SmoothStep(from: number, to: number, tx: number): number;
  75792. /**
  75793. * Moves a value current towards target.
  75794. *
  75795. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75796. * Negative values of maxDelta pushes the value away from target.
  75797. * @param current current value
  75798. * @param target target value
  75799. * @param maxDelta max distance to move
  75800. * @returns resulting value
  75801. */
  75802. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75803. /**
  75804. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75805. *
  75806. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75807. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75808. * @param current current value
  75809. * @param target target value
  75810. * @param maxDelta max distance to move
  75811. * @returns resulting angle
  75812. */
  75813. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75814. /**
  75815. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75816. * @param start start value
  75817. * @param end target value
  75818. * @param amount amount to lerp between
  75819. * @returns the lerped value
  75820. */
  75821. static Lerp(start: number, end: number, amount: number): number;
  75822. /**
  75823. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75824. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75825. * @param start start value
  75826. * @param end target value
  75827. * @param amount amount to lerp between
  75828. * @returns the lerped value
  75829. */
  75830. static LerpAngle(start: number, end: number, amount: number): number;
  75831. /**
  75832. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75833. * @param a start value
  75834. * @param b target value
  75835. * @param value value between a and b
  75836. * @returns the inverseLerp value
  75837. */
  75838. static InverseLerp(a: number, b: number, value: number): number;
  75839. /**
  75840. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75841. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75842. * @param value1 spline value
  75843. * @param tangent1 spline value
  75844. * @param value2 spline value
  75845. * @param tangent2 spline value
  75846. * @param amount input value
  75847. * @returns hermite result
  75848. */
  75849. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75850. /**
  75851. * Returns a random float number between and min and max values
  75852. * @param min min value of random
  75853. * @param max max value of random
  75854. * @returns random value
  75855. */
  75856. static RandomRange(min: number, max: number): number;
  75857. /**
  75858. * This function returns percentage of a number in a given range.
  75859. *
  75860. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75861. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75862. * @param number to convert to percentage
  75863. * @param min min range
  75864. * @param max max range
  75865. * @returns the percentage
  75866. */
  75867. static RangeToPercent(number: number, min: number, max: number): number;
  75868. /**
  75869. * This function returns number that corresponds to the percentage in a given range.
  75870. *
  75871. * PercentToRange(0.34,0,100) will return 34.
  75872. * @param percent to convert to number
  75873. * @param min min range
  75874. * @param max max range
  75875. * @returns the number
  75876. */
  75877. static PercentToRange(percent: number, min: number, max: number): number;
  75878. /**
  75879. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75880. * @param angle The angle to normalize in radian.
  75881. * @return The converted angle.
  75882. */
  75883. static NormalizeRadians(angle: number): number;
  75884. }
  75885. }
  75886. declare module BABYLON {
  75887. /**
  75888. * Constant used to convert a value to gamma space
  75889. * @ignorenaming
  75890. */
  75891. export const ToGammaSpace: number;
  75892. /**
  75893. * Constant used to convert a value to linear space
  75894. * @ignorenaming
  75895. */
  75896. export const ToLinearSpace = 2.2;
  75897. /**
  75898. * Constant used to define the minimal number value in Babylon.js
  75899. * @ignorenaming
  75900. */
  75901. let Epsilon: number;
  75902. }
  75903. declare module BABYLON {
  75904. /**
  75905. * Class used to represent a viewport on screen
  75906. */
  75907. export class Viewport {
  75908. /** viewport left coordinate */
  75909. x: number;
  75910. /** viewport top coordinate */
  75911. y: number;
  75912. /**viewport width */
  75913. width: number;
  75914. /** viewport height */
  75915. height: number;
  75916. /**
  75917. * Creates a Viewport object located at (x, y) and sized (width, height)
  75918. * @param x defines viewport left coordinate
  75919. * @param y defines viewport top coordinate
  75920. * @param width defines the viewport width
  75921. * @param height defines the viewport height
  75922. */
  75923. constructor(
  75924. /** viewport left coordinate */
  75925. x: number,
  75926. /** viewport top coordinate */
  75927. y: number,
  75928. /**viewport width */
  75929. width: number,
  75930. /** viewport height */
  75931. height: number);
  75932. /**
  75933. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75934. * @param renderWidth defines the rendering width
  75935. * @param renderHeight defines the rendering height
  75936. * @returns a new Viewport
  75937. */
  75938. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75939. /**
  75940. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75941. * @param renderWidth defines the rendering width
  75942. * @param renderHeight defines the rendering height
  75943. * @param ref defines the target viewport
  75944. * @returns the current viewport
  75945. */
  75946. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75947. /**
  75948. * Returns a new Viewport copied from the current one
  75949. * @returns a new Viewport
  75950. */
  75951. clone(): Viewport;
  75952. }
  75953. }
  75954. declare module BABYLON {
  75955. /**
  75956. * Class containing a set of static utilities functions for arrays.
  75957. */
  75958. export class ArrayTools {
  75959. /**
  75960. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75961. * @param size the number of element to construct and put in the array
  75962. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75963. * @returns a new array filled with new objects
  75964. */
  75965. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75966. }
  75967. }
  75968. declare module BABYLON {
  75969. /**
  75970. * Class representing a vector containing 2 coordinates
  75971. */
  75972. export class Vector2 {
  75973. /** defines the first coordinate */
  75974. x: number;
  75975. /** defines the second coordinate */
  75976. y: number;
  75977. /**
  75978. * Creates a new Vector2 from the given x and y coordinates
  75979. * @param x defines the first coordinate
  75980. * @param y defines the second coordinate
  75981. */
  75982. constructor(
  75983. /** defines the first coordinate */
  75984. x?: number,
  75985. /** defines the second coordinate */
  75986. y?: number);
  75987. /**
  75988. * Gets a string with the Vector2 coordinates
  75989. * @returns a string with the Vector2 coordinates
  75990. */
  75991. toString(): string;
  75992. /**
  75993. * Gets class name
  75994. * @returns the string "Vector2"
  75995. */
  75996. getClassName(): string;
  75997. /**
  75998. * Gets current vector hash code
  75999. * @returns the Vector2 hash code as a number
  76000. */
  76001. getHashCode(): number;
  76002. /**
  76003. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  76004. * @param array defines the source array
  76005. * @param index defines the offset in source array
  76006. * @returns the current Vector2
  76007. */
  76008. toArray(array: FloatArray, index?: number): Vector2;
  76009. /**
  76010. * Copy the current vector to an array
  76011. * @returns a new array with 2 elements: the Vector2 coordinates.
  76012. */
  76013. asArray(): number[];
  76014. /**
  76015. * Sets the Vector2 coordinates with the given Vector2 coordinates
  76016. * @param source defines the source Vector2
  76017. * @returns the current updated Vector2
  76018. */
  76019. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  76020. /**
  76021. * Sets the Vector2 coordinates with the given floats
  76022. * @param x defines the first coordinate
  76023. * @param y defines the second coordinate
  76024. * @returns the current updated Vector2
  76025. */
  76026. copyFromFloats(x: number, y: number): Vector2;
  76027. /**
  76028. * Sets the Vector2 coordinates with the given floats
  76029. * @param x defines the first coordinate
  76030. * @param y defines the second coordinate
  76031. * @returns the current updated Vector2
  76032. */
  76033. set(x: number, y: number): Vector2;
  76034. /**
  76035. * Add another vector with the current one
  76036. * @param otherVector defines the other vector
  76037. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  76038. */
  76039. add(otherVector: DeepImmutable<Vector2>): Vector2;
  76040. /**
  76041. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  76042. * @param otherVector defines the other vector
  76043. * @param result defines the target vector
  76044. * @returns the unmodified current Vector2
  76045. */
  76046. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76047. /**
  76048. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  76049. * @param otherVector defines the other vector
  76050. * @returns the current updated Vector2
  76051. */
  76052. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76053. /**
  76054. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  76055. * @param otherVector defines the other vector
  76056. * @returns a new Vector2
  76057. */
  76058. addVector3(otherVector: Vector3): Vector2;
  76059. /**
  76060. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  76061. * @param otherVector defines the other vector
  76062. * @returns a new Vector2
  76063. */
  76064. subtract(otherVector: Vector2): Vector2;
  76065. /**
  76066. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  76067. * @param otherVector defines the other vector
  76068. * @param result defines the target vector
  76069. * @returns the unmodified current Vector2
  76070. */
  76071. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76072. /**
  76073. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  76074. * @param otherVector defines the other vector
  76075. * @returns the current updated Vector2
  76076. */
  76077. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76078. /**
  76079. * Multiplies in place the current Vector2 coordinates by the given ones
  76080. * @param otherVector defines the other vector
  76081. * @returns the current updated Vector2
  76082. */
  76083. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76084. /**
  76085. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  76086. * @param otherVector defines the other vector
  76087. * @returns a new Vector2
  76088. */
  76089. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  76090. /**
  76091. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  76092. * @param otherVector defines the other vector
  76093. * @param result defines the target vector
  76094. * @returns the unmodified current Vector2
  76095. */
  76096. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76097. /**
  76098. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  76099. * @param x defines the first coordinate
  76100. * @param y defines the second coordinate
  76101. * @returns a new Vector2
  76102. */
  76103. multiplyByFloats(x: number, y: number): Vector2;
  76104. /**
  76105. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  76106. * @param otherVector defines the other vector
  76107. * @returns a new Vector2
  76108. */
  76109. divide(otherVector: Vector2): Vector2;
  76110. /**
  76111. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  76112. * @param otherVector defines the other vector
  76113. * @param result defines the target vector
  76114. * @returns the unmodified current Vector2
  76115. */
  76116. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76117. /**
  76118. * Divides the current Vector2 coordinates by the given ones
  76119. * @param otherVector defines the other vector
  76120. * @returns the current updated Vector2
  76121. */
  76122. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76123. /**
  76124. * Gets a new Vector2 with current Vector2 negated coordinates
  76125. * @returns a new Vector2
  76126. */
  76127. negate(): Vector2;
  76128. /**
  76129. * Negate this vector in place
  76130. * @returns this
  76131. */
  76132. negateInPlace(): Vector2;
  76133. /**
  76134. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  76135. * @param result defines the Vector3 object where to store the result
  76136. * @returns the current Vector2
  76137. */
  76138. negateToRef(result: Vector2): Vector2;
  76139. /**
  76140. * Multiply the Vector2 coordinates by scale
  76141. * @param scale defines the scaling factor
  76142. * @returns the current updated Vector2
  76143. */
  76144. scaleInPlace(scale: number): Vector2;
  76145. /**
  76146. * Returns a new Vector2 scaled by "scale" from the current Vector2
  76147. * @param scale defines the scaling factor
  76148. * @returns a new Vector2
  76149. */
  76150. scale(scale: number): Vector2;
  76151. /**
  76152. * Scale the current Vector2 values by a factor to a given Vector2
  76153. * @param scale defines the scale factor
  76154. * @param result defines the Vector2 object where to store the result
  76155. * @returns the unmodified current Vector2
  76156. */
  76157. scaleToRef(scale: number, result: Vector2): Vector2;
  76158. /**
  76159. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  76160. * @param scale defines the scale factor
  76161. * @param result defines the Vector2 object where to store the result
  76162. * @returns the unmodified current Vector2
  76163. */
  76164. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  76165. /**
  76166. * Gets a boolean if two vectors are equals
  76167. * @param otherVector defines the other vector
  76168. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  76169. */
  76170. equals(otherVector: DeepImmutable<Vector2>): boolean;
  76171. /**
  76172. * Gets a boolean if two vectors are equals (using an epsilon value)
  76173. * @param otherVector defines the other vector
  76174. * @param epsilon defines the minimal distance to consider equality
  76175. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  76176. */
  76177. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  76178. /**
  76179. * Gets a new Vector2 from current Vector2 floored values
  76180. * @returns a new Vector2
  76181. */
  76182. floor(): Vector2;
  76183. /**
  76184. * Gets a new Vector2 from current Vector2 floored values
  76185. * @returns a new Vector2
  76186. */
  76187. fract(): Vector2;
  76188. /**
  76189. * Gets the length of the vector
  76190. * @returns the vector length (float)
  76191. */
  76192. length(): number;
  76193. /**
  76194. * Gets the vector squared length
  76195. * @returns the vector squared length (float)
  76196. */
  76197. lengthSquared(): number;
  76198. /**
  76199. * Normalize the vector
  76200. * @returns the current updated Vector2
  76201. */
  76202. normalize(): Vector2;
  76203. /**
  76204. * Gets a new Vector2 copied from the Vector2
  76205. * @returns a new Vector2
  76206. */
  76207. clone(): Vector2;
  76208. /**
  76209. * Gets a new Vector2(0, 0)
  76210. * @returns a new Vector2
  76211. */
  76212. static Zero(): Vector2;
  76213. /**
  76214. * Gets a new Vector2(1, 1)
  76215. * @returns a new Vector2
  76216. */
  76217. static One(): Vector2;
  76218. /**
  76219. * Gets a new Vector2 set from the given index element of the given array
  76220. * @param array defines the data source
  76221. * @param offset defines the offset in the data source
  76222. * @returns a new Vector2
  76223. */
  76224. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  76225. /**
  76226. * Sets "result" from the given index element of the given array
  76227. * @param array defines the data source
  76228. * @param offset defines the offset in the data source
  76229. * @param result defines the target vector
  76230. */
  76231. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  76232. /**
  76233. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  76234. * @param value1 defines 1st point of control
  76235. * @param value2 defines 2nd point of control
  76236. * @param value3 defines 3rd point of control
  76237. * @param value4 defines 4th point of control
  76238. * @param amount defines the interpolation factor
  76239. * @returns a new Vector2
  76240. */
  76241. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  76242. /**
  76243. * 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".
  76244. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  76245. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  76246. * @param value defines the value to clamp
  76247. * @param min defines the lower limit
  76248. * @param max defines the upper limit
  76249. * @returns a new Vector2
  76250. */
  76251. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  76252. /**
  76253. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  76254. * @param value1 defines the 1st control point
  76255. * @param tangent1 defines the outgoing tangent
  76256. * @param value2 defines the 2nd control point
  76257. * @param tangent2 defines the incoming tangent
  76258. * @param amount defines the interpolation factor
  76259. * @returns a new Vector2
  76260. */
  76261. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  76262. /**
  76263. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  76264. * @param start defines the start vector
  76265. * @param end defines the end vector
  76266. * @param amount defines the interpolation factor
  76267. * @returns a new Vector2
  76268. */
  76269. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  76270. /**
  76271. * Gets the dot product of the vector "left" and the vector "right"
  76272. * @param left defines first vector
  76273. * @param right defines second vector
  76274. * @returns the dot product (float)
  76275. */
  76276. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  76277. /**
  76278. * Returns a new Vector2 equal to the normalized given vector
  76279. * @param vector defines the vector to normalize
  76280. * @returns a new Vector2
  76281. */
  76282. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  76283. /**
  76284. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  76285. * @param left defines 1st vector
  76286. * @param right defines 2nd vector
  76287. * @returns a new Vector2
  76288. */
  76289. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76290. /**
  76291. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  76292. * @param left defines 1st vector
  76293. * @param right defines 2nd vector
  76294. * @returns a new Vector2
  76295. */
  76296. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76297. /**
  76298. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  76299. * @param vector defines the vector to transform
  76300. * @param transformation defines the matrix to apply
  76301. * @returns a new Vector2
  76302. */
  76303. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  76304. /**
  76305. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  76306. * @param vector defines the vector to transform
  76307. * @param transformation defines the matrix to apply
  76308. * @param result defines the target vector
  76309. */
  76310. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  76311. /**
  76312. * Determines if a given vector is included in a triangle
  76313. * @param p defines the vector to test
  76314. * @param p0 defines 1st triangle point
  76315. * @param p1 defines 2nd triangle point
  76316. * @param p2 defines 3rd triangle point
  76317. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  76318. */
  76319. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  76320. /**
  76321. * Gets the distance between the vectors "value1" and "value2"
  76322. * @param value1 defines first vector
  76323. * @param value2 defines second vector
  76324. * @returns the distance between vectors
  76325. */
  76326. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76327. /**
  76328. * Returns the squared distance between the vectors "value1" and "value2"
  76329. * @param value1 defines first vector
  76330. * @param value2 defines second vector
  76331. * @returns the squared distance between vectors
  76332. */
  76333. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76334. /**
  76335. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  76336. * @param value1 defines first vector
  76337. * @param value2 defines second vector
  76338. * @returns a new Vector2
  76339. */
  76340. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  76341. /**
  76342. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  76343. * @param p defines the middle point
  76344. * @param segA defines one point of the segment
  76345. * @param segB defines the other point of the segment
  76346. * @returns the shortest distance
  76347. */
  76348. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  76349. }
  76350. /**
  76351. * Class used to store (x,y,z) vector representation
  76352. * A Vector3 is the main object used in 3D geometry
  76353. * It can represent etiher the coordinates of a point the space, either a direction
  76354. * Reminder: js uses a left handed forward facing system
  76355. */
  76356. export class Vector3 {
  76357. /**
  76358. * Defines the first coordinates (on X axis)
  76359. */
  76360. x: number;
  76361. /**
  76362. * Defines the second coordinates (on Y axis)
  76363. */
  76364. y: number;
  76365. /**
  76366. * Defines the third coordinates (on Z axis)
  76367. */
  76368. z: number;
  76369. private static _UpReadOnly;
  76370. private static _ZeroReadOnly;
  76371. /**
  76372. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  76373. * @param x defines the first coordinates (on X axis)
  76374. * @param y defines the second coordinates (on Y axis)
  76375. * @param z defines the third coordinates (on Z axis)
  76376. */
  76377. constructor(
  76378. /**
  76379. * Defines the first coordinates (on X axis)
  76380. */
  76381. x?: number,
  76382. /**
  76383. * Defines the second coordinates (on Y axis)
  76384. */
  76385. y?: number,
  76386. /**
  76387. * Defines the third coordinates (on Z axis)
  76388. */
  76389. z?: number);
  76390. /**
  76391. * Creates a string representation of the Vector3
  76392. * @returns a string with the Vector3 coordinates.
  76393. */
  76394. toString(): string;
  76395. /**
  76396. * Gets the class name
  76397. * @returns the string "Vector3"
  76398. */
  76399. getClassName(): string;
  76400. /**
  76401. * Creates the Vector3 hash code
  76402. * @returns a number which tends to be unique between Vector3 instances
  76403. */
  76404. getHashCode(): number;
  76405. /**
  76406. * Creates an array containing three elements : the coordinates of the Vector3
  76407. * @returns a new array of numbers
  76408. */
  76409. asArray(): number[];
  76410. /**
  76411. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  76412. * @param array defines the destination array
  76413. * @param index defines the offset in the destination array
  76414. * @returns the current Vector3
  76415. */
  76416. toArray(array: FloatArray, index?: number): Vector3;
  76417. /**
  76418. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  76419. * @returns a new Quaternion object, computed from the Vector3 coordinates
  76420. */
  76421. toQuaternion(): Quaternion;
  76422. /**
  76423. * Adds the given vector to the current Vector3
  76424. * @param otherVector defines the second operand
  76425. * @returns the current updated Vector3
  76426. */
  76427. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76428. /**
  76429. * Adds the given coordinates to the current Vector3
  76430. * @param x defines the x coordinate of the operand
  76431. * @param y defines the y coordinate of the operand
  76432. * @param z defines the z coordinate of the operand
  76433. * @returns the current updated Vector3
  76434. */
  76435. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76436. /**
  76437. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  76438. * @param otherVector defines the second operand
  76439. * @returns the resulting Vector3
  76440. */
  76441. add(otherVector: DeepImmutable<Vector3>): Vector3;
  76442. /**
  76443. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  76444. * @param otherVector defines the second operand
  76445. * @param result defines the Vector3 object where to store the result
  76446. * @returns the current Vector3
  76447. */
  76448. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76449. /**
  76450. * Subtract the given vector from the current Vector3
  76451. * @param otherVector defines the second operand
  76452. * @returns the current updated Vector3
  76453. */
  76454. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76455. /**
  76456. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  76457. * @param otherVector defines the second operand
  76458. * @returns the resulting Vector3
  76459. */
  76460. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  76461. /**
  76462. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  76463. * @param otherVector defines the second operand
  76464. * @param result defines the Vector3 object where to store the result
  76465. * @returns the current Vector3
  76466. */
  76467. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76468. /**
  76469. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  76470. * @param x defines the x coordinate of the operand
  76471. * @param y defines the y coordinate of the operand
  76472. * @param z defines the z coordinate of the operand
  76473. * @returns the resulting Vector3
  76474. */
  76475. subtractFromFloats(x: number, y: number, z: number): Vector3;
  76476. /**
  76477. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  76478. * @param x defines the x coordinate of the operand
  76479. * @param y defines the y coordinate of the operand
  76480. * @param z defines the z coordinate of the operand
  76481. * @param result defines the Vector3 object where to store the result
  76482. * @returns the current Vector3
  76483. */
  76484. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76485. /**
  76486. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76487. * @returns a new Vector3
  76488. */
  76489. negate(): Vector3;
  76490. /**
  76491. * Negate this vector in place
  76492. * @returns this
  76493. */
  76494. negateInPlace(): Vector3;
  76495. /**
  76496. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76497. * @param result defines the Vector3 object where to store the result
  76498. * @returns the current Vector3
  76499. */
  76500. negateToRef(result: Vector3): Vector3;
  76501. /**
  76502. * Multiplies the Vector3 coordinates by the float "scale"
  76503. * @param scale defines the multiplier factor
  76504. * @returns the current updated Vector3
  76505. */
  76506. scaleInPlace(scale: number): Vector3;
  76507. /**
  76508. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76509. * @param scale defines the multiplier factor
  76510. * @returns a new Vector3
  76511. */
  76512. scale(scale: number): Vector3;
  76513. /**
  76514. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76515. * @param scale defines the multiplier factor
  76516. * @param result defines the Vector3 object where to store the result
  76517. * @returns the current Vector3
  76518. */
  76519. scaleToRef(scale: number, result: Vector3): Vector3;
  76520. /**
  76521. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76522. * @param scale defines the scale factor
  76523. * @param result defines the Vector3 object where to store the result
  76524. * @returns the unmodified current Vector3
  76525. */
  76526. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76527. /**
  76528. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76529. * @param otherVector defines the second operand
  76530. * @returns true if both vectors are equals
  76531. */
  76532. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76533. /**
  76534. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76535. * @param otherVector defines the second operand
  76536. * @param epsilon defines the minimal distance to define values as equals
  76537. * @returns true if both vectors are distant less than epsilon
  76538. */
  76539. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76540. /**
  76541. * Returns true if the current Vector3 coordinates equals the given floats
  76542. * @param x defines the x coordinate of the operand
  76543. * @param y defines the y coordinate of the operand
  76544. * @param z defines the z coordinate of the operand
  76545. * @returns true if both vectors are equals
  76546. */
  76547. equalsToFloats(x: number, y: number, z: number): boolean;
  76548. /**
  76549. * Multiplies the current Vector3 coordinates by the given ones
  76550. * @param otherVector defines the second operand
  76551. * @returns the current updated Vector3
  76552. */
  76553. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76554. /**
  76555. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76556. * @param otherVector defines the second operand
  76557. * @returns the new Vector3
  76558. */
  76559. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76560. /**
  76561. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76562. * @param otherVector defines the second operand
  76563. * @param result defines the Vector3 object where to store the result
  76564. * @returns the current Vector3
  76565. */
  76566. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76567. /**
  76568. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76569. * @param x defines the x coordinate of the operand
  76570. * @param y defines the y coordinate of the operand
  76571. * @param z defines the z coordinate of the operand
  76572. * @returns the new Vector3
  76573. */
  76574. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76575. /**
  76576. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76577. * @param otherVector defines the second operand
  76578. * @returns the new Vector3
  76579. */
  76580. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76581. /**
  76582. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  76583. * @param otherVector defines the second operand
  76584. * @param result defines the Vector3 object where to store the result
  76585. * @returns the current Vector3
  76586. */
  76587. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76588. /**
  76589. * Divides the current Vector3 coordinates by the given ones.
  76590. * @param otherVector defines the second operand
  76591. * @returns the current updated Vector3
  76592. */
  76593. divideInPlace(otherVector: Vector3): Vector3;
  76594. /**
  76595. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76596. * @param other defines the second operand
  76597. * @returns the current updated Vector3
  76598. */
  76599. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76600. /**
  76601. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76602. * @param other defines the second operand
  76603. * @returns the current updated Vector3
  76604. */
  76605. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76606. /**
  76607. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76608. * @param x defines the x coordinate of the operand
  76609. * @param y defines the y coordinate of the operand
  76610. * @param z defines the z coordinate of the operand
  76611. * @returns the current updated Vector3
  76612. */
  76613. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76614. /**
  76615. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76616. * @param x defines the x coordinate of the operand
  76617. * @param y defines the y coordinate of the operand
  76618. * @param z defines the z coordinate of the operand
  76619. * @returns the current updated Vector3
  76620. */
  76621. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76622. /**
  76623. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76624. * Check if is non uniform within a certain amount of decimal places to account for this
  76625. * @param epsilon the amount the values can differ
  76626. * @returns if the the vector is non uniform to a certain number of decimal places
  76627. */
  76628. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76629. /**
  76630. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76631. */
  76632. get isNonUniform(): boolean;
  76633. /**
  76634. * Gets a new Vector3 from current Vector3 floored values
  76635. * @returns a new Vector3
  76636. */
  76637. floor(): Vector3;
  76638. /**
  76639. * Gets a new Vector3 from current Vector3 floored values
  76640. * @returns a new Vector3
  76641. */
  76642. fract(): Vector3;
  76643. /**
  76644. * Gets the length of the Vector3
  76645. * @returns the length of the Vector3
  76646. */
  76647. length(): number;
  76648. /**
  76649. * Gets the squared length of the Vector3
  76650. * @returns squared length of the Vector3
  76651. */
  76652. lengthSquared(): number;
  76653. /**
  76654. * Normalize the current Vector3.
  76655. * Please note that this is an in place operation.
  76656. * @returns the current updated Vector3
  76657. */
  76658. normalize(): Vector3;
  76659. /**
  76660. * Reorders the x y z properties of the vector in place
  76661. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76662. * @returns the current updated vector
  76663. */
  76664. reorderInPlace(order: string): this;
  76665. /**
  76666. * Rotates the vector around 0,0,0 by a quaternion
  76667. * @param quaternion the rotation quaternion
  76668. * @param result vector to store the result
  76669. * @returns the resulting vector
  76670. */
  76671. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76672. /**
  76673. * Rotates a vector around a given point
  76674. * @param quaternion the rotation quaternion
  76675. * @param point the point to rotate around
  76676. * @param result vector to store the result
  76677. * @returns the resulting vector
  76678. */
  76679. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76680. /**
  76681. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76682. * The cross product is then orthogonal to both current and "other"
  76683. * @param other defines the right operand
  76684. * @returns the cross product
  76685. */
  76686. cross(other: Vector3): Vector3;
  76687. /**
  76688. * Normalize the current Vector3 with the given input length.
  76689. * Please note that this is an in place operation.
  76690. * @param len the length of the vector
  76691. * @returns the current updated Vector3
  76692. */
  76693. normalizeFromLength(len: number): Vector3;
  76694. /**
  76695. * Normalize the current Vector3 to a new vector
  76696. * @returns the new Vector3
  76697. */
  76698. normalizeToNew(): Vector3;
  76699. /**
  76700. * Normalize the current Vector3 to the reference
  76701. * @param reference define the Vector3 to update
  76702. * @returns the updated Vector3
  76703. */
  76704. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76705. /**
  76706. * Creates a new Vector3 copied from the current Vector3
  76707. * @returns the new Vector3
  76708. */
  76709. clone(): Vector3;
  76710. /**
  76711. * Copies the given vector coordinates to the current Vector3 ones
  76712. * @param source defines the source Vector3
  76713. * @returns the current updated Vector3
  76714. */
  76715. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76716. /**
  76717. * Copies the given floats to the current Vector3 coordinates
  76718. * @param x defines the x coordinate of the operand
  76719. * @param y defines the y coordinate of the operand
  76720. * @param z defines the z coordinate of the operand
  76721. * @returns the current updated Vector3
  76722. */
  76723. copyFromFloats(x: number, y: number, z: number): Vector3;
  76724. /**
  76725. * Copies the given floats to the current Vector3 coordinates
  76726. * @param x defines the x coordinate of the operand
  76727. * @param y defines the y coordinate of the operand
  76728. * @param z defines the z coordinate of the operand
  76729. * @returns the current updated Vector3
  76730. */
  76731. set(x: number, y: number, z: number): Vector3;
  76732. /**
  76733. * Copies the given float to the current Vector3 coordinates
  76734. * @param v defines the x, y and z coordinates of the operand
  76735. * @returns the current updated Vector3
  76736. */
  76737. setAll(v: number): Vector3;
  76738. /**
  76739. * Get the clip factor between two vectors
  76740. * @param vector0 defines the first operand
  76741. * @param vector1 defines the second operand
  76742. * @param axis defines the axis to use
  76743. * @param size defines the size along the axis
  76744. * @returns the clip factor
  76745. */
  76746. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76747. /**
  76748. * Get angle between two vectors
  76749. * @param vector0 angle between vector0 and vector1
  76750. * @param vector1 angle between vector0 and vector1
  76751. * @param normal direction of the normal
  76752. * @return the angle between vector0 and vector1
  76753. */
  76754. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76755. /**
  76756. * Returns a new Vector3 set from the index "offset" of the given array
  76757. * @param array defines the source array
  76758. * @param offset defines the offset in the source array
  76759. * @returns the new Vector3
  76760. */
  76761. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76762. /**
  76763. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76764. * @param array defines the source array
  76765. * @param offset defines the offset in the source array
  76766. * @returns the new Vector3
  76767. * @deprecated Please use FromArray instead.
  76768. */
  76769. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76770. /**
  76771. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76772. * @param array defines the source array
  76773. * @param offset defines the offset in the source array
  76774. * @param result defines the Vector3 where to store the result
  76775. */
  76776. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76777. /**
  76778. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76779. * @param array defines the source array
  76780. * @param offset defines the offset in the source array
  76781. * @param result defines the Vector3 where to store the result
  76782. * @deprecated Please use FromArrayToRef instead.
  76783. */
  76784. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76785. /**
  76786. * Sets the given vector "result" with the given floats.
  76787. * @param x defines the x coordinate of the source
  76788. * @param y defines the y coordinate of the source
  76789. * @param z defines the z coordinate of the source
  76790. * @param result defines the Vector3 where to store the result
  76791. */
  76792. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76793. /**
  76794. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76795. * @returns a new empty Vector3
  76796. */
  76797. static Zero(): Vector3;
  76798. /**
  76799. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76800. * @returns a new unit Vector3
  76801. */
  76802. static One(): Vector3;
  76803. /**
  76804. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76805. * @returns a new up Vector3
  76806. */
  76807. static Up(): Vector3;
  76808. /**
  76809. * Gets a up Vector3 that must not be updated
  76810. */
  76811. static get UpReadOnly(): DeepImmutable<Vector3>;
  76812. /**
  76813. * Gets a zero Vector3 that must not be updated
  76814. */
  76815. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76816. /**
  76817. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76818. * @returns a new down Vector3
  76819. */
  76820. static Down(): Vector3;
  76821. /**
  76822. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76823. * @returns a new forward Vector3
  76824. */
  76825. static Forward(): Vector3;
  76826. /**
  76827. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76828. * @returns a new forward Vector3
  76829. */
  76830. static Backward(): Vector3;
  76831. /**
  76832. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76833. * @returns a new right Vector3
  76834. */
  76835. static Right(): Vector3;
  76836. /**
  76837. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76838. * @returns a new left Vector3
  76839. */
  76840. static Left(): Vector3;
  76841. /**
  76842. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76843. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76844. * @param vector defines the Vector3 to transform
  76845. * @param transformation defines the transformation matrix
  76846. * @returns the transformed Vector3
  76847. */
  76848. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76849. /**
  76850. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76851. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76852. * @param vector defines the Vector3 to transform
  76853. * @param transformation defines the transformation matrix
  76854. * @param result defines the Vector3 where to store the result
  76855. */
  76856. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76857. /**
  76858. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76859. * This method computes tranformed coordinates only, not transformed direction vectors
  76860. * @param x define the x coordinate of the source vector
  76861. * @param y define the y coordinate of the source vector
  76862. * @param z define the z coordinate of the source vector
  76863. * @param transformation defines the transformation matrix
  76864. * @param result defines the Vector3 where to store the result
  76865. */
  76866. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76867. /**
  76868. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76869. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76870. * @param vector defines the Vector3 to transform
  76871. * @param transformation defines the transformation matrix
  76872. * @returns the new Vector3
  76873. */
  76874. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76875. /**
  76876. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76877. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76878. * @param vector defines the Vector3 to transform
  76879. * @param transformation defines the transformation matrix
  76880. * @param result defines the Vector3 where to store the result
  76881. */
  76882. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76883. /**
  76884. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76885. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76886. * @param x define the x coordinate of the source vector
  76887. * @param y define the y coordinate of the source vector
  76888. * @param z define the z coordinate of the source vector
  76889. * @param transformation defines the transformation matrix
  76890. * @param result defines the Vector3 where to store the result
  76891. */
  76892. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76893. /**
  76894. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76895. * @param value1 defines the first control point
  76896. * @param value2 defines the second control point
  76897. * @param value3 defines the third control point
  76898. * @param value4 defines the fourth control point
  76899. * @param amount defines the amount on the spline to use
  76900. * @returns the new Vector3
  76901. */
  76902. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76903. /**
  76904. * 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"
  76905. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76906. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76907. * @param value defines the current value
  76908. * @param min defines the lower range value
  76909. * @param max defines the upper range value
  76910. * @returns the new Vector3
  76911. */
  76912. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76913. /**
  76914. * 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"
  76915. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76916. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76917. * @param value defines the current value
  76918. * @param min defines the lower range value
  76919. * @param max defines the upper range value
  76920. * @param result defines the Vector3 where to store the result
  76921. */
  76922. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76923. /**
  76924. * Checks if a given vector is inside a specific range
  76925. * @param v defines the vector to test
  76926. * @param min defines the minimum range
  76927. * @param max defines the maximum range
  76928. */
  76929. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76930. /**
  76931. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76932. * @param value1 defines the first control point
  76933. * @param tangent1 defines the first tangent vector
  76934. * @param value2 defines the second control point
  76935. * @param tangent2 defines the second tangent vector
  76936. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76937. * @returns the new Vector3
  76938. */
  76939. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76940. /**
  76941. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76942. * @param start defines the start value
  76943. * @param end defines the end value
  76944. * @param amount max defines amount between both (between 0 and 1)
  76945. * @returns the new Vector3
  76946. */
  76947. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76948. /**
  76949. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76950. * @param start defines the start value
  76951. * @param end defines the end value
  76952. * @param amount max defines amount between both (between 0 and 1)
  76953. * @param result defines the Vector3 where to store the result
  76954. */
  76955. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76956. /**
  76957. * Returns the dot product (float) between the vectors "left" and "right"
  76958. * @param left defines the left operand
  76959. * @param right defines the right operand
  76960. * @returns the dot product
  76961. */
  76962. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76963. /**
  76964. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76965. * The cross product is then orthogonal to both "left" and "right"
  76966. * @param left defines the left operand
  76967. * @param right defines the right operand
  76968. * @returns the cross product
  76969. */
  76970. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76971. /**
  76972. * Sets the given vector "result" with the cross product of "left" and "right"
  76973. * The cross product is then orthogonal to both "left" and "right"
  76974. * @param left defines the left operand
  76975. * @param right defines the right operand
  76976. * @param result defines the Vector3 where to store the result
  76977. */
  76978. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76979. /**
  76980. * Returns a new Vector3 as the normalization of the given vector
  76981. * @param vector defines the Vector3 to normalize
  76982. * @returns the new Vector3
  76983. */
  76984. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76985. /**
  76986. * Sets the given vector "result" with the normalization of the given first vector
  76987. * @param vector defines the Vector3 to normalize
  76988. * @param result defines the Vector3 where to store the result
  76989. */
  76990. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76991. /**
  76992. * Project a Vector3 onto screen space
  76993. * @param vector defines the Vector3 to project
  76994. * @param world defines the world matrix to use
  76995. * @param transform defines the transform (view x projection) matrix to use
  76996. * @param viewport defines the screen viewport to use
  76997. * @returns the new Vector3
  76998. */
  76999. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  77000. /** @hidden */
  77001. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  77002. /**
  77003. * Unproject from screen space to object space
  77004. * @param source defines the screen space Vector3 to use
  77005. * @param viewportWidth defines the current width of the viewport
  77006. * @param viewportHeight defines the current height of the viewport
  77007. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77008. * @param transform defines the transform (view x projection) matrix to use
  77009. * @returns the new Vector3
  77010. */
  77011. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  77012. /**
  77013. * Unproject from screen space to object space
  77014. * @param source defines the screen space Vector3 to use
  77015. * @param viewportWidth defines the current width of the viewport
  77016. * @param viewportHeight defines the current height of the viewport
  77017. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77018. * @param view defines the view matrix to use
  77019. * @param projection defines the projection matrix to use
  77020. * @returns the new Vector3
  77021. */
  77022. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  77023. /**
  77024. * Unproject from screen space to object space
  77025. * @param source defines the screen space Vector3 to use
  77026. * @param viewportWidth defines the current width of the viewport
  77027. * @param viewportHeight defines the current height of the viewport
  77028. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77029. * @param view defines the view matrix to use
  77030. * @param projection defines the projection matrix to use
  77031. * @param result defines the Vector3 where to store the result
  77032. */
  77033. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77034. /**
  77035. * Unproject from screen space to object space
  77036. * @param sourceX defines the screen space x coordinate to use
  77037. * @param sourceY defines the screen space y coordinate to use
  77038. * @param sourceZ defines the screen space z coordinate to use
  77039. * @param viewportWidth defines the current width of the viewport
  77040. * @param viewportHeight defines the current height of the viewport
  77041. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77042. * @param view defines the view matrix to use
  77043. * @param projection defines the projection matrix to use
  77044. * @param result defines the Vector3 where to store the result
  77045. */
  77046. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77047. /**
  77048. * Gets the minimal coordinate values between two Vector3
  77049. * @param left defines the first operand
  77050. * @param right defines the second operand
  77051. * @returns the new Vector3
  77052. */
  77053. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77054. /**
  77055. * Gets the maximal coordinate values between two Vector3
  77056. * @param left defines the first operand
  77057. * @param right defines the second operand
  77058. * @returns the new Vector3
  77059. */
  77060. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77061. /**
  77062. * Returns the distance between the vectors "value1" and "value2"
  77063. * @param value1 defines the first operand
  77064. * @param value2 defines the second operand
  77065. * @returns the distance
  77066. */
  77067. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77068. /**
  77069. * Returns the squared distance between the vectors "value1" and "value2"
  77070. * @param value1 defines the first operand
  77071. * @param value2 defines the second operand
  77072. * @returns the squared distance
  77073. */
  77074. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77075. /**
  77076. * Returns a new Vector3 located at the center between "value1" and "value2"
  77077. * @param value1 defines the first operand
  77078. * @param value2 defines the second operand
  77079. * @returns the new Vector3
  77080. */
  77081. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  77082. /**
  77083. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  77084. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  77085. * to something in order to rotate it from its local system to the given target system
  77086. * Note: axis1, axis2 and axis3 are normalized during this operation
  77087. * @param axis1 defines the first axis
  77088. * @param axis2 defines the second axis
  77089. * @param axis3 defines the third axis
  77090. * @returns a new Vector3
  77091. */
  77092. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  77093. /**
  77094. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  77095. * @param axis1 defines the first axis
  77096. * @param axis2 defines the second axis
  77097. * @param axis3 defines the third axis
  77098. * @param ref defines the Vector3 where to store the result
  77099. */
  77100. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  77101. }
  77102. /**
  77103. * Vector4 class created for EulerAngle class conversion to Quaternion
  77104. */
  77105. export class Vector4 {
  77106. /** x value of the vector */
  77107. x: number;
  77108. /** y value of the vector */
  77109. y: number;
  77110. /** z value of the vector */
  77111. z: number;
  77112. /** w value of the vector */
  77113. w: number;
  77114. /**
  77115. * Creates a Vector4 object from the given floats.
  77116. * @param x x value of the vector
  77117. * @param y y value of the vector
  77118. * @param z z value of the vector
  77119. * @param w w value of the vector
  77120. */
  77121. constructor(
  77122. /** x value of the vector */
  77123. x: number,
  77124. /** y value of the vector */
  77125. y: number,
  77126. /** z value of the vector */
  77127. z: number,
  77128. /** w value of the vector */
  77129. w: number);
  77130. /**
  77131. * Returns the string with the Vector4 coordinates.
  77132. * @returns a string containing all the vector values
  77133. */
  77134. toString(): string;
  77135. /**
  77136. * Returns the string "Vector4".
  77137. * @returns "Vector4"
  77138. */
  77139. getClassName(): string;
  77140. /**
  77141. * Returns the Vector4 hash code.
  77142. * @returns a unique hash code
  77143. */
  77144. getHashCode(): number;
  77145. /**
  77146. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  77147. * @returns the resulting array
  77148. */
  77149. asArray(): number[];
  77150. /**
  77151. * Populates the given array from the given index with the Vector4 coordinates.
  77152. * @param array array to populate
  77153. * @param index index of the array to start at (default: 0)
  77154. * @returns the Vector4.
  77155. */
  77156. toArray(array: FloatArray, index?: number): Vector4;
  77157. /**
  77158. * Adds the given vector to the current Vector4.
  77159. * @param otherVector the vector to add
  77160. * @returns the updated Vector4.
  77161. */
  77162. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77163. /**
  77164. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  77165. * @param otherVector the vector to add
  77166. * @returns the resulting vector
  77167. */
  77168. add(otherVector: DeepImmutable<Vector4>): Vector4;
  77169. /**
  77170. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  77171. * @param otherVector the vector to add
  77172. * @param result the vector to store the result
  77173. * @returns the current Vector4.
  77174. */
  77175. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77176. /**
  77177. * Subtract in place the given vector from the current Vector4.
  77178. * @param otherVector the vector to subtract
  77179. * @returns the updated Vector4.
  77180. */
  77181. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77182. /**
  77183. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  77184. * @param otherVector the vector to add
  77185. * @returns the new vector with the result
  77186. */
  77187. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  77188. /**
  77189. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  77190. * @param otherVector the vector to subtract
  77191. * @param result the vector to store the result
  77192. * @returns the current Vector4.
  77193. */
  77194. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77195. /**
  77196. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77197. */
  77198. /**
  77199. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77200. * @param x value to subtract
  77201. * @param y value to subtract
  77202. * @param z value to subtract
  77203. * @param w value to subtract
  77204. * @returns new vector containing the result
  77205. */
  77206. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77207. /**
  77208. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77209. * @param x value to subtract
  77210. * @param y value to subtract
  77211. * @param z value to subtract
  77212. * @param w value to subtract
  77213. * @param result the vector to store the result in
  77214. * @returns the current Vector4.
  77215. */
  77216. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  77217. /**
  77218. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  77219. * @returns a new vector with the negated values
  77220. */
  77221. negate(): Vector4;
  77222. /**
  77223. * Negate this vector in place
  77224. * @returns this
  77225. */
  77226. negateInPlace(): Vector4;
  77227. /**
  77228. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  77229. * @param result defines the Vector3 object where to store the result
  77230. * @returns the current Vector4
  77231. */
  77232. negateToRef(result: Vector4): Vector4;
  77233. /**
  77234. * Multiplies the current Vector4 coordinates by scale (float).
  77235. * @param scale the number to scale with
  77236. * @returns the updated Vector4.
  77237. */
  77238. scaleInPlace(scale: number): Vector4;
  77239. /**
  77240. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  77241. * @param scale the number to scale with
  77242. * @returns a new vector with the result
  77243. */
  77244. scale(scale: number): Vector4;
  77245. /**
  77246. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  77247. * @param scale the number to scale with
  77248. * @param result a vector to store the result in
  77249. * @returns the current Vector4.
  77250. */
  77251. scaleToRef(scale: number, result: Vector4): Vector4;
  77252. /**
  77253. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  77254. * @param scale defines the scale factor
  77255. * @param result defines the Vector4 object where to store the result
  77256. * @returns the unmodified current Vector4
  77257. */
  77258. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  77259. /**
  77260. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  77261. * @param otherVector the vector to compare against
  77262. * @returns true if they are equal
  77263. */
  77264. equals(otherVector: DeepImmutable<Vector4>): boolean;
  77265. /**
  77266. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  77267. * @param otherVector vector to compare against
  77268. * @param epsilon (Default: very small number)
  77269. * @returns true if they are equal
  77270. */
  77271. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  77272. /**
  77273. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  77274. * @param x x value to compare against
  77275. * @param y y value to compare against
  77276. * @param z z value to compare against
  77277. * @param w w value to compare against
  77278. * @returns true if equal
  77279. */
  77280. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  77281. /**
  77282. * Multiplies in place the current Vector4 by the given one.
  77283. * @param otherVector vector to multiple with
  77284. * @returns the updated Vector4.
  77285. */
  77286. multiplyInPlace(otherVector: Vector4): Vector4;
  77287. /**
  77288. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  77289. * @param otherVector vector to multiple with
  77290. * @returns resulting new vector
  77291. */
  77292. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  77293. /**
  77294. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  77295. * @param otherVector vector to multiple with
  77296. * @param result vector to store the result
  77297. * @returns the current Vector4.
  77298. */
  77299. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77300. /**
  77301. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  77302. * @param x x value multiply with
  77303. * @param y y value multiply with
  77304. * @param z z value multiply with
  77305. * @param w w value multiply with
  77306. * @returns resulting new vector
  77307. */
  77308. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  77309. /**
  77310. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  77311. * @param otherVector vector to devide with
  77312. * @returns resulting new vector
  77313. */
  77314. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  77315. /**
  77316. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  77317. * @param otherVector vector to devide with
  77318. * @param result vector to store the result
  77319. * @returns the current Vector4.
  77320. */
  77321. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77322. /**
  77323. * Divides the current Vector3 coordinates by the given ones.
  77324. * @param otherVector vector to devide with
  77325. * @returns the updated Vector3.
  77326. */
  77327. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77328. /**
  77329. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  77330. * @param other defines the second operand
  77331. * @returns the current updated Vector4
  77332. */
  77333. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77334. /**
  77335. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  77336. * @param other defines the second operand
  77337. * @returns the current updated Vector4
  77338. */
  77339. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77340. /**
  77341. * Gets a new Vector4 from current Vector4 floored values
  77342. * @returns a new Vector4
  77343. */
  77344. floor(): Vector4;
  77345. /**
  77346. * Gets a new Vector4 from current Vector3 floored values
  77347. * @returns a new Vector4
  77348. */
  77349. fract(): Vector4;
  77350. /**
  77351. * Returns the Vector4 length (float).
  77352. * @returns the length
  77353. */
  77354. length(): number;
  77355. /**
  77356. * Returns the Vector4 squared length (float).
  77357. * @returns the length squared
  77358. */
  77359. lengthSquared(): number;
  77360. /**
  77361. * Normalizes in place the Vector4.
  77362. * @returns the updated Vector4.
  77363. */
  77364. normalize(): Vector4;
  77365. /**
  77366. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  77367. * @returns this converted to a new vector3
  77368. */
  77369. toVector3(): Vector3;
  77370. /**
  77371. * Returns a new Vector4 copied from the current one.
  77372. * @returns the new cloned vector
  77373. */
  77374. clone(): Vector4;
  77375. /**
  77376. * Updates the current Vector4 with the given one coordinates.
  77377. * @param source the source vector to copy from
  77378. * @returns the updated Vector4.
  77379. */
  77380. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  77381. /**
  77382. * Updates the current Vector4 coordinates with the given floats.
  77383. * @param x float to copy from
  77384. * @param y float to copy from
  77385. * @param z float to copy from
  77386. * @param w float to copy from
  77387. * @returns the updated Vector4.
  77388. */
  77389. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77390. /**
  77391. * Updates the current Vector4 coordinates with the given floats.
  77392. * @param x float to set from
  77393. * @param y float to set from
  77394. * @param z float to set from
  77395. * @param w float to set from
  77396. * @returns the updated Vector4.
  77397. */
  77398. set(x: number, y: number, z: number, w: number): Vector4;
  77399. /**
  77400. * Copies the given float to the current Vector3 coordinates
  77401. * @param v defines the x, y, z and w coordinates of the operand
  77402. * @returns the current updated Vector3
  77403. */
  77404. setAll(v: number): Vector4;
  77405. /**
  77406. * Returns a new Vector4 set from the starting index of the given array.
  77407. * @param array the array to pull values from
  77408. * @param offset the offset into the array to start at
  77409. * @returns the new vector
  77410. */
  77411. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  77412. /**
  77413. * Updates the given vector "result" from the starting index of the given array.
  77414. * @param array the array to pull values from
  77415. * @param offset the offset into the array to start at
  77416. * @param result the vector to store the result in
  77417. */
  77418. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  77419. /**
  77420. * Updates the given vector "result" from the starting index of the given Float32Array.
  77421. * @param array the array to pull values from
  77422. * @param offset the offset into the array to start at
  77423. * @param result the vector to store the result in
  77424. */
  77425. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  77426. /**
  77427. * Updates the given vector "result" coordinates from the given floats.
  77428. * @param x float to set from
  77429. * @param y float to set from
  77430. * @param z float to set from
  77431. * @param w float to set from
  77432. * @param result the vector to the floats in
  77433. */
  77434. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  77435. /**
  77436. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  77437. * @returns the new vector
  77438. */
  77439. static Zero(): Vector4;
  77440. /**
  77441. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  77442. * @returns the new vector
  77443. */
  77444. static One(): Vector4;
  77445. /**
  77446. * Returns a new normalized Vector4 from the given one.
  77447. * @param vector the vector to normalize
  77448. * @returns the vector
  77449. */
  77450. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  77451. /**
  77452. * Updates the given vector "result" from the normalization of the given one.
  77453. * @param vector the vector to normalize
  77454. * @param result the vector to store the result in
  77455. */
  77456. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  77457. /**
  77458. * Returns a vector with the minimum values from the left and right vectors
  77459. * @param left left vector to minimize
  77460. * @param right right vector to minimize
  77461. * @returns a new vector with the minimum of the left and right vector values
  77462. */
  77463. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77464. /**
  77465. * Returns a vector with the maximum values from the left and right vectors
  77466. * @param left left vector to maximize
  77467. * @param right right vector to maximize
  77468. * @returns a new vector with the maximum of the left and right vector values
  77469. */
  77470. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77471. /**
  77472. * Returns the distance (float) between the vectors "value1" and "value2".
  77473. * @param value1 value to calulate the distance between
  77474. * @param value2 value to calulate the distance between
  77475. * @return the distance between the two vectors
  77476. */
  77477. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77478. /**
  77479. * Returns the squared distance (float) between the vectors "value1" and "value2".
  77480. * @param value1 value to calulate the distance between
  77481. * @param value2 value to calulate the distance between
  77482. * @return the distance between the two vectors squared
  77483. */
  77484. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77485. /**
  77486. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77487. * @param value1 value to calulate the center between
  77488. * @param value2 value to calulate the center between
  77489. * @return the center between the two vectors
  77490. */
  77491. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77492. /**
  77493. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77494. * This methods computes transformed normalized direction vectors only.
  77495. * @param vector the vector to transform
  77496. * @param transformation the transformation matrix to apply
  77497. * @returns the new vector
  77498. */
  77499. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77500. /**
  77501. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77502. * This methods computes transformed normalized direction vectors only.
  77503. * @param vector the vector to transform
  77504. * @param transformation the transformation matrix to apply
  77505. * @param result the vector to store the result in
  77506. */
  77507. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77508. /**
  77509. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77510. * This methods computes transformed normalized direction vectors only.
  77511. * @param x value to transform
  77512. * @param y value to transform
  77513. * @param z value to transform
  77514. * @param w value to transform
  77515. * @param transformation the transformation matrix to apply
  77516. * @param result the vector to store the results in
  77517. */
  77518. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77519. /**
  77520. * Creates a new Vector4 from a Vector3
  77521. * @param source defines the source data
  77522. * @param w defines the 4th component (default is 0)
  77523. * @returns a new Vector4
  77524. */
  77525. static FromVector3(source: Vector3, w?: number): Vector4;
  77526. }
  77527. /**
  77528. * Class used to store quaternion data
  77529. * @see https://en.wikipedia.org/wiki/Quaternion
  77530. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  77531. */
  77532. export class Quaternion {
  77533. /** defines the first component (0 by default) */
  77534. x: number;
  77535. /** defines the second component (0 by default) */
  77536. y: number;
  77537. /** defines the third component (0 by default) */
  77538. z: number;
  77539. /** defines the fourth component (1.0 by default) */
  77540. w: number;
  77541. /**
  77542. * Creates a new Quaternion from the given floats
  77543. * @param x defines the first component (0 by default)
  77544. * @param y defines the second component (0 by default)
  77545. * @param z defines the third component (0 by default)
  77546. * @param w defines the fourth component (1.0 by default)
  77547. */
  77548. constructor(
  77549. /** defines the first component (0 by default) */
  77550. x?: number,
  77551. /** defines the second component (0 by default) */
  77552. y?: number,
  77553. /** defines the third component (0 by default) */
  77554. z?: number,
  77555. /** defines the fourth component (1.0 by default) */
  77556. w?: number);
  77557. /**
  77558. * Gets a string representation for the current quaternion
  77559. * @returns a string with the Quaternion coordinates
  77560. */
  77561. toString(): string;
  77562. /**
  77563. * Gets the class name of the quaternion
  77564. * @returns the string "Quaternion"
  77565. */
  77566. getClassName(): string;
  77567. /**
  77568. * Gets a hash code for this quaternion
  77569. * @returns the quaternion hash code
  77570. */
  77571. getHashCode(): number;
  77572. /**
  77573. * Copy the quaternion to an array
  77574. * @returns a new array populated with 4 elements from the quaternion coordinates
  77575. */
  77576. asArray(): number[];
  77577. /**
  77578. * Check if two quaternions are equals
  77579. * @param otherQuaternion defines the second operand
  77580. * @return true if the current quaternion and the given one coordinates are strictly equals
  77581. */
  77582. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77583. /**
  77584. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77585. * @param otherQuaternion defines the other quaternion
  77586. * @param epsilon defines the minimal distance to consider equality
  77587. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77588. */
  77589. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77590. /**
  77591. * Clone the current quaternion
  77592. * @returns a new quaternion copied from the current one
  77593. */
  77594. clone(): Quaternion;
  77595. /**
  77596. * Copy a quaternion to the current one
  77597. * @param other defines the other quaternion
  77598. * @returns the updated current quaternion
  77599. */
  77600. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77601. /**
  77602. * Updates the current quaternion with the given float coordinates
  77603. * @param x defines the x coordinate
  77604. * @param y defines the y coordinate
  77605. * @param z defines the z coordinate
  77606. * @param w defines the w coordinate
  77607. * @returns the updated current quaternion
  77608. */
  77609. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77610. /**
  77611. * Updates the current quaternion from the given float coordinates
  77612. * @param x defines the x coordinate
  77613. * @param y defines the y coordinate
  77614. * @param z defines the z coordinate
  77615. * @param w defines the w coordinate
  77616. * @returns the updated current quaternion
  77617. */
  77618. set(x: number, y: number, z: number, w: number): Quaternion;
  77619. /**
  77620. * Adds two quaternions
  77621. * @param other defines the second operand
  77622. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77623. */
  77624. add(other: DeepImmutable<Quaternion>): Quaternion;
  77625. /**
  77626. * Add a quaternion to the current one
  77627. * @param other defines the quaternion to add
  77628. * @returns the current quaternion
  77629. */
  77630. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77631. /**
  77632. * Subtract two quaternions
  77633. * @param other defines the second operand
  77634. * @returns a new quaternion as the subtraction result of the given one from the current one
  77635. */
  77636. subtract(other: Quaternion): Quaternion;
  77637. /**
  77638. * Multiplies the current quaternion by a scale factor
  77639. * @param value defines the scale factor
  77640. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77641. */
  77642. scale(value: number): Quaternion;
  77643. /**
  77644. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77645. * @param scale defines the scale factor
  77646. * @param result defines the Quaternion object where to store the result
  77647. * @returns the unmodified current quaternion
  77648. */
  77649. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77650. /**
  77651. * Multiplies in place the current quaternion by a scale factor
  77652. * @param value defines the scale factor
  77653. * @returns the current modified quaternion
  77654. */
  77655. scaleInPlace(value: number): Quaternion;
  77656. /**
  77657. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77658. * @param scale defines the scale factor
  77659. * @param result defines the Quaternion object where to store the result
  77660. * @returns the unmodified current quaternion
  77661. */
  77662. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77663. /**
  77664. * Multiplies two quaternions
  77665. * @param q1 defines the second operand
  77666. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77667. */
  77668. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77669. /**
  77670. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77671. * @param q1 defines the second operand
  77672. * @param result defines the target quaternion
  77673. * @returns the current quaternion
  77674. */
  77675. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77676. /**
  77677. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77678. * @param q1 defines the second operand
  77679. * @returns the currentupdated quaternion
  77680. */
  77681. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77682. /**
  77683. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77684. * @param ref defines the target quaternion
  77685. * @returns the current quaternion
  77686. */
  77687. conjugateToRef(ref: Quaternion): Quaternion;
  77688. /**
  77689. * Conjugates in place (1-q) the current quaternion
  77690. * @returns the current updated quaternion
  77691. */
  77692. conjugateInPlace(): Quaternion;
  77693. /**
  77694. * Conjugates in place (1-q) the current quaternion
  77695. * @returns a new quaternion
  77696. */
  77697. conjugate(): Quaternion;
  77698. /**
  77699. * Gets length of current quaternion
  77700. * @returns the quaternion length (float)
  77701. */
  77702. length(): number;
  77703. /**
  77704. * Normalize in place the current quaternion
  77705. * @returns the current updated quaternion
  77706. */
  77707. normalize(): Quaternion;
  77708. /**
  77709. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77710. * @param order is a reserved parameter and is ignore for now
  77711. * @returns a new Vector3 containing the Euler angles
  77712. */
  77713. toEulerAngles(order?: string): Vector3;
  77714. /**
  77715. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77716. * @param result defines the vector which will be filled with the Euler angles
  77717. * @param order is a reserved parameter and is ignore for now
  77718. * @returns the current unchanged quaternion
  77719. */
  77720. toEulerAnglesToRef(result: Vector3): Quaternion;
  77721. /**
  77722. * Updates the given rotation matrix with the current quaternion values
  77723. * @param result defines the target matrix
  77724. * @returns the current unchanged quaternion
  77725. */
  77726. toRotationMatrix(result: Matrix): Quaternion;
  77727. /**
  77728. * Updates the current quaternion from the given rotation matrix values
  77729. * @param matrix defines the source matrix
  77730. * @returns the current updated quaternion
  77731. */
  77732. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77733. /**
  77734. * Creates a new quaternion from a rotation matrix
  77735. * @param matrix defines the source matrix
  77736. * @returns a new quaternion created from the given rotation matrix values
  77737. */
  77738. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77739. /**
  77740. * Updates the given quaternion with the given rotation matrix values
  77741. * @param matrix defines the source matrix
  77742. * @param result defines the target quaternion
  77743. */
  77744. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77745. /**
  77746. * Returns the dot product (float) between the quaternions "left" and "right"
  77747. * @param left defines the left operand
  77748. * @param right defines the right operand
  77749. * @returns the dot product
  77750. */
  77751. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77752. /**
  77753. * Checks if the two quaternions are close to each other
  77754. * @param quat0 defines the first quaternion to check
  77755. * @param quat1 defines the second quaternion to check
  77756. * @returns true if the two quaternions are close to each other
  77757. */
  77758. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77759. /**
  77760. * Creates an empty quaternion
  77761. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77762. */
  77763. static Zero(): Quaternion;
  77764. /**
  77765. * Inverse a given quaternion
  77766. * @param q defines the source quaternion
  77767. * @returns a new quaternion as the inverted current quaternion
  77768. */
  77769. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77770. /**
  77771. * Inverse a given quaternion
  77772. * @param q defines the source quaternion
  77773. * @param result the quaternion the result will be stored in
  77774. * @returns the result quaternion
  77775. */
  77776. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77777. /**
  77778. * Creates an identity quaternion
  77779. * @returns the identity quaternion
  77780. */
  77781. static Identity(): Quaternion;
  77782. /**
  77783. * Gets a boolean indicating if the given quaternion is identity
  77784. * @param quaternion defines the quaternion to check
  77785. * @returns true if the quaternion is identity
  77786. */
  77787. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77788. /**
  77789. * Creates a quaternion from a rotation around an axis
  77790. * @param axis defines the axis to use
  77791. * @param angle defines the angle to use
  77792. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77793. */
  77794. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77795. /**
  77796. * Creates a rotation around an axis and stores it into the given quaternion
  77797. * @param axis defines the axis to use
  77798. * @param angle defines the angle to use
  77799. * @param result defines the target quaternion
  77800. * @returns the target quaternion
  77801. */
  77802. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77803. /**
  77804. * Creates a new quaternion from data stored into an array
  77805. * @param array defines the data source
  77806. * @param offset defines the offset in the source array where the data starts
  77807. * @returns a new quaternion
  77808. */
  77809. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77810. /**
  77811. * Updates the given quaternion "result" from the starting index of the given array.
  77812. * @param array the array to pull values from
  77813. * @param offset the offset into the array to start at
  77814. * @param result the quaternion to store the result in
  77815. */
  77816. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  77817. /**
  77818. * Create a quaternion from Euler rotation angles
  77819. * @param x Pitch
  77820. * @param y Yaw
  77821. * @param z Roll
  77822. * @returns the new Quaternion
  77823. */
  77824. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77825. /**
  77826. * Updates a quaternion from Euler rotation angles
  77827. * @param x Pitch
  77828. * @param y Yaw
  77829. * @param z Roll
  77830. * @param result the quaternion to store the result
  77831. * @returns the updated quaternion
  77832. */
  77833. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77834. /**
  77835. * Create a quaternion from Euler rotation vector
  77836. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77837. * @returns the new Quaternion
  77838. */
  77839. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77840. /**
  77841. * Updates a quaternion from Euler rotation vector
  77842. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77843. * @param result the quaternion to store the result
  77844. * @returns the updated quaternion
  77845. */
  77846. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77847. /**
  77848. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77849. * @param yaw defines the rotation around Y axis
  77850. * @param pitch defines the rotation around X axis
  77851. * @param roll defines the rotation around Z axis
  77852. * @returns the new quaternion
  77853. */
  77854. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77855. /**
  77856. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77857. * @param yaw defines the rotation around Y axis
  77858. * @param pitch defines the rotation around X axis
  77859. * @param roll defines the rotation around Z axis
  77860. * @param result defines the target quaternion
  77861. */
  77862. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77863. /**
  77864. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77865. * @param alpha defines the rotation around first axis
  77866. * @param beta defines the rotation around second axis
  77867. * @param gamma defines the rotation around third axis
  77868. * @returns the new quaternion
  77869. */
  77870. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77871. /**
  77872. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77873. * @param alpha defines the rotation around first axis
  77874. * @param beta defines the rotation around second axis
  77875. * @param gamma defines the rotation around third axis
  77876. * @param result defines the target quaternion
  77877. */
  77878. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77879. /**
  77880. * 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)
  77881. * @param axis1 defines the first axis
  77882. * @param axis2 defines the second axis
  77883. * @param axis3 defines the third axis
  77884. * @returns the new quaternion
  77885. */
  77886. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77887. /**
  77888. * 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
  77889. * @param axis1 defines the first axis
  77890. * @param axis2 defines the second axis
  77891. * @param axis3 defines the third axis
  77892. * @param ref defines the target quaternion
  77893. */
  77894. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77895. /**
  77896. * Interpolates between two quaternions
  77897. * @param left defines first quaternion
  77898. * @param right defines second quaternion
  77899. * @param amount defines the gradient to use
  77900. * @returns the new interpolated quaternion
  77901. */
  77902. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77903. /**
  77904. * Interpolates between two quaternions and stores it into a target quaternion
  77905. * @param left defines first quaternion
  77906. * @param right defines second quaternion
  77907. * @param amount defines the gradient to use
  77908. * @param result defines the target quaternion
  77909. */
  77910. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77911. /**
  77912. * Interpolate between two quaternions using Hermite interpolation
  77913. * @param value1 defines first quaternion
  77914. * @param tangent1 defines the incoming tangent
  77915. * @param value2 defines second quaternion
  77916. * @param tangent2 defines the outgoing tangent
  77917. * @param amount defines the target quaternion
  77918. * @returns the new interpolated quaternion
  77919. */
  77920. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77921. }
  77922. /**
  77923. * Class used to store matrix data (4x4)
  77924. */
  77925. export class Matrix {
  77926. private static _updateFlagSeed;
  77927. private static _identityReadOnly;
  77928. private _isIdentity;
  77929. private _isIdentityDirty;
  77930. private _isIdentity3x2;
  77931. private _isIdentity3x2Dirty;
  77932. /**
  77933. * Gets the update flag of the matrix which is an unique number for the matrix.
  77934. * It will be incremented every time the matrix data change.
  77935. * You can use it to speed the comparison between two versions of the same matrix.
  77936. */
  77937. updateFlag: number;
  77938. private readonly _m;
  77939. /**
  77940. * Gets the internal data of the matrix
  77941. */
  77942. get m(): DeepImmutable<Float32Array>;
  77943. /** @hidden */
  77944. _markAsUpdated(): void;
  77945. /** @hidden */
  77946. private _updateIdentityStatus;
  77947. /**
  77948. * Creates an empty matrix (filled with zeros)
  77949. */
  77950. constructor();
  77951. /**
  77952. * Check if the current matrix is identity
  77953. * @returns true is the matrix is the identity matrix
  77954. */
  77955. isIdentity(): boolean;
  77956. /**
  77957. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77958. * @returns true is the matrix is the identity matrix
  77959. */
  77960. isIdentityAs3x2(): boolean;
  77961. /**
  77962. * Gets the determinant of the matrix
  77963. * @returns the matrix determinant
  77964. */
  77965. determinant(): number;
  77966. /**
  77967. * Returns the matrix as a Float32Array
  77968. * @returns the matrix underlying array
  77969. */
  77970. toArray(): DeepImmutable<Float32Array>;
  77971. /**
  77972. * Returns the matrix as a Float32Array
  77973. * @returns the matrix underlying array.
  77974. */
  77975. asArray(): DeepImmutable<Float32Array>;
  77976. /**
  77977. * Inverts the current matrix in place
  77978. * @returns the current inverted matrix
  77979. */
  77980. invert(): Matrix;
  77981. /**
  77982. * Sets all the matrix elements to zero
  77983. * @returns the current matrix
  77984. */
  77985. reset(): Matrix;
  77986. /**
  77987. * Adds the current matrix with a second one
  77988. * @param other defines the matrix to add
  77989. * @returns a new matrix as the addition of the current matrix and the given one
  77990. */
  77991. add(other: DeepImmutable<Matrix>): Matrix;
  77992. /**
  77993. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77994. * @param other defines the matrix to add
  77995. * @param result defines the target matrix
  77996. * @returns the current matrix
  77997. */
  77998. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77999. /**
  78000. * Adds in place the given matrix to the current matrix
  78001. * @param other defines the second operand
  78002. * @returns the current updated matrix
  78003. */
  78004. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  78005. /**
  78006. * Sets the given matrix to the current inverted Matrix
  78007. * @param other defines the target matrix
  78008. * @returns the unmodified current matrix
  78009. */
  78010. invertToRef(other: Matrix): Matrix;
  78011. /**
  78012. * add a value at the specified position in the current Matrix
  78013. * @param index the index of the value within the matrix. between 0 and 15.
  78014. * @param value the value to be added
  78015. * @returns the current updated matrix
  78016. */
  78017. addAtIndex(index: number, value: number): Matrix;
  78018. /**
  78019. * mutiply the specified position in the current Matrix by a value
  78020. * @param index the index of the value within the matrix. between 0 and 15.
  78021. * @param value the value to be added
  78022. * @returns the current updated matrix
  78023. */
  78024. multiplyAtIndex(index: number, value: number): Matrix;
  78025. /**
  78026. * Inserts the translation vector (using 3 floats) in the current matrix
  78027. * @param x defines the 1st component of the translation
  78028. * @param y defines the 2nd component of the translation
  78029. * @param z defines the 3rd component of the translation
  78030. * @returns the current updated matrix
  78031. */
  78032. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78033. /**
  78034. * Adds the translation vector (using 3 floats) in the current matrix
  78035. * @param x defines the 1st component of the translation
  78036. * @param y defines the 2nd component of the translation
  78037. * @param z defines the 3rd component of the translation
  78038. * @returns the current updated matrix
  78039. */
  78040. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78041. /**
  78042. * Inserts the translation vector in the current matrix
  78043. * @param vector3 defines the translation to insert
  78044. * @returns the current updated matrix
  78045. */
  78046. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  78047. /**
  78048. * Gets the translation value of the current matrix
  78049. * @returns a new Vector3 as the extracted translation from the matrix
  78050. */
  78051. getTranslation(): Vector3;
  78052. /**
  78053. * Fill a Vector3 with the extracted translation from the matrix
  78054. * @param result defines the Vector3 where to store the translation
  78055. * @returns the current matrix
  78056. */
  78057. getTranslationToRef(result: Vector3): Matrix;
  78058. /**
  78059. * Remove rotation and scaling part from the matrix
  78060. * @returns the updated matrix
  78061. */
  78062. removeRotationAndScaling(): Matrix;
  78063. /**
  78064. * Multiply two matrices
  78065. * @param other defines the second operand
  78066. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  78067. */
  78068. multiply(other: DeepImmutable<Matrix>): Matrix;
  78069. /**
  78070. * Copy the current matrix from the given one
  78071. * @param other defines the source matrix
  78072. * @returns the current updated matrix
  78073. */
  78074. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  78075. /**
  78076. * Populates the given array from the starting index with the current matrix values
  78077. * @param array defines the target array
  78078. * @param offset defines the offset in the target array where to start storing values
  78079. * @returns the current matrix
  78080. */
  78081. copyToArray(array: Float32Array, offset?: number): Matrix;
  78082. /**
  78083. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  78084. * @param other defines the second operand
  78085. * @param result defines the matrix where to store the multiplication
  78086. * @returns the current matrix
  78087. */
  78088. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78089. /**
  78090. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  78091. * @param other defines the second operand
  78092. * @param result defines the array where to store the multiplication
  78093. * @param offset defines the offset in the target array where to start storing values
  78094. * @returns the current matrix
  78095. */
  78096. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  78097. /**
  78098. * Check equality between this matrix and a second one
  78099. * @param value defines the second matrix to compare
  78100. * @returns true is the current matrix and the given one values are strictly equal
  78101. */
  78102. equals(value: DeepImmutable<Matrix>): boolean;
  78103. /**
  78104. * Clone the current matrix
  78105. * @returns a new matrix from the current matrix
  78106. */
  78107. clone(): Matrix;
  78108. /**
  78109. * Returns the name of the current matrix class
  78110. * @returns the string "Matrix"
  78111. */
  78112. getClassName(): string;
  78113. /**
  78114. * Gets the hash code of the current matrix
  78115. * @returns the hash code
  78116. */
  78117. getHashCode(): number;
  78118. /**
  78119. * Decomposes the current Matrix into a translation, rotation and scaling components
  78120. * @param scale defines the scale vector3 given as a reference to update
  78121. * @param rotation defines the rotation quaternion given as a reference to update
  78122. * @param translation defines the translation vector3 given as a reference to update
  78123. * @returns true if operation was successful
  78124. */
  78125. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  78126. /**
  78127. * Gets specific row of the matrix
  78128. * @param index defines the number of the row to get
  78129. * @returns the index-th row of the current matrix as a new Vector4
  78130. */
  78131. getRow(index: number): Nullable<Vector4>;
  78132. /**
  78133. * Sets the index-th row of the current matrix to the vector4 values
  78134. * @param index defines the number of the row to set
  78135. * @param row defines the target vector4
  78136. * @returns the updated current matrix
  78137. */
  78138. setRow(index: number, row: Vector4): Matrix;
  78139. /**
  78140. * Compute the transpose of the matrix
  78141. * @returns the new transposed matrix
  78142. */
  78143. transpose(): Matrix;
  78144. /**
  78145. * Compute the transpose of the matrix and store it in a given matrix
  78146. * @param result defines the target matrix
  78147. * @returns the current matrix
  78148. */
  78149. transposeToRef(result: Matrix): Matrix;
  78150. /**
  78151. * Sets the index-th row of the current matrix with the given 4 x float values
  78152. * @param index defines the row index
  78153. * @param x defines the x component to set
  78154. * @param y defines the y component to set
  78155. * @param z defines the z component to set
  78156. * @param w defines the w component to set
  78157. * @returns the updated current matrix
  78158. */
  78159. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  78160. /**
  78161. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  78162. * @param scale defines the scale factor
  78163. * @returns a new matrix
  78164. */
  78165. scale(scale: number): Matrix;
  78166. /**
  78167. * Scale the current matrix values by a factor to a given result matrix
  78168. * @param scale defines the scale factor
  78169. * @param result defines the matrix to store the result
  78170. * @returns the current matrix
  78171. */
  78172. scaleToRef(scale: number, result: Matrix): Matrix;
  78173. /**
  78174. * Scale the current matrix values by a factor and add the result to a given matrix
  78175. * @param scale defines the scale factor
  78176. * @param result defines the Matrix to store the result
  78177. * @returns the current matrix
  78178. */
  78179. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  78180. /**
  78181. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  78182. * @param ref matrix to store the result
  78183. */
  78184. toNormalMatrix(ref: Matrix): void;
  78185. /**
  78186. * Gets only rotation part of the current matrix
  78187. * @returns a new matrix sets to the extracted rotation matrix from the current one
  78188. */
  78189. getRotationMatrix(): Matrix;
  78190. /**
  78191. * Extracts the rotation matrix from the current one and sets it as the given "result"
  78192. * @param result defines the target matrix to store data to
  78193. * @returns the current matrix
  78194. */
  78195. getRotationMatrixToRef(result: Matrix): Matrix;
  78196. /**
  78197. * Toggles model matrix from being right handed to left handed in place and vice versa
  78198. */
  78199. toggleModelMatrixHandInPlace(): void;
  78200. /**
  78201. * Toggles projection matrix from being right handed to left handed in place and vice versa
  78202. */
  78203. toggleProjectionMatrixHandInPlace(): void;
  78204. /**
  78205. * Creates a matrix from an array
  78206. * @param array defines the source array
  78207. * @param offset defines an offset in the source array
  78208. * @returns a new Matrix set from the starting index of the given array
  78209. */
  78210. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  78211. /**
  78212. * Copy the content of an array into a given matrix
  78213. * @param array defines the source array
  78214. * @param offset defines an offset in the source array
  78215. * @param result defines the target matrix
  78216. */
  78217. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  78218. /**
  78219. * Stores an array into a matrix after having multiplied each component by a given factor
  78220. * @param array defines the source array
  78221. * @param offset defines the offset in the source array
  78222. * @param scale defines the scaling factor
  78223. * @param result defines the target matrix
  78224. */
  78225. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  78226. /**
  78227. * Gets an identity matrix that must not be updated
  78228. */
  78229. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  78230. /**
  78231. * Stores a list of values (16) inside a given matrix
  78232. * @param initialM11 defines 1st value of 1st row
  78233. * @param initialM12 defines 2nd value of 1st row
  78234. * @param initialM13 defines 3rd value of 1st row
  78235. * @param initialM14 defines 4th value of 1st row
  78236. * @param initialM21 defines 1st value of 2nd row
  78237. * @param initialM22 defines 2nd value of 2nd row
  78238. * @param initialM23 defines 3rd value of 2nd row
  78239. * @param initialM24 defines 4th value of 2nd row
  78240. * @param initialM31 defines 1st value of 3rd row
  78241. * @param initialM32 defines 2nd value of 3rd row
  78242. * @param initialM33 defines 3rd value of 3rd row
  78243. * @param initialM34 defines 4th value of 3rd row
  78244. * @param initialM41 defines 1st value of 4th row
  78245. * @param initialM42 defines 2nd value of 4th row
  78246. * @param initialM43 defines 3rd value of 4th row
  78247. * @param initialM44 defines 4th value of 4th row
  78248. * @param result defines the target matrix
  78249. */
  78250. 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;
  78251. /**
  78252. * Creates new matrix from a list of values (16)
  78253. * @param initialM11 defines 1st value of 1st row
  78254. * @param initialM12 defines 2nd value of 1st row
  78255. * @param initialM13 defines 3rd value of 1st row
  78256. * @param initialM14 defines 4th value of 1st row
  78257. * @param initialM21 defines 1st value of 2nd row
  78258. * @param initialM22 defines 2nd value of 2nd row
  78259. * @param initialM23 defines 3rd value of 2nd row
  78260. * @param initialM24 defines 4th value of 2nd row
  78261. * @param initialM31 defines 1st value of 3rd row
  78262. * @param initialM32 defines 2nd value of 3rd row
  78263. * @param initialM33 defines 3rd value of 3rd row
  78264. * @param initialM34 defines 4th value of 3rd row
  78265. * @param initialM41 defines 1st value of 4th row
  78266. * @param initialM42 defines 2nd value of 4th row
  78267. * @param initialM43 defines 3rd value of 4th row
  78268. * @param initialM44 defines 4th value of 4th row
  78269. * @returns the new matrix
  78270. */
  78271. 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;
  78272. /**
  78273. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78274. * @param scale defines the scale vector3
  78275. * @param rotation defines the rotation quaternion
  78276. * @param translation defines the translation vector3
  78277. * @returns a new matrix
  78278. */
  78279. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  78280. /**
  78281. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78282. * @param scale defines the scale vector3
  78283. * @param rotation defines the rotation quaternion
  78284. * @param translation defines the translation vector3
  78285. * @param result defines the target matrix
  78286. */
  78287. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  78288. /**
  78289. * Creates a new identity matrix
  78290. * @returns a new identity matrix
  78291. */
  78292. static Identity(): Matrix;
  78293. /**
  78294. * Creates a new identity matrix and stores the result in a given matrix
  78295. * @param result defines the target matrix
  78296. */
  78297. static IdentityToRef(result: Matrix): void;
  78298. /**
  78299. * Creates a new zero matrix
  78300. * @returns a new zero matrix
  78301. */
  78302. static Zero(): Matrix;
  78303. /**
  78304. * Creates a new rotation matrix for "angle" radians around the X axis
  78305. * @param angle defines the angle (in radians) to use
  78306. * @return the new matrix
  78307. */
  78308. static RotationX(angle: number): Matrix;
  78309. /**
  78310. * Creates a new matrix as the invert of a given matrix
  78311. * @param source defines the source matrix
  78312. * @returns the new matrix
  78313. */
  78314. static Invert(source: DeepImmutable<Matrix>): Matrix;
  78315. /**
  78316. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  78317. * @param angle defines the angle (in radians) to use
  78318. * @param result defines the target matrix
  78319. */
  78320. static RotationXToRef(angle: number, result: Matrix): void;
  78321. /**
  78322. * Creates a new rotation matrix for "angle" radians around the Y axis
  78323. * @param angle defines the angle (in radians) to use
  78324. * @return the new matrix
  78325. */
  78326. static RotationY(angle: number): Matrix;
  78327. /**
  78328. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  78329. * @param angle defines the angle (in radians) to use
  78330. * @param result defines the target matrix
  78331. */
  78332. static RotationYToRef(angle: number, result: Matrix): void;
  78333. /**
  78334. * Creates a new rotation matrix for "angle" radians around the Z axis
  78335. * @param angle defines the angle (in radians) to use
  78336. * @return the new matrix
  78337. */
  78338. static RotationZ(angle: number): Matrix;
  78339. /**
  78340. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  78341. * @param angle defines the angle (in radians) to use
  78342. * @param result defines the target matrix
  78343. */
  78344. static RotationZToRef(angle: number, result: Matrix): void;
  78345. /**
  78346. * Creates a new rotation matrix for "angle" radians around the given axis
  78347. * @param axis defines the axis to use
  78348. * @param angle defines the angle (in radians) to use
  78349. * @return the new matrix
  78350. */
  78351. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  78352. /**
  78353. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  78354. * @param axis defines the axis to use
  78355. * @param angle defines the angle (in radians) to use
  78356. * @param result defines the target matrix
  78357. */
  78358. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  78359. /**
  78360. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  78361. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  78362. * @param from defines the vector to align
  78363. * @param to defines the vector to align to
  78364. * @param result defines the target matrix
  78365. */
  78366. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  78367. /**
  78368. * Creates a rotation matrix
  78369. * @param yaw defines the yaw angle in radians (Y axis)
  78370. * @param pitch defines the pitch angle in radians (X axis)
  78371. * @param roll defines the roll angle in radians (X axis)
  78372. * @returns the new rotation matrix
  78373. */
  78374. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  78375. /**
  78376. * Creates a rotation matrix and stores it in a given matrix
  78377. * @param yaw defines the yaw angle in radians (Y axis)
  78378. * @param pitch defines the pitch angle in radians (X axis)
  78379. * @param roll defines the roll angle in radians (X axis)
  78380. * @param result defines the target matrix
  78381. */
  78382. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  78383. /**
  78384. * Creates a scaling matrix
  78385. * @param x defines the scale factor on X axis
  78386. * @param y defines the scale factor on Y axis
  78387. * @param z defines the scale factor on Z axis
  78388. * @returns the new matrix
  78389. */
  78390. static Scaling(x: number, y: number, z: number): Matrix;
  78391. /**
  78392. * Creates a scaling matrix and stores it in a given matrix
  78393. * @param x defines the scale factor on X axis
  78394. * @param y defines the scale factor on Y axis
  78395. * @param z defines the scale factor on Z axis
  78396. * @param result defines the target matrix
  78397. */
  78398. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  78399. /**
  78400. * Creates a translation matrix
  78401. * @param x defines the translation on X axis
  78402. * @param y defines the translation on Y axis
  78403. * @param z defines the translationon Z axis
  78404. * @returns the new matrix
  78405. */
  78406. static Translation(x: number, y: number, z: number): Matrix;
  78407. /**
  78408. * Creates a translation matrix and stores it in a given matrix
  78409. * @param x defines the translation on X axis
  78410. * @param y defines the translation on Y axis
  78411. * @param z defines the translationon Z axis
  78412. * @param result defines the target matrix
  78413. */
  78414. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  78415. /**
  78416. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78417. * @param startValue defines the start value
  78418. * @param endValue defines the end value
  78419. * @param gradient defines the gradient factor
  78420. * @returns the new matrix
  78421. */
  78422. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78423. /**
  78424. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78425. * @param startValue defines the start value
  78426. * @param endValue defines the end value
  78427. * @param gradient defines the gradient factor
  78428. * @param result defines the Matrix object where to store data
  78429. */
  78430. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78431. /**
  78432. * Builds a new matrix whose values are computed by:
  78433. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78434. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78435. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78436. * @param startValue defines the first matrix
  78437. * @param endValue defines the second matrix
  78438. * @param gradient defines the gradient between the two matrices
  78439. * @returns the new matrix
  78440. */
  78441. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78442. /**
  78443. * Update a matrix to values which are computed by:
  78444. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78445. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78446. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78447. * @param startValue defines the first matrix
  78448. * @param endValue defines the second matrix
  78449. * @param gradient defines the gradient between the two matrices
  78450. * @param result defines the target matrix
  78451. */
  78452. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78453. /**
  78454. * 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"
  78455. * This function works in left handed mode
  78456. * @param eye defines the final position of the entity
  78457. * @param target defines where the entity should look at
  78458. * @param up defines the up vector for the entity
  78459. * @returns the new matrix
  78460. */
  78461. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78462. /**
  78463. * 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".
  78464. * This function works in left handed mode
  78465. * @param eye defines the final position of the entity
  78466. * @param target defines where the entity should look at
  78467. * @param up defines the up vector for the entity
  78468. * @param result defines the target matrix
  78469. */
  78470. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78471. /**
  78472. * 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"
  78473. * This function works in right handed mode
  78474. * @param eye defines the final position of the entity
  78475. * @param target defines where the entity should look at
  78476. * @param up defines the up vector for the entity
  78477. * @returns the new matrix
  78478. */
  78479. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78480. /**
  78481. * 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".
  78482. * This function works in right handed mode
  78483. * @param eye defines the final position of the entity
  78484. * @param target defines where the entity should look at
  78485. * @param up defines the up vector for the entity
  78486. * @param result defines the target matrix
  78487. */
  78488. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78489. /**
  78490. * Create a left-handed orthographic projection matrix
  78491. * @param width defines the viewport width
  78492. * @param height defines the viewport height
  78493. * @param znear defines the near clip plane
  78494. * @param zfar defines the far clip plane
  78495. * @returns a new matrix as a left-handed orthographic projection matrix
  78496. */
  78497. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78498. /**
  78499. * Store a left-handed orthographic projection to a given matrix
  78500. * @param width defines the viewport width
  78501. * @param height defines the viewport height
  78502. * @param znear defines the near clip plane
  78503. * @param zfar defines the far clip plane
  78504. * @param result defines the target matrix
  78505. */
  78506. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78507. /**
  78508. * Create a left-handed orthographic projection matrix
  78509. * @param left defines the viewport left coordinate
  78510. * @param right defines the viewport right coordinate
  78511. * @param bottom defines the viewport bottom coordinate
  78512. * @param top defines the viewport top coordinate
  78513. * @param znear defines the near clip plane
  78514. * @param zfar defines the far clip plane
  78515. * @returns a new matrix as a left-handed orthographic projection matrix
  78516. */
  78517. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78518. /**
  78519. * Stores a left-handed orthographic projection into a given matrix
  78520. * @param left defines the viewport left coordinate
  78521. * @param right defines the viewport right coordinate
  78522. * @param bottom defines the viewport bottom coordinate
  78523. * @param top defines the viewport top coordinate
  78524. * @param znear defines the near clip plane
  78525. * @param zfar defines the far clip plane
  78526. * @param result defines the target matrix
  78527. */
  78528. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78529. /**
  78530. * Creates a right-handed orthographic projection matrix
  78531. * @param left defines the viewport left coordinate
  78532. * @param right defines the viewport right coordinate
  78533. * @param bottom defines the viewport bottom coordinate
  78534. * @param top defines the viewport top coordinate
  78535. * @param znear defines the near clip plane
  78536. * @param zfar defines the far clip plane
  78537. * @returns a new matrix as a right-handed orthographic projection matrix
  78538. */
  78539. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78540. /**
  78541. * Stores a right-handed orthographic projection into a given matrix
  78542. * @param left defines the viewport left coordinate
  78543. * @param right defines the viewport right coordinate
  78544. * @param bottom defines the viewport bottom coordinate
  78545. * @param top defines the viewport top coordinate
  78546. * @param znear defines the near clip plane
  78547. * @param zfar defines the far clip plane
  78548. * @param result defines the target matrix
  78549. */
  78550. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78551. /**
  78552. * Creates a left-handed perspective projection matrix
  78553. * @param width defines the viewport width
  78554. * @param height defines the viewport height
  78555. * @param znear defines the near clip plane
  78556. * @param zfar defines the far clip plane
  78557. * @returns a new matrix as a left-handed perspective projection matrix
  78558. */
  78559. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78560. /**
  78561. * Creates a left-handed perspective projection matrix
  78562. * @param fov defines the horizontal field of view
  78563. * @param aspect defines the aspect ratio
  78564. * @param znear defines the near clip plane
  78565. * @param zfar defines the far clip plane
  78566. * @returns a new matrix as a left-handed perspective projection matrix
  78567. */
  78568. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78569. /**
  78570. * Stores a left-handed perspective projection into a given matrix
  78571. * @param fov defines the horizontal field of view
  78572. * @param aspect defines the aspect ratio
  78573. * @param znear defines the near clip plane
  78574. * @param zfar defines the far clip plane
  78575. * @param result defines the target matrix
  78576. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78577. */
  78578. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78579. /**
  78580. * Stores a left-handed perspective projection into a given matrix with depth reversed
  78581. * @param fov defines the horizontal field of view
  78582. * @param aspect defines the aspect ratio
  78583. * @param znear defines the near clip plane
  78584. * @param zfar not used as infinity is used as far clip
  78585. * @param result defines the target matrix
  78586. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78587. */
  78588. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78589. /**
  78590. * Creates a right-handed perspective projection matrix
  78591. * @param fov defines the horizontal field of view
  78592. * @param aspect defines the aspect ratio
  78593. * @param znear defines the near clip plane
  78594. * @param zfar defines the far clip plane
  78595. * @returns a new matrix as a right-handed perspective projection matrix
  78596. */
  78597. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78598. /**
  78599. * Stores a right-handed perspective projection into a given matrix
  78600. * @param fov defines the horizontal field of view
  78601. * @param aspect defines the aspect ratio
  78602. * @param znear defines the near clip plane
  78603. * @param zfar defines the far clip plane
  78604. * @param result defines the target matrix
  78605. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78606. */
  78607. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78608. /**
  78609. * Stores a right-handed perspective projection into a given matrix
  78610. * @param fov defines the horizontal field of view
  78611. * @param aspect defines the aspect ratio
  78612. * @param znear defines the near clip plane
  78613. * @param zfar not used as infinity is used as far clip
  78614. * @param result defines the target matrix
  78615. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78616. */
  78617. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78618. /**
  78619. * Stores a perspective projection for WebVR info a given matrix
  78620. * @param fov defines the field of view
  78621. * @param znear defines the near clip plane
  78622. * @param zfar defines the far clip plane
  78623. * @param result defines the target matrix
  78624. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78625. */
  78626. static PerspectiveFovWebVRToRef(fov: {
  78627. upDegrees: number;
  78628. downDegrees: number;
  78629. leftDegrees: number;
  78630. rightDegrees: number;
  78631. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78632. /**
  78633. * Computes a complete transformation matrix
  78634. * @param viewport defines the viewport to use
  78635. * @param world defines the world matrix
  78636. * @param view defines the view matrix
  78637. * @param projection defines the projection matrix
  78638. * @param zmin defines the near clip plane
  78639. * @param zmax defines the far clip plane
  78640. * @returns the transformation matrix
  78641. */
  78642. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78643. /**
  78644. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78645. * @param matrix defines the matrix to use
  78646. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78647. */
  78648. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78649. /**
  78650. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78651. * @param matrix defines the matrix to use
  78652. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78653. */
  78654. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78655. /**
  78656. * Compute the transpose of a given matrix
  78657. * @param matrix defines the matrix to transpose
  78658. * @returns the new matrix
  78659. */
  78660. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78661. /**
  78662. * Compute the transpose of a matrix and store it in a target matrix
  78663. * @param matrix defines the matrix to transpose
  78664. * @param result defines the target matrix
  78665. */
  78666. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78667. /**
  78668. * Computes a reflection matrix from a plane
  78669. * @param plane defines the reflection plane
  78670. * @returns a new matrix
  78671. */
  78672. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78673. /**
  78674. * Computes a reflection matrix from a plane
  78675. * @param plane defines the reflection plane
  78676. * @param result defines the target matrix
  78677. */
  78678. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78679. /**
  78680. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78681. * @param xaxis defines the value of the 1st axis
  78682. * @param yaxis defines the value of the 2nd axis
  78683. * @param zaxis defines the value of the 3rd axis
  78684. * @param result defines the target matrix
  78685. */
  78686. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78687. /**
  78688. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78689. * @param quat defines the quaternion to use
  78690. * @param result defines the target matrix
  78691. */
  78692. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78693. }
  78694. /**
  78695. * @hidden
  78696. */
  78697. export class TmpVectors {
  78698. static Vector2: Vector2[];
  78699. static Vector3: Vector3[];
  78700. static Vector4: Vector4[];
  78701. static Quaternion: Quaternion[];
  78702. static Matrix: Matrix[];
  78703. }
  78704. }
  78705. declare module BABYLON {
  78706. /**
  78707. * Defines potential orientation for back face culling
  78708. */
  78709. export enum Orientation {
  78710. /**
  78711. * Clockwise
  78712. */
  78713. CW = 0,
  78714. /** Counter clockwise */
  78715. CCW = 1
  78716. }
  78717. /** Class used to represent a Bezier curve */
  78718. export class BezierCurve {
  78719. /**
  78720. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78721. * @param t defines the time
  78722. * @param x1 defines the left coordinate on X axis
  78723. * @param y1 defines the left coordinate on Y axis
  78724. * @param x2 defines the right coordinate on X axis
  78725. * @param y2 defines the right coordinate on Y axis
  78726. * @returns the interpolated value
  78727. */
  78728. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78729. }
  78730. /**
  78731. * Defines angle representation
  78732. */
  78733. export class Angle {
  78734. private _radians;
  78735. /**
  78736. * Creates an Angle object of "radians" radians (float).
  78737. * @param radians the angle in radians
  78738. */
  78739. constructor(radians: number);
  78740. /**
  78741. * Get value in degrees
  78742. * @returns the Angle value in degrees (float)
  78743. */
  78744. degrees(): number;
  78745. /**
  78746. * Get value in radians
  78747. * @returns the Angle value in radians (float)
  78748. */
  78749. radians(): number;
  78750. /**
  78751. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78752. * @param a defines first vector
  78753. * @param b defines second vector
  78754. * @returns a new Angle
  78755. */
  78756. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78757. /**
  78758. * Gets a new Angle object from the given float in radians
  78759. * @param radians defines the angle value in radians
  78760. * @returns a new Angle
  78761. */
  78762. static FromRadians(radians: number): Angle;
  78763. /**
  78764. * Gets a new Angle object from the given float in degrees
  78765. * @param degrees defines the angle value in degrees
  78766. * @returns a new Angle
  78767. */
  78768. static FromDegrees(degrees: number): Angle;
  78769. }
  78770. /**
  78771. * This represents an arc in a 2d space.
  78772. */
  78773. export class Arc2 {
  78774. /** Defines the start point of the arc */
  78775. startPoint: Vector2;
  78776. /** Defines the mid point of the arc */
  78777. midPoint: Vector2;
  78778. /** Defines the end point of the arc */
  78779. endPoint: Vector2;
  78780. /**
  78781. * Defines the center point of the arc.
  78782. */
  78783. centerPoint: Vector2;
  78784. /**
  78785. * Defines the radius of the arc.
  78786. */
  78787. radius: number;
  78788. /**
  78789. * Defines the angle of the arc (from mid point to end point).
  78790. */
  78791. angle: Angle;
  78792. /**
  78793. * Defines the start angle of the arc (from start point to middle point).
  78794. */
  78795. startAngle: Angle;
  78796. /**
  78797. * Defines the orientation of the arc (clock wise/counter clock wise).
  78798. */
  78799. orientation: Orientation;
  78800. /**
  78801. * Creates an Arc object from the three given points : start, middle and end.
  78802. * @param startPoint Defines the start point of the arc
  78803. * @param midPoint Defines the midlle point of the arc
  78804. * @param endPoint Defines the end point of the arc
  78805. */
  78806. constructor(
  78807. /** Defines the start point of the arc */
  78808. startPoint: Vector2,
  78809. /** Defines the mid point of the arc */
  78810. midPoint: Vector2,
  78811. /** Defines the end point of the arc */
  78812. endPoint: Vector2);
  78813. }
  78814. /**
  78815. * Represents a 2D path made up of multiple 2D points
  78816. */
  78817. export class Path2 {
  78818. private _points;
  78819. private _length;
  78820. /**
  78821. * If the path start and end point are the same
  78822. */
  78823. closed: boolean;
  78824. /**
  78825. * Creates a Path2 object from the starting 2D coordinates x and y.
  78826. * @param x the starting points x value
  78827. * @param y the starting points y value
  78828. */
  78829. constructor(x: number, y: number);
  78830. /**
  78831. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78832. * @param x the added points x value
  78833. * @param y the added points y value
  78834. * @returns the updated Path2.
  78835. */
  78836. addLineTo(x: number, y: number): Path2;
  78837. /**
  78838. * 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.
  78839. * @param midX middle point x value
  78840. * @param midY middle point y value
  78841. * @param endX end point x value
  78842. * @param endY end point y value
  78843. * @param numberOfSegments (default: 36)
  78844. * @returns the updated Path2.
  78845. */
  78846. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78847. /**
  78848. * Closes the Path2.
  78849. * @returns the Path2.
  78850. */
  78851. close(): Path2;
  78852. /**
  78853. * Gets the sum of the distance between each sequential point in the path
  78854. * @returns the Path2 total length (float).
  78855. */
  78856. length(): number;
  78857. /**
  78858. * Gets the points which construct the path
  78859. * @returns the Path2 internal array of points.
  78860. */
  78861. getPoints(): Vector2[];
  78862. /**
  78863. * Retreives the point at the distance aways from the starting point
  78864. * @param normalizedLengthPosition the length along the path to retreive the point from
  78865. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78866. */
  78867. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78868. /**
  78869. * Creates a new path starting from an x and y position
  78870. * @param x starting x value
  78871. * @param y starting y value
  78872. * @returns a new Path2 starting at the coordinates (x, y).
  78873. */
  78874. static StartingAt(x: number, y: number): Path2;
  78875. }
  78876. /**
  78877. * Represents a 3D path made up of multiple 3D points
  78878. */
  78879. export class Path3D {
  78880. /**
  78881. * an array of Vector3, the curve axis of the Path3D
  78882. */
  78883. path: Vector3[];
  78884. private _curve;
  78885. private _distances;
  78886. private _tangents;
  78887. private _normals;
  78888. private _binormals;
  78889. private _raw;
  78890. private _alignTangentsWithPath;
  78891. private readonly _pointAtData;
  78892. /**
  78893. * new Path3D(path, normal, raw)
  78894. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78895. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78896. * @param path an array of Vector3, the curve axis of the Path3D
  78897. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78898. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78899. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78900. */
  78901. constructor(
  78902. /**
  78903. * an array of Vector3, the curve axis of the Path3D
  78904. */
  78905. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78906. /**
  78907. * Returns the Path3D array of successive Vector3 designing its curve.
  78908. * @returns the Path3D array of successive Vector3 designing its curve.
  78909. */
  78910. getCurve(): Vector3[];
  78911. /**
  78912. * Returns the Path3D array of successive Vector3 designing its curve.
  78913. * @returns the Path3D array of successive Vector3 designing its curve.
  78914. */
  78915. getPoints(): Vector3[];
  78916. /**
  78917. * @returns the computed length (float) of the path.
  78918. */
  78919. length(): number;
  78920. /**
  78921. * Returns an array populated with tangent vectors on each Path3D curve point.
  78922. * @returns an array populated with tangent vectors on each Path3D curve point.
  78923. */
  78924. getTangents(): Vector3[];
  78925. /**
  78926. * Returns an array populated with normal vectors on each Path3D curve point.
  78927. * @returns an array populated with normal vectors on each Path3D curve point.
  78928. */
  78929. getNormals(): Vector3[];
  78930. /**
  78931. * Returns an array populated with binormal vectors on each Path3D curve point.
  78932. * @returns an array populated with binormal vectors on each Path3D curve point.
  78933. */
  78934. getBinormals(): Vector3[];
  78935. /**
  78936. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78937. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78938. */
  78939. getDistances(): number[];
  78940. /**
  78941. * Returns an interpolated point along this path
  78942. * @param position the position of the point along this path, from 0.0 to 1.0
  78943. * @returns a new Vector3 as the point
  78944. */
  78945. getPointAt(position: number): Vector3;
  78946. /**
  78947. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78948. * @param position the position of the point along this path, from 0.0 to 1.0
  78949. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78950. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78951. */
  78952. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78953. /**
  78954. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78955. * @param position the position of the point along this path, from 0.0 to 1.0
  78956. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78957. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78958. */
  78959. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78960. /**
  78961. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78962. * @param position the position of the point along this path, from 0.0 to 1.0
  78963. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78964. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78965. */
  78966. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78967. /**
  78968. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78969. * @param position the position of the point along this path, from 0.0 to 1.0
  78970. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78971. */
  78972. getDistanceAt(position: number): number;
  78973. /**
  78974. * Returns the array index of the previous point of an interpolated point along this path
  78975. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78976. * @returns the array index
  78977. */
  78978. getPreviousPointIndexAt(position: number): number;
  78979. /**
  78980. * 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)
  78981. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78982. * @returns the sub position
  78983. */
  78984. getSubPositionAt(position: number): number;
  78985. /**
  78986. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78987. * @param target the vector of which to get the closest position to
  78988. * @returns the position of the closest virtual point on this path to the target vector
  78989. */
  78990. getClosestPositionTo(target: Vector3): number;
  78991. /**
  78992. * Returns a sub path (slice) of this path
  78993. * @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
  78994. * @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
  78995. * @returns a sub path (slice) of this path
  78996. */
  78997. slice(start?: number, end?: number): Path3D;
  78998. /**
  78999. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  79000. * @param path path which all values are copied into the curves points
  79001. * @param firstNormal which should be projected onto the curve
  79002. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  79003. * @returns the same object updated.
  79004. */
  79005. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  79006. private _compute;
  79007. private _getFirstNonNullVector;
  79008. private _getLastNonNullVector;
  79009. private _normalVector;
  79010. /**
  79011. * Updates the point at data for an interpolated point along this curve
  79012. * @param position the position of the point along this curve, from 0.0 to 1.0
  79013. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  79014. * @returns the (updated) point at data
  79015. */
  79016. private _updatePointAtData;
  79017. /**
  79018. * Updates the point at data from the specified parameters
  79019. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  79020. * @param point the interpolated point
  79021. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  79022. */
  79023. private _setPointAtData;
  79024. /**
  79025. * Updates the point at interpolation matrix for the tangents, normals and binormals
  79026. */
  79027. private _updateInterpolationMatrix;
  79028. }
  79029. /**
  79030. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79031. * A Curve3 is designed from a series of successive Vector3.
  79032. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  79033. */
  79034. export class Curve3 {
  79035. private _points;
  79036. private _length;
  79037. /**
  79038. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  79039. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  79040. * @param v1 (Vector3) the control point
  79041. * @param v2 (Vector3) the end point of the Quadratic Bezier
  79042. * @param nbPoints (integer) the wanted number of points in the curve
  79043. * @returns the created Curve3
  79044. */
  79045. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79046. /**
  79047. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  79048. * @param v0 (Vector3) the origin point of the Cubic Bezier
  79049. * @param v1 (Vector3) the first control point
  79050. * @param v2 (Vector3) the second control point
  79051. * @param v3 (Vector3) the end point of the Cubic Bezier
  79052. * @param nbPoints (integer) the wanted number of points in the curve
  79053. * @returns the created Curve3
  79054. */
  79055. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79056. /**
  79057. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  79058. * @param p1 (Vector3) the origin point of the Hermite Spline
  79059. * @param t1 (Vector3) the tangent vector at the origin point
  79060. * @param p2 (Vector3) the end point of the Hermite Spline
  79061. * @param t2 (Vector3) the tangent vector at the end point
  79062. * @param nbPoints (integer) the wanted number of points in the curve
  79063. * @returns the created Curve3
  79064. */
  79065. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79066. /**
  79067. * Returns a Curve3 object along a CatmullRom Spline curve :
  79068. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  79069. * @param nbPoints (integer) the wanted number of points between each curve control points
  79070. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  79071. * @returns the created Curve3
  79072. */
  79073. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  79074. /**
  79075. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79076. * A Curve3 is designed from a series of successive Vector3.
  79077. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  79078. * @param points points which make up the curve
  79079. */
  79080. constructor(points: Vector3[]);
  79081. /**
  79082. * @returns the Curve3 stored array of successive Vector3
  79083. */
  79084. getPoints(): Vector3[];
  79085. /**
  79086. * @returns the computed length (float) of the curve.
  79087. */
  79088. length(): number;
  79089. /**
  79090. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  79091. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  79092. * curveA and curveB keep unchanged.
  79093. * @param curve the curve to continue from this curve
  79094. * @returns the newly constructed curve
  79095. */
  79096. continue(curve: DeepImmutable<Curve3>): Curve3;
  79097. private _computeLength;
  79098. }
  79099. }
  79100. declare module BABYLON {
  79101. /**
  79102. * This represents the main contract an easing function should follow.
  79103. * Easing functions are used throughout the animation system.
  79104. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79105. */
  79106. export interface IEasingFunction {
  79107. /**
  79108. * Given an input gradient between 0 and 1, this returns the corrseponding value
  79109. * of the easing function.
  79110. * The link below provides some of the most common examples of easing functions.
  79111. * @see https://easings.net/
  79112. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79113. * @returns the corresponding value on the curve defined by the easing function
  79114. */
  79115. ease(gradient: number): number;
  79116. }
  79117. /**
  79118. * Base class used for every default easing function.
  79119. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79120. */
  79121. export class EasingFunction implements IEasingFunction {
  79122. /**
  79123. * Interpolation follows the mathematical formula associated with the easing function.
  79124. */
  79125. static readonly EASINGMODE_EASEIN: number;
  79126. /**
  79127. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  79128. */
  79129. static readonly EASINGMODE_EASEOUT: number;
  79130. /**
  79131. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  79132. */
  79133. static readonly EASINGMODE_EASEINOUT: number;
  79134. private _easingMode;
  79135. /**
  79136. * Sets the easing mode of the current function.
  79137. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  79138. */
  79139. setEasingMode(easingMode: number): void;
  79140. /**
  79141. * Gets the current easing mode.
  79142. * @returns the easing mode
  79143. */
  79144. getEasingMode(): number;
  79145. /**
  79146. * @hidden
  79147. */
  79148. easeInCore(gradient: number): number;
  79149. /**
  79150. * Given an input gradient between 0 and 1, this returns the corresponding value
  79151. * of the easing function.
  79152. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79153. * @returns the corresponding value on the curve defined by the easing function
  79154. */
  79155. ease(gradient: number): number;
  79156. }
  79157. /**
  79158. * Easing function with a circle shape (see link below).
  79159. * @see https://easings.net/#easeInCirc
  79160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79161. */
  79162. export class CircleEase extends EasingFunction implements IEasingFunction {
  79163. /** @hidden */
  79164. easeInCore(gradient: number): number;
  79165. }
  79166. /**
  79167. * Easing function with a ease back shape (see link below).
  79168. * @see https://easings.net/#easeInBack
  79169. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79170. */
  79171. export class BackEase extends EasingFunction implements IEasingFunction {
  79172. /** Defines the amplitude of the function */
  79173. amplitude: number;
  79174. /**
  79175. * Instantiates a back ease easing
  79176. * @see https://easings.net/#easeInBack
  79177. * @param amplitude Defines the amplitude of the function
  79178. */
  79179. constructor(
  79180. /** Defines the amplitude of the function */
  79181. amplitude?: number);
  79182. /** @hidden */
  79183. easeInCore(gradient: number): number;
  79184. }
  79185. /**
  79186. * Easing function with a bouncing shape (see link below).
  79187. * @see https://easings.net/#easeInBounce
  79188. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79189. */
  79190. export class BounceEase extends EasingFunction implements IEasingFunction {
  79191. /** Defines the number of bounces */
  79192. bounces: number;
  79193. /** Defines the amplitude of the bounce */
  79194. bounciness: number;
  79195. /**
  79196. * Instantiates a bounce easing
  79197. * @see https://easings.net/#easeInBounce
  79198. * @param bounces Defines the number of bounces
  79199. * @param bounciness Defines the amplitude of the bounce
  79200. */
  79201. constructor(
  79202. /** Defines the number of bounces */
  79203. bounces?: number,
  79204. /** Defines the amplitude of the bounce */
  79205. bounciness?: number);
  79206. /** @hidden */
  79207. easeInCore(gradient: number): number;
  79208. }
  79209. /**
  79210. * Easing function with a power of 3 shape (see link below).
  79211. * @see https://easings.net/#easeInCubic
  79212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79213. */
  79214. export class CubicEase extends EasingFunction implements IEasingFunction {
  79215. /** @hidden */
  79216. easeInCore(gradient: number): number;
  79217. }
  79218. /**
  79219. * Easing function with an elastic shape (see link below).
  79220. * @see https://easings.net/#easeInElastic
  79221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79222. */
  79223. export class ElasticEase extends EasingFunction implements IEasingFunction {
  79224. /** Defines the number of oscillations*/
  79225. oscillations: number;
  79226. /** Defines the amplitude of the oscillations*/
  79227. springiness: number;
  79228. /**
  79229. * Instantiates an elastic easing function
  79230. * @see https://easings.net/#easeInElastic
  79231. * @param oscillations Defines the number of oscillations
  79232. * @param springiness Defines the amplitude of the oscillations
  79233. */
  79234. constructor(
  79235. /** Defines the number of oscillations*/
  79236. oscillations?: number,
  79237. /** Defines the amplitude of the oscillations*/
  79238. springiness?: number);
  79239. /** @hidden */
  79240. easeInCore(gradient: number): number;
  79241. }
  79242. /**
  79243. * Easing function with an exponential shape (see link below).
  79244. * @see https://easings.net/#easeInExpo
  79245. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79246. */
  79247. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  79248. /** Defines the exponent of the function */
  79249. exponent: number;
  79250. /**
  79251. * Instantiates an exponential easing function
  79252. * @see https://easings.net/#easeInExpo
  79253. * @param exponent Defines the exponent of the function
  79254. */
  79255. constructor(
  79256. /** Defines the exponent of the function */
  79257. exponent?: number);
  79258. /** @hidden */
  79259. easeInCore(gradient: number): number;
  79260. }
  79261. /**
  79262. * Easing function with a power shape (see link below).
  79263. * @see https://easings.net/#easeInQuad
  79264. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79265. */
  79266. export class PowerEase extends EasingFunction implements IEasingFunction {
  79267. /** Defines the power of the function */
  79268. power: number;
  79269. /**
  79270. * Instantiates an power base easing function
  79271. * @see https://easings.net/#easeInQuad
  79272. * @param power Defines the power of the function
  79273. */
  79274. constructor(
  79275. /** Defines the power of the function */
  79276. power?: number);
  79277. /** @hidden */
  79278. easeInCore(gradient: number): number;
  79279. }
  79280. /**
  79281. * Easing function with a power of 2 shape (see link below).
  79282. * @see https://easings.net/#easeInQuad
  79283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79284. */
  79285. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  79286. /** @hidden */
  79287. easeInCore(gradient: number): number;
  79288. }
  79289. /**
  79290. * Easing function with a power of 4 shape (see link below).
  79291. * @see https://easings.net/#easeInQuart
  79292. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79293. */
  79294. export class QuarticEase extends EasingFunction implements IEasingFunction {
  79295. /** @hidden */
  79296. easeInCore(gradient: number): number;
  79297. }
  79298. /**
  79299. * Easing function with a power of 5 shape (see link below).
  79300. * @see https://easings.net/#easeInQuint
  79301. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79302. */
  79303. export class QuinticEase extends EasingFunction implements IEasingFunction {
  79304. /** @hidden */
  79305. easeInCore(gradient: number): number;
  79306. }
  79307. /**
  79308. * Easing function with a sin shape (see link below).
  79309. * @see https://easings.net/#easeInSine
  79310. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79311. */
  79312. export class SineEase extends EasingFunction implements IEasingFunction {
  79313. /** @hidden */
  79314. easeInCore(gradient: number): number;
  79315. }
  79316. /**
  79317. * Easing function with a bezier shape (see link below).
  79318. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79319. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79320. */
  79321. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  79322. /** Defines the x component of the start tangent in the bezier curve */
  79323. x1: number;
  79324. /** Defines the y component of the start tangent in the bezier curve */
  79325. y1: number;
  79326. /** Defines the x component of the end tangent in the bezier curve */
  79327. x2: number;
  79328. /** Defines the y component of the end tangent in the bezier curve */
  79329. y2: number;
  79330. /**
  79331. * Instantiates a bezier function
  79332. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79333. * @param x1 Defines the x component of the start tangent in the bezier curve
  79334. * @param y1 Defines the y component of the start tangent in the bezier curve
  79335. * @param x2 Defines the x component of the end tangent in the bezier curve
  79336. * @param y2 Defines the y component of the end tangent in the bezier curve
  79337. */
  79338. constructor(
  79339. /** Defines the x component of the start tangent in the bezier curve */
  79340. x1?: number,
  79341. /** Defines the y component of the start tangent in the bezier curve */
  79342. y1?: number,
  79343. /** Defines the x component of the end tangent in the bezier curve */
  79344. x2?: number,
  79345. /** Defines the y component of the end tangent in the bezier curve */
  79346. y2?: number);
  79347. /** @hidden */
  79348. easeInCore(gradient: number): number;
  79349. }
  79350. }
  79351. declare module BABYLON {
  79352. /**
  79353. * Class used to hold a RBG color
  79354. */
  79355. export class Color3 {
  79356. /**
  79357. * Defines the red component (between 0 and 1, default is 0)
  79358. */
  79359. r: number;
  79360. /**
  79361. * Defines the green component (between 0 and 1, default is 0)
  79362. */
  79363. g: number;
  79364. /**
  79365. * Defines the blue component (between 0 and 1, default is 0)
  79366. */
  79367. b: number;
  79368. /**
  79369. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  79370. * @param r defines the red component (between 0 and 1, default is 0)
  79371. * @param g defines the green component (between 0 and 1, default is 0)
  79372. * @param b defines the blue component (between 0 and 1, default is 0)
  79373. */
  79374. constructor(
  79375. /**
  79376. * Defines the red component (between 0 and 1, default is 0)
  79377. */
  79378. r?: number,
  79379. /**
  79380. * Defines the green component (between 0 and 1, default is 0)
  79381. */
  79382. g?: number,
  79383. /**
  79384. * Defines the blue component (between 0 and 1, default is 0)
  79385. */
  79386. b?: number);
  79387. /**
  79388. * Creates a string with the Color3 current values
  79389. * @returns the string representation of the Color3 object
  79390. */
  79391. toString(): string;
  79392. /**
  79393. * Returns the string "Color3"
  79394. * @returns "Color3"
  79395. */
  79396. getClassName(): string;
  79397. /**
  79398. * Compute the Color3 hash code
  79399. * @returns an unique number that can be used to hash Color3 objects
  79400. */
  79401. getHashCode(): number;
  79402. /**
  79403. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  79404. * @param array defines the array where to store the r,g,b components
  79405. * @param index defines an optional index in the target array to define where to start storing values
  79406. * @returns the current Color3 object
  79407. */
  79408. toArray(array: FloatArray, index?: number): Color3;
  79409. /**
  79410. * Returns a new Color4 object from the current Color3 and the given alpha
  79411. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  79412. * @returns a new Color4 object
  79413. */
  79414. toColor4(alpha?: number): Color4;
  79415. /**
  79416. * Returns a new array populated with 3 numeric elements : red, green and blue values
  79417. * @returns the new array
  79418. */
  79419. asArray(): number[];
  79420. /**
  79421. * Returns the luminance value
  79422. * @returns a float value
  79423. */
  79424. toLuminance(): number;
  79425. /**
  79426. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  79427. * @param otherColor defines the second operand
  79428. * @returns the new Color3 object
  79429. */
  79430. multiply(otherColor: DeepImmutable<Color3>): Color3;
  79431. /**
  79432. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  79433. * @param otherColor defines the second operand
  79434. * @param result defines the Color3 object where to store the result
  79435. * @returns the current Color3
  79436. */
  79437. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79438. /**
  79439. * Determines equality between Color3 objects
  79440. * @param otherColor defines the second operand
  79441. * @returns true if the rgb values are equal to the given ones
  79442. */
  79443. equals(otherColor: DeepImmutable<Color3>): boolean;
  79444. /**
  79445. * Determines equality between the current Color3 object and a set of r,b,g values
  79446. * @param r defines the red component to check
  79447. * @param g defines the green component to check
  79448. * @param b defines the blue component to check
  79449. * @returns true if the rgb values are equal to the given ones
  79450. */
  79451. equalsFloats(r: number, g: number, b: number): boolean;
  79452. /**
  79453. * Multiplies in place each rgb value by scale
  79454. * @param scale defines the scaling factor
  79455. * @returns the updated Color3
  79456. */
  79457. scale(scale: number): Color3;
  79458. /**
  79459. * Multiplies the rgb values by scale and stores the result into "result"
  79460. * @param scale defines the scaling factor
  79461. * @param result defines the Color3 object where to store the result
  79462. * @returns the unmodified current Color3
  79463. */
  79464. scaleToRef(scale: number, result: Color3): Color3;
  79465. /**
  79466. * Scale the current Color3 values by a factor and add the result to a given Color3
  79467. * @param scale defines the scale factor
  79468. * @param result defines color to store the result into
  79469. * @returns the unmodified current Color3
  79470. */
  79471. scaleAndAddToRef(scale: number, result: Color3): Color3;
  79472. /**
  79473. * Clamps the rgb values by the min and max values and stores the result into "result"
  79474. * @param min defines minimum clamping value (default is 0)
  79475. * @param max defines maximum clamping value (default is 1)
  79476. * @param result defines color to store the result into
  79477. * @returns the original Color3
  79478. */
  79479. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  79480. /**
  79481. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  79482. * @param otherColor defines the second operand
  79483. * @returns the new Color3
  79484. */
  79485. add(otherColor: DeepImmutable<Color3>): Color3;
  79486. /**
  79487. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  79488. * @param otherColor defines the second operand
  79489. * @param result defines Color3 object to store the result into
  79490. * @returns the unmodified current Color3
  79491. */
  79492. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79493. /**
  79494. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79495. * @param otherColor defines the second operand
  79496. * @returns the new Color3
  79497. */
  79498. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79499. /**
  79500. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79501. * @param otherColor defines the second operand
  79502. * @param result defines Color3 object to store the result into
  79503. * @returns the unmodified current Color3
  79504. */
  79505. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79506. /**
  79507. * Copy the current object
  79508. * @returns a new Color3 copied the current one
  79509. */
  79510. clone(): Color3;
  79511. /**
  79512. * Copies the rgb values from the source in the current Color3
  79513. * @param source defines the source Color3 object
  79514. * @returns the updated Color3 object
  79515. */
  79516. copyFrom(source: DeepImmutable<Color3>): Color3;
  79517. /**
  79518. * Updates the Color3 rgb values from the given floats
  79519. * @param r defines the red component to read from
  79520. * @param g defines the green component to read from
  79521. * @param b defines the blue component to read from
  79522. * @returns the current Color3 object
  79523. */
  79524. copyFromFloats(r: number, g: number, b: number): Color3;
  79525. /**
  79526. * Updates the Color3 rgb values from the given floats
  79527. * @param r defines the red component to read from
  79528. * @param g defines the green component to read from
  79529. * @param b defines the blue component to read from
  79530. * @returns the current Color3 object
  79531. */
  79532. set(r: number, g: number, b: number): Color3;
  79533. /**
  79534. * Compute the Color3 hexadecimal code as a string
  79535. * @returns a string containing the hexadecimal representation of the Color3 object
  79536. */
  79537. toHexString(): string;
  79538. /**
  79539. * Computes a new Color3 converted from the current one to linear space
  79540. * @returns a new Color3 object
  79541. */
  79542. toLinearSpace(): Color3;
  79543. /**
  79544. * Converts current color in rgb space to HSV values
  79545. * @returns a new color3 representing the HSV values
  79546. */
  79547. toHSV(): Color3;
  79548. /**
  79549. * Converts current color in rgb space to HSV values
  79550. * @param result defines the Color3 where to store the HSV values
  79551. */
  79552. toHSVToRef(result: Color3): void;
  79553. /**
  79554. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79555. * @param convertedColor defines the Color3 object where to store the linear space version
  79556. * @returns the unmodified Color3
  79557. */
  79558. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79559. /**
  79560. * Computes a new Color3 converted from the current one to gamma space
  79561. * @returns a new Color3 object
  79562. */
  79563. toGammaSpace(): Color3;
  79564. /**
  79565. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79566. * @param convertedColor defines the Color3 object where to store the gamma space version
  79567. * @returns the unmodified Color3
  79568. */
  79569. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79570. private static _BlackReadOnly;
  79571. /**
  79572. * Convert Hue, saturation and value to a Color3 (RGB)
  79573. * @param hue defines the hue
  79574. * @param saturation defines the saturation
  79575. * @param value defines the value
  79576. * @param result defines the Color3 where to store the RGB values
  79577. */
  79578. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79579. /**
  79580. * Creates a new Color3 from the string containing valid hexadecimal values
  79581. * @param hex defines a string containing valid hexadecimal values
  79582. * @returns a new Color3 object
  79583. */
  79584. static FromHexString(hex: string): Color3;
  79585. /**
  79586. * Creates a new Color3 from the starting index of the given array
  79587. * @param array defines the source array
  79588. * @param offset defines an offset in the source array
  79589. * @returns a new Color3 object
  79590. */
  79591. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79592. /**
  79593. * Creates a new Color3 from integer values (< 256)
  79594. * @param r defines the red component to read from (value between 0 and 255)
  79595. * @param g defines the green component to read from (value between 0 and 255)
  79596. * @param b defines the blue component to read from (value between 0 and 255)
  79597. * @returns a new Color3 object
  79598. */
  79599. static FromInts(r: number, g: number, b: number): Color3;
  79600. /**
  79601. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79602. * @param start defines the start Color3 value
  79603. * @param end defines the end Color3 value
  79604. * @param amount defines the gradient value between start and end
  79605. * @returns a new Color3 object
  79606. */
  79607. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79608. /**
  79609. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79610. * @param left defines the start value
  79611. * @param right defines the end value
  79612. * @param amount defines the gradient factor
  79613. * @param result defines the Color3 object where to store the result
  79614. */
  79615. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79616. /**
  79617. * Returns a Color3 value containing a red color
  79618. * @returns a new Color3 object
  79619. */
  79620. static Red(): Color3;
  79621. /**
  79622. * Returns a Color3 value containing a green color
  79623. * @returns a new Color3 object
  79624. */
  79625. static Green(): Color3;
  79626. /**
  79627. * Returns a Color3 value containing a blue color
  79628. * @returns a new Color3 object
  79629. */
  79630. static Blue(): Color3;
  79631. /**
  79632. * Returns a Color3 value containing a black color
  79633. * @returns a new Color3 object
  79634. */
  79635. static Black(): Color3;
  79636. /**
  79637. * Gets a Color3 value containing a black color that must not be updated
  79638. */
  79639. static get BlackReadOnly(): DeepImmutable<Color3>;
  79640. /**
  79641. * Returns a Color3 value containing a white color
  79642. * @returns a new Color3 object
  79643. */
  79644. static White(): Color3;
  79645. /**
  79646. * Returns a Color3 value containing a purple color
  79647. * @returns a new Color3 object
  79648. */
  79649. static Purple(): Color3;
  79650. /**
  79651. * Returns a Color3 value containing a magenta color
  79652. * @returns a new Color3 object
  79653. */
  79654. static Magenta(): Color3;
  79655. /**
  79656. * Returns a Color3 value containing a yellow color
  79657. * @returns a new Color3 object
  79658. */
  79659. static Yellow(): Color3;
  79660. /**
  79661. * Returns a Color3 value containing a gray color
  79662. * @returns a new Color3 object
  79663. */
  79664. static Gray(): Color3;
  79665. /**
  79666. * Returns a Color3 value containing a teal color
  79667. * @returns a new Color3 object
  79668. */
  79669. static Teal(): Color3;
  79670. /**
  79671. * Returns a Color3 value containing a random color
  79672. * @returns a new Color3 object
  79673. */
  79674. static Random(): Color3;
  79675. }
  79676. /**
  79677. * Class used to hold a RBGA color
  79678. */
  79679. export class Color4 {
  79680. /**
  79681. * Defines the red component (between 0 and 1, default is 0)
  79682. */
  79683. r: number;
  79684. /**
  79685. * Defines the green component (between 0 and 1, default is 0)
  79686. */
  79687. g: number;
  79688. /**
  79689. * Defines the blue component (between 0 and 1, default is 0)
  79690. */
  79691. b: number;
  79692. /**
  79693. * Defines the alpha component (between 0 and 1, default is 1)
  79694. */
  79695. a: number;
  79696. /**
  79697. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79698. * @param r defines the red component (between 0 and 1, default is 0)
  79699. * @param g defines the green component (between 0 and 1, default is 0)
  79700. * @param b defines the blue component (between 0 and 1, default is 0)
  79701. * @param a defines the alpha component (between 0 and 1, default is 1)
  79702. */
  79703. constructor(
  79704. /**
  79705. * Defines the red component (between 0 and 1, default is 0)
  79706. */
  79707. r?: number,
  79708. /**
  79709. * Defines the green component (between 0 and 1, default is 0)
  79710. */
  79711. g?: number,
  79712. /**
  79713. * Defines the blue component (between 0 and 1, default is 0)
  79714. */
  79715. b?: number,
  79716. /**
  79717. * Defines the alpha component (between 0 and 1, default is 1)
  79718. */
  79719. a?: number);
  79720. /**
  79721. * Adds in place the given Color4 values to the current Color4 object
  79722. * @param right defines the second operand
  79723. * @returns the current updated Color4 object
  79724. */
  79725. addInPlace(right: DeepImmutable<Color4>): Color4;
  79726. /**
  79727. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79728. * @returns the new array
  79729. */
  79730. asArray(): number[];
  79731. /**
  79732. * Stores from the starting index in the given array the Color4 successive values
  79733. * @param array defines the array where to store the r,g,b components
  79734. * @param index defines an optional index in the target array to define where to start storing values
  79735. * @returns the current Color4 object
  79736. */
  79737. toArray(array: number[], index?: number): Color4;
  79738. /**
  79739. * Determines equality between Color4 objects
  79740. * @param otherColor defines the second operand
  79741. * @returns true if the rgba values are equal to the given ones
  79742. */
  79743. equals(otherColor: DeepImmutable<Color4>): boolean;
  79744. /**
  79745. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79746. * @param right defines the second operand
  79747. * @returns a new Color4 object
  79748. */
  79749. add(right: DeepImmutable<Color4>): Color4;
  79750. /**
  79751. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79752. * @param right defines the second operand
  79753. * @returns a new Color4 object
  79754. */
  79755. subtract(right: DeepImmutable<Color4>): Color4;
  79756. /**
  79757. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79758. * @param right defines the second operand
  79759. * @param result defines the Color4 object where to store the result
  79760. * @returns the current Color4 object
  79761. */
  79762. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79763. /**
  79764. * Creates a new Color4 with the current Color4 values multiplied by scale
  79765. * @param scale defines the scaling factor to apply
  79766. * @returns a new Color4 object
  79767. */
  79768. scale(scale: number): Color4;
  79769. /**
  79770. * Multiplies the current Color4 values by scale and stores the result in "result"
  79771. * @param scale defines the scaling factor to apply
  79772. * @param result defines the Color4 object where to store the result
  79773. * @returns the current unmodified Color4
  79774. */
  79775. scaleToRef(scale: number, result: Color4): Color4;
  79776. /**
  79777. * Scale the current Color4 values by a factor and add the result to a given Color4
  79778. * @param scale defines the scale factor
  79779. * @param result defines the Color4 object where to store the result
  79780. * @returns the unmodified current Color4
  79781. */
  79782. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79783. /**
  79784. * Clamps the rgb values by the min and max values and stores the result into "result"
  79785. * @param min defines minimum clamping value (default is 0)
  79786. * @param max defines maximum clamping value (default is 1)
  79787. * @param result defines color to store the result into.
  79788. * @returns the cuurent Color4
  79789. */
  79790. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79791. /**
  79792. * Multipy an Color4 value by another and return a new Color4 object
  79793. * @param color defines the Color4 value to multiply by
  79794. * @returns a new Color4 object
  79795. */
  79796. multiply(color: Color4): Color4;
  79797. /**
  79798. * Multipy a Color4 value by another and push the result in a reference value
  79799. * @param color defines the Color4 value to multiply by
  79800. * @param result defines the Color4 to fill the result in
  79801. * @returns the result Color4
  79802. */
  79803. multiplyToRef(color: Color4, result: Color4): Color4;
  79804. /**
  79805. * Creates a string with the Color4 current values
  79806. * @returns the string representation of the Color4 object
  79807. */
  79808. toString(): string;
  79809. /**
  79810. * Returns the string "Color4"
  79811. * @returns "Color4"
  79812. */
  79813. getClassName(): string;
  79814. /**
  79815. * Compute the Color4 hash code
  79816. * @returns an unique number that can be used to hash Color4 objects
  79817. */
  79818. getHashCode(): number;
  79819. /**
  79820. * Creates a new Color4 copied from the current one
  79821. * @returns a new Color4 object
  79822. */
  79823. clone(): Color4;
  79824. /**
  79825. * Copies the given Color4 values into the current one
  79826. * @param source defines the source Color4 object
  79827. * @returns the current updated Color4 object
  79828. */
  79829. copyFrom(source: Color4): Color4;
  79830. /**
  79831. * Copies the given float values into the current one
  79832. * @param r defines the red component to read from
  79833. * @param g defines the green component to read from
  79834. * @param b defines the blue component to read from
  79835. * @param a defines the alpha component to read from
  79836. * @returns the current updated Color4 object
  79837. */
  79838. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79839. /**
  79840. * Copies the given float values into the current one
  79841. * @param r defines the red component to read from
  79842. * @param g defines the green component to read from
  79843. * @param b defines the blue component to read from
  79844. * @param a defines the alpha component to read from
  79845. * @returns the current updated Color4 object
  79846. */
  79847. set(r: number, g: number, b: number, a: number): Color4;
  79848. /**
  79849. * Compute the Color4 hexadecimal code as a string
  79850. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  79851. * @returns a string containing the hexadecimal representation of the Color4 object
  79852. */
  79853. toHexString(returnAsColor3?: boolean): string;
  79854. /**
  79855. * Computes a new Color4 converted from the current one to linear space
  79856. * @returns a new Color4 object
  79857. */
  79858. toLinearSpace(): Color4;
  79859. /**
  79860. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79861. * @param convertedColor defines the Color4 object where to store the linear space version
  79862. * @returns the unmodified Color4
  79863. */
  79864. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79865. /**
  79866. * Computes a new Color4 converted from the current one to gamma space
  79867. * @returns a new Color4 object
  79868. */
  79869. toGammaSpace(): Color4;
  79870. /**
  79871. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79872. * @param convertedColor defines the Color4 object where to store the gamma space version
  79873. * @returns the unmodified Color4
  79874. */
  79875. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79876. /**
  79877. * Creates a new Color4 from the string containing valid hexadecimal values
  79878. * @param hex defines a string containing valid hexadecimal values
  79879. * @returns a new Color4 object
  79880. */
  79881. static FromHexString(hex: string): Color4;
  79882. /**
  79883. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79884. * @param left defines the start value
  79885. * @param right defines the end value
  79886. * @param amount defines the gradient factor
  79887. * @returns a new Color4 object
  79888. */
  79889. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79890. /**
  79891. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79892. * @param left defines the start value
  79893. * @param right defines the end value
  79894. * @param amount defines the gradient factor
  79895. * @param result defines the Color4 object where to store data
  79896. */
  79897. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79898. /**
  79899. * Creates a new Color4 from a Color3 and an alpha value
  79900. * @param color3 defines the source Color3 to read from
  79901. * @param alpha defines the alpha component (1.0 by default)
  79902. * @returns a new Color4 object
  79903. */
  79904. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79905. /**
  79906. * Creates a new Color4 from the starting index element of the given array
  79907. * @param array defines the source array to read from
  79908. * @param offset defines the offset in the source array
  79909. * @returns a new Color4 object
  79910. */
  79911. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79912. /**
  79913. * Creates a new Color3 from integer values (< 256)
  79914. * @param r defines the red component to read from (value between 0 and 255)
  79915. * @param g defines the green component to read from (value between 0 and 255)
  79916. * @param b defines the blue component to read from (value between 0 and 255)
  79917. * @param a defines the alpha component to read from (value between 0 and 255)
  79918. * @returns a new Color3 object
  79919. */
  79920. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79921. /**
  79922. * Check the content of a given array and convert it to an array containing RGBA data
  79923. * If the original array was already containing count * 4 values then it is returned directly
  79924. * @param colors defines the array to check
  79925. * @param count defines the number of RGBA data to expect
  79926. * @returns an array containing count * 4 values (RGBA)
  79927. */
  79928. static CheckColors4(colors: number[], count: number): number[];
  79929. }
  79930. /**
  79931. * @hidden
  79932. */
  79933. export class TmpColors {
  79934. static Color3: Color3[];
  79935. static Color4: Color4[];
  79936. }
  79937. }
  79938. declare module BABYLON {
  79939. /**
  79940. * Defines an interface which represents an animation key frame
  79941. */
  79942. export interface IAnimationKey {
  79943. /**
  79944. * Frame of the key frame
  79945. */
  79946. frame: number;
  79947. /**
  79948. * Value at the specifies key frame
  79949. */
  79950. value: any;
  79951. /**
  79952. * The input tangent for the cubic hermite spline
  79953. */
  79954. inTangent?: any;
  79955. /**
  79956. * The output tangent for the cubic hermite spline
  79957. */
  79958. outTangent?: any;
  79959. /**
  79960. * The animation interpolation type
  79961. */
  79962. interpolation?: AnimationKeyInterpolation;
  79963. }
  79964. /**
  79965. * Enum for the animation key frame interpolation type
  79966. */
  79967. export enum AnimationKeyInterpolation {
  79968. /**
  79969. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79970. */
  79971. STEP = 1
  79972. }
  79973. }
  79974. declare module BABYLON {
  79975. /**
  79976. * Represents the range of an animation
  79977. */
  79978. export class AnimationRange {
  79979. /**The name of the animation range**/
  79980. name: string;
  79981. /**The starting frame of the animation */
  79982. from: number;
  79983. /**The ending frame of the animation*/
  79984. to: number;
  79985. /**
  79986. * Initializes the range of an animation
  79987. * @param name The name of the animation range
  79988. * @param from The starting frame of the animation
  79989. * @param to The ending frame of the animation
  79990. */
  79991. constructor(
  79992. /**The name of the animation range**/
  79993. name: string,
  79994. /**The starting frame of the animation */
  79995. from: number,
  79996. /**The ending frame of the animation*/
  79997. to: number);
  79998. /**
  79999. * Makes a copy of the animation range
  80000. * @returns A copy of the animation range
  80001. */
  80002. clone(): AnimationRange;
  80003. }
  80004. }
  80005. declare module BABYLON {
  80006. /**
  80007. * Composed of a frame, and an action function
  80008. */
  80009. export class AnimationEvent {
  80010. /** The frame for which the event is triggered **/
  80011. frame: number;
  80012. /** The event to perform when triggered **/
  80013. action: (currentFrame: number) => void;
  80014. /** Specifies if the event should be triggered only once**/
  80015. onlyOnce?: boolean | undefined;
  80016. /**
  80017. * Specifies if the animation event is done
  80018. */
  80019. isDone: boolean;
  80020. /**
  80021. * Initializes the animation event
  80022. * @param frame The frame for which the event is triggered
  80023. * @param action The event to perform when triggered
  80024. * @param onlyOnce Specifies if the event should be triggered only once
  80025. */
  80026. constructor(
  80027. /** The frame for which the event is triggered **/
  80028. frame: number,
  80029. /** The event to perform when triggered **/
  80030. action: (currentFrame: number) => void,
  80031. /** Specifies if the event should be triggered only once**/
  80032. onlyOnce?: boolean | undefined);
  80033. /** @hidden */
  80034. _clone(): AnimationEvent;
  80035. }
  80036. }
  80037. declare module BABYLON {
  80038. /**
  80039. * Interface used to define a behavior
  80040. */
  80041. export interface Behavior<T> {
  80042. /** gets or sets behavior's name */
  80043. name: string;
  80044. /**
  80045. * Function called when the behavior needs to be initialized (after attaching it to a target)
  80046. */
  80047. init(): void;
  80048. /**
  80049. * Called when the behavior is attached to a target
  80050. * @param target defines the target where the behavior is attached to
  80051. */
  80052. attach(target: T): void;
  80053. /**
  80054. * Called when the behavior is detached from its target
  80055. */
  80056. detach(): void;
  80057. }
  80058. /**
  80059. * Interface implemented by classes supporting behaviors
  80060. */
  80061. export interface IBehaviorAware<T> {
  80062. /**
  80063. * Attach a behavior
  80064. * @param behavior defines the behavior to attach
  80065. * @returns the current host
  80066. */
  80067. addBehavior(behavior: Behavior<T>): T;
  80068. /**
  80069. * Remove a behavior from the current object
  80070. * @param behavior defines the behavior to detach
  80071. * @returns the current host
  80072. */
  80073. removeBehavior(behavior: Behavior<T>): T;
  80074. /**
  80075. * Gets a behavior using its name to search
  80076. * @param name defines the name to search
  80077. * @returns the behavior or null if not found
  80078. */
  80079. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  80080. }
  80081. }
  80082. declare module BABYLON {
  80083. /**
  80084. * Defines an array and its length.
  80085. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  80086. */
  80087. export interface ISmartArrayLike<T> {
  80088. /**
  80089. * The data of the array.
  80090. */
  80091. data: Array<T>;
  80092. /**
  80093. * The active length of the array.
  80094. */
  80095. length: number;
  80096. }
  80097. /**
  80098. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80099. */
  80100. export class SmartArray<T> implements ISmartArrayLike<T> {
  80101. /**
  80102. * The full set of data from the array.
  80103. */
  80104. data: Array<T>;
  80105. /**
  80106. * The active length of the array.
  80107. */
  80108. length: number;
  80109. protected _id: number;
  80110. /**
  80111. * Instantiates a Smart Array.
  80112. * @param capacity defines the default capacity of the array.
  80113. */
  80114. constructor(capacity: number);
  80115. /**
  80116. * Pushes a value at the end of the active data.
  80117. * @param value defines the object to push in the array.
  80118. */
  80119. push(value: T): void;
  80120. /**
  80121. * Iterates over the active data and apply the lambda to them.
  80122. * @param func defines the action to apply on each value.
  80123. */
  80124. forEach(func: (content: T) => void): void;
  80125. /**
  80126. * Sorts the full sets of data.
  80127. * @param compareFn defines the comparison function to apply.
  80128. */
  80129. sort(compareFn: (a: T, b: T) => number): void;
  80130. /**
  80131. * Resets the active data to an empty array.
  80132. */
  80133. reset(): void;
  80134. /**
  80135. * Releases all the data from the array as well as the array.
  80136. */
  80137. dispose(): void;
  80138. /**
  80139. * Concats the active data with a given array.
  80140. * @param array defines the data to concatenate with.
  80141. */
  80142. concat(array: any): void;
  80143. /**
  80144. * Returns the position of a value in the active data.
  80145. * @param value defines the value to find the index for
  80146. * @returns the index if found in the active data otherwise -1
  80147. */
  80148. indexOf(value: T): number;
  80149. /**
  80150. * Returns whether an element is part of the active data.
  80151. * @param value defines the value to look for
  80152. * @returns true if found in the active data otherwise false
  80153. */
  80154. contains(value: T): boolean;
  80155. private static _GlobalId;
  80156. }
  80157. /**
  80158. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80159. * The data in this array can only be present once
  80160. */
  80161. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  80162. private _duplicateId;
  80163. /**
  80164. * Pushes a value at the end of the active data.
  80165. * THIS DOES NOT PREVENT DUPPLICATE DATA
  80166. * @param value defines the object to push in the array.
  80167. */
  80168. push(value: T): void;
  80169. /**
  80170. * Pushes a value at the end of the active data.
  80171. * If the data is already present, it won t be added again
  80172. * @param value defines the object to push in the array.
  80173. * @returns true if added false if it was already present
  80174. */
  80175. pushNoDuplicate(value: T): boolean;
  80176. /**
  80177. * Resets the active data to an empty array.
  80178. */
  80179. reset(): void;
  80180. /**
  80181. * Concats the active data with a given array.
  80182. * This ensures no dupplicate will be present in the result.
  80183. * @param array defines the data to concatenate with.
  80184. */
  80185. concatWithNoDuplicate(array: any): void;
  80186. }
  80187. }
  80188. declare module BABYLON {
  80189. /**
  80190. * @ignore
  80191. * This is a list of all the different input types that are available in the application.
  80192. * Fo instance: ArcRotateCameraGamepadInput...
  80193. */
  80194. export var CameraInputTypes: {};
  80195. /**
  80196. * This is the contract to implement in order to create a new input class.
  80197. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  80198. */
  80199. export interface ICameraInput<TCamera extends Camera> {
  80200. /**
  80201. * Defines the camera the input is attached to.
  80202. */
  80203. camera: Nullable<TCamera>;
  80204. /**
  80205. * Gets the class name of the current intput.
  80206. * @returns the class name
  80207. */
  80208. getClassName(): string;
  80209. /**
  80210. * Get the friendly name associated with the input class.
  80211. * @returns the input friendly name
  80212. */
  80213. getSimpleName(): string;
  80214. /**
  80215. * Attach the input controls to a specific dom element to get the input from.
  80216. * @param element Defines the element the controls should be listened from
  80217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80218. */
  80219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80220. /**
  80221. * Detach the current controls from the specified dom element.
  80222. * @param element Defines the element to stop listening the inputs from
  80223. */
  80224. detachControl(element: Nullable<HTMLElement>): void;
  80225. /**
  80226. * Update the current camera state depending on the inputs that have been used this frame.
  80227. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80228. */
  80229. checkInputs?: () => void;
  80230. }
  80231. /**
  80232. * Represents a map of input types to input instance or input index to input instance.
  80233. */
  80234. export interface CameraInputsMap<TCamera extends Camera> {
  80235. /**
  80236. * Accessor to the input by input type.
  80237. */
  80238. [name: string]: ICameraInput<TCamera>;
  80239. /**
  80240. * Accessor to the input by input index.
  80241. */
  80242. [idx: number]: ICameraInput<TCamera>;
  80243. }
  80244. /**
  80245. * This represents the input manager used within a camera.
  80246. * It helps dealing with all the different kind of input attached to a camera.
  80247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80248. */
  80249. export class CameraInputsManager<TCamera extends Camera> {
  80250. /**
  80251. * Defines the list of inputs attahed to the camera.
  80252. */
  80253. attached: CameraInputsMap<TCamera>;
  80254. /**
  80255. * Defines the dom element the camera is collecting inputs from.
  80256. * This is null if the controls have not been attached.
  80257. */
  80258. attachedElement: Nullable<HTMLElement>;
  80259. /**
  80260. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80261. */
  80262. noPreventDefault: boolean;
  80263. /**
  80264. * Defined the camera the input manager belongs to.
  80265. */
  80266. camera: TCamera;
  80267. /**
  80268. * Update the current camera state depending on the inputs that have been used this frame.
  80269. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80270. */
  80271. checkInputs: () => void;
  80272. /**
  80273. * Instantiate a new Camera Input Manager.
  80274. * @param camera Defines the camera the input manager blongs to
  80275. */
  80276. constructor(camera: TCamera);
  80277. /**
  80278. * Add an input method to a camera
  80279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80280. * @param input camera input method
  80281. */
  80282. add(input: ICameraInput<TCamera>): void;
  80283. /**
  80284. * Remove a specific input method from a camera
  80285. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  80286. * @param inputToRemove camera input method
  80287. */
  80288. remove(inputToRemove: ICameraInput<TCamera>): void;
  80289. /**
  80290. * Remove a specific input type from a camera
  80291. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  80292. * @param inputType the type of the input to remove
  80293. */
  80294. removeByType(inputType: string): void;
  80295. private _addCheckInputs;
  80296. /**
  80297. * Attach the input controls to the currently attached dom element to listen the events from.
  80298. * @param input Defines the input to attach
  80299. */
  80300. attachInput(input: ICameraInput<TCamera>): void;
  80301. /**
  80302. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  80303. * @param element Defines the dom element to collect the events from
  80304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80305. */
  80306. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  80307. /**
  80308. * Detach the current manager inputs controls from a specific dom element.
  80309. * @param element Defines the dom element to collect the events from
  80310. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  80311. */
  80312. detachElement(element: HTMLElement, disconnect?: boolean): void;
  80313. /**
  80314. * Rebuild the dynamic inputCheck function from the current list of
  80315. * defined inputs in the manager.
  80316. */
  80317. rebuildInputCheck(): void;
  80318. /**
  80319. * Remove all attached input methods from a camera
  80320. */
  80321. clear(): void;
  80322. /**
  80323. * Serialize the current input manager attached to a camera.
  80324. * This ensures than once parsed,
  80325. * the input associated to the camera will be identical to the current ones
  80326. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  80327. */
  80328. serialize(serializedCamera: any): void;
  80329. /**
  80330. * Parses an input manager serialized JSON to restore the previous list of inputs
  80331. * and states associated to a camera.
  80332. * @param parsedCamera Defines the JSON to parse
  80333. */
  80334. parse(parsedCamera: any): void;
  80335. }
  80336. }
  80337. declare module BABYLON {
  80338. /**
  80339. * Class used to store data that will be store in GPU memory
  80340. */
  80341. export class Buffer {
  80342. private _engine;
  80343. private _buffer;
  80344. /** @hidden */
  80345. _data: Nullable<DataArray>;
  80346. private _updatable;
  80347. private _instanced;
  80348. private _divisor;
  80349. /**
  80350. * Gets the byte stride.
  80351. */
  80352. readonly byteStride: number;
  80353. /**
  80354. * Constructor
  80355. * @param engine the engine
  80356. * @param data the data to use for this buffer
  80357. * @param updatable whether the data is updatable
  80358. * @param stride the stride (optional)
  80359. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80360. * @param instanced whether the buffer is instanced (optional)
  80361. * @param useBytes set to true if the stride in in bytes (optional)
  80362. * @param divisor sets an optional divisor for instances (1 by default)
  80363. */
  80364. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  80365. /**
  80366. * Create a new VertexBuffer based on the current buffer
  80367. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80368. * @param offset defines offset in the buffer (0 by default)
  80369. * @param size defines the size in floats of attributes (position is 3 for instance)
  80370. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80371. * @param instanced defines if the vertex buffer contains indexed data
  80372. * @param useBytes defines if the offset and stride are in bytes *
  80373. * @param divisor sets an optional divisor for instances (1 by default)
  80374. * @returns the new vertex buffer
  80375. */
  80376. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  80377. /**
  80378. * Gets a boolean indicating if the Buffer is updatable?
  80379. * @returns true if the buffer is updatable
  80380. */
  80381. isUpdatable(): boolean;
  80382. /**
  80383. * Gets current buffer's data
  80384. * @returns a DataArray or null
  80385. */
  80386. getData(): Nullable<DataArray>;
  80387. /**
  80388. * Gets underlying native buffer
  80389. * @returns underlying native buffer
  80390. */
  80391. getBuffer(): Nullable<DataBuffer>;
  80392. /**
  80393. * Gets the stride in float32 units (i.e. byte stride / 4).
  80394. * May not be an integer if the byte stride is not divisible by 4.
  80395. * @returns the stride in float32 units
  80396. * @deprecated Please use byteStride instead.
  80397. */
  80398. getStrideSize(): number;
  80399. /**
  80400. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80401. * @param data defines the data to store
  80402. */
  80403. create(data?: Nullable<DataArray>): void;
  80404. /** @hidden */
  80405. _rebuild(): void;
  80406. /**
  80407. * Update current buffer data
  80408. * @param data defines the data to store
  80409. */
  80410. update(data: DataArray): void;
  80411. /**
  80412. * Updates the data directly.
  80413. * @param data the new data
  80414. * @param offset the new offset
  80415. * @param vertexCount the vertex count (optional)
  80416. * @param useBytes set to true if the offset is in bytes
  80417. */
  80418. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  80419. /**
  80420. * Release all resources
  80421. */
  80422. dispose(): void;
  80423. }
  80424. /**
  80425. * Specialized buffer used to store vertex data
  80426. */
  80427. export class VertexBuffer {
  80428. /** @hidden */
  80429. _buffer: Buffer;
  80430. private _kind;
  80431. private _size;
  80432. private _ownsBuffer;
  80433. private _instanced;
  80434. private _instanceDivisor;
  80435. /**
  80436. * The byte type.
  80437. */
  80438. static readonly BYTE: number;
  80439. /**
  80440. * The unsigned byte type.
  80441. */
  80442. static readonly UNSIGNED_BYTE: number;
  80443. /**
  80444. * The short type.
  80445. */
  80446. static readonly SHORT: number;
  80447. /**
  80448. * The unsigned short type.
  80449. */
  80450. static readonly UNSIGNED_SHORT: number;
  80451. /**
  80452. * The integer type.
  80453. */
  80454. static readonly INT: number;
  80455. /**
  80456. * The unsigned integer type.
  80457. */
  80458. static readonly UNSIGNED_INT: number;
  80459. /**
  80460. * The float type.
  80461. */
  80462. static readonly FLOAT: number;
  80463. /**
  80464. * Gets or sets the instance divisor when in instanced mode
  80465. */
  80466. get instanceDivisor(): number;
  80467. set instanceDivisor(value: number);
  80468. /**
  80469. * Gets the byte stride.
  80470. */
  80471. readonly byteStride: number;
  80472. /**
  80473. * Gets the byte offset.
  80474. */
  80475. readonly byteOffset: number;
  80476. /**
  80477. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  80478. */
  80479. readonly normalized: boolean;
  80480. /**
  80481. * Gets the data type of each component in the array.
  80482. */
  80483. readonly type: number;
  80484. /**
  80485. * Constructor
  80486. * @param engine the engine
  80487. * @param data the data to use for this vertex buffer
  80488. * @param kind the vertex buffer kind
  80489. * @param updatable whether the data is updatable
  80490. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80491. * @param stride the stride (optional)
  80492. * @param instanced whether the buffer is instanced (optional)
  80493. * @param offset the offset of the data (optional)
  80494. * @param size the number of components (optional)
  80495. * @param type the type of the component (optional)
  80496. * @param normalized whether the data contains normalized data (optional)
  80497. * @param useBytes set to true if stride and offset are in bytes (optional)
  80498. * @param divisor defines the instance divisor to use (1 by default)
  80499. */
  80500. 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);
  80501. /** @hidden */
  80502. _rebuild(): void;
  80503. /**
  80504. * Returns the kind of the VertexBuffer (string)
  80505. * @returns a string
  80506. */
  80507. getKind(): string;
  80508. /**
  80509. * Gets a boolean indicating if the VertexBuffer is updatable?
  80510. * @returns true if the buffer is updatable
  80511. */
  80512. isUpdatable(): boolean;
  80513. /**
  80514. * Gets current buffer's data
  80515. * @returns a DataArray or null
  80516. */
  80517. getData(): Nullable<DataArray>;
  80518. /**
  80519. * Gets underlying native buffer
  80520. * @returns underlying native buffer
  80521. */
  80522. getBuffer(): Nullable<DataBuffer>;
  80523. /**
  80524. * Gets the stride in float32 units (i.e. byte stride / 4).
  80525. * May not be an integer if the byte stride is not divisible by 4.
  80526. * @returns the stride in float32 units
  80527. * @deprecated Please use byteStride instead.
  80528. */
  80529. getStrideSize(): number;
  80530. /**
  80531. * Returns the offset as a multiple of the type byte length.
  80532. * @returns the offset in bytes
  80533. * @deprecated Please use byteOffset instead.
  80534. */
  80535. getOffset(): number;
  80536. /**
  80537. * Returns the number of components per vertex attribute (integer)
  80538. * @returns the size in float
  80539. */
  80540. getSize(): number;
  80541. /**
  80542. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80543. * @returns true if this buffer is instanced
  80544. */
  80545. getIsInstanced(): boolean;
  80546. /**
  80547. * Returns the instancing divisor, zero for non-instanced (integer).
  80548. * @returns a number
  80549. */
  80550. getInstanceDivisor(): number;
  80551. /**
  80552. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80553. * @param data defines the data to store
  80554. */
  80555. create(data?: DataArray): void;
  80556. /**
  80557. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80558. * This function will create a new buffer if the current one is not updatable
  80559. * @param data defines the data to store
  80560. */
  80561. update(data: DataArray): void;
  80562. /**
  80563. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80564. * Returns the directly updated WebGLBuffer.
  80565. * @param data the new data
  80566. * @param offset the new offset
  80567. * @param useBytes set to true if the offset is in bytes
  80568. */
  80569. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80570. /**
  80571. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80572. */
  80573. dispose(): void;
  80574. /**
  80575. * Enumerates each value of this vertex buffer as numbers.
  80576. * @param count the number of values to enumerate
  80577. * @param callback the callback function called for each value
  80578. */
  80579. forEach(count: number, callback: (value: number, index: number) => void): void;
  80580. /**
  80581. * Positions
  80582. */
  80583. static readonly PositionKind: string;
  80584. /**
  80585. * Normals
  80586. */
  80587. static readonly NormalKind: string;
  80588. /**
  80589. * Tangents
  80590. */
  80591. static readonly TangentKind: string;
  80592. /**
  80593. * Texture coordinates
  80594. */
  80595. static readonly UVKind: string;
  80596. /**
  80597. * Texture coordinates 2
  80598. */
  80599. static readonly UV2Kind: string;
  80600. /**
  80601. * Texture coordinates 3
  80602. */
  80603. static readonly UV3Kind: string;
  80604. /**
  80605. * Texture coordinates 4
  80606. */
  80607. static readonly UV4Kind: string;
  80608. /**
  80609. * Texture coordinates 5
  80610. */
  80611. static readonly UV5Kind: string;
  80612. /**
  80613. * Texture coordinates 6
  80614. */
  80615. static readonly UV6Kind: string;
  80616. /**
  80617. * Colors
  80618. */
  80619. static readonly ColorKind: string;
  80620. /**
  80621. * Matrix indices (for bones)
  80622. */
  80623. static readonly MatricesIndicesKind: string;
  80624. /**
  80625. * Matrix weights (for bones)
  80626. */
  80627. static readonly MatricesWeightsKind: string;
  80628. /**
  80629. * Additional matrix indices (for bones)
  80630. */
  80631. static readonly MatricesIndicesExtraKind: string;
  80632. /**
  80633. * Additional matrix weights (for bones)
  80634. */
  80635. static readonly MatricesWeightsExtraKind: string;
  80636. /**
  80637. * Deduces the stride given a kind.
  80638. * @param kind The kind string to deduce
  80639. * @returns The deduced stride
  80640. */
  80641. static DeduceStride(kind: string): number;
  80642. /**
  80643. * Gets the byte length of the given type.
  80644. * @param type the type
  80645. * @returns the number of bytes
  80646. */
  80647. static GetTypeByteLength(type: number): number;
  80648. /**
  80649. * Enumerates each value of the given parameters as numbers.
  80650. * @param data the data to enumerate
  80651. * @param byteOffset the byte offset of the data
  80652. * @param byteStride the byte stride of the data
  80653. * @param componentCount the number of components per element
  80654. * @param componentType the type of the component
  80655. * @param count the number of values to enumerate
  80656. * @param normalized whether the data is normalized
  80657. * @param callback the callback function called for each value
  80658. */
  80659. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80660. private static _GetFloatValue;
  80661. }
  80662. }
  80663. declare module BABYLON {
  80664. /**
  80665. * @hidden
  80666. */
  80667. export class IntersectionInfo {
  80668. bu: Nullable<number>;
  80669. bv: Nullable<number>;
  80670. distance: number;
  80671. faceId: number;
  80672. subMeshId: number;
  80673. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80674. }
  80675. }
  80676. declare module BABYLON {
  80677. /**
  80678. * Represens a plane by the equation ax + by + cz + d = 0
  80679. */
  80680. export class Plane {
  80681. private static _TmpMatrix;
  80682. /**
  80683. * Normal of the plane (a,b,c)
  80684. */
  80685. normal: Vector3;
  80686. /**
  80687. * d component of the plane
  80688. */
  80689. d: number;
  80690. /**
  80691. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80692. * @param a a component of the plane
  80693. * @param b b component of the plane
  80694. * @param c c component of the plane
  80695. * @param d d component of the plane
  80696. */
  80697. constructor(a: number, b: number, c: number, d: number);
  80698. /**
  80699. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80700. */
  80701. asArray(): number[];
  80702. /**
  80703. * @returns a new plane copied from the current Plane.
  80704. */
  80705. clone(): Plane;
  80706. /**
  80707. * @returns the string "Plane".
  80708. */
  80709. getClassName(): string;
  80710. /**
  80711. * @returns the Plane hash code.
  80712. */
  80713. getHashCode(): number;
  80714. /**
  80715. * Normalize the current Plane in place.
  80716. * @returns the updated Plane.
  80717. */
  80718. normalize(): Plane;
  80719. /**
  80720. * Applies a transformation the plane and returns the result
  80721. * @param transformation the transformation matrix to be applied to the plane
  80722. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80723. */
  80724. transform(transformation: DeepImmutable<Matrix>): Plane;
  80725. /**
  80726. * Calcualtte the dot product between the point and the plane normal
  80727. * @param point point to calculate the dot product with
  80728. * @returns the dot product (float) of the point coordinates and the plane normal.
  80729. */
  80730. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80731. /**
  80732. * Updates the current Plane from the plane defined by the three given points.
  80733. * @param point1 one of the points used to contruct the plane
  80734. * @param point2 one of the points used to contruct the plane
  80735. * @param point3 one of the points used to contruct the plane
  80736. * @returns the updated Plane.
  80737. */
  80738. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80739. /**
  80740. * Checks if the plane is facing a given direction
  80741. * @param direction the direction to check if the plane is facing
  80742. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80743. * @returns True is the vector "direction" is the same side than the plane normal.
  80744. */
  80745. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80746. /**
  80747. * Calculates the distance to a point
  80748. * @param point point to calculate distance to
  80749. * @returns the signed distance (float) from the given point to the Plane.
  80750. */
  80751. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80752. /**
  80753. * Creates a plane from an array
  80754. * @param array the array to create a plane from
  80755. * @returns a new Plane from the given array.
  80756. */
  80757. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80758. /**
  80759. * Creates a plane from three points
  80760. * @param point1 point used to create the plane
  80761. * @param point2 point used to create the plane
  80762. * @param point3 point used to create the plane
  80763. * @returns a new Plane defined by the three given points.
  80764. */
  80765. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80766. /**
  80767. * Creates a plane from an origin point and a normal
  80768. * @param origin origin of the plane to be constructed
  80769. * @param normal normal of the plane to be constructed
  80770. * @returns a new Plane the normal vector to this plane at the given origin point.
  80771. * Note : the vector "normal" is updated because normalized.
  80772. */
  80773. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80774. /**
  80775. * Calculates the distance from a plane and a point
  80776. * @param origin origin of the plane to be constructed
  80777. * @param normal normal of the plane to be constructed
  80778. * @param point point to calculate distance to
  80779. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80780. */
  80781. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80782. }
  80783. }
  80784. declare module BABYLON {
  80785. /**
  80786. * Class used to store bounding sphere information
  80787. */
  80788. export class BoundingSphere {
  80789. /**
  80790. * Gets the center of the bounding sphere in local space
  80791. */
  80792. readonly center: Vector3;
  80793. /**
  80794. * Radius of the bounding sphere in local space
  80795. */
  80796. radius: number;
  80797. /**
  80798. * Gets the center of the bounding sphere in world space
  80799. */
  80800. readonly centerWorld: Vector3;
  80801. /**
  80802. * Radius of the bounding sphere in world space
  80803. */
  80804. radiusWorld: number;
  80805. /**
  80806. * Gets the minimum vector in local space
  80807. */
  80808. readonly minimum: Vector3;
  80809. /**
  80810. * Gets the maximum vector in local space
  80811. */
  80812. readonly maximum: Vector3;
  80813. private _worldMatrix;
  80814. private static readonly TmpVector3;
  80815. /**
  80816. * Creates a new bounding sphere
  80817. * @param min defines the minimum vector (in local space)
  80818. * @param max defines the maximum vector (in local space)
  80819. * @param worldMatrix defines the new world matrix
  80820. */
  80821. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80822. /**
  80823. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80824. * @param min defines the new minimum vector (in local space)
  80825. * @param max defines the new maximum vector (in local space)
  80826. * @param worldMatrix defines the new world matrix
  80827. */
  80828. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80829. /**
  80830. * Scale the current bounding sphere by applying a scale factor
  80831. * @param factor defines the scale factor to apply
  80832. * @returns the current bounding box
  80833. */
  80834. scale(factor: number): BoundingSphere;
  80835. /**
  80836. * Gets the world matrix of the bounding box
  80837. * @returns a matrix
  80838. */
  80839. getWorldMatrix(): DeepImmutable<Matrix>;
  80840. /** @hidden */
  80841. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80842. /**
  80843. * Tests if the bounding sphere is intersecting the frustum planes
  80844. * @param frustumPlanes defines the frustum planes to test
  80845. * @returns true if there is an intersection
  80846. */
  80847. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80848. /**
  80849. * Tests if the bounding sphere center is in between the frustum planes.
  80850. * Used for optimistic fast inclusion.
  80851. * @param frustumPlanes defines the frustum planes to test
  80852. * @returns true if the sphere center is in between the frustum planes
  80853. */
  80854. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80855. /**
  80856. * Tests if a point is inside the bounding sphere
  80857. * @param point defines the point to test
  80858. * @returns true if the point is inside the bounding sphere
  80859. */
  80860. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80861. /**
  80862. * Checks if two sphere intersct
  80863. * @param sphere0 sphere 0
  80864. * @param sphere1 sphere 1
  80865. * @returns true if the speres intersect
  80866. */
  80867. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80868. }
  80869. }
  80870. declare module BABYLON {
  80871. /**
  80872. * Class used to store bounding box information
  80873. */
  80874. export class BoundingBox implements ICullable {
  80875. /**
  80876. * Gets the 8 vectors representing the bounding box in local space
  80877. */
  80878. readonly vectors: Vector3[];
  80879. /**
  80880. * Gets the center of the bounding box in local space
  80881. */
  80882. readonly center: Vector3;
  80883. /**
  80884. * Gets the center of the bounding box in world space
  80885. */
  80886. readonly centerWorld: Vector3;
  80887. /**
  80888. * Gets the extend size in local space
  80889. */
  80890. readonly extendSize: Vector3;
  80891. /**
  80892. * Gets the extend size in world space
  80893. */
  80894. readonly extendSizeWorld: Vector3;
  80895. /**
  80896. * Gets the OBB (object bounding box) directions
  80897. */
  80898. readonly directions: Vector3[];
  80899. /**
  80900. * Gets the 8 vectors representing the bounding box in world space
  80901. */
  80902. readonly vectorsWorld: Vector3[];
  80903. /**
  80904. * Gets the minimum vector in world space
  80905. */
  80906. readonly minimumWorld: Vector3;
  80907. /**
  80908. * Gets the maximum vector in world space
  80909. */
  80910. readonly maximumWorld: Vector3;
  80911. /**
  80912. * Gets the minimum vector in local space
  80913. */
  80914. readonly minimum: Vector3;
  80915. /**
  80916. * Gets the maximum vector in local space
  80917. */
  80918. readonly maximum: Vector3;
  80919. private _worldMatrix;
  80920. private static readonly TmpVector3;
  80921. /**
  80922. * @hidden
  80923. */
  80924. _tag: number;
  80925. /**
  80926. * Creates a new bounding box
  80927. * @param min defines the minimum vector (in local space)
  80928. * @param max defines the maximum vector (in local space)
  80929. * @param worldMatrix defines the new world matrix
  80930. */
  80931. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80932. /**
  80933. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80934. * @param min defines the new minimum vector (in local space)
  80935. * @param max defines the new maximum vector (in local space)
  80936. * @param worldMatrix defines the new world matrix
  80937. */
  80938. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80939. /**
  80940. * Scale the current bounding box by applying a scale factor
  80941. * @param factor defines the scale factor to apply
  80942. * @returns the current bounding box
  80943. */
  80944. scale(factor: number): BoundingBox;
  80945. /**
  80946. * Gets the world matrix of the bounding box
  80947. * @returns a matrix
  80948. */
  80949. getWorldMatrix(): DeepImmutable<Matrix>;
  80950. /** @hidden */
  80951. _update(world: DeepImmutable<Matrix>): void;
  80952. /**
  80953. * Tests if the bounding box is intersecting the frustum planes
  80954. * @param frustumPlanes defines the frustum planes to test
  80955. * @returns true if there is an intersection
  80956. */
  80957. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80958. /**
  80959. * Tests if the bounding box is entirely inside the frustum planes
  80960. * @param frustumPlanes defines the frustum planes to test
  80961. * @returns true if there is an inclusion
  80962. */
  80963. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80964. /**
  80965. * Tests if a point is inside the bounding box
  80966. * @param point defines the point to test
  80967. * @returns true if the point is inside the bounding box
  80968. */
  80969. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80970. /**
  80971. * Tests if the bounding box intersects with a bounding sphere
  80972. * @param sphere defines the sphere to test
  80973. * @returns true if there is an intersection
  80974. */
  80975. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80976. /**
  80977. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80978. * @param min defines the min vector to use
  80979. * @param max defines the max vector to use
  80980. * @returns true if there is an intersection
  80981. */
  80982. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80983. /**
  80984. * Tests if two bounding boxes are intersections
  80985. * @param box0 defines the first box to test
  80986. * @param box1 defines the second box to test
  80987. * @returns true if there is an intersection
  80988. */
  80989. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80990. /**
  80991. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80992. * @param minPoint defines the minimum vector of the bounding box
  80993. * @param maxPoint defines the maximum vector of the bounding box
  80994. * @param sphereCenter defines the sphere center
  80995. * @param sphereRadius defines the sphere radius
  80996. * @returns true if there is an intersection
  80997. */
  80998. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80999. /**
  81000. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  81001. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81002. * @param frustumPlanes defines the frustum planes to test
  81003. * @return true if there is an inclusion
  81004. */
  81005. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81006. /**
  81007. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  81008. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81009. * @param frustumPlanes defines the frustum planes to test
  81010. * @return true if there is an intersection
  81011. */
  81012. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81013. }
  81014. }
  81015. declare module BABYLON {
  81016. /** @hidden */
  81017. export class Collider {
  81018. /** Define if a collision was found */
  81019. collisionFound: boolean;
  81020. /**
  81021. * Define last intersection point in local space
  81022. */
  81023. intersectionPoint: Vector3;
  81024. /**
  81025. * Define last collided mesh
  81026. */
  81027. collidedMesh: Nullable<AbstractMesh>;
  81028. private _collisionPoint;
  81029. private _planeIntersectionPoint;
  81030. private _tempVector;
  81031. private _tempVector2;
  81032. private _tempVector3;
  81033. private _tempVector4;
  81034. private _edge;
  81035. private _baseToVertex;
  81036. private _destinationPoint;
  81037. private _slidePlaneNormal;
  81038. private _displacementVector;
  81039. /** @hidden */
  81040. _radius: Vector3;
  81041. /** @hidden */
  81042. _retry: number;
  81043. private _velocity;
  81044. private _basePoint;
  81045. private _epsilon;
  81046. /** @hidden */
  81047. _velocityWorldLength: number;
  81048. /** @hidden */
  81049. _basePointWorld: Vector3;
  81050. private _velocityWorld;
  81051. private _normalizedVelocity;
  81052. /** @hidden */
  81053. _initialVelocity: Vector3;
  81054. /** @hidden */
  81055. _initialPosition: Vector3;
  81056. private _nearestDistance;
  81057. private _collisionMask;
  81058. get collisionMask(): number;
  81059. set collisionMask(mask: number);
  81060. /**
  81061. * Gets the plane normal used to compute the sliding response (in local space)
  81062. */
  81063. get slidePlaneNormal(): Vector3;
  81064. /** @hidden */
  81065. _initialize(source: Vector3, dir: Vector3, e: number): void;
  81066. /** @hidden */
  81067. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  81068. /** @hidden */
  81069. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  81070. /** @hidden */
  81071. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81072. /** @hidden */
  81073. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81074. /** @hidden */
  81075. _getResponse(pos: Vector3, vel: Vector3): void;
  81076. }
  81077. }
  81078. declare module BABYLON {
  81079. /**
  81080. * Interface for cullable objects
  81081. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  81082. */
  81083. export interface ICullable {
  81084. /**
  81085. * Checks if the object or part of the object is in the frustum
  81086. * @param frustumPlanes Camera near/planes
  81087. * @returns true if the object is in frustum otherwise false
  81088. */
  81089. isInFrustum(frustumPlanes: Plane[]): boolean;
  81090. /**
  81091. * Checks if a cullable object (mesh...) is in the camera frustum
  81092. * Unlike isInFrustum this cheks the full bounding box
  81093. * @param frustumPlanes Camera near/planes
  81094. * @returns true if the object is in frustum otherwise false
  81095. */
  81096. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81097. }
  81098. /**
  81099. * Info for a bounding data of a mesh
  81100. */
  81101. export class BoundingInfo implements ICullable {
  81102. /**
  81103. * Bounding box for the mesh
  81104. */
  81105. readonly boundingBox: BoundingBox;
  81106. /**
  81107. * Bounding sphere for the mesh
  81108. */
  81109. readonly boundingSphere: BoundingSphere;
  81110. private _isLocked;
  81111. private static readonly TmpVector3;
  81112. /**
  81113. * Constructs bounding info
  81114. * @param minimum min vector of the bounding box/sphere
  81115. * @param maximum max vector of the bounding box/sphere
  81116. * @param worldMatrix defines the new world matrix
  81117. */
  81118. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81119. /**
  81120. * Recreates the entire bounding info from scratch as if we call the constructor in place
  81121. * @param min defines the new minimum vector (in local space)
  81122. * @param max defines the new maximum vector (in local space)
  81123. * @param worldMatrix defines the new world matrix
  81124. */
  81125. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81126. /**
  81127. * min vector of the bounding box/sphere
  81128. */
  81129. get minimum(): Vector3;
  81130. /**
  81131. * max vector of the bounding box/sphere
  81132. */
  81133. get maximum(): Vector3;
  81134. /**
  81135. * If the info is locked and won't be updated to avoid perf overhead
  81136. */
  81137. get isLocked(): boolean;
  81138. set isLocked(value: boolean);
  81139. /**
  81140. * Updates the bounding sphere and box
  81141. * @param world world matrix to be used to update
  81142. */
  81143. update(world: DeepImmutable<Matrix>): void;
  81144. /**
  81145. * Recreate the bounding info to be centered around a specific point given a specific extend.
  81146. * @param center New center of the bounding info
  81147. * @param extend New extend of the bounding info
  81148. * @returns the current bounding info
  81149. */
  81150. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  81151. /**
  81152. * Scale the current bounding info by applying a scale factor
  81153. * @param factor defines the scale factor to apply
  81154. * @returns the current bounding info
  81155. */
  81156. scale(factor: number): BoundingInfo;
  81157. /**
  81158. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  81159. * @param frustumPlanes defines the frustum to test
  81160. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  81161. * @returns true if the bounding info is in the frustum planes
  81162. */
  81163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  81164. /**
  81165. * Gets the world distance between the min and max points of the bounding box
  81166. */
  81167. get diagonalLength(): number;
  81168. /**
  81169. * Checks if a cullable object (mesh...) is in the camera frustum
  81170. * Unlike isInFrustum this cheks the full bounding box
  81171. * @param frustumPlanes Camera near/planes
  81172. * @returns true if the object is in frustum otherwise false
  81173. */
  81174. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81175. /** @hidden */
  81176. _checkCollision(collider: Collider): boolean;
  81177. /**
  81178. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  81179. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81180. * @param point the point to check intersection with
  81181. * @returns if the point intersects
  81182. */
  81183. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81184. /**
  81185. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  81186. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81187. * @param boundingInfo the bounding info to check intersection with
  81188. * @param precise if the intersection should be done using OBB
  81189. * @returns if the bounding info intersects
  81190. */
  81191. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  81192. }
  81193. }
  81194. declare module BABYLON {
  81195. /**
  81196. * Extracts minimum and maximum values from a list of indexed positions
  81197. * @param positions defines the positions to use
  81198. * @param indices defines the indices to the positions
  81199. * @param indexStart defines the start index
  81200. * @param indexCount defines the end index
  81201. * @param bias defines bias value to add to the result
  81202. * @return minimum and maximum values
  81203. */
  81204. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  81205. minimum: Vector3;
  81206. maximum: Vector3;
  81207. };
  81208. /**
  81209. * Extracts minimum and maximum values from a list of positions
  81210. * @param positions defines the positions to use
  81211. * @param start defines the start index in the positions array
  81212. * @param count defines the number of positions to handle
  81213. * @param bias defines bias value to add to the result
  81214. * @param stride defines the stride size to use (distance between two positions in the positions array)
  81215. * @return minimum and maximum values
  81216. */
  81217. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  81218. minimum: Vector3;
  81219. maximum: Vector3;
  81220. };
  81221. }
  81222. declare module BABYLON {
  81223. /** @hidden */
  81224. export class WebGLDataBuffer extends DataBuffer {
  81225. private _buffer;
  81226. constructor(resource: WebGLBuffer);
  81227. get underlyingResource(): any;
  81228. }
  81229. }
  81230. declare module BABYLON {
  81231. /** @hidden */
  81232. export class WebGLPipelineContext implements IPipelineContext {
  81233. engine: ThinEngine;
  81234. program: Nullable<WebGLProgram>;
  81235. context?: WebGLRenderingContext;
  81236. vertexShader?: WebGLShader;
  81237. fragmentShader?: WebGLShader;
  81238. isParallelCompiled: boolean;
  81239. onCompiled?: () => void;
  81240. transformFeedback?: WebGLTransformFeedback | null;
  81241. vertexCompilationError: Nullable<string>;
  81242. fragmentCompilationError: Nullable<string>;
  81243. programLinkError: Nullable<string>;
  81244. programValidationError: Nullable<string>;
  81245. get isAsync(): boolean;
  81246. get isReady(): boolean;
  81247. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  81248. _getVertexShaderCode(): string | null;
  81249. _getFragmentShaderCode(): string | null;
  81250. }
  81251. }
  81252. declare module BABYLON {
  81253. interface ThinEngine {
  81254. /**
  81255. * Create an uniform buffer
  81256. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81257. * @param elements defines the content of the uniform buffer
  81258. * @returns the webGL uniform buffer
  81259. */
  81260. createUniformBuffer(elements: FloatArray): DataBuffer;
  81261. /**
  81262. * Create a dynamic uniform buffer
  81263. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81264. * @param elements defines the content of the uniform buffer
  81265. * @returns the webGL uniform buffer
  81266. */
  81267. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  81268. /**
  81269. * Update an existing uniform buffer
  81270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81271. * @param uniformBuffer defines the target uniform buffer
  81272. * @param elements defines the content to update
  81273. * @param offset defines the offset in the uniform buffer where update should start
  81274. * @param count defines the size of the data to update
  81275. */
  81276. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  81277. /**
  81278. * Bind an uniform buffer to the current webGL context
  81279. * @param buffer defines the buffer to bind
  81280. */
  81281. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  81282. /**
  81283. * Bind a buffer to the current webGL context at a given location
  81284. * @param buffer defines the buffer to bind
  81285. * @param location defines the index where to bind the buffer
  81286. */
  81287. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  81288. /**
  81289. * Bind a specific block at a given index in a specific shader program
  81290. * @param pipelineContext defines the pipeline context to use
  81291. * @param blockName defines the block name
  81292. * @param index defines the index where to bind the block
  81293. */
  81294. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  81295. }
  81296. }
  81297. declare module BABYLON {
  81298. /**
  81299. * Uniform buffer objects.
  81300. *
  81301. * Handles blocks of uniform on the GPU.
  81302. *
  81303. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81304. *
  81305. * For more information, please refer to :
  81306. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81307. */
  81308. export class UniformBuffer {
  81309. private _engine;
  81310. private _buffer;
  81311. private _data;
  81312. private _bufferData;
  81313. private _dynamic?;
  81314. private _uniformLocations;
  81315. private _uniformSizes;
  81316. private _uniformLocationPointer;
  81317. private _needSync;
  81318. private _noUBO;
  81319. private _currentEffect;
  81320. /** @hidden */
  81321. _alreadyBound: boolean;
  81322. private static _MAX_UNIFORM_SIZE;
  81323. private static _tempBuffer;
  81324. /**
  81325. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81326. * This is dynamic to allow compat with webgl 1 and 2.
  81327. * You will need to pass the name of the uniform as well as the value.
  81328. */
  81329. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81330. /**
  81331. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81332. * This is dynamic to allow compat with webgl 1 and 2.
  81333. * You will need to pass the name of the uniform as well as the value.
  81334. */
  81335. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81336. /**
  81337. * Lambda to Update a single float in a uniform buffer.
  81338. * This is dynamic to allow compat with webgl 1 and 2.
  81339. * You will need to pass the name of the uniform as well as the value.
  81340. */
  81341. updateFloat: (name: string, x: number) => void;
  81342. /**
  81343. * Lambda to Update a vec2 of float in a uniform buffer.
  81344. * This is dynamic to allow compat with webgl 1 and 2.
  81345. * You will need to pass the name of the uniform as well as the value.
  81346. */
  81347. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81348. /**
  81349. * Lambda to Update a vec3 of float in a uniform buffer.
  81350. * This is dynamic to allow compat with webgl 1 and 2.
  81351. * You will need to pass the name of the uniform as well as the value.
  81352. */
  81353. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81354. /**
  81355. * Lambda to Update a vec4 of float in a uniform buffer.
  81356. * This is dynamic to allow compat with webgl 1 and 2.
  81357. * You will need to pass the name of the uniform as well as the value.
  81358. */
  81359. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81360. /**
  81361. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81362. * This is dynamic to allow compat with webgl 1 and 2.
  81363. * You will need to pass the name of the uniform as well as the value.
  81364. */
  81365. updateMatrix: (name: string, mat: Matrix) => void;
  81366. /**
  81367. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81368. * This is dynamic to allow compat with webgl 1 and 2.
  81369. * You will need to pass the name of the uniform as well as the value.
  81370. */
  81371. updateVector3: (name: string, vector: Vector3) => void;
  81372. /**
  81373. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81374. * This is dynamic to allow compat with webgl 1 and 2.
  81375. * You will need to pass the name of the uniform as well as the value.
  81376. */
  81377. updateVector4: (name: string, vector: Vector4) => void;
  81378. /**
  81379. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81380. * This is dynamic to allow compat with webgl 1 and 2.
  81381. * You will need to pass the name of the uniform as well as the value.
  81382. */
  81383. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81384. /**
  81385. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81386. * This is dynamic to allow compat with webgl 1 and 2.
  81387. * You will need to pass the name of the uniform as well as the value.
  81388. */
  81389. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81390. /**
  81391. * Instantiates a new Uniform buffer objects.
  81392. *
  81393. * Handles blocks of uniform on the GPU.
  81394. *
  81395. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81396. *
  81397. * For more information, please refer to :
  81398. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81399. * @param engine Define the engine the buffer is associated with
  81400. * @param data Define the data contained in the buffer
  81401. * @param dynamic Define if the buffer is updatable
  81402. */
  81403. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81404. /**
  81405. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81406. * or just falling back on setUniformXXX calls.
  81407. */
  81408. get useUbo(): boolean;
  81409. /**
  81410. * Indicates if the WebGL underlying uniform buffer is in sync
  81411. * with the javascript cache data.
  81412. */
  81413. get isSync(): boolean;
  81414. /**
  81415. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81416. * Also, a dynamic UniformBuffer will disable cache verification and always
  81417. * update the underlying WebGL uniform buffer to the GPU.
  81418. * @returns if Dynamic, otherwise false
  81419. */
  81420. isDynamic(): boolean;
  81421. /**
  81422. * The data cache on JS side.
  81423. * @returns the underlying data as a float array
  81424. */
  81425. getData(): Float32Array;
  81426. /**
  81427. * The underlying WebGL Uniform buffer.
  81428. * @returns the webgl buffer
  81429. */
  81430. getBuffer(): Nullable<DataBuffer>;
  81431. /**
  81432. * std140 layout specifies how to align data within an UBO structure.
  81433. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81434. * for specs.
  81435. */
  81436. private _fillAlignment;
  81437. /**
  81438. * Adds an uniform in the buffer.
  81439. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81440. * for the layout to be correct !
  81441. * @param name Name of the uniform, as used in the uniform block in the shader.
  81442. * @param size Data size, or data directly.
  81443. */
  81444. addUniform(name: string, size: number | number[]): void;
  81445. /**
  81446. * Adds a Matrix 4x4 to the uniform buffer.
  81447. * @param name Name of the uniform, as used in the uniform block in the shader.
  81448. * @param mat A 4x4 matrix.
  81449. */
  81450. addMatrix(name: string, mat: Matrix): void;
  81451. /**
  81452. * Adds a vec2 to the uniform buffer.
  81453. * @param name Name of the uniform, as used in the uniform block in the shader.
  81454. * @param x Define the x component value of the vec2
  81455. * @param y Define the y component value of the vec2
  81456. */
  81457. addFloat2(name: string, x: number, y: number): void;
  81458. /**
  81459. * Adds a vec3 to the uniform buffer.
  81460. * @param name Name of the uniform, as used in the uniform block in the shader.
  81461. * @param x Define the x component value of the vec3
  81462. * @param y Define the y component value of the vec3
  81463. * @param z Define the z component value of the vec3
  81464. */
  81465. addFloat3(name: string, x: number, y: number, z: number): void;
  81466. /**
  81467. * Adds a vec3 to the uniform buffer.
  81468. * @param name Name of the uniform, as used in the uniform block in the shader.
  81469. * @param color Define the vec3 from a Color
  81470. */
  81471. addColor3(name: string, color: Color3): void;
  81472. /**
  81473. * Adds a vec4 to the uniform buffer.
  81474. * @param name Name of the uniform, as used in the uniform block in the shader.
  81475. * @param color Define the rgb components from a Color
  81476. * @param alpha Define the a component of the vec4
  81477. */
  81478. addColor4(name: string, color: Color3, alpha: number): void;
  81479. /**
  81480. * Adds a vec3 to the uniform buffer.
  81481. * @param name Name of the uniform, as used in the uniform block in the shader.
  81482. * @param vector Define the vec3 components from a Vector
  81483. */
  81484. addVector3(name: string, vector: Vector3): void;
  81485. /**
  81486. * Adds a Matrix 3x3 to the uniform buffer.
  81487. * @param name Name of the uniform, as used in the uniform block in the shader.
  81488. */
  81489. addMatrix3x3(name: string): void;
  81490. /**
  81491. * Adds a Matrix 2x2 to the uniform buffer.
  81492. * @param name Name of the uniform, as used in the uniform block in the shader.
  81493. */
  81494. addMatrix2x2(name: string): void;
  81495. /**
  81496. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81497. */
  81498. create(): void;
  81499. /** @hidden */
  81500. _rebuild(): void;
  81501. /**
  81502. * Updates the WebGL Uniform Buffer on the GPU.
  81503. * If the `dynamic` flag is set to true, no cache comparison is done.
  81504. * Otherwise, the buffer will be updated only if the cache differs.
  81505. */
  81506. update(): void;
  81507. /**
  81508. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81509. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81510. * @param data Define the flattened data
  81511. * @param size Define the size of the data.
  81512. */
  81513. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81514. private _valueCache;
  81515. private _cacheMatrix;
  81516. private _updateMatrix3x3ForUniform;
  81517. private _updateMatrix3x3ForEffect;
  81518. private _updateMatrix2x2ForEffect;
  81519. private _updateMatrix2x2ForUniform;
  81520. private _updateFloatForEffect;
  81521. private _updateFloatForUniform;
  81522. private _updateFloat2ForEffect;
  81523. private _updateFloat2ForUniform;
  81524. private _updateFloat3ForEffect;
  81525. private _updateFloat3ForUniform;
  81526. private _updateFloat4ForEffect;
  81527. private _updateFloat4ForUniform;
  81528. private _updateMatrixForEffect;
  81529. private _updateMatrixForUniform;
  81530. private _updateVector3ForEffect;
  81531. private _updateVector3ForUniform;
  81532. private _updateVector4ForEffect;
  81533. private _updateVector4ForUniform;
  81534. private _updateColor3ForEffect;
  81535. private _updateColor3ForUniform;
  81536. private _updateColor4ForEffect;
  81537. private _updateColor4ForUniform;
  81538. /**
  81539. * Sets a sampler uniform on the effect.
  81540. * @param name Define the name of the sampler.
  81541. * @param texture Define the texture to set in the sampler
  81542. */
  81543. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81544. /**
  81545. * Directly updates the value of the uniform in the cache AND on the GPU.
  81546. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81547. * @param data Define the flattened data
  81548. */
  81549. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81550. /**
  81551. * Binds this uniform buffer to an effect.
  81552. * @param effect Define the effect to bind the buffer to
  81553. * @param name Name of the uniform block in the shader.
  81554. */
  81555. bindToEffect(effect: Effect, name: string): void;
  81556. /**
  81557. * Disposes the uniform buffer.
  81558. */
  81559. dispose(): void;
  81560. }
  81561. }
  81562. declare module BABYLON {
  81563. /**
  81564. * Enum that determines the text-wrapping mode to use.
  81565. */
  81566. export enum InspectableType {
  81567. /**
  81568. * Checkbox for booleans
  81569. */
  81570. Checkbox = 0,
  81571. /**
  81572. * Sliders for numbers
  81573. */
  81574. Slider = 1,
  81575. /**
  81576. * Vector3
  81577. */
  81578. Vector3 = 2,
  81579. /**
  81580. * Quaternions
  81581. */
  81582. Quaternion = 3,
  81583. /**
  81584. * Color3
  81585. */
  81586. Color3 = 4,
  81587. /**
  81588. * String
  81589. */
  81590. String = 5
  81591. }
  81592. /**
  81593. * Interface used to define custom inspectable properties.
  81594. * This interface is used by the inspector to display custom property grids
  81595. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81596. */
  81597. export interface IInspectable {
  81598. /**
  81599. * Gets the label to display
  81600. */
  81601. label: string;
  81602. /**
  81603. * Gets the name of the property to edit
  81604. */
  81605. propertyName: string;
  81606. /**
  81607. * Gets the type of the editor to use
  81608. */
  81609. type: InspectableType;
  81610. /**
  81611. * Gets the minimum value of the property when using in "slider" mode
  81612. */
  81613. min?: number;
  81614. /**
  81615. * Gets the maximum value of the property when using in "slider" mode
  81616. */
  81617. max?: number;
  81618. /**
  81619. * Gets the setp to use when using in "slider" mode
  81620. */
  81621. step?: number;
  81622. }
  81623. }
  81624. declare module BABYLON {
  81625. /**
  81626. * Class used to provide helper for timing
  81627. */
  81628. export class TimingTools {
  81629. /**
  81630. * Polyfill for setImmediate
  81631. * @param action defines the action to execute after the current execution block
  81632. */
  81633. static SetImmediate(action: () => void): void;
  81634. }
  81635. }
  81636. declare module BABYLON {
  81637. /**
  81638. * Class used to enable instatition of objects by class name
  81639. */
  81640. export class InstantiationTools {
  81641. /**
  81642. * Use this object to register external classes like custom textures or material
  81643. * to allow the laoders to instantiate them
  81644. */
  81645. static RegisteredExternalClasses: {
  81646. [key: string]: Object;
  81647. };
  81648. /**
  81649. * Tries to instantiate a new object from a given class name
  81650. * @param className defines the class name to instantiate
  81651. * @returns the new object or null if the system was not able to do the instantiation
  81652. */
  81653. static Instantiate(className: string): any;
  81654. }
  81655. }
  81656. declare module BABYLON {
  81657. /**
  81658. * Define options used to create a depth texture
  81659. */
  81660. export class DepthTextureCreationOptions {
  81661. /** Specifies whether or not a stencil should be allocated in the texture */
  81662. generateStencil?: boolean;
  81663. /** Specifies whether or not bilinear filtering is enable on the texture */
  81664. bilinearFiltering?: boolean;
  81665. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81666. comparisonFunction?: number;
  81667. /** Specifies if the created texture is a cube texture */
  81668. isCube?: boolean;
  81669. }
  81670. }
  81671. declare module BABYLON {
  81672. interface ThinEngine {
  81673. /**
  81674. * Creates a depth stencil cube texture.
  81675. * This is only available in WebGL 2.
  81676. * @param size The size of face edge in the cube texture.
  81677. * @param options The options defining the cube texture.
  81678. * @returns The cube texture
  81679. */
  81680. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81681. /**
  81682. * Creates a cube texture
  81683. * @param rootUrl defines the url where the files to load is located
  81684. * @param scene defines the current scene
  81685. * @param files defines the list of files to load (1 per face)
  81686. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81687. * @param onLoad defines an optional callback raised when the texture is loaded
  81688. * @param onError defines an optional callback raised if there is an issue to load the texture
  81689. * @param format defines the format of the data
  81690. * @param forcedExtension defines the extension to use to pick the right loader
  81691. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81692. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81693. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81694. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81695. * @returns the cube texture as an InternalTexture
  81696. */
  81697. 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;
  81698. /**
  81699. * Creates a cube texture
  81700. * @param rootUrl defines the url where the files to load is located
  81701. * @param scene defines the current scene
  81702. * @param files defines the list of files to load (1 per face)
  81703. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81704. * @param onLoad defines an optional callback raised when the texture is loaded
  81705. * @param onError defines an optional callback raised if there is an issue to load the texture
  81706. * @param format defines the format of the data
  81707. * @param forcedExtension defines the extension to use to pick the right loader
  81708. * @returns the cube texture as an InternalTexture
  81709. */
  81710. 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;
  81711. /**
  81712. * Creates a cube texture
  81713. * @param rootUrl defines the url where the files to load is located
  81714. * @param scene defines the current scene
  81715. * @param files defines the list of files to load (1 per face)
  81716. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81717. * @param onLoad defines an optional callback raised when the texture is loaded
  81718. * @param onError defines an optional callback raised if there is an issue to load the texture
  81719. * @param format defines the format of the data
  81720. * @param forcedExtension defines the extension to use to pick the right loader
  81721. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81722. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81723. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81724. * @returns the cube texture as an InternalTexture
  81725. */
  81726. 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;
  81727. /** @hidden */
  81728. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81729. /** @hidden */
  81730. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81731. /** @hidden */
  81732. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81733. /** @hidden */
  81734. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81735. /**
  81736. * @hidden
  81737. */
  81738. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81739. }
  81740. }
  81741. declare module BABYLON {
  81742. /**
  81743. * Class for creating a cube texture
  81744. */
  81745. export class CubeTexture extends BaseTexture {
  81746. private _delayedOnLoad;
  81747. /**
  81748. * Observable triggered once the texture has been loaded.
  81749. */
  81750. onLoadObservable: Observable<CubeTexture>;
  81751. /**
  81752. * The url of the texture
  81753. */
  81754. url: string;
  81755. /**
  81756. * Gets or sets the center of the bounding box associated with the cube texture.
  81757. * It must define where the camera used to render the texture was set
  81758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81759. */
  81760. boundingBoxPosition: Vector3;
  81761. private _boundingBoxSize;
  81762. /**
  81763. * Gets or sets the size of the bounding box associated with the cube texture
  81764. * When defined, the cubemap will switch to local mode
  81765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81766. * @example https://www.babylonjs-playground.com/#RNASML
  81767. */
  81768. set boundingBoxSize(value: Vector3);
  81769. /**
  81770. * Returns the bounding box size
  81771. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81772. */
  81773. get boundingBoxSize(): Vector3;
  81774. protected _rotationY: number;
  81775. /**
  81776. * Sets texture matrix rotation angle around Y axis in radians.
  81777. */
  81778. set rotationY(value: number);
  81779. /**
  81780. * Gets texture matrix rotation angle around Y axis radians.
  81781. */
  81782. get rotationY(): number;
  81783. /**
  81784. * Are mip maps generated for this texture or not.
  81785. */
  81786. get noMipmap(): boolean;
  81787. private _noMipmap;
  81788. private _files;
  81789. protected _forcedExtension: Nullable<string>;
  81790. private _extensions;
  81791. private _textureMatrix;
  81792. private _format;
  81793. private _createPolynomials;
  81794. /** @hidden */
  81795. _prefiltered: boolean;
  81796. /**
  81797. * Creates a cube texture from an array of image urls
  81798. * @param files defines an array of image urls
  81799. * @param scene defines the hosting scene
  81800. * @param noMipmap specifies if mip maps are not used
  81801. * @returns a cube texture
  81802. */
  81803. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81804. /**
  81805. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81806. * @param url defines the url of the prefiltered texture
  81807. * @param scene defines the scene the texture is attached to
  81808. * @param forcedExtension defines the extension of the file if different from the url
  81809. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81810. * @return the prefiltered texture
  81811. */
  81812. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81813. /**
  81814. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81815. * as prefiltered data.
  81816. * @param rootUrl defines the url of the texture or the root name of the six images
  81817. * @param scene defines the scene the texture is attached to
  81818. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81819. * @param noMipmap defines if mipmaps should be created or not
  81820. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81821. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81822. * @param onError defines a callback triggered in case of error during load
  81823. * @param format defines the internal format to use for the texture once loaded
  81824. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81825. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81826. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81827. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81828. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81829. * @return the cube texture
  81830. */
  81831. 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);
  81832. /**
  81833. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81834. */
  81835. get isPrefiltered(): boolean;
  81836. /**
  81837. * Get the current class name of the texture useful for serialization or dynamic coding.
  81838. * @returns "CubeTexture"
  81839. */
  81840. getClassName(): string;
  81841. /**
  81842. * Update the url (and optional buffer) of this texture if url was null during construction.
  81843. * @param url the url of the texture
  81844. * @param forcedExtension defines the extension to use
  81845. * @param onLoad callback called when the texture is loaded (defaults to null)
  81846. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81847. */
  81848. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81849. /**
  81850. * Delays loading of the cube texture
  81851. * @param forcedExtension defines the extension to use
  81852. */
  81853. delayLoad(forcedExtension?: string): void;
  81854. /**
  81855. * Returns the reflection texture matrix
  81856. * @returns the reflection texture matrix
  81857. */
  81858. getReflectionTextureMatrix(): Matrix;
  81859. /**
  81860. * Sets the reflection texture matrix
  81861. * @param value Reflection texture matrix
  81862. */
  81863. setReflectionTextureMatrix(value: Matrix): void;
  81864. /**
  81865. * Parses text to create a cube texture
  81866. * @param parsedTexture define the serialized text to read from
  81867. * @param scene defines the hosting scene
  81868. * @param rootUrl defines the root url of the cube texture
  81869. * @returns a cube texture
  81870. */
  81871. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81872. /**
  81873. * Makes a clone, or deep copy, of the cube texture
  81874. * @returns a new cube texture
  81875. */
  81876. clone(): CubeTexture;
  81877. }
  81878. }
  81879. declare module BABYLON {
  81880. /**
  81881. * Manages the defines for the Material
  81882. */
  81883. export class MaterialDefines {
  81884. /** @hidden */
  81885. protected _keys: string[];
  81886. private _isDirty;
  81887. /** @hidden */
  81888. _renderId: number;
  81889. /** @hidden */
  81890. _areLightsDirty: boolean;
  81891. /** @hidden */
  81892. _areLightsDisposed: boolean;
  81893. /** @hidden */
  81894. _areAttributesDirty: boolean;
  81895. /** @hidden */
  81896. _areTexturesDirty: boolean;
  81897. /** @hidden */
  81898. _areFresnelDirty: boolean;
  81899. /** @hidden */
  81900. _areMiscDirty: boolean;
  81901. /** @hidden */
  81902. _areImageProcessingDirty: boolean;
  81903. /** @hidden */
  81904. _normals: boolean;
  81905. /** @hidden */
  81906. _uvs: boolean;
  81907. /** @hidden */
  81908. _needNormals: boolean;
  81909. /** @hidden */
  81910. _needUVs: boolean;
  81911. [id: string]: any;
  81912. /**
  81913. * Specifies if the material needs to be re-calculated
  81914. */
  81915. get isDirty(): boolean;
  81916. /**
  81917. * Marks the material to indicate that it has been re-calculated
  81918. */
  81919. markAsProcessed(): void;
  81920. /**
  81921. * Marks the material to indicate that it needs to be re-calculated
  81922. */
  81923. markAsUnprocessed(): void;
  81924. /**
  81925. * Marks the material to indicate all of its defines need to be re-calculated
  81926. */
  81927. markAllAsDirty(): void;
  81928. /**
  81929. * Marks the material to indicate that image processing needs to be re-calculated
  81930. */
  81931. markAsImageProcessingDirty(): void;
  81932. /**
  81933. * Marks the material to indicate the lights need to be re-calculated
  81934. * @param disposed Defines whether the light is dirty due to dispose or not
  81935. */
  81936. markAsLightDirty(disposed?: boolean): void;
  81937. /**
  81938. * Marks the attribute state as changed
  81939. */
  81940. markAsAttributesDirty(): void;
  81941. /**
  81942. * Marks the texture state as changed
  81943. */
  81944. markAsTexturesDirty(): void;
  81945. /**
  81946. * Marks the fresnel state as changed
  81947. */
  81948. markAsFresnelDirty(): void;
  81949. /**
  81950. * Marks the misc state as changed
  81951. */
  81952. markAsMiscDirty(): void;
  81953. /**
  81954. * Rebuilds the material defines
  81955. */
  81956. rebuild(): void;
  81957. /**
  81958. * Specifies if two material defines are equal
  81959. * @param other - A material define instance to compare to
  81960. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81961. */
  81962. isEqual(other: MaterialDefines): boolean;
  81963. /**
  81964. * Clones this instance's defines to another instance
  81965. * @param other - material defines to clone values to
  81966. */
  81967. cloneTo(other: MaterialDefines): void;
  81968. /**
  81969. * Resets the material define values
  81970. */
  81971. reset(): void;
  81972. /**
  81973. * Converts the material define values to a string
  81974. * @returns - String of material define information
  81975. */
  81976. toString(): string;
  81977. }
  81978. }
  81979. declare module BABYLON {
  81980. /**
  81981. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81982. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81983. * 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;
  81984. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81985. */
  81986. export class ColorCurves {
  81987. private _dirty;
  81988. private _tempColor;
  81989. private _globalCurve;
  81990. private _highlightsCurve;
  81991. private _midtonesCurve;
  81992. private _shadowsCurve;
  81993. private _positiveCurve;
  81994. private _negativeCurve;
  81995. private _globalHue;
  81996. private _globalDensity;
  81997. private _globalSaturation;
  81998. private _globalExposure;
  81999. /**
  82000. * Gets the global Hue value.
  82001. * 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).
  82002. */
  82003. get globalHue(): number;
  82004. /**
  82005. * Sets the global Hue value.
  82006. * 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).
  82007. */
  82008. set globalHue(value: number);
  82009. /**
  82010. * Gets the global Density value.
  82011. * 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.
  82012. * Values less than zero provide a filter of opposite hue.
  82013. */
  82014. get globalDensity(): number;
  82015. /**
  82016. * Sets the global Density value.
  82017. * 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.
  82018. * Values less than zero provide a filter of opposite hue.
  82019. */
  82020. set globalDensity(value: number);
  82021. /**
  82022. * Gets the global Saturation value.
  82023. * 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.
  82024. */
  82025. get globalSaturation(): number;
  82026. /**
  82027. * Sets the global Saturation value.
  82028. * 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.
  82029. */
  82030. set globalSaturation(value: number);
  82031. /**
  82032. * Gets the global Exposure value.
  82033. * 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.
  82034. */
  82035. get globalExposure(): number;
  82036. /**
  82037. * Sets the global Exposure value.
  82038. * 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.
  82039. */
  82040. set globalExposure(value: number);
  82041. private _highlightsHue;
  82042. private _highlightsDensity;
  82043. private _highlightsSaturation;
  82044. private _highlightsExposure;
  82045. /**
  82046. * Gets the highlights Hue value.
  82047. * 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).
  82048. */
  82049. get highlightsHue(): number;
  82050. /**
  82051. * Sets the highlights Hue value.
  82052. * 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).
  82053. */
  82054. set highlightsHue(value: number);
  82055. /**
  82056. * Gets the highlights Density value.
  82057. * 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.
  82058. * Values less than zero provide a filter of opposite hue.
  82059. */
  82060. get highlightsDensity(): number;
  82061. /**
  82062. * Sets the highlights Density value.
  82063. * 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.
  82064. * Values less than zero provide a filter of opposite hue.
  82065. */
  82066. set highlightsDensity(value: number);
  82067. /**
  82068. * Gets the highlights Saturation value.
  82069. * 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.
  82070. */
  82071. get highlightsSaturation(): number;
  82072. /**
  82073. * Sets the highlights Saturation value.
  82074. * 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.
  82075. */
  82076. set highlightsSaturation(value: number);
  82077. /**
  82078. * Gets the highlights Exposure value.
  82079. * 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.
  82080. */
  82081. get highlightsExposure(): number;
  82082. /**
  82083. * Sets the highlights Exposure value.
  82084. * 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.
  82085. */
  82086. set highlightsExposure(value: number);
  82087. private _midtonesHue;
  82088. private _midtonesDensity;
  82089. private _midtonesSaturation;
  82090. private _midtonesExposure;
  82091. /**
  82092. * Gets the midtones Hue value.
  82093. * 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).
  82094. */
  82095. get midtonesHue(): number;
  82096. /**
  82097. * Sets the midtones Hue value.
  82098. * 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).
  82099. */
  82100. set midtonesHue(value: number);
  82101. /**
  82102. * Gets the midtones Density value.
  82103. * 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.
  82104. * Values less than zero provide a filter of opposite hue.
  82105. */
  82106. get midtonesDensity(): number;
  82107. /**
  82108. * Sets the midtones Density value.
  82109. * 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.
  82110. * Values less than zero provide a filter of opposite hue.
  82111. */
  82112. set midtonesDensity(value: number);
  82113. /**
  82114. * Gets the midtones Saturation value.
  82115. * 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.
  82116. */
  82117. get midtonesSaturation(): number;
  82118. /**
  82119. * Sets the midtones Saturation value.
  82120. * 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.
  82121. */
  82122. set midtonesSaturation(value: number);
  82123. /**
  82124. * Gets the midtones Exposure value.
  82125. * 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.
  82126. */
  82127. get midtonesExposure(): number;
  82128. /**
  82129. * Sets the midtones Exposure value.
  82130. * 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.
  82131. */
  82132. set midtonesExposure(value: number);
  82133. private _shadowsHue;
  82134. private _shadowsDensity;
  82135. private _shadowsSaturation;
  82136. private _shadowsExposure;
  82137. /**
  82138. * Gets the shadows Hue value.
  82139. * 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).
  82140. */
  82141. get shadowsHue(): number;
  82142. /**
  82143. * Sets the shadows Hue value.
  82144. * 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).
  82145. */
  82146. set shadowsHue(value: number);
  82147. /**
  82148. * Gets the shadows Density value.
  82149. * 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.
  82150. * Values less than zero provide a filter of opposite hue.
  82151. */
  82152. get shadowsDensity(): number;
  82153. /**
  82154. * Sets the shadows Density value.
  82155. * 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.
  82156. * Values less than zero provide a filter of opposite hue.
  82157. */
  82158. set shadowsDensity(value: number);
  82159. /**
  82160. * Gets the shadows Saturation value.
  82161. * 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.
  82162. */
  82163. get shadowsSaturation(): number;
  82164. /**
  82165. * Sets the shadows Saturation value.
  82166. * 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.
  82167. */
  82168. set shadowsSaturation(value: number);
  82169. /**
  82170. * Gets the shadows Exposure value.
  82171. * 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.
  82172. */
  82173. get shadowsExposure(): number;
  82174. /**
  82175. * Sets the shadows Exposure value.
  82176. * 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.
  82177. */
  82178. set shadowsExposure(value: number);
  82179. /**
  82180. * Returns the class name
  82181. * @returns The class name
  82182. */
  82183. getClassName(): string;
  82184. /**
  82185. * Binds the color curves to the shader.
  82186. * @param colorCurves The color curve to bind
  82187. * @param effect The effect to bind to
  82188. * @param positiveUniform The positive uniform shader parameter
  82189. * @param neutralUniform The neutral uniform shader parameter
  82190. * @param negativeUniform The negative uniform shader parameter
  82191. */
  82192. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  82193. /**
  82194. * Prepare the list of uniforms associated with the ColorCurves effects.
  82195. * @param uniformsList The list of uniforms used in the effect
  82196. */
  82197. static PrepareUniforms(uniformsList: string[]): void;
  82198. /**
  82199. * Returns color grading data based on a hue, density, saturation and exposure value.
  82200. * @param filterHue The hue of the color filter.
  82201. * @param filterDensity The density of the color filter.
  82202. * @param saturation The saturation.
  82203. * @param exposure The exposure.
  82204. * @param result The result data container.
  82205. */
  82206. private getColorGradingDataToRef;
  82207. /**
  82208. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  82209. * @param value The input slider value in range [-100,100].
  82210. * @returns Adjusted value.
  82211. */
  82212. private static applyColorGradingSliderNonlinear;
  82213. /**
  82214. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  82215. * @param hue The hue (H) input.
  82216. * @param saturation The saturation (S) input.
  82217. * @param brightness The brightness (B) input.
  82218. * @result An RGBA color represented as Vector4.
  82219. */
  82220. private static fromHSBToRef;
  82221. /**
  82222. * Returns a value clamped between min and max
  82223. * @param value The value to clamp
  82224. * @param min The minimum of value
  82225. * @param max The maximum of value
  82226. * @returns The clamped value.
  82227. */
  82228. private static clamp;
  82229. /**
  82230. * Clones the current color curve instance.
  82231. * @return The cloned curves
  82232. */
  82233. clone(): ColorCurves;
  82234. /**
  82235. * Serializes the current color curve instance to a json representation.
  82236. * @return a JSON representation
  82237. */
  82238. serialize(): any;
  82239. /**
  82240. * Parses the color curve from a json representation.
  82241. * @param source the JSON source to parse
  82242. * @return The parsed curves
  82243. */
  82244. static Parse(source: any): ColorCurves;
  82245. }
  82246. }
  82247. declare module BABYLON {
  82248. /**
  82249. * Interface to follow in your material defines to integrate easily the
  82250. * Image proccessing functions.
  82251. * @hidden
  82252. */
  82253. export interface IImageProcessingConfigurationDefines {
  82254. IMAGEPROCESSING: boolean;
  82255. VIGNETTE: boolean;
  82256. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82257. VIGNETTEBLENDMODEOPAQUE: boolean;
  82258. TONEMAPPING: boolean;
  82259. TONEMAPPING_ACES: boolean;
  82260. CONTRAST: boolean;
  82261. EXPOSURE: boolean;
  82262. COLORCURVES: boolean;
  82263. COLORGRADING: boolean;
  82264. COLORGRADING3D: boolean;
  82265. SAMPLER3DGREENDEPTH: boolean;
  82266. SAMPLER3DBGRMAP: boolean;
  82267. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82268. }
  82269. /**
  82270. * @hidden
  82271. */
  82272. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  82273. IMAGEPROCESSING: boolean;
  82274. VIGNETTE: boolean;
  82275. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82276. VIGNETTEBLENDMODEOPAQUE: boolean;
  82277. TONEMAPPING: boolean;
  82278. TONEMAPPING_ACES: boolean;
  82279. CONTRAST: boolean;
  82280. COLORCURVES: boolean;
  82281. COLORGRADING: boolean;
  82282. COLORGRADING3D: boolean;
  82283. SAMPLER3DGREENDEPTH: boolean;
  82284. SAMPLER3DBGRMAP: boolean;
  82285. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82286. EXPOSURE: boolean;
  82287. constructor();
  82288. }
  82289. /**
  82290. * This groups together the common properties used for image processing either in direct forward pass
  82291. * or through post processing effect depending on the use of the image processing pipeline in your scene
  82292. * or not.
  82293. */
  82294. export class ImageProcessingConfiguration {
  82295. /**
  82296. * Default tone mapping applied in BabylonJS.
  82297. */
  82298. static readonly TONEMAPPING_STANDARD: number;
  82299. /**
  82300. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  82301. * to other engines rendering to increase portability.
  82302. */
  82303. static readonly TONEMAPPING_ACES: number;
  82304. /**
  82305. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  82306. */
  82307. colorCurves: Nullable<ColorCurves>;
  82308. private _colorCurvesEnabled;
  82309. /**
  82310. * Gets wether the color curves effect is enabled.
  82311. */
  82312. get colorCurvesEnabled(): boolean;
  82313. /**
  82314. * Sets wether the color curves effect is enabled.
  82315. */
  82316. set colorCurvesEnabled(value: boolean);
  82317. private _colorGradingTexture;
  82318. /**
  82319. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82320. */
  82321. get colorGradingTexture(): Nullable<BaseTexture>;
  82322. /**
  82323. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82324. */
  82325. set colorGradingTexture(value: Nullable<BaseTexture>);
  82326. private _colorGradingEnabled;
  82327. /**
  82328. * Gets wether the color grading effect is enabled.
  82329. */
  82330. get colorGradingEnabled(): boolean;
  82331. /**
  82332. * Sets wether the color grading effect is enabled.
  82333. */
  82334. set colorGradingEnabled(value: boolean);
  82335. private _colorGradingWithGreenDepth;
  82336. /**
  82337. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  82338. */
  82339. get colorGradingWithGreenDepth(): boolean;
  82340. /**
  82341. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  82342. */
  82343. set colorGradingWithGreenDepth(value: boolean);
  82344. private _colorGradingBGR;
  82345. /**
  82346. * Gets wether the color grading texture contains BGR values.
  82347. */
  82348. get colorGradingBGR(): boolean;
  82349. /**
  82350. * Sets wether the color grading texture contains BGR values.
  82351. */
  82352. set colorGradingBGR(value: boolean);
  82353. /** @hidden */
  82354. _exposure: number;
  82355. /**
  82356. * Gets the Exposure used in the effect.
  82357. */
  82358. get exposure(): number;
  82359. /**
  82360. * Sets the Exposure used in the effect.
  82361. */
  82362. set exposure(value: number);
  82363. private _toneMappingEnabled;
  82364. /**
  82365. * Gets wether the tone mapping effect is enabled.
  82366. */
  82367. get toneMappingEnabled(): boolean;
  82368. /**
  82369. * Sets wether the tone mapping effect is enabled.
  82370. */
  82371. set toneMappingEnabled(value: boolean);
  82372. private _toneMappingType;
  82373. /**
  82374. * Gets the type of tone mapping effect.
  82375. */
  82376. get toneMappingType(): number;
  82377. /**
  82378. * Sets the type of tone mapping effect used in BabylonJS.
  82379. */
  82380. set toneMappingType(value: number);
  82381. protected _contrast: number;
  82382. /**
  82383. * Gets the contrast used in the effect.
  82384. */
  82385. get contrast(): number;
  82386. /**
  82387. * Sets the contrast used in the effect.
  82388. */
  82389. set contrast(value: number);
  82390. /**
  82391. * Vignette stretch size.
  82392. */
  82393. vignetteStretch: number;
  82394. /**
  82395. * Vignette centre X Offset.
  82396. */
  82397. vignetteCentreX: number;
  82398. /**
  82399. * Vignette centre Y Offset.
  82400. */
  82401. vignetteCentreY: number;
  82402. /**
  82403. * Vignette weight or intensity of the vignette effect.
  82404. */
  82405. vignetteWeight: number;
  82406. /**
  82407. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  82408. * if vignetteEnabled is set to true.
  82409. */
  82410. vignetteColor: Color4;
  82411. /**
  82412. * Camera field of view used by the Vignette effect.
  82413. */
  82414. vignetteCameraFov: number;
  82415. private _vignetteBlendMode;
  82416. /**
  82417. * Gets the vignette blend mode allowing different kind of effect.
  82418. */
  82419. get vignetteBlendMode(): number;
  82420. /**
  82421. * Sets the vignette blend mode allowing different kind of effect.
  82422. */
  82423. set vignetteBlendMode(value: number);
  82424. private _vignetteEnabled;
  82425. /**
  82426. * Gets wether the vignette effect is enabled.
  82427. */
  82428. get vignetteEnabled(): boolean;
  82429. /**
  82430. * Sets wether the vignette effect is enabled.
  82431. */
  82432. set vignetteEnabled(value: boolean);
  82433. private _applyByPostProcess;
  82434. /**
  82435. * Gets wether the image processing is applied through a post process or not.
  82436. */
  82437. get applyByPostProcess(): boolean;
  82438. /**
  82439. * Sets wether the image processing is applied through a post process or not.
  82440. */
  82441. set applyByPostProcess(value: boolean);
  82442. private _isEnabled;
  82443. /**
  82444. * Gets wether the image processing is enabled or not.
  82445. */
  82446. get isEnabled(): boolean;
  82447. /**
  82448. * Sets wether the image processing is enabled or not.
  82449. */
  82450. set isEnabled(value: boolean);
  82451. /**
  82452. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  82453. */
  82454. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  82455. /**
  82456. * Method called each time the image processing information changes requires to recompile the effect.
  82457. */
  82458. protected _updateParameters(): void;
  82459. /**
  82460. * Gets the current class name.
  82461. * @return "ImageProcessingConfiguration"
  82462. */
  82463. getClassName(): string;
  82464. /**
  82465. * Prepare the list of uniforms associated with the Image Processing effects.
  82466. * @param uniforms The list of uniforms used in the effect
  82467. * @param defines the list of defines currently in use
  82468. */
  82469. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  82470. /**
  82471. * Prepare the list of samplers associated with the Image Processing effects.
  82472. * @param samplersList The list of uniforms used in the effect
  82473. * @param defines the list of defines currently in use
  82474. */
  82475. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  82476. /**
  82477. * Prepare the list of defines associated to the shader.
  82478. * @param defines the list of defines to complete
  82479. * @param forPostProcess Define if we are currently in post process mode or not
  82480. */
  82481. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  82482. /**
  82483. * Returns true if all the image processing information are ready.
  82484. * @returns True if ready, otherwise, false
  82485. */
  82486. isReady(): boolean;
  82487. /**
  82488. * Binds the image processing to the shader.
  82489. * @param effect The effect to bind to
  82490. * @param overrideAspectRatio Override the aspect ratio of the effect
  82491. */
  82492. bind(effect: Effect, overrideAspectRatio?: number): void;
  82493. /**
  82494. * Clones the current image processing instance.
  82495. * @return The cloned image processing
  82496. */
  82497. clone(): ImageProcessingConfiguration;
  82498. /**
  82499. * Serializes the current image processing instance to a json representation.
  82500. * @return a JSON representation
  82501. */
  82502. serialize(): any;
  82503. /**
  82504. * Parses the image processing from a json representation.
  82505. * @param source the JSON source to parse
  82506. * @return The parsed image processing
  82507. */
  82508. static Parse(source: any): ImageProcessingConfiguration;
  82509. private static _VIGNETTEMODE_MULTIPLY;
  82510. private static _VIGNETTEMODE_OPAQUE;
  82511. /**
  82512. * Used to apply the vignette as a mix with the pixel color.
  82513. */
  82514. static get VIGNETTEMODE_MULTIPLY(): number;
  82515. /**
  82516. * Used to apply the vignette as a replacement of the pixel color.
  82517. */
  82518. static get VIGNETTEMODE_OPAQUE(): number;
  82519. }
  82520. }
  82521. declare module BABYLON {
  82522. /** @hidden */
  82523. export var postprocessVertexShader: {
  82524. name: string;
  82525. shader: string;
  82526. };
  82527. }
  82528. declare module BABYLON {
  82529. interface ThinEngine {
  82530. /**
  82531. * Creates a new render target texture
  82532. * @param size defines the size of the texture
  82533. * @param options defines the options used to create the texture
  82534. * @returns a new render target texture stored in an InternalTexture
  82535. */
  82536. createRenderTargetTexture(size: number | {
  82537. width: number;
  82538. height: number;
  82539. layers?: number;
  82540. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82541. /**
  82542. * Creates a depth stencil texture.
  82543. * This is only available in WebGL 2 or with the depth texture extension available.
  82544. * @param size The size of face edge in the texture.
  82545. * @param options The options defining the texture.
  82546. * @returns The texture
  82547. */
  82548. createDepthStencilTexture(size: number | {
  82549. width: number;
  82550. height: number;
  82551. layers?: number;
  82552. }, options: DepthTextureCreationOptions): InternalTexture;
  82553. /** @hidden */
  82554. _createDepthStencilTexture(size: number | {
  82555. width: number;
  82556. height: number;
  82557. layers?: number;
  82558. }, options: DepthTextureCreationOptions): InternalTexture;
  82559. }
  82560. }
  82561. declare module BABYLON {
  82562. /** Defines supported spaces */
  82563. export enum Space {
  82564. /** Local (object) space */
  82565. LOCAL = 0,
  82566. /** World space */
  82567. WORLD = 1,
  82568. /** Bone space */
  82569. BONE = 2
  82570. }
  82571. /** Defines the 3 main axes */
  82572. export class Axis {
  82573. /** X axis */
  82574. static X: Vector3;
  82575. /** Y axis */
  82576. static Y: Vector3;
  82577. /** Z axis */
  82578. static Z: Vector3;
  82579. }
  82580. }
  82581. declare module BABYLON {
  82582. /**
  82583. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82584. * This is the base of the follow, arc rotate cameras and Free camera
  82585. * @see http://doc.babylonjs.com/features/cameras
  82586. */
  82587. export class TargetCamera extends Camera {
  82588. private static _RigCamTransformMatrix;
  82589. private static _TargetTransformMatrix;
  82590. private static _TargetFocalPoint;
  82591. /**
  82592. * Define the current direction the camera is moving to
  82593. */
  82594. cameraDirection: Vector3;
  82595. /**
  82596. * Define the current rotation the camera is rotating to
  82597. */
  82598. cameraRotation: Vector2;
  82599. /**
  82600. * When set, the up vector of the camera will be updated by the rotation of the camera
  82601. */
  82602. updateUpVectorFromRotation: boolean;
  82603. private _tmpQuaternion;
  82604. /**
  82605. * Define the current rotation of the camera
  82606. */
  82607. rotation: Vector3;
  82608. /**
  82609. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82610. */
  82611. rotationQuaternion: Quaternion;
  82612. /**
  82613. * Define the current speed of the camera
  82614. */
  82615. speed: number;
  82616. /**
  82617. * Add constraint to the camera to prevent it to move freely in all directions and
  82618. * around all axis.
  82619. */
  82620. noRotationConstraint: boolean;
  82621. /**
  82622. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82623. * panning
  82624. */
  82625. invertRotation: boolean;
  82626. /**
  82627. * Speed multiplier for inverse camera panning
  82628. */
  82629. inverseRotationSpeed: number;
  82630. /**
  82631. * Define the current target of the camera as an object or a position.
  82632. */
  82633. lockedTarget: any;
  82634. /** @hidden */
  82635. _currentTarget: Vector3;
  82636. /** @hidden */
  82637. _initialFocalDistance: number;
  82638. /** @hidden */
  82639. _viewMatrix: Matrix;
  82640. /** @hidden */
  82641. _camMatrix: Matrix;
  82642. /** @hidden */
  82643. _cameraTransformMatrix: Matrix;
  82644. /** @hidden */
  82645. _cameraRotationMatrix: Matrix;
  82646. /** @hidden */
  82647. _referencePoint: Vector3;
  82648. /** @hidden */
  82649. _transformedReferencePoint: Vector3;
  82650. protected _globalCurrentTarget: Vector3;
  82651. protected _globalCurrentUpVector: Vector3;
  82652. /** @hidden */
  82653. _reset: () => void;
  82654. private _defaultUp;
  82655. /**
  82656. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82657. * This is the base of the follow, arc rotate cameras and Free camera
  82658. * @see http://doc.babylonjs.com/features/cameras
  82659. * @param name Defines the name of the camera in the scene
  82660. * @param position Defines the start position of the camera in the scene
  82661. * @param scene Defines the scene the camera belongs to
  82662. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82663. */
  82664. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82665. /**
  82666. * Gets the position in front of the camera at a given distance.
  82667. * @param distance The distance from the camera we want the position to be
  82668. * @returns the position
  82669. */
  82670. getFrontPosition(distance: number): Vector3;
  82671. /** @hidden */
  82672. _getLockedTargetPosition(): Nullable<Vector3>;
  82673. private _storedPosition;
  82674. private _storedRotation;
  82675. private _storedRotationQuaternion;
  82676. /**
  82677. * Store current camera state of the camera (fov, position, rotation, etc..)
  82678. * @returns the camera
  82679. */
  82680. storeState(): Camera;
  82681. /**
  82682. * Restored camera state. You must call storeState() first
  82683. * @returns whether it was successful or not
  82684. * @hidden
  82685. */
  82686. _restoreStateValues(): boolean;
  82687. /** @hidden */
  82688. _initCache(): void;
  82689. /** @hidden */
  82690. _updateCache(ignoreParentClass?: boolean): void;
  82691. /** @hidden */
  82692. _isSynchronizedViewMatrix(): boolean;
  82693. /** @hidden */
  82694. _computeLocalCameraSpeed(): number;
  82695. /**
  82696. * Defines the target the camera should look at.
  82697. * @param target Defines the new target as a Vector or a mesh
  82698. */
  82699. setTarget(target: Vector3): void;
  82700. /**
  82701. * Return the current target position of the camera. This value is expressed in local space.
  82702. * @returns the target position
  82703. */
  82704. getTarget(): Vector3;
  82705. /** @hidden */
  82706. _decideIfNeedsToMove(): boolean;
  82707. /** @hidden */
  82708. _updatePosition(): void;
  82709. /** @hidden */
  82710. _checkInputs(): void;
  82711. protected _updateCameraRotationMatrix(): void;
  82712. /**
  82713. * 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)
  82714. * @returns the current camera
  82715. */
  82716. private _rotateUpVectorWithCameraRotationMatrix;
  82717. private _cachedRotationZ;
  82718. private _cachedQuaternionRotationZ;
  82719. /** @hidden */
  82720. _getViewMatrix(): Matrix;
  82721. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82722. /**
  82723. * @hidden
  82724. */
  82725. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82726. /**
  82727. * @hidden
  82728. */
  82729. _updateRigCameras(): void;
  82730. private _getRigCamPositionAndTarget;
  82731. /**
  82732. * Gets the current object class name.
  82733. * @return the class name
  82734. */
  82735. getClassName(): string;
  82736. }
  82737. }
  82738. declare module BABYLON {
  82739. /**
  82740. * Gather the list of keyboard event types as constants.
  82741. */
  82742. export class KeyboardEventTypes {
  82743. /**
  82744. * The keydown event is fired when a key becomes active (pressed).
  82745. */
  82746. static readonly KEYDOWN: number;
  82747. /**
  82748. * The keyup event is fired when a key has been released.
  82749. */
  82750. static readonly KEYUP: number;
  82751. }
  82752. /**
  82753. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82754. */
  82755. export class KeyboardInfo {
  82756. /**
  82757. * Defines the type of event (KeyboardEventTypes)
  82758. */
  82759. type: number;
  82760. /**
  82761. * Defines the related dom event
  82762. */
  82763. event: KeyboardEvent;
  82764. /**
  82765. * Instantiates a new keyboard info.
  82766. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82767. * @param type Defines the type of event (KeyboardEventTypes)
  82768. * @param event Defines the related dom event
  82769. */
  82770. constructor(
  82771. /**
  82772. * Defines the type of event (KeyboardEventTypes)
  82773. */
  82774. type: number,
  82775. /**
  82776. * Defines the related dom event
  82777. */
  82778. event: KeyboardEvent);
  82779. }
  82780. /**
  82781. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82782. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82783. */
  82784. export class KeyboardInfoPre extends KeyboardInfo {
  82785. /**
  82786. * Defines the type of event (KeyboardEventTypes)
  82787. */
  82788. type: number;
  82789. /**
  82790. * Defines the related dom event
  82791. */
  82792. event: KeyboardEvent;
  82793. /**
  82794. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82795. */
  82796. skipOnPointerObservable: boolean;
  82797. /**
  82798. * Instantiates a new keyboard pre info.
  82799. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82800. * @param type Defines the type of event (KeyboardEventTypes)
  82801. * @param event Defines the related dom event
  82802. */
  82803. constructor(
  82804. /**
  82805. * Defines the type of event (KeyboardEventTypes)
  82806. */
  82807. type: number,
  82808. /**
  82809. * Defines the related dom event
  82810. */
  82811. event: KeyboardEvent);
  82812. }
  82813. }
  82814. declare module BABYLON {
  82815. /**
  82816. * Manage the keyboard inputs to control the movement of a free camera.
  82817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82818. */
  82819. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82820. /**
  82821. * Defines the camera the input is attached to.
  82822. */
  82823. camera: FreeCamera;
  82824. /**
  82825. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82826. */
  82827. keysUp: number[];
  82828. /**
  82829. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  82830. */
  82831. keysUpward: number[];
  82832. /**
  82833. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82834. */
  82835. keysDown: number[];
  82836. /**
  82837. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  82838. */
  82839. keysDownward: number[];
  82840. /**
  82841. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82842. */
  82843. keysLeft: number[];
  82844. /**
  82845. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82846. */
  82847. keysRight: number[];
  82848. private _keys;
  82849. private _onCanvasBlurObserver;
  82850. private _onKeyboardObserver;
  82851. private _engine;
  82852. private _scene;
  82853. /**
  82854. * Attach the input controls to a specific dom element to get the input from.
  82855. * @param element Defines the element the controls should be listened from
  82856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82857. */
  82858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82859. /**
  82860. * Detach the current controls from the specified dom element.
  82861. * @param element Defines the element to stop listening the inputs from
  82862. */
  82863. detachControl(element: Nullable<HTMLElement>): void;
  82864. /**
  82865. * Update the current camera state depending on the inputs that have been used this frame.
  82866. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82867. */
  82868. checkInputs(): void;
  82869. /**
  82870. * Gets the class name of the current intput.
  82871. * @returns the class name
  82872. */
  82873. getClassName(): string;
  82874. /** @hidden */
  82875. _onLostFocus(): void;
  82876. /**
  82877. * Get the friendly name associated with the input class.
  82878. * @returns the input friendly name
  82879. */
  82880. getSimpleName(): string;
  82881. }
  82882. }
  82883. declare module BABYLON {
  82884. /**
  82885. * Interface describing all the common properties and methods a shadow light needs to implement.
  82886. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82887. * as well as binding the different shadow properties to the effects.
  82888. */
  82889. export interface IShadowLight extends Light {
  82890. /**
  82891. * The light id in the scene (used in scene.findLighById for instance)
  82892. */
  82893. id: string;
  82894. /**
  82895. * The position the shdow will be casted from.
  82896. */
  82897. position: Vector3;
  82898. /**
  82899. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82900. */
  82901. direction: Vector3;
  82902. /**
  82903. * The transformed position. Position of the light in world space taking parenting in account.
  82904. */
  82905. transformedPosition: Vector3;
  82906. /**
  82907. * The transformed direction. Direction of the light in world space taking parenting in account.
  82908. */
  82909. transformedDirection: Vector3;
  82910. /**
  82911. * The friendly name of the light in the scene.
  82912. */
  82913. name: string;
  82914. /**
  82915. * Defines the shadow projection clipping minimum z value.
  82916. */
  82917. shadowMinZ: number;
  82918. /**
  82919. * Defines the shadow projection clipping maximum z value.
  82920. */
  82921. shadowMaxZ: number;
  82922. /**
  82923. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82924. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82925. */
  82926. computeTransformedInformation(): boolean;
  82927. /**
  82928. * Gets the scene the light belongs to.
  82929. * @returns The scene
  82930. */
  82931. getScene(): Scene;
  82932. /**
  82933. * Callback defining a custom Projection Matrix Builder.
  82934. * This can be used to override the default projection matrix computation.
  82935. */
  82936. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82937. /**
  82938. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82939. * @param matrix The materix to updated with the projection information
  82940. * @param viewMatrix The transform matrix of the light
  82941. * @param renderList The list of mesh to render in the map
  82942. * @returns The current light
  82943. */
  82944. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82945. /**
  82946. * Gets the current depth scale used in ESM.
  82947. * @returns The scale
  82948. */
  82949. getDepthScale(): number;
  82950. /**
  82951. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82952. * @returns true if a cube texture needs to be use
  82953. */
  82954. needCube(): boolean;
  82955. /**
  82956. * Detects if the projection matrix requires to be recomputed this frame.
  82957. * @returns true if it requires to be recomputed otherwise, false.
  82958. */
  82959. needProjectionMatrixCompute(): boolean;
  82960. /**
  82961. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82962. */
  82963. forceProjectionMatrixCompute(): void;
  82964. /**
  82965. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82966. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82967. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82968. */
  82969. getShadowDirection(faceIndex?: number): Vector3;
  82970. /**
  82971. * Gets the minZ used for shadow according to both the scene and the light.
  82972. * @param activeCamera The camera we are returning the min for
  82973. * @returns the depth min z
  82974. */
  82975. getDepthMinZ(activeCamera: Camera): number;
  82976. /**
  82977. * Gets the maxZ used for shadow according to both the scene and the light.
  82978. * @param activeCamera The camera we are returning the max for
  82979. * @returns the depth max z
  82980. */
  82981. getDepthMaxZ(activeCamera: Camera): number;
  82982. }
  82983. /**
  82984. * Base implementation IShadowLight
  82985. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82986. */
  82987. export abstract class ShadowLight extends Light implements IShadowLight {
  82988. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82989. protected _position: Vector3;
  82990. protected _setPosition(value: Vector3): void;
  82991. /**
  82992. * Sets the position the shadow will be casted from. Also use as the light position for both
  82993. * point and spot lights.
  82994. */
  82995. get position(): Vector3;
  82996. /**
  82997. * Sets the position the shadow will be casted from. Also use as the light position for both
  82998. * point and spot lights.
  82999. */
  83000. set position(value: Vector3);
  83001. protected _direction: Vector3;
  83002. protected _setDirection(value: Vector3): void;
  83003. /**
  83004. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  83005. * Also use as the light direction on spot and directional lights.
  83006. */
  83007. get direction(): Vector3;
  83008. /**
  83009. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  83010. * Also use as the light direction on spot and directional lights.
  83011. */
  83012. set direction(value: Vector3);
  83013. protected _shadowMinZ: number;
  83014. /**
  83015. * Gets the shadow projection clipping minimum z value.
  83016. */
  83017. get shadowMinZ(): number;
  83018. /**
  83019. * Sets the shadow projection clipping minimum z value.
  83020. */
  83021. set shadowMinZ(value: number);
  83022. protected _shadowMaxZ: number;
  83023. /**
  83024. * Sets the shadow projection clipping maximum z value.
  83025. */
  83026. get shadowMaxZ(): number;
  83027. /**
  83028. * Gets the shadow projection clipping maximum z value.
  83029. */
  83030. set shadowMaxZ(value: number);
  83031. /**
  83032. * Callback defining a custom Projection Matrix Builder.
  83033. * This can be used to override the default projection matrix computation.
  83034. */
  83035. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83036. /**
  83037. * The transformed position. Position of the light in world space taking parenting in account.
  83038. */
  83039. transformedPosition: Vector3;
  83040. /**
  83041. * The transformed direction. Direction of the light in world space taking parenting in account.
  83042. */
  83043. transformedDirection: Vector3;
  83044. private _needProjectionMatrixCompute;
  83045. /**
  83046. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83047. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83048. */
  83049. computeTransformedInformation(): boolean;
  83050. /**
  83051. * Return the depth scale used for the shadow map.
  83052. * @returns the depth scale.
  83053. */
  83054. getDepthScale(): number;
  83055. /**
  83056. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83057. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83058. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83059. */
  83060. getShadowDirection(faceIndex?: number): Vector3;
  83061. /**
  83062. * Returns the ShadowLight absolute position in the World.
  83063. * @returns the position vector in world space
  83064. */
  83065. getAbsolutePosition(): Vector3;
  83066. /**
  83067. * Sets the ShadowLight direction toward the passed target.
  83068. * @param target The point to target in local space
  83069. * @returns the updated ShadowLight direction
  83070. */
  83071. setDirectionToTarget(target: Vector3): Vector3;
  83072. /**
  83073. * Returns the light rotation in euler definition.
  83074. * @returns the x y z rotation in local space.
  83075. */
  83076. getRotation(): Vector3;
  83077. /**
  83078. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83079. * @returns true if a cube texture needs to be use
  83080. */
  83081. needCube(): boolean;
  83082. /**
  83083. * Detects if the projection matrix requires to be recomputed this frame.
  83084. * @returns true if it requires to be recomputed otherwise, false.
  83085. */
  83086. needProjectionMatrixCompute(): boolean;
  83087. /**
  83088. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83089. */
  83090. forceProjectionMatrixCompute(): void;
  83091. /** @hidden */
  83092. _initCache(): void;
  83093. /** @hidden */
  83094. _isSynchronized(): boolean;
  83095. /**
  83096. * Computes the world matrix of the node
  83097. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83098. * @returns the world matrix
  83099. */
  83100. computeWorldMatrix(force?: boolean): Matrix;
  83101. /**
  83102. * Gets the minZ used for shadow according to both the scene and the light.
  83103. * @param activeCamera The camera we are returning the min for
  83104. * @returns the depth min z
  83105. */
  83106. getDepthMinZ(activeCamera: Camera): number;
  83107. /**
  83108. * Gets the maxZ used for shadow according to both the scene and the light.
  83109. * @param activeCamera The camera we are returning the max for
  83110. * @returns the depth max z
  83111. */
  83112. getDepthMaxZ(activeCamera: Camera): number;
  83113. /**
  83114. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83115. * @param matrix The materix to updated with the projection information
  83116. * @param viewMatrix The transform matrix of the light
  83117. * @param renderList The list of mesh to render in the map
  83118. * @returns The current light
  83119. */
  83120. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83121. }
  83122. }
  83123. declare module BABYLON {
  83124. /**
  83125. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  83126. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  83127. */
  83128. export class EffectFallbacks implements IEffectFallbacks {
  83129. private _defines;
  83130. private _currentRank;
  83131. private _maxRank;
  83132. private _mesh;
  83133. /**
  83134. * Removes the fallback from the bound mesh.
  83135. */
  83136. unBindMesh(): void;
  83137. /**
  83138. * Adds a fallback on the specified property.
  83139. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83140. * @param define The name of the define in the shader
  83141. */
  83142. addFallback(rank: number, define: string): void;
  83143. /**
  83144. * Sets the mesh to use CPU skinning when needing to fallback.
  83145. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83146. * @param mesh The mesh to use the fallbacks.
  83147. */
  83148. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  83149. /**
  83150. * Checks to see if more fallbacks are still availible.
  83151. */
  83152. get hasMoreFallbacks(): boolean;
  83153. /**
  83154. * Removes the defines that should be removed when falling back.
  83155. * @param currentDefines defines the current define statements for the shader.
  83156. * @param effect defines the current effect we try to compile
  83157. * @returns The resulting defines with defines of the current rank removed.
  83158. */
  83159. reduce(currentDefines: string, effect: Effect): string;
  83160. }
  83161. }
  83162. declare module BABYLON {
  83163. /**
  83164. * "Static Class" containing the most commonly used helper while dealing with material for
  83165. * rendering purpose.
  83166. *
  83167. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  83168. *
  83169. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  83170. */
  83171. export class MaterialHelper {
  83172. /**
  83173. * Bind the current view position to an effect.
  83174. * @param effect The effect to be bound
  83175. * @param scene The scene the eyes position is used from
  83176. */
  83177. static BindEyePosition(effect: Effect, scene: Scene): void;
  83178. /**
  83179. * Helps preparing the defines values about the UVs in used in the effect.
  83180. * UVs are shared as much as we can accross channels in the shaders.
  83181. * @param texture The texture we are preparing the UVs for
  83182. * @param defines The defines to update
  83183. * @param key The channel key "diffuse", "specular"... used in the shader
  83184. */
  83185. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  83186. /**
  83187. * Binds a texture matrix value to its corrsponding uniform
  83188. * @param texture The texture to bind the matrix for
  83189. * @param uniformBuffer The uniform buffer receivin the data
  83190. * @param key The channel key "diffuse", "specular"... used in the shader
  83191. */
  83192. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  83193. /**
  83194. * Gets the current status of the fog (should it be enabled?)
  83195. * @param mesh defines the mesh to evaluate for fog support
  83196. * @param scene defines the hosting scene
  83197. * @returns true if fog must be enabled
  83198. */
  83199. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  83200. /**
  83201. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  83202. * @param mesh defines the current mesh
  83203. * @param scene defines the current scene
  83204. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  83205. * @param pointsCloud defines if point cloud rendering has to be turned on
  83206. * @param fogEnabled defines if fog has to be turned on
  83207. * @param alphaTest defines if alpha testing has to be turned on
  83208. * @param defines defines the current list of defines
  83209. */
  83210. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  83211. /**
  83212. * Helper used to prepare the list of defines associated with frame values for shader compilation
  83213. * @param scene defines the current scene
  83214. * @param engine defines the current engine
  83215. * @param defines specifies the list of active defines
  83216. * @param useInstances defines if instances have to be turned on
  83217. * @param useClipPlane defines if clip plane have to be turned on
  83218. */
  83219. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  83220. /**
  83221. * Prepares the defines for bones
  83222. * @param mesh The mesh containing the geometry data we will draw
  83223. * @param defines The defines to update
  83224. */
  83225. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  83226. /**
  83227. * Prepares the defines for morph targets
  83228. * @param mesh The mesh containing the geometry data we will draw
  83229. * @param defines The defines to update
  83230. */
  83231. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  83232. /**
  83233. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  83234. * @param mesh The mesh containing the geometry data we will draw
  83235. * @param defines The defines to update
  83236. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  83237. * @param useBones Precise whether bones should be used or not (override mesh info)
  83238. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  83239. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  83240. * @returns false if defines are considered not dirty and have not been checked
  83241. */
  83242. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  83243. /**
  83244. * Prepares the defines related to multiview
  83245. * @param scene The scene we are intending to draw
  83246. * @param defines The defines to update
  83247. */
  83248. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  83249. /**
  83250. * Prepares the defines related to the light information passed in parameter
  83251. * @param scene The scene we are intending to draw
  83252. * @param mesh The mesh the effect is compiling for
  83253. * @param light The light the effect is compiling for
  83254. * @param lightIndex The index of the light
  83255. * @param defines The defines to update
  83256. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83257. * @param state Defines the current state regarding what is needed (normals, etc...)
  83258. */
  83259. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  83260. needNormals: boolean;
  83261. needRebuild: boolean;
  83262. shadowEnabled: boolean;
  83263. specularEnabled: boolean;
  83264. lightmapMode: boolean;
  83265. }): void;
  83266. /**
  83267. * Prepares the defines related to the light information passed in parameter
  83268. * @param scene The scene we are intending to draw
  83269. * @param mesh The mesh the effect is compiling for
  83270. * @param defines The defines to update
  83271. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83272. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  83273. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  83274. * @returns true if normals will be required for the rest of the effect
  83275. */
  83276. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  83277. /**
  83278. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  83279. * @param lightIndex defines the light index
  83280. * @param uniformsList The uniform list
  83281. * @param samplersList The sampler list
  83282. * @param projectedLightTexture defines if projected texture must be used
  83283. * @param uniformBuffersList defines an optional list of uniform buffers
  83284. */
  83285. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  83286. /**
  83287. * Prepares the uniforms and samplers list to be used in the effect
  83288. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  83289. * @param samplersList The sampler list
  83290. * @param defines The defines helping in the list generation
  83291. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  83292. */
  83293. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  83294. /**
  83295. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  83296. * @param defines The defines to update while falling back
  83297. * @param fallbacks The authorized effect fallbacks
  83298. * @param maxSimultaneousLights The maximum number of lights allowed
  83299. * @param rank the current rank of the Effect
  83300. * @returns The newly affected rank
  83301. */
  83302. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  83303. private static _TmpMorphInfluencers;
  83304. /**
  83305. * Prepares the list of attributes required for morph targets according to the effect defines.
  83306. * @param attribs The current list of supported attribs
  83307. * @param mesh The mesh to prepare the morph targets attributes for
  83308. * @param influencers The number of influencers
  83309. */
  83310. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  83311. /**
  83312. * Prepares the list of attributes required for morph targets according to the effect defines.
  83313. * @param attribs The current list of supported attribs
  83314. * @param mesh The mesh to prepare the morph targets attributes for
  83315. * @param defines The current Defines of the effect
  83316. */
  83317. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  83318. /**
  83319. * Prepares the list of attributes required for bones according to the effect defines.
  83320. * @param attribs The current list of supported attribs
  83321. * @param mesh The mesh to prepare the bones attributes for
  83322. * @param defines The current Defines of the effect
  83323. * @param fallbacks The current efffect fallback strategy
  83324. */
  83325. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  83326. /**
  83327. * Check and prepare the list of attributes required for instances according to the effect defines.
  83328. * @param attribs The current list of supported attribs
  83329. * @param defines The current MaterialDefines of the effect
  83330. */
  83331. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  83332. /**
  83333. * Add the list of attributes required for instances to the attribs array.
  83334. * @param attribs The current list of supported attribs
  83335. */
  83336. static PushAttributesForInstances(attribs: string[]): void;
  83337. /**
  83338. * Binds the light information to the effect.
  83339. * @param light The light containing the generator
  83340. * @param effect The effect we are binding the data to
  83341. * @param lightIndex The light index in the effect used to render
  83342. */
  83343. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  83344. /**
  83345. * Binds the lights information from the scene to the effect for the given mesh.
  83346. * @param light Light to bind
  83347. * @param lightIndex Light index
  83348. * @param scene The scene where the light belongs to
  83349. * @param effect The effect we are binding the data to
  83350. * @param useSpecular Defines if specular is supported
  83351. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83352. */
  83353. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83354. /**
  83355. * Binds the lights information from the scene to the effect for the given mesh.
  83356. * @param scene The scene the lights belongs to
  83357. * @param mesh The mesh we are binding the information to render
  83358. * @param effect The effect we are binding the data to
  83359. * @param defines The generated defines for the effect
  83360. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  83361. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83362. */
  83363. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  83364. private static _tempFogColor;
  83365. /**
  83366. * Binds the fog information from the scene to the effect for the given mesh.
  83367. * @param scene The scene the lights belongs to
  83368. * @param mesh The mesh we are binding the information to render
  83369. * @param effect The effect we are binding the data to
  83370. * @param linearSpace Defines if the fog effect is applied in linear space
  83371. */
  83372. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  83373. /**
  83374. * Binds the bones information from the mesh to the effect.
  83375. * @param mesh The mesh we are binding the information to render
  83376. * @param effect The effect we are binding the data to
  83377. */
  83378. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  83379. /**
  83380. * Binds the morph targets information from the mesh to the effect.
  83381. * @param abstractMesh The mesh we are binding the information to render
  83382. * @param effect The effect we are binding the data to
  83383. */
  83384. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  83385. /**
  83386. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  83387. * @param defines The generated defines used in the effect
  83388. * @param effect The effect we are binding the data to
  83389. * @param scene The scene we are willing to render with logarithmic scale for
  83390. */
  83391. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  83392. /**
  83393. * Binds the clip plane information from the scene to the effect.
  83394. * @param scene The scene the clip plane information are extracted from
  83395. * @param effect The effect we are binding the data to
  83396. */
  83397. static BindClipPlane(effect: Effect, scene: Scene): void;
  83398. }
  83399. }
  83400. declare module BABYLON {
  83401. /** @hidden */
  83402. export var packingFunctions: {
  83403. name: string;
  83404. shader: string;
  83405. };
  83406. }
  83407. declare module BABYLON {
  83408. /** @hidden */
  83409. export var clipPlaneFragmentDeclaration: {
  83410. name: string;
  83411. shader: string;
  83412. };
  83413. }
  83414. declare module BABYLON {
  83415. /** @hidden */
  83416. export var clipPlaneFragment: {
  83417. name: string;
  83418. shader: string;
  83419. };
  83420. }
  83421. declare module BABYLON {
  83422. /** @hidden */
  83423. export var shadowMapPixelShader: {
  83424. name: string;
  83425. shader: string;
  83426. };
  83427. }
  83428. declare module BABYLON {
  83429. /** @hidden */
  83430. export var bonesDeclaration: {
  83431. name: string;
  83432. shader: string;
  83433. };
  83434. }
  83435. declare module BABYLON {
  83436. /** @hidden */
  83437. export var morphTargetsVertexGlobalDeclaration: {
  83438. name: string;
  83439. shader: string;
  83440. };
  83441. }
  83442. declare module BABYLON {
  83443. /** @hidden */
  83444. export var morphTargetsVertexDeclaration: {
  83445. name: string;
  83446. shader: string;
  83447. };
  83448. }
  83449. declare module BABYLON {
  83450. /** @hidden */
  83451. export var instancesDeclaration: {
  83452. name: string;
  83453. shader: string;
  83454. };
  83455. }
  83456. declare module BABYLON {
  83457. /** @hidden */
  83458. export var helperFunctions: {
  83459. name: string;
  83460. shader: string;
  83461. };
  83462. }
  83463. declare module BABYLON {
  83464. /** @hidden */
  83465. export var clipPlaneVertexDeclaration: {
  83466. name: string;
  83467. shader: string;
  83468. };
  83469. }
  83470. declare module BABYLON {
  83471. /** @hidden */
  83472. export var morphTargetsVertex: {
  83473. name: string;
  83474. shader: string;
  83475. };
  83476. }
  83477. declare module BABYLON {
  83478. /** @hidden */
  83479. export var instancesVertex: {
  83480. name: string;
  83481. shader: string;
  83482. };
  83483. }
  83484. declare module BABYLON {
  83485. /** @hidden */
  83486. export var bonesVertex: {
  83487. name: string;
  83488. shader: string;
  83489. };
  83490. }
  83491. declare module BABYLON {
  83492. /** @hidden */
  83493. export var clipPlaneVertex: {
  83494. name: string;
  83495. shader: string;
  83496. };
  83497. }
  83498. declare module BABYLON {
  83499. /** @hidden */
  83500. export var shadowMapVertexShader: {
  83501. name: string;
  83502. shader: string;
  83503. };
  83504. }
  83505. declare module BABYLON {
  83506. /** @hidden */
  83507. export var depthBoxBlurPixelShader: {
  83508. name: string;
  83509. shader: string;
  83510. };
  83511. }
  83512. declare module BABYLON {
  83513. /**
  83514. * Class representing a ray with position and direction
  83515. */
  83516. export class Ray {
  83517. /** origin point */
  83518. origin: Vector3;
  83519. /** direction */
  83520. direction: Vector3;
  83521. /** length of the ray */
  83522. length: number;
  83523. private static readonly TmpVector3;
  83524. private _tmpRay;
  83525. /**
  83526. * Creates a new ray
  83527. * @param origin origin point
  83528. * @param direction direction
  83529. * @param length length of the ray
  83530. */
  83531. constructor(
  83532. /** origin point */
  83533. origin: Vector3,
  83534. /** direction */
  83535. direction: Vector3,
  83536. /** length of the ray */
  83537. length?: number);
  83538. /**
  83539. * Checks if the ray intersects a box
  83540. * @param minimum bound of the box
  83541. * @param maximum bound of the box
  83542. * @param intersectionTreshold extra extend to be added to the box in all direction
  83543. * @returns if the box was hit
  83544. */
  83545. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83546. /**
  83547. * Checks if the ray intersects a box
  83548. * @param box the bounding box to check
  83549. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83550. * @returns if the box was hit
  83551. */
  83552. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83553. /**
  83554. * If the ray hits a sphere
  83555. * @param sphere the bounding sphere to check
  83556. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83557. * @returns true if it hits the sphere
  83558. */
  83559. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83560. /**
  83561. * If the ray hits a triange
  83562. * @param vertex0 triangle vertex
  83563. * @param vertex1 triangle vertex
  83564. * @param vertex2 triangle vertex
  83565. * @returns intersection information if hit
  83566. */
  83567. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83568. /**
  83569. * Checks if ray intersects a plane
  83570. * @param plane the plane to check
  83571. * @returns the distance away it was hit
  83572. */
  83573. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83574. /**
  83575. * Calculate the intercept of a ray on a given axis
  83576. * @param axis to check 'x' | 'y' | 'z'
  83577. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83578. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83579. */
  83580. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83581. /**
  83582. * Checks if ray intersects a mesh
  83583. * @param mesh the mesh to check
  83584. * @param fastCheck if only the bounding box should checked
  83585. * @returns picking info of the intersecton
  83586. */
  83587. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83588. /**
  83589. * Checks if ray intersects a mesh
  83590. * @param meshes the meshes to check
  83591. * @param fastCheck if only the bounding box should checked
  83592. * @param results array to store result in
  83593. * @returns Array of picking infos
  83594. */
  83595. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83596. private _comparePickingInfo;
  83597. private static smallnum;
  83598. private static rayl;
  83599. /**
  83600. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83601. * @param sega the first point of the segment to test the intersection against
  83602. * @param segb the second point of the segment to test the intersection against
  83603. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83604. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83605. */
  83606. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83607. /**
  83608. * Update the ray from viewport position
  83609. * @param x position
  83610. * @param y y position
  83611. * @param viewportWidth viewport width
  83612. * @param viewportHeight viewport height
  83613. * @param world world matrix
  83614. * @param view view matrix
  83615. * @param projection projection matrix
  83616. * @returns this ray updated
  83617. */
  83618. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83619. /**
  83620. * Creates a ray with origin and direction of 0,0,0
  83621. * @returns the new ray
  83622. */
  83623. static Zero(): Ray;
  83624. /**
  83625. * Creates a new ray from screen space and viewport
  83626. * @param x position
  83627. * @param y y position
  83628. * @param viewportWidth viewport width
  83629. * @param viewportHeight viewport height
  83630. * @param world world matrix
  83631. * @param view view matrix
  83632. * @param projection projection matrix
  83633. * @returns new ray
  83634. */
  83635. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83636. /**
  83637. * 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
  83638. * transformed to the given world matrix.
  83639. * @param origin The origin point
  83640. * @param end The end point
  83641. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83642. * @returns the new ray
  83643. */
  83644. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83645. /**
  83646. * Transforms a ray by a matrix
  83647. * @param ray ray to transform
  83648. * @param matrix matrix to apply
  83649. * @returns the resulting new ray
  83650. */
  83651. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83652. /**
  83653. * Transforms a ray by a matrix
  83654. * @param ray ray to transform
  83655. * @param matrix matrix to apply
  83656. * @param result ray to store result in
  83657. */
  83658. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83659. /**
  83660. * Unproject a ray from screen space to object space
  83661. * @param sourceX defines the screen space x coordinate to use
  83662. * @param sourceY defines the screen space y coordinate to use
  83663. * @param viewportWidth defines the current width of the viewport
  83664. * @param viewportHeight defines the current height of the viewport
  83665. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83666. * @param view defines the view matrix to use
  83667. * @param projection defines the projection matrix to use
  83668. */
  83669. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83670. }
  83671. /**
  83672. * Type used to define predicate used to select faces when a mesh intersection is detected
  83673. */
  83674. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83675. interface Scene {
  83676. /** @hidden */
  83677. _tempPickingRay: Nullable<Ray>;
  83678. /** @hidden */
  83679. _cachedRayForTransform: Ray;
  83680. /** @hidden */
  83681. _pickWithRayInverseMatrix: Matrix;
  83682. /** @hidden */
  83683. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83684. /** @hidden */
  83685. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83686. }
  83687. }
  83688. declare module BABYLON {
  83689. /**
  83690. * Groups all the scene component constants in one place to ease maintenance.
  83691. * @hidden
  83692. */
  83693. export class SceneComponentConstants {
  83694. static readonly NAME_EFFECTLAYER: string;
  83695. static readonly NAME_LAYER: string;
  83696. static readonly NAME_LENSFLARESYSTEM: string;
  83697. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83698. static readonly NAME_PARTICLESYSTEM: string;
  83699. static readonly NAME_GAMEPAD: string;
  83700. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83701. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83702. static readonly NAME_DEPTHRENDERER: string;
  83703. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83704. static readonly NAME_SPRITE: string;
  83705. static readonly NAME_OUTLINERENDERER: string;
  83706. static readonly NAME_PROCEDURALTEXTURE: string;
  83707. static readonly NAME_SHADOWGENERATOR: string;
  83708. static readonly NAME_OCTREE: string;
  83709. static readonly NAME_PHYSICSENGINE: string;
  83710. static readonly NAME_AUDIO: string;
  83711. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83712. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83713. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83714. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83715. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83716. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83717. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83718. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83719. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83720. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83721. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83722. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83723. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83724. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83725. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83726. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83727. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83728. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83729. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83730. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83731. static readonly STEP_AFTERRENDER_AUDIO: number;
  83732. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83733. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83734. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83735. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83736. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83737. static readonly STEP_POINTERMOVE_SPRITE: number;
  83738. static readonly STEP_POINTERDOWN_SPRITE: number;
  83739. static readonly STEP_POINTERUP_SPRITE: number;
  83740. }
  83741. /**
  83742. * This represents a scene component.
  83743. *
  83744. * This is used to decouple the dependency the scene is having on the different workloads like
  83745. * layers, post processes...
  83746. */
  83747. export interface ISceneComponent {
  83748. /**
  83749. * The name of the component. Each component must have a unique name.
  83750. */
  83751. name: string;
  83752. /**
  83753. * The scene the component belongs to.
  83754. */
  83755. scene: Scene;
  83756. /**
  83757. * Register the component to one instance of a scene.
  83758. */
  83759. register(): void;
  83760. /**
  83761. * Rebuilds the elements related to this component in case of
  83762. * context lost for instance.
  83763. */
  83764. rebuild(): void;
  83765. /**
  83766. * Disposes the component and the associated ressources.
  83767. */
  83768. dispose(): void;
  83769. }
  83770. /**
  83771. * This represents a SERIALIZABLE scene component.
  83772. *
  83773. * This extends Scene Component to add Serialization methods on top.
  83774. */
  83775. export interface ISceneSerializableComponent extends ISceneComponent {
  83776. /**
  83777. * Adds all the elements from the container to the scene
  83778. * @param container the container holding the elements
  83779. */
  83780. addFromContainer(container: AbstractScene): void;
  83781. /**
  83782. * Removes all the elements in the container from the scene
  83783. * @param container contains the elements to remove
  83784. * @param dispose if the removed element should be disposed (default: false)
  83785. */
  83786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83787. /**
  83788. * Serializes the component data to the specified json object
  83789. * @param serializationObject The object to serialize to
  83790. */
  83791. serialize(serializationObject: any): void;
  83792. }
  83793. /**
  83794. * Strong typing of a Mesh related stage step action
  83795. */
  83796. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83797. /**
  83798. * Strong typing of a Evaluate Sub Mesh related stage step action
  83799. */
  83800. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83801. /**
  83802. * Strong typing of a Active Mesh related stage step action
  83803. */
  83804. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83805. /**
  83806. * Strong typing of a Camera related stage step action
  83807. */
  83808. export type CameraStageAction = (camera: Camera) => void;
  83809. /**
  83810. * Strong typing of a Camera Frame buffer related stage step action
  83811. */
  83812. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83813. /**
  83814. * Strong typing of a Render Target related stage step action
  83815. */
  83816. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83817. /**
  83818. * Strong typing of a RenderingGroup related stage step action
  83819. */
  83820. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83821. /**
  83822. * Strong typing of a Mesh Render related stage step action
  83823. */
  83824. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83825. /**
  83826. * Strong typing of a simple stage step action
  83827. */
  83828. export type SimpleStageAction = () => void;
  83829. /**
  83830. * Strong typing of a render target action.
  83831. */
  83832. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83833. /**
  83834. * Strong typing of a pointer move action.
  83835. */
  83836. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83837. /**
  83838. * Strong typing of a pointer up/down action.
  83839. */
  83840. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83841. /**
  83842. * Representation of a stage in the scene (Basically a list of ordered steps)
  83843. * @hidden
  83844. */
  83845. export class Stage<T extends Function> extends Array<{
  83846. index: number;
  83847. component: ISceneComponent;
  83848. action: T;
  83849. }> {
  83850. /**
  83851. * Hide ctor from the rest of the world.
  83852. * @param items The items to add.
  83853. */
  83854. private constructor();
  83855. /**
  83856. * Creates a new Stage.
  83857. * @returns A new instance of a Stage
  83858. */
  83859. static Create<T extends Function>(): Stage<T>;
  83860. /**
  83861. * Registers a step in an ordered way in the targeted stage.
  83862. * @param index Defines the position to register the step in
  83863. * @param component Defines the component attached to the step
  83864. * @param action Defines the action to launch during the step
  83865. */
  83866. registerStep(index: number, component: ISceneComponent, action: T): void;
  83867. /**
  83868. * Clears all the steps from the stage.
  83869. */
  83870. clear(): void;
  83871. }
  83872. }
  83873. declare module BABYLON {
  83874. interface Scene {
  83875. /** @hidden */
  83876. _pointerOverSprite: Nullable<Sprite>;
  83877. /** @hidden */
  83878. _pickedDownSprite: Nullable<Sprite>;
  83879. /** @hidden */
  83880. _tempSpritePickingRay: Nullable<Ray>;
  83881. /**
  83882. * All of the sprite managers added to this scene
  83883. * @see http://doc.babylonjs.com/babylon101/sprites
  83884. */
  83885. spriteManagers: Array<ISpriteManager>;
  83886. /**
  83887. * An event triggered when sprites rendering is about to start
  83888. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83889. */
  83890. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83891. /**
  83892. * An event triggered when sprites rendering is done
  83893. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83894. */
  83895. onAfterSpritesRenderingObservable: Observable<Scene>;
  83896. /** @hidden */
  83897. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83898. /** Launch a ray to try to pick a sprite in the scene
  83899. * @param x position on screen
  83900. * @param y position on screen
  83901. * @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
  83902. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83903. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83904. * @returns a PickingInfo
  83905. */
  83906. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83907. /** Use the given ray to pick a sprite in the scene
  83908. * @param ray The ray (in world space) to use to pick meshes
  83909. * @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
  83910. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83911. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83912. * @returns a PickingInfo
  83913. */
  83914. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83915. /** @hidden */
  83916. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83917. /** Launch a ray to try to pick sprites in the scene
  83918. * @param x position on screen
  83919. * @param y position on screen
  83920. * @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
  83921. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83922. * @returns a PickingInfo array
  83923. */
  83924. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83925. /** Use the given ray to pick sprites in the scene
  83926. * @param ray The ray (in world space) to use to pick meshes
  83927. * @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
  83928. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83929. * @returns a PickingInfo array
  83930. */
  83931. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83932. /**
  83933. * Force the sprite under the pointer
  83934. * @param sprite defines the sprite to use
  83935. */
  83936. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83937. /**
  83938. * Gets the sprite under the pointer
  83939. * @returns a Sprite or null if no sprite is under the pointer
  83940. */
  83941. getPointerOverSprite(): Nullable<Sprite>;
  83942. }
  83943. /**
  83944. * Defines the sprite scene component responsible to manage sprites
  83945. * in a given scene.
  83946. */
  83947. export class SpriteSceneComponent implements ISceneComponent {
  83948. /**
  83949. * The component name helpfull to identify the component in the list of scene components.
  83950. */
  83951. readonly name: string;
  83952. /**
  83953. * The scene the component belongs to.
  83954. */
  83955. scene: Scene;
  83956. /** @hidden */
  83957. private _spritePredicate;
  83958. /**
  83959. * Creates a new instance of the component for the given scene
  83960. * @param scene Defines the scene to register the component in
  83961. */
  83962. constructor(scene: Scene);
  83963. /**
  83964. * Registers the component in a given scene
  83965. */
  83966. register(): void;
  83967. /**
  83968. * Rebuilds the elements related to this component in case of
  83969. * context lost for instance.
  83970. */
  83971. rebuild(): void;
  83972. /**
  83973. * Disposes the component and the associated ressources.
  83974. */
  83975. dispose(): void;
  83976. private _pickSpriteButKeepRay;
  83977. private _pointerMove;
  83978. private _pointerDown;
  83979. private _pointerUp;
  83980. }
  83981. }
  83982. declare module BABYLON {
  83983. /** @hidden */
  83984. export var fogFragmentDeclaration: {
  83985. name: string;
  83986. shader: string;
  83987. };
  83988. }
  83989. declare module BABYLON {
  83990. /** @hidden */
  83991. export var fogFragment: {
  83992. name: string;
  83993. shader: string;
  83994. };
  83995. }
  83996. declare module BABYLON {
  83997. /** @hidden */
  83998. export var spritesPixelShader: {
  83999. name: string;
  84000. shader: string;
  84001. };
  84002. }
  84003. declare module BABYLON {
  84004. /** @hidden */
  84005. export var fogVertexDeclaration: {
  84006. name: string;
  84007. shader: string;
  84008. };
  84009. }
  84010. declare module BABYLON {
  84011. /** @hidden */
  84012. export var spritesVertexShader: {
  84013. name: string;
  84014. shader: string;
  84015. };
  84016. }
  84017. declare module BABYLON {
  84018. /**
  84019. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84020. */
  84021. export interface ISpriteManager extends IDisposable {
  84022. /**
  84023. * Restricts the camera to viewing objects with the same layerMask.
  84024. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84025. */
  84026. layerMask: number;
  84027. /**
  84028. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84029. */
  84030. isPickable: boolean;
  84031. /**
  84032. * Specifies the rendering group id for this mesh (0 by default)
  84033. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84034. */
  84035. renderingGroupId: number;
  84036. /**
  84037. * Defines the list of sprites managed by the manager.
  84038. */
  84039. sprites: Array<Sprite>;
  84040. /**
  84041. * Tests the intersection of a sprite with a specific ray.
  84042. * @param ray The ray we are sending to test the collision
  84043. * @param camera The camera space we are sending rays in
  84044. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84045. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84046. * @returns picking info or null.
  84047. */
  84048. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84049. /**
  84050. * Intersects the sprites with a ray
  84051. * @param ray defines the ray to intersect with
  84052. * @param camera defines the current active camera
  84053. * @param predicate defines a predicate used to select candidate sprites
  84054. * @returns null if no hit or a PickingInfo array
  84055. */
  84056. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84057. /**
  84058. * Renders the list of sprites on screen.
  84059. */
  84060. render(): void;
  84061. }
  84062. /**
  84063. * Class used to manage multiple sprites on the same spritesheet
  84064. * @see http://doc.babylonjs.com/babylon101/sprites
  84065. */
  84066. export class SpriteManager implements ISpriteManager {
  84067. /** defines the manager's name */
  84068. name: string;
  84069. /** Gets the list of sprites */
  84070. sprites: Sprite[];
  84071. /** Gets or sets the rendering group id (0 by default) */
  84072. renderingGroupId: number;
  84073. /** Gets or sets camera layer mask */
  84074. layerMask: number;
  84075. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84076. fogEnabled: boolean;
  84077. /** Gets or sets a boolean indicating if the sprites are pickable */
  84078. isPickable: boolean;
  84079. /** Defines the default width of a cell in the spritesheet */
  84080. cellWidth: number;
  84081. /** Defines the default height of a cell in the spritesheet */
  84082. cellHeight: number;
  84083. /** Associative array from JSON sprite data file */
  84084. private _cellData;
  84085. /** Array of sprite names from JSON sprite data file */
  84086. private _spriteMap;
  84087. /** True when packed cell data from JSON file is ready*/
  84088. private _packedAndReady;
  84089. /**
  84090. * An event triggered when the manager is disposed.
  84091. */
  84092. onDisposeObservable: Observable<SpriteManager>;
  84093. private _onDisposeObserver;
  84094. /**
  84095. * Callback called when the manager is disposed
  84096. */
  84097. set onDispose(callback: () => void);
  84098. private _capacity;
  84099. private _fromPacked;
  84100. private _spriteTexture;
  84101. private _epsilon;
  84102. private _scene;
  84103. private _vertexData;
  84104. private _buffer;
  84105. private _vertexBuffers;
  84106. private _indexBuffer;
  84107. private _effectBase;
  84108. private _effectFog;
  84109. /**
  84110. * Gets or sets the spritesheet texture
  84111. */
  84112. get texture(): Texture;
  84113. set texture(value: Texture);
  84114. private _blendMode;
  84115. /**
  84116. * Blend mode use to render the particle, it can be any of
  84117. * the static Constants.ALPHA_x properties provided in this class.
  84118. * Default value is Constants.ALPHA_COMBINE
  84119. */
  84120. get blendMode(): number;
  84121. set blendMode(blendMode: number);
  84122. /** Disables writing to the depth buffer when rendering the sprites.
  84123. * It can be handy to disable depth writing when using textures without alpha channel
  84124. * and setting some specific blend modes.
  84125. */
  84126. disableDepthWrite: boolean;
  84127. /**
  84128. * Creates a new sprite manager
  84129. * @param name defines the manager's name
  84130. * @param imgUrl defines the sprite sheet url
  84131. * @param capacity defines the maximum allowed number of sprites
  84132. * @param cellSize defines the size of a sprite cell
  84133. * @param scene defines the hosting scene
  84134. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84135. * @param samplingMode defines the smapling mode to use with spritesheet
  84136. * @param fromPacked set to false; do not alter
  84137. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84138. */
  84139. constructor(
  84140. /** defines the manager's name */
  84141. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84142. private _makePacked;
  84143. private _appendSpriteVertex;
  84144. /**
  84145. * Intersects the sprites with a ray
  84146. * @param ray defines the ray to intersect with
  84147. * @param camera defines the current active camera
  84148. * @param predicate defines a predicate used to select candidate sprites
  84149. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84150. * @returns null if no hit or a PickingInfo
  84151. */
  84152. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84153. /**
  84154. * Intersects the sprites with a ray
  84155. * @param ray defines the ray to intersect with
  84156. * @param camera defines the current active camera
  84157. * @param predicate defines a predicate used to select candidate sprites
  84158. * @returns null if no hit or a PickingInfo array
  84159. */
  84160. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84161. /**
  84162. * Render all child sprites
  84163. */
  84164. render(): void;
  84165. /**
  84166. * Release associated resources
  84167. */
  84168. dispose(): void;
  84169. }
  84170. }
  84171. declare module BABYLON {
  84172. /** Interface used by value gradients (color, factor, ...) */
  84173. export interface IValueGradient {
  84174. /**
  84175. * Gets or sets the gradient value (between 0 and 1)
  84176. */
  84177. gradient: number;
  84178. }
  84179. /** Class used to store color4 gradient */
  84180. export class ColorGradient implements IValueGradient {
  84181. /**
  84182. * Gets or sets the gradient value (between 0 and 1)
  84183. */
  84184. gradient: number;
  84185. /**
  84186. * Gets or sets first associated color
  84187. */
  84188. color1: Color4;
  84189. /**
  84190. * Gets or sets second associated color
  84191. */
  84192. color2?: Color4 | undefined;
  84193. /**
  84194. * Creates a new color4 gradient
  84195. * @param gradient gets or sets the gradient value (between 0 and 1)
  84196. * @param color1 gets or sets first associated color
  84197. * @param color2 gets or sets first second color
  84198. */
  84199. constructor(
  84200. /**
  84201. * Gets or sets the gradient value (between 0 and 1)
  84202. */
  84203. gradient: number,
  84204. /**
  84205. * Gets or sets first associated color
  84206. */
  84207. color1: Color4,
  84208. /**
  84209. * Gets or sets second associated color
  84210. */
  84211. color2?: Color4 | undefined);
  84212. /**
  84213. * Will get a color picked randomly between color1 and color2.
  84214. * If color2 is undefined then color1 will be used
  84215. * @param result defines the target Color4 to store the result in
  84216. */
  84217. getColorToRef(result: Color4): void;
  84218. }
  84219. /** Class used to store color 3 gradient */
  84220. export class Color3Gradient implements IValueGradient {
  84221. /**
  84222. * Gets or sets the gradient value (between 0 and 1)
  84223. */
  84224. gradient: number;
  84225. /**
  84226. * Gets or sets the associated color
  84227. */
  84228. color: Color3;
  84229. /**
  84230. * Creates a new color3 gradient
  84231. * @param gradient gets or sets the gradient value (between 0 and 1)
  84232. * @param color gets or sets associated color
  84233. */
  84234. constructor(
  84235. /**
  84236. * Gets or sets the gradient value (between 0 and 1)
  84237. */
  84238. gradient: number,
  84239. /**
  84240. * Gets or sets the associated color
  84241. */
  84242. color: Color3);
  84243. }
  84244. /** Class used to store factor gradient */
  84245. export class FactorGradient implements IValueGradient {
  84246. /**
  84247. * Gets or sets the gradient value (between 0 and 1)
  84248. */
  84249. gradient: number;
  84250. /**
  84251. * Gets or sets first associated factor
  84252. */
  84253. factor1: number;
  84254. /**
  84255. * Gets or sets second associated factor
  84256. */
  84257. factor2?: number | undefined;
  84258. /**
  84259. * Creates a new factor gradient
  84260. * @param gradient gets or sets the gradient value (between 0 and 1)
  84261. * @param factor1 gets or sets first associated factor
  84262. * @param factor2 gets or sets second associated factor
  84263. */
  84264. constructor(
  84265. /**
  84266. * Gets or sets the gradient value (between 0 and 1)
  84267. */
  84268. gradient: number,
  84269. /**
  84270. * Gets or sets first associated factor
  84271. */
  84272. factor1: number,
  84273. /**
  84274. * Gets or sets second associated factor
  84275. */
  84276. factor2?: number | undefined);
  84277. /**
  84278. * Will get a number picked randomly between factor1 and factor2.
  84279. * If factor2 is undefined then factor1 will be used
  84280. * @returns the picked number
  84281. */
  84282. getFactor(): number;
  84283. }
  84284. /**
  84285. * Helper used to simplify some generic gradient tasks
  84286. */
  84287. export class GradientHelper {
  84288. /**
  84289. * Gets the current gradient from an array of IValueGradient
  84290. * @param ratio defines the current ratio to get
  84291. * @param gradients defines the array of IValueGradient
  84292. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84293. */
  84294. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84295. }
  84296. }
  84297. declare module BABYLON {
  84298. /**
  84299. * Interface for the size containing width and height
  84300. */
  84301. export interface ISize {
  84302. /**
  84303. * Width
  84304. */
  84305. width: number;
  84306. /**
  84307. * Heighht
  84308. */
  84309. height: number;
  84310. }
  84311. /**
  84312. * Size containing widht and height
  84313. */
  84314. export class Size implements ISize {
  84315. /**
  84316. * Width
  84317. */
  84318. width: number;
  84319. /**
  84320. * Height
  84321. */
  84322. height: number;
  84323. /**
  84324. * Creates a Size object from the given width and height (floats).
  84325. * @param width width of the new size
  84326. * @param height height of the new size
  84327. */
  84328. constructor(width: number, height: number);
  84329. /**
  84330. * Returns a string with the Size width and height
  84331. * @returns a string with the Size width and height
  84332. */
  84333. toString(): string;
  84334. /**
  84335. * "Size"
  84336. * @returns the string "Size"
  84337. */
  84338. getClassName(): string;
  84339. /**
  84340. * Returns the Size hash code.
  84341. * @returns a hash code for a unique width and height
  84342. */
  84343. getHashCode(): number;
  84344. /**
  84345. * Updates the current size from the given one.
  84346. * @param src the given size
  84347. */
  84348. copyFrom(src: Size): void;
  84349. /**
  84350. * Updates in place the current Size from the given floats.
  84351. * @param width width of the new size
  84352. * @param height height of the new size
  84353. * @returns the updated Size.
  84354. */
  84355. copyFromFloats(width: number, height: number): Size;
  84356. /**
  84357. * Updates in place the current Size from the given floats.
  84358. * @param width width to set
  84359. * @param height height to set
  84360. * @returns the updated Size.
  84361. */
  84362. set(width: number, height: number): Size;
  84363. /**
  84364. * Multiplies the width and height by numbers
  84365. * @param w factor to multiple the width by
  84366. * @param h factor to multiple the height by
  84367. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84368. */
  84369. multiplyByFloats(w: number, h: number): Size;
  84370. /**
  84371. * Clones the size
  84372. * @returns a new Size copied from the given one.
  84373. */
  84374. clone(): Size;
  84375. /**
  84376. * True if the current Size and the given one width and height are strictly equal.
  84377. * @param other the other size to compare against
  84378. * @returns True if the current Size and the given one width and height are strictly equal.
  84379. */
  84380. equals(other: Size): boolean;
  84381. /**
  84382. * The surface of the Size : width * height (float).
  84383. */
  84384. get surface(): number;
  84385. /**
  84386. * Create a new size of zero
  84387. * @returns a new Size set to (0.0, 0.0)
  84388. */
  84389. static Zero(): Size;
  84390. /**
  84391. * Sums the width and height of two sizes
  84392. * @param otherSize size to add to this size
  84393. * @returns a new Size set as the addition result of the current Size and the given one.
  84394. */
  84395. add(otherSize: Size): Size;
  84396. /**
  84397. * Subtracts the width and height of two
  84398. * @param otherSize size to subtract to this size
  84399. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84400. */
  84401. subtract(otherSize: Size): Size;
  84402. /**
  84403. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84404. * @param start starting size to lerp between
  84405. * @param end end size to lerp between
  84406. * @param amount amount to lerp between the start and end values
  84407. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84408. */
  84409. static Lerp(start: Size, end: Size, amount: number): Size;
  84410. }
  84411. }
  84412. declare module BABYLON {
  84413. interface ThinEngine {
  84414. /**
  84415. * Creates a dynamic texture
  84416. * @param width defines the width of the texture
  84417. * @param height defines the height of the texture
  84418. * @param generateMipMaps defines if the engine should generate the mip levels
  84419. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84420. * @returns the dynamic texture inside an InternalTexture
  84421. */
  84422. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84423. /**
  84424. * Update the content of a dynamic texture
  84425. * @param texture defines the texture to update
  84426. * @param canvas defines the canvas containing the source
  84427. * @param invertY defines if data must be stored with Y axis inverted
  84428. * @param premulAlpha defines if alpha is stored as premultiplied
  84429. * @param format defines the format of the data
  84430. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84431. */
  84432. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84433. }
  84434. }
  84435. declare module BABYLON {
  84436. /**
  84437. * Helper class used to generate a canvas to manipulate images
  84438. */
  84439. export class CanvasGenerator {
  84440. /**
  84441. * Create a new canvas (or offscreen canvas depending on the context)
  84442. * @param width defines the expected width
  84443. * @param height defines the expected height
  84444. * @return a new canvas or offscreen canvas
  84445. */
  84446. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84447. }
  84448. }
  84449. declare module BABYLON {
  84450. /**
  84451. * A class extending Texture allowing drawing on a texture
  84452. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84453. */
  84454. export class DynamicTexture extends Texture {
  84455. private _generateMipMaps;
  84456. private _canvas;
  84457. private _context;
  84458. private _engine;
  84459. /**
  84460. * Creates a DynamicTexture
  84461. * @param name defines the name of the texture
  84462. * @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
  84463. * @param scene defines the scene where you want the texture
  84464. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84465. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84466. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84467. */
  84468. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84469. /**
  84470. * Get the current class name of the texture useful for serialization or dynamic coding.
  84471. * @returns "DynamicTexture"
  84472. */
  84473. getClassName(): string;
  84474. /**
  84475. * Gets the current state of canRescale
  84476. */
  84477. get canRescale(): boolean;
  84478. private _recreate;
  84479. /**
  84480. * Scales the texture
  84481. * @param ratio the scale factor to apply to both width and height
  84482. */
  84483. scale(ratio: number): void;
  84484. /**
  84485. * Resizes the texture
  84486. * @param width the new width
  84487. * @param height the new height
  84488. */
  84489. scaleTo(width: number, height: number): void;
  84490. /**
  84491. * Gets the context of the canvas used by the texture
  84492. * @returns the canvas context of the dynamic texture
  84493. */
  84494. getContext(): CanvasRenderingContext2D;
  84495. /**
  84496. * Clears the texture
  84497. */
  84498. clear(): void;
  84499. /**
  84500. * Updates the texture
  84501. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84502. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84503. */
  84504. update(invertY?: boolean, premulAlpha?: boolean): void;
  84505. /**
  84506. * Draws text onto the texture
  84507. * @param text defines the text to be drawn
  84508. * @param x defines the placement of the text from the left
  84509. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84510. * @param font defines the font to be used with font-style, font-size, font-name
  84511. * @param color defines the color used for the text
  84512. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84513. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84514. * @param update defines whether texture is immediately update (default is true)
  84515. */
  84516. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84517. /**
  84518. * Clones the texture
  84519. * @returns the clone of the texture.
  84520. */
  84521. clone(): DynamicTexture;
  84522. /**
  84523. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84524. * @returns a serialized dynamic texture object
  84525. */
  84526. serialize(): any;
  84527. /** @hidden */
  84528. _rebuild(): void;
  84529. }
  84530. }
  84531. declare module BABYLON {
  84532. interface Engine {
  84533. /**
  84534. * Creates a raw texture
  84535. * @param data defines the data to store in the texture
  84536. * @param width defines the width of the texture
  84537. * @param height defines the height of the texture
  84538. * @param format defines the format of the data
  84539. * @param generateMipMaps defines if the engine should generate the mip levels
  84540. * @param invertY defines if data must be stored with Y axis inverted
  84541. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84542. * @param compression defines the compression used (null by default)
  84543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84544. * @returns the raw texture inside an InternalTexture
  84545. */
  84546. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84547. /**
  84548. * Update a raw texture
  84549. * @param texture defines the texture to update
  84550. * @param data defines the data to store in the texture
  84551. * @param format defines the format of the data
  84552. * @param invertY defines if data must be stored with Y axis inverted
  84553. */
  84554. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84555. /**
  84556. * Update a raw texture
  84557. * @param texture defines the texture to update
  84558. * @param data defines the data to store in the texture
  84559. * @param format defines the format of the data
  84560. * @param invertY defines if data must be stored with Y axis inverted
  84561. * @param compression defines the compression used (null by default)
  84562. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84563. */
  84564. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84565. /**
  84566. * Creates a new raw cube texture
  84567. * @param data defines the array of data to use to create each face
  84568. * @param size defines the size of the textures
  84569. * @param format defines the format of the data
  84570. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84571. * @param generateMipMaps defines if the engine should generate the mip levels
  84572. * @param invertY defines if data must be stored with Y axis inverted
  84573. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84574. * @param compression defines the compression used (null by default)
  84575. * @returns the cube texture as an InternalTexture
  84576. */
  84577. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84578. /**
  84579. * Update a raw cube texture
  84580. * @param texture defines the texture to udpdate
  84581. * @param data defines the data to store
  84582. * @param format defines the data format
  84583. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84584. * @param invertY defines if data must be stored with Y axis inverted
  84585. */
  84586. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84587. /**
  84588. * Update a raw cube texture
  84589. * @param texture defines the texture to udpdate
  84590. * @param data defines the data to store
  84591. * @param format defines the data format
  84592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84593. * @param invertY defines if data must be stored with Y axis inverted
  84594. * @param compression defines the compression used (null by default)
  84595. */
  84596. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84597. /**
  84598. * Update a raw cube texture
  84599. * @param texture defines the texture to udpdate
  84600. * @param data defines the data to store
  84601. * @param format defines the data format
  84602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84603. * @param invertY defines if data must be stored with Y axis inverted
  84604. * @param compression defines the compression used (null by default)
  84605. * @param level defines which level of the texture to update
  84606. */
  84607. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84608. /**
  84609. * Creates a new raw cube texture from a specified url
  84610. * @param url defines the url where the data is located
  84611. * @param scene defines the current scene
  84612. * @param size defines the size of the textures
  84613. * @param format defines the format of the data
  84614. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84615. * @param noMipmap defines if the engine should avoid generating the mip levels
  84616. * @param callback defines a callback used to extract texture data from loaded data
  84617. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84618. * @param onLoad defines a callback called when texture is loaded
  84619. * @param onError defines a callback called if there is an error
  84620. * @returns the cube texture as an InternalTexture
  84621. */
  84622. 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;
  84623. /**
  84624. * Creates a new raw cube texture from a specified url
  84625. * @param url defines the url where the data is located
  84626. * @param scene defines the current scene
  84627. * @param size defines the size of the textures
  84628. * @param format defines the format of the data
  84629. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84630. * @param noMipmap defines if the engine should avoid generating the mip levels
  84631. * @param callback defines a callback used to extract texture data from loaded data
  84632. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84633. * @param onLoad defines a callback called when texture is loaded
  84634. * @param onError defines a callback called if there is an error
  84635. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84636. * @param invertY defines if data must be stored with Y axis inverted
  84637. * @returns the cube texture as an InternalTexture
  84638. */
  84639. 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;
  84640. /**
  84641. * Creates a new raw 3D texture
  84642. * @param data defines the data used to create the texture
  84643. * @param width defines the width of the texture
  84644. * @param height defines the height of the texture
  84645. * @param depth defines the depth of the texture
  84646. * @param format defines the format of the texture
  84647. * @param generateMipMaps defines if the engine must generate mip levels
  84648. * @param invertY defines if data must be stored with Y axis inverted
  84649. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84650. * @param compression defines the compressed used (can be null)
  84651. * @param textureType defines the compressed used (can be null)
  84652. * @returns a new raw 3D texture (stored in an InternalTexture)
  84653. */
  84654. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84655. /**
  84656. * Update a raw 3D texture
  84657. * @param texture defines the texture to update
  84658. * @param data defines the data to store
  84659. * @param format defines the data format
  84660. * @param invertY defines if data must be stored with Y axis inverted
  84661. */
  84662. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84663. /**
  84664. * Update a raw 3D texture
  84665. * @param texture defines the texture to update
  84666. * @param data defines the data to store
  84667. * @param format defines the data format
  84668. * @param invertY defines if data must be stored with Y axis inverted
  84669. * @param compression defines the used compression (can be null)
  84670. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84671. */
  84672. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84673. /**
  84674. * Creates a new raw 2D array texture
  84675. * @param data defines the data used to create the texture
  84676. * @param width defines the width of the texture
  84677. * @param height defines the height of the texture
  84678. * @param depth defines the number of layers of the texture
  84679. * @param format defines the format of the texture
  84680. * @param generateMipMaps defines if the engine must generate mip levels
  84681. * @param invertY defines if data must be stored with Y axis inverted
  84682. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84683. * @param compression defines the compressed used (can be null)
  84684. * @param textureType defines the compressed used (can be null)
  84685. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84686. */
  84687. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84688. /**
  84689. * Update a raw 2D array texture
  84690. * @param texture defines the texture to update
  84691. * @param data defines the data to store
  84692. * @param format defines the data format
  84693. * @param invertY defines if data must be stored with Y axis inverted
  84694. */
  84695. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84696. /**
  84697. * Update a raw 2D array texture
  84698. * @param texture defines the texture to update
  84699. * @param data defines the data to store
  84700. * @param format defines the data format
  84701. * @param invertY defines if data must be stored with Y axis inverted
  84702. * @param compression defines the used compression (can be null)
  84703. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84704. */
  84705. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84706. }
  84707. }
  84708. declare module BABYLON {
  84709. /**
  84710. * Raw texture can help creating a texture directly from an array of data.
  84711. * This can be super useful if you either get the data from an uncompressed source or
  84712. * if you wish to create your texture pixel by pixel.
  84713. */
  84714. export class RawTexture extends Texture {
  84715. /**
  84716. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84717. */
  84718. format: number;
  84719. private _engine;
  84720. /**
  84721. * Instantiates a new RawTexture.
  84722. * Raw texture can help creating a texture directly from an array of data.
  84723. * This can be super useful if you either get the data from an uncompressed source or
  84724. * if you wish to create your texture pixel by pixel.
  84725. * @param data define the array of data to use to create the texture
  84726. * @param width define the width of the texture
  84727. * @param height define the height of the texture
  84728. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84729. * @param scene define the scene the texture belongs to
  84730. * @param generateMipMaps define whether mip maps should be generated or not
  84731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84733. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84734. */
  84735. constructor(data: ArrayBufferView, width: number, height: number,
  84736. /**
  84737. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84738. */
  84739. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84740. /**
  84741. * Updates the texture underlying data.
  84742. * @param data Define the new data of the texture
  84743. */
  84744. update(data: ArrayBufferView): void;
  84745. /**
  84746. * Creates a luminance texture from some data.
  84747. * @param data Define the texture data
  84748. * @param width Define the width of the texture
  84749. * @param height Define the height of the texture
  84750. * @param scene Define the scene the texture belongs to
  84751. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84754. * @returns the luminance texture
  84755. */
  84756. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84757. /**
  84758. * Creates a luminance alpha texture from some data.
  84759. * @param data Define the texture data
  84760. * @param width Define the width of the texture
  84761. * @param height Define the height of the texture
  84762. * @param scene Define the scene the texture belongs to
  84763. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84764. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84765. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84766. * @returns the luminance alpha texture
  84767. */
  84768. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84769. /**
  84770. * Creates an alpha texture from some data.
  84771. * @param data Define the texture data
  84772. * @param width Define the width of the texture
  84773. * @param height Define the height of the texture
  84774. * @param scene Define the scene the texture belongs to
  84775. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84778. * @returns the alpha texture
  84779. */
  84780. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84781. /**
  84782. * Creates a RGB texture from some data.
  84783. * @param data Define the texture data
  84784. * @param width Define the width of the texture
  84785. * @param height Define the height of the texture
  84786. * @param scene Define the scene the texture belongs to
  84787. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84788. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84789. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84790. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84791. * @returns the RGB alpha texture
  84792. */
  84793. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84794. /**
  84795. * Creates a RGBA texture from some data.
  84796. * @param data Define the texture data
  84797. * @param width Define the width of the texture
  84798. * @param height Define the height of the texture
  84799. * @param scene Define the scene the texture belongs to
  84800. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84801. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84802. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84803. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84804. * @returns the RGBA texture
  84805. */
  84806. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84807. /**
  84808. * Creates a R texture from some data.
  84809. * @param data Define the texture data
  84810. * @param width Define the width of the texture
  84811. * @param height Define the height of the texture
  84812. * @param scene Define the scene the texture belongs to
  84813. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84814. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84815. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84816. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84817. * @returns the R texture
  84818. */
  84819. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84820. }
  84821. }
  84822. declare module BABYLON {
  84823. interface AbstractScene {
  84824. /**
  84825. * The list of procedural textures added to the scene
  84826. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84827. */
  84828. proceduralTextures: Array<ProceduralTexture>;
  84829. }
  84830. /**
  84831. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84832. * in a given scene.
  84833. */
  84834. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84835. /**
  84836. * The component name helpfull to identify the component in the list of scene components.
  84837. */
  84838. readonly name: string;
  84839. /**
  84840. * The scene the component belongs to.
  84841. */
  84842. scene: Scene;
  84843. /**
  84844. * Creates a new instance of the component for the given scene
  84845. * @param scene Defines the scene to register the component in
  84846. */
  84847. constructor(scene: Scene);
  84848. /**
  84849. * Registers the component in a given scene
  84850. */
  84851. register(): void;
  84852. /**
  84853. * Rebuilds the elements related to this component in case of
  84854. * context lost for instance.
  84855. */
  84856. rebuild(): void;
  84857. /**
  84858. * Disposes the component and the associated ressources.
  84859. */
  84860. dispose(): void;
  84861. private _beforeClear;
  84862. }
  84863. }
  84864. declare module BABYLON {
  84865. interface ThinEngine {
  84866. /**
  84867. * Creates a new render target cube texture
  84868. * @param size defines the size of the texture
  84869. * @param options defines the options used to create the texture
  84870. * @returns a new render target cube texture stored in an InternalTexture
  84871. */
  84872. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84873. }
  84874. }
  84875. declare module BABYLON {
  84876. /** @hidden */
  84877. export var proceduralVertexShader: {
  84878. name: string;
  84879. shader: string;
  84880. };
  84881. }
  84882. declare module BABYLON {
  84883. /**
  84884. * 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.
  84885. * This is the base class of any Procedural texture and contains most of the shareable code.
  84886. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84887. */
  84888. export class ProceduralTexture extends Texture {
  84889. isCube: boolean;
  84890. /**
  84891. * Define if the texture is enabled or not (disabled texture will not render)
  84892. */
  84893. isEnabled: boolean;
  84894. /**
  84895. * Define if the texture must be cleared before rendering (default is true)
  84896. */
  84897. autoClear: boolean;
  84898. /**
  84899. * Callback called when the texture is generated
  84900. */
  84901. onGenerated: () => void;
  84902. /**
  84903. * Event raised when the texture is generated
  84904. */
  84905. onGeneratedObservable: Observable<ProceduralTexture>;
  84906. /** @hidden */
  84907. _generateMipMaps: boolean;
  84908. /** @hidden **/
  84909. _effect: Effect;
  84910. /** @hidden */
  84911. _textures: {
  84912. [key: string]: Texture;
  84913. };
  84914. /** @hidden */
  84915. protected _fallbackTexture: Nullable<Texture>;
  84916. private _size;
  84917. private _currentRefreshId;
  84918. private _frameId;
  84919. private _refreshRate;
  84920. private _vertexBuffers;
  84921. private _indexBuffer;
  84922. private _uniforms;
  84923. private _samplers;
  84924. private _fragment;
  84925. private _floats;
  84926. private _ints;
  84927. private _floatsArrays;
  84928. private _colors3;
  84929. private _colors4;
  84930. private _vectors2;
  84931. private _vectors3;
  84932. private _matrices;
  84933. private _fallbackTextureUsed;
  84934. private _engine;
  84935. private _cachedDefines;
  84936. private _contentUpdateId;
  84937. private _contentData;
  84938. /**
  84939. * Instantiates a new procedural texture.
  84940. * 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.
  84941. * This is the base class of any Procedural texture and contains most of the shareable code.
  84942. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84943. * @param name Define the name of the texture
  84944. * @param size Define the size of the texture to create
  84945. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84946. * @param scene Define the scene the texture belongs to
  84947. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84948. * @param generateMipMaps Define if the texture should creates mip maps or not
  84949. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84950. */
  84951. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84952. /**
  84953. * The effect that is created when initializing the post process.
  84954. * @returns The created effect corresponding the the postprocess.
  84955. */
  84956. getEffect(): Effect;
  84957. /**
  84958. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84959. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84960. */
  84961. getContent(): Nullable<ArrayBufferView>;
  84962. private _createIndexBuffer;
  84963. /** @hidden */
  84964. _rebuild(): void;
  84965. /**
  84966. * Resets the texture in order to recreate its associated resources.
  84967. * This can be called in case of context loss
  84968. */
  84969. reset(): void;
  84970. protected _getDefines(): string;
  84971. /**
  84972. * Is the texture ready to be used ? (rendered at least once)
  84973. * @returns true if ready, otherwise, false.
  84974. */
  84975. isReady(): boolean;
  84976. /**
  84977. * Resets the refresh counter of the texture and start bak from scratch.
  84978. * Could be useful to regenerate the texture if it is setup to render only once.
  84979. */
  84980. resetRefreshCounter(): void;
  84981. /**
  84982. * Set the fragment shader to use in order to render the texture.
  84983. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84984. */
  84985. setFragment(fragment: any): void;
  84986. /**
  84987. * Define the refresh rate of the texture or the rendering frequency.
  84988. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84989. */
  84990. get refreshRate(): number;
  84991. set refreshRate(value: number);
  84992. /** @hidden */
  84993. _shouldRender(): boolean;
  84994. /**
  84995. * Get the size the texture is rendering at.
  84996. * @returns the size (texture is always squared)
  84997. */
  84998. getRenderSize(): number;
  84999. /**
  85000. * Resize the texture to new value.
  85001. * @param size Define the new size the texture should have
  85002. * @param generateMipMaps Define whether the new texture should create mip maps
  85003. */
  85004. resize(size: number, generateMipMaps: boolean): void;
  85005. private _checkUniform;
  85006. /**
  85007. * Set a texture in the shader program used to render.
  85008. * @param name Define the name of the uniform samplers as defined in the shader
  85009. * @param texture Define the texture to bind to this sampler
  85010. * @return the texture itself allowing "fluent" like uniform updates
  85011. */
  85012. setTexture(name: string, texture: Texture): ProceduralTexture;
  85013. /**
  85014. * Set a float in the shader.
  85015. * @param name Define the name of the uniform as defined in the shader
  85016. * @param value Define the value to give to the uniform
  85017. * @return the texture itself allowing "fluent" like uniform updates
  85018. */
  85019. setFloat(name: string, value: number): ProceduralTexture;
  85020. /**
  85021. * Set a int in the shader.
  85022. * @param name Define the name of the uniform as defined in the shader
  85023. * @param value Define the value to give to the uniform
  85024. * @return the texture itself allowing "fluent" like uniform updates
  85025. */
  85026. setInt(name: string, value: number): ProceduralTexture;
  85027. /**
  85028. * Set an array of floats in the shader.
  85029. * @param name Define the name of the uniform as defined in the shader
  85030. * @param value Define the value to give to the uniform
  85031. * @return the texture itself allowing "fluent" like uniform updates
  85032. */
  85033. setFloats(name: string, value: number[]): ProceduralTexture;
  85034. /**
  85035. * Set a vec3 in the shader from a Color3.
  85036. * @param name Define the name of the uniform as defined in the shader
  85037. * @param value Define the value to give to the uniform
  85038. * @return the texture itself allowing "fluent" like uniform updates
  85039. */
  85040. setColor3(name: string, value: Color3): ProceduralTexture;
  85041. /**
  85042. * Set a vec4 in the shader from a Color4.
  85043. * @param name Define the name of the uniform as defined in the shader
  85044. * @param value Define the value to give to the uniform
  85045. * @return the texture itself allowing "fluent" like uniform updates
  85046. */
  85047. setColor4(name: string, value: Color4): ProceduralTexture;
  85048. /**
  85049. * Set a vec2 in the shader from a Vector2.
  85050. * @param name Define the name of the uniform as defined in the shader
  85051. * @param value Define the value to give to the uniform
  85052. * @return the texture itself allowing "fluent" like uniform updates
  85053. */
  85054. setVector2(name: string, value: Vector2): ProceduralTexture;
  85055. /**
  85056. * Set a vec3 in the shader from a Vector3.
  85057. * @param name Define the name of the uniform as defined in the shader
  85058. * @param value Define the value to give to the uniform
  85059. * @return the texture itself allowing "fluent" like uniform updates
  85060. */
  85061. setVector3(name: string, value: Vector3): ProceduralTexture;
  85062. /**
  85063. * Set a mat4 in the shader from a MAtrix.
  85064. * @param name Define the name of the uniform as defined in the shader
  85065. * @param value Define the value to give to the uniform
  85066. * @return the texture itself allowing "fluent" like uniform updates
  85067. */
  85068. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85069. /**
  85070. * Render the texture to its associated render target.
  85071. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85072. */
  85073. render(useCameraPostProcess?: boolean): void;
  85074. /**
  85075. * Clone the texture.
  85076. * @returns the cloned texture
  85077. */
  85078. clone(): ProceduralTexture;
  85079. /**
  85080. * Dispose the texture and release its asoociated resources.
  85081. */
  85082. dispose(): void;
  85083. }
  85084. }
  85085. declare module BABYLON {
  85086. /**
  85087. * This represents the base class for particle system in Babylon.
  85088. * 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.
  85089. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85090. * @example https://doc.babylonjs.com/babylon101/particles
  85091. */
  85092. export class BaseParticleSystem {
  85093. /**
  85094. * Source color is added to the destination color without alpha affecting the result
  85095. */
  85096. static BLENDMODE_ONEONE: number;
  85097. /**
  85098. * Blend current color and particle color using particle’s alpha
  85099. */
  85100. static BLENDMODE_STANDARD: number;
  85101. /**
  85102. * Add current color and particle color multiplied by particle’s alpha
  85103. */
  85104. static BLENDMODE_ADD: number;
  85105. /**
  85106. * Multiply current color with particle color
  85107. */
  85108. static BLENDMODE_MULTIPLY: number;
  85109. /**
  85110. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85111. */
  85112. static BLENDMODE_MULTIPLYADD: number;
  85113. /**
  85114. * List of animations used by the particle system.
  85115. */
  85116. animations: Animation[];
  85117. /**
  85118. * Gets or sets the unique id of the particle system
  85119. */
  85120. uniqueId: number;
  85121. /**
  85122. * The id of the Particle system.
  85123. */
  85124. id: string;
  85125. /**
  85126. * The friendly name of the Particle system.
  85127. */
  85128. name: string;
  85129. /**
  85130. * The rendering group used by the Particle system to chose when to render.
  85131. */
  85132. renderingGroupId: number;
  85133. /**
  85134. * The emitter represents the Mesh or position we are attaching the particle system to.
  85135. */
  85136. emitter: Nullable<AbstractMesh | Vector3>;
  85137. /**
  85138. * The maximum number of particles to emit per frame
  85139. */
  85140. emitRate: number;
  85141. /**
  85142. * If you want to launch only a few particles at once, that can be done, as well.
  85143. */
  85144. manualEmitCount: number;
  85145. /**
  85146. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85147. */
  85148. updateSpeed: number;
  85149. /**
  85150. * The amount of time the particle system is running (depends of the overall update speed).
  85151. */
  85152. targetStopDuration: number;
  85153. /**
  85154. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85155. */
  85156. disposeOnStop: boolean;
  85157. /**
  85158. * Minimum power of emitting particles.
  85159. */
  85160. minEmitPower: number;
  85161. /**
  85162. * Maximum power of emitting particles.
  85163. */
  85164. maxEmitPower: number;
  85165. /**
  85166. * Minimum life time of emitting particles.
  85167. */
  85168. minLifeTime: number;
  85169. /**
  85170. * Maximum life time of emitting particles.
  85171. */
  85172. maxLifeTime: number;
  85173. /**
  85174. * Minimum Size of emitting particles.
  85175. */
  85176. minSize: number;
  85177. /**
  85178. * Maximum Size of emitting particles.
  85179. */
  85180. maxSize: number;
  85181. /**
  85182. * Minimum scale of emitting particles on X axis.
  85183. */
  85184. minScaleX: number;
  85185. /**
  85186. * Maximum scale of emitting particles on X axis.
  85187. */
  85188. maxScaleX: number;
  85189. /**
  85190. * Minimum scale of emitting particles on Y axis.
  85191. */
  85192. minScaleY: number;
  85193. /**
  85194. * Maximum scale of emitting particles on Y axis.
  85195. */
  85196. maxScaleY: number;
  85197. /**
  85198. * Gets or sets the minimal initial rotation in radians.
  85199. */
  85200. minInitialRotation: number;
  85201. /**
  85202. * Gets or sets the maximal initial rotation in radians.
  85203. */
  85204. maxInitialRotation: number;
  85205. /**
  85206. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85207. */
  85208. minAngularSpeed: number;
  85209. /**
  85210. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85211. */
  85212. maxAngularSpeed: number;
  85213. /**
  85214. * The texture used to render each particle. (this can be a spritesheet)
  85215. */
  85216. particleTexture: Nullable<Texture>;
  85217. /**
  85218. * The layer mask we are rendering the particles through.
  85219. */
  85220. layerMask: number;
  85221. /**
  85222. * This can help using your own shader to render the particle system.
  85223. * The according effect will be created
  85224. */
  85225. customShader: any;
  85226. /**
  85227. * By default particle system starts as soon as they are created. This prevents the
  85228. * automatic start to happen and let you decide when to start emitting particles.
  85229. */
  85230. preventAutoStart: boolean;
  85231. private _noiseTexture;
  85232. /**
  85233. * Gets or sets a texture used to add random noise to particle positions
  85234. */
  85235. get noiseTexture(): Nullable<ProceduralTexture>;
  85236. set noiseTexture(value: Nullable<ProceduralTexture>);
  85237. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85238. noiseStrength: Vector3;
  85239. /**
  85240. * Callback triggered when the particle animation is ending.
  85241. */
  85242. onAnimationEnd: Nullable<() => void>;
  85243. /**
  85244. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85245. */
  85246. blendMode: number;
  85247. /**
  85248. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85249. * to override the particles.
  85250. */
  85251. forceDepthWrite: boolean;
  85252. /** 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 */
  85253. preWarmCycles: number;
  85254. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85255. preWarmStepOffset: number;
  85256. /**
  85257. * 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)
  85258. */
  85259. spriteCellChangeSpeed: number;
  85260. /**
  85261. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85262. */
  85263. startSpriteCellID: number;
  85264. /**
  85265. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85266. */
  85267. endSpriteCellID: number;
  85268. /**
  85269. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85270. */
  85271. spriteCellWidth: number;
  85272. /**
  85273. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85274. */
  85275. spriteCellHeight: number;
  85276. /**
  85277. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85278. */
  85279. spriteRandomStartCell: boolean;
  85280. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85281. translationPivot: Vector2;
  85282. /** @hidden */
  85283. protected _isAnimationSheetEnabled: boolean;
  85284. /**
  85285. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85286. */
  85287. beginAnimationOnStart: boolean;
  85288. /**
  85289. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85290. */
  85291. beginAnimationFrom: number;
  85292. /**
  85293. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85294. */
  85295. beginAnimationTo: number;
  85296. /**
  85297. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85298. */
  85299. beginAnimationLoop: boolean;
  85300. /**
  85301. * Gets or sets a world offset applied to all particles
  85302. */
  85303. worldOffset: Vector3;
  85304. /**
  85305. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85306. */
  85307. get isAnimationSheetEnabled(): boolean;
  85308. set isAnimationSheetEnabled(value: boolean);
  85309. /**
  85310. * Get hosting scene
  85311. * @returns the scene
  85312. */
  85313. getScene(): Scene;
  85314. /**
  85315. * You can use gravity if you want to give an orientation to your particles.
  85316. */
  85317. gravity: Vector3;
  85318. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85319. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85320. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85321. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85322. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85323. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85324. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85325. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85326. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85327. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85328. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85329. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85330. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85331. /**
  85332. * Defines the delay in milliseconds before starting the system (0 by default)
  85333. */
  85334. startDelay: number;
  85335. /**
  85336. * Gets the current list of drag gradients.
  85337. * You must use addDragGradient and removeDragGradient to udpate this list
  85338. * @returns the list of drag gradients
  85339. */
  85340. getDragGradients(): Nullable<Array<FactorGradient>>;
  85341. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85342. limitVelocityDamping: number;
  85343. /**
  85344. * Gets the current list of limit velocity gradients.
  85345. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85346. * @returns the list of limit velocity gradients
  85347. */
  85348. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85349. /**
  85350. * Gets the current list of color gradients.
  85351. * You must use addColorGradient and removeColorGradient to udpate this list
  85352. * @returns the list of color gradients
  85353. */
  85354. getColorGradients(): Nullable<Array<ColorGradient>>;
  85355. /**
  85356. * Gets the current list of size gradients.
  85357. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85358. * @returns the list of size gradients
  85359. */
  85360. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85361. /**
  85362. * Gets the current list of color remap gradients.
  85363. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85364. * @returns the list of color remap gradients
  85365. */
  85366. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85367. /**
  85368. * Gets the current list of alpha remap gradients.
  85369. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85370. * @returns the list of alpha remap gradients
  85371. */
  85372. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85373. /**
  85374. * Gets the current list of life time gradients.
  85375. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85376. * @returns the list of life time gradients
  85377. */
  85378. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85379. /**
  85380. * Gets the current list of angular speed gradients.
  85381. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85382. * @returns the list of angular speed gradients
  85383. */
  85384. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85385. /**
  85386. * Gets the current list of velocity gradients.
  85387. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85388. * @returns the list of velocity gradients
  85389. */
  85390. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85391. /**
  85392. * Gets the current list of start size gradients.
  85393. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85394. * @returns the list of start size gradients
  85395. */
  85396. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85397. /**
  85398. * Gets the current list of emit rate gradients.
  85399. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85400. * @returns the list of emit rate gradients
  85401. */
  85402. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85403. /**
  85404. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85405. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85406. */
  85407. get direction1(): Vector3;
  85408. set direction1(value: Vector3);
  85409. /**
  85410. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85411. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85412. */
  85413. get direction2(): Vector3;
  85414. set direction2(value: Vector3);
  85415. /**
  85416. * 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.
  85417. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85418. */
  85419. get minEmitBox(): Vector3;
  85420. set minEmitBox(value: Vector3);
  85421. /**
  85422. * 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.
  85423. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85424. */
  85425. get maxEmitBox(): Vector3;
  85426. set maxEmitBox(value: Vector3);
  85427. /**
  85428. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85429. */
  85430. color1: Color4;
  85431. /**
  85432. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85433. */
  85434. color2: Color4;
  85435. /**
  85436. * Color the particle will have at the end of its lifetime
  85437. */
  85438. colorDead: Color4;
  85439. /**
  85440. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85441. */
  85442. textureMask: Color4;
  85443. /**
  85444. * The particle emitter type defines the emitter used by the particle system.
  85445. * It can be for example box, sphere, or cone...
  85446. */
  85447. particleEmitterType: IParticleEmitterType;
  85448. /** @hidden */
  85449. _isSubEmitter: boolean;
  85450. /**
  85451. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85452. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85453. */
  85454. billboardMode: number;
  85455. protected _isBillboardBased: boolean;
  85456. /**
  85457. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85458. */
  85459. get isBillboardBased(): boolean;
  85460. set isBillboardBased(value: boolean);
  85461. /**
  85462. * The scene the particle system belongs to.
  85463. */
  85464. protected _scene: Scene;
  85465. /**
  85466. * Local cache of defines for image processing.
  85467. */
  85468. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85469. /**
  85470. * Default configuration related to image processing available in the standard Material.
  85471. */
  85472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85473. /**
  85474. * Gets the image processing configuration used either in this material.
  85475. */
  85476. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  85477. /**
  85478. * Sets the Default image processing configuration used either in the this material.
  85479. *
  85480. * If sets to null, the scene one is in use.
  85481. */
  85482. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  85483. /**
  85484. * Attaches a new image processing configuration to the Standard Material.
  85485. * @param configuration
  85486. */
  85487. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85488. /** @hidden */
  85489. protected _reset(): void;
  85490. /** @hidden */
  85491. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85492. /**
  85493. * Instantiates a particle system.
  85494. * 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.
  85495. * @param name The name of the particle system
  85496. */
  85497. constructor(name: string);
  85498. /**
  85499. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85500. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85501. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85502. * @returns the emitter
  85503. */
  85504. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85505. /**
  85506. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85507. * @param radius The radius of the hemisphere to emit from
  85508. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85509. * @returns the emitter
  85510. */
  85511. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85512. /**
  85513. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85514. * @param radius The radius of the sphere to emit from
  85515. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85516. * @returns the emitter
  85517. */
  85518. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85519. /**
  85520. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85521. * @param radius The radius of the sphere to emit from
  85522. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85523. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85524. * @returns the emitter
  85525. */
  85526. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85527. /**
  85528. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85529. * @param radius The radius of the emission cylinder
  85530. * @param height The height of the emission cylinder
  85531. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85532. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85533. * @returns the emitter
  85534. */
  85535. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85536. /**
  85537. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85538. * @param radius The radius of the cylinder to emit from
  85539. * @param height The height of the emission cylinder
  85540. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85541. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85542. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85543. * @returns the emitter
  85544. */
  85545. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85546. /**
  85547. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85548. * @param radius The radius of the cone to emit from
  85549. * @param angle The base angle of the cone
  85550. * @returns the emitter
  85551. */
  85552. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85553. /**
  85554. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85557. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85558. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85559. * @returns the emitter
  85560. */
  85561. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85562. }
  85563. }
  85564. declare module BABYLON {
  85565. /**
  85566. * Type of sub emitter
  85567. */
  85568. export enum SubEmitterType {
  85569. /**
  85570. * Attached to the particle over it's lifetime
  85571. */
  85572. ATTACHED = 0,
  85573. /**
  85574. * Created when the particle dies
  85575. */
  85576. END = 1
  85577. }
  85578. /**
  85579. * Sub emitter class used to emit particles from an existing particle
  85580. */
  85581. export class SubEmitter {
  85582. /**
  85583. * the particle system to be used by the sub emitter
  85584. */
  85585. particleSystem: ParticleSystem;
  85586. /**
  85587. * Type of the submitter (Default: END)
  85588. */
  85589. type: SubEmitterType;
  85590. /**
  85591. * 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)
  85592. * Note: This only is supported when using an emitter of type Mesh
  85593. */
  85594. inheritDirection: boolean;
  85595. /**
  85596. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85597. */
  85598. inheritedVelocityAmount: number;
  85599. /**
  85600. * Creates a sub emitter
  85601. * @param particleSystem the particle system to be used by the sub emitter
  85602. */
  85603. constructor(
  85604. /**
  85605. * the particle system to be used by the sub emitter
  85606. */
  85607. particleSystem: ParticleSystem);
  85608. /**
  85609. * Clones the sub emitter
  85610. * @returns the cloned sub emitter
  85611. */
  85612. clone(): SubEmitter;
  85613. /**
  85614. * Serialize current object to a JSON object
  85615. * @returns the serialized object
  85616. */
  85617. serialize(): any;
  85618. /** @hidden */
  85619. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85620. /**
  85621. * Creates a new SubEmitter from a serialized JSON version
  85622. * @param serializationObject defines the JSON object to read from
  85623. * @param scene defines the hosting scene
  85624. * @param rootUrl defines the rootUrl for data loading
  85625. * @returns a new SubEmitter
  85626. */
  85627. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85628. /** Release associated resources */
  85629. dispose(): void;
  85630. }
  85631. }
  85632. declare module BABYLON {
  85633. /** @hidden */
  85634. export var imageProcessingDeclaration: {
  85635. name: string;
  85636. shader: string;
  85637. };
  85638. }
  85639. declare module BABYLON {
  85640. /** @hidden */
  85641. export var imageProcessingFunctions: {
  85642. name: string;
  85643. shader: string;
  85644. };
  85645. }
  85646. declare module BABYLON {
  85647. /** @hidden */
  85648. export var particlesPixelShader: {
  85649. name: string;
  85650. shader: string;
  85651. };
  85652. }
  85653. declare module BABYLON {
  85654. /** @hidden */
  85655. export var particlesVertexShader: {
  85656. name: string;
  85657. shader: string;
  85658. };
  85659. }
  85660. declare module BABYLON {
  85661. /**
  85662. * This represents a particle system in Babylon.
  85663. * 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.
  85664. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85665. * @example https://doc.babylonjs.com/babylon101/particles
  85666. */
  85667. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85668. /**
  85669. * Billboard mode will only apply to Y axis
  85670. */
  85671. static readonly BILLBOARDMODE_Y: number;
  85672. /**
  85673. * Billboard mode will apply to all axes
  85674. */
  85675. static readonly BILLBOARDMODE_ALL: number;
  85676. /**
  85677. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85678. */
  85679. static readonly BILLBOARDMODE_STRETCHED: number;
  85680. /**
  85681. * This function can be defined to provide custom update for active particles.
  85682. * This function will be called instead of regular update (age, position, color, etc.).
  85683. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85684. */
  85685. updateFunction: (particles: Particle[]) => void;
  85686. private _emitterWorldMatrix;
  85687. /**
  85688. * This function can be defined to specify initial direction for every new particle.
  85689. * It by default use the emitterType defined function
  85690. */
  85691. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85692. /**
  85693. * This function can be defined to specify initial position for every new particle.
  85694. * It by default use the emitterType defined function
  85695. */
  85696. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85697. /**
  85698. * @hidden
  85699. */
  85700. _inheritedVelocityOffset: Vector3;
  85701. /**
  85702. * An event triggered when the system is disposed
  85703. */
  85704. onDisposeObservable: Observable<ParticleSystem>;
  85705. private _onDisposeObserver;
  85706. /**
  85707. * Sets a callback that will be triggered when the system is disposed
  85708. */
  85709. set onDispose(callback: () => void);
  85710. private _particles;
  85711. private _epsilon;
  85712. private _capacity;
  85713. private _stockParticles;
  85714. private _newPartsExcess;
  85715. private _vertexData;
  85716. private _vertexBuffer;
  85717. private _vertexBuffers;
  85718. private _spriteBuffer;
  85719. private _indexBuffer;
  85720. private _effect;
  85721. private _customEffect;
  85722. private _cachedDefines;
  85723. private _scaledColorStep;
  85724. private _colorDiff;
  85725. private _scaledDirection;
  85726. private _scaledGravity;
  85727. private _currentRenderId;
  85728. private _alive;
  85729. private _useInstancing;
  85730. private _started;
  85731. private _stopped;
  85732. private _actualFrame;
  85733. private _scaledUpdateSpeed;
  85734. private _vertexBufferSize;
  85735. /** @hidden */
  85736. _currentEmitRateGradient: Nullable<FactorGradient>;
  85737. /** @hidden */
  85738. _currentEmitRate1: number;
  85739. /** @hidden */
  85740. _currentEmitRate2: number;
  85741. /** @hidden */
  85742. _currentStartSizeGradient: Nullable<FactorGradient>;
  85743. /** @hidden */
  85744. _currentStartSize1: number;
  85745. /** @hidden */
  85746. _currentStartSize2: number;
  85747. private readonly _rawTextureWidth;
  85748. private _rampGradientsTexture;
  85749. private _useRampGradients;
  85750. /** Gets or sets a boolean indicating that ramp gradients must be used
  85751. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85752. */
  85753. get useRampGradients(): boolean;
  85754. set useRampGradients(value: boolean);
  85755. /**
  85756. * 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.
  85757. * 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: [])
  85758. */
  85759. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85760. private _subEmitters;
  85761. /**
  85762. * @hidden
  85763. * If the particle systems emitter should be disposed when the particle system is disposed
  85764. */
  85765. _disposeEmitterOnDispose: boolean;
  85766. /**
  85767. * The current active Sub-systems, this property is used by the root particle system only.
  85768. */
  85769. activeSubSystems: Array<ParticleSystem>;
  85770. /**
  85771. * Specifies if the particles are updated in emitter local space or world space
  85772. */
  85773. isLocal: boolean;
  85774. private _rootParticleSystem;
  85775. /**
  85776. * Gets the current list of active particles
  85777. */
  85778. get particles(): Particle[];
  85779. /**
  85780. * Gets the number of particles active at the same time.
  85781. * @returns The number of active particles.
  85782. */
  85783. getActiveCount(): number;
  85784. /**
  85785. * Returns the string "ParticleSystem"
  85786. * @returns a string containing the class name
  85787. */
  85788. getClassName(): string;
  85789. /**
  85790. * Gets a boolean indicating that the system is stopping
  85791. * @returns true if the system is currently stopping
  85792. */
  85793. isStopping(): boolean;
  85794. /**
  85795. * Instantiates a particle system.
  85796. * 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.
  85797. * @param name The name of the particle system
  85798. * @param capacity The max number of particles alive at the same time
  85799. * @param scene The scene the particle system belongs to
  85800. * @param customEffect a custom effect used to change the way particles are rendered by default
  85801. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85802. * @param epsilon Offset used to render the particles
  85803. */
  85804. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85805. private _addFactorGradient;
  85806. private _removeFactorGradient;
  85807. /**
  85808. * Adds a new life time gradient
  85809. * @param gradient defines the gradient to use (between 0 and 1)
  85810. * @param factor defines the life time factor to affect to the specified gradient
  85811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85812. * @returns the current particle system
  85813. */
  85814. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85815. /**
  85816. * Remove a specific life time gradient
  85817. * @param gradient defines the gradient to remove
  85818. * @returns the current particle system
  85819. */
  85820. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85821. /**
  85822. * Adds a new size gradient
  85823. * @param gradient defines the gradient to use (between 0 and 1)
  85824. * @param factor defines the size factor to affect to the specified gradient
  85825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85826. * @returns the current particle system
  85827. */
  85828. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85829. /**
  85830. * Remove a specific size gradient
  85831. * @param gradient defines the gradient to remove
  85832. * @returns the current particle system
  85833. */
  85834. removeSizeGradient(gradient: number): IParticleSystem;
  85835. /**
  85836. * Adds a new color remap gradient
  85837. * @param gradient defines the gradient to use (between 0 and 1)
  85838. * @param min defines the color remap minimal range
  85839. * @param max defines the color remap maximal range
  85840. * @returns the current particle system
  85841. */
  85842. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85843. /**
  85844. * Remove a specific color remap gradient
  85845. * @param gradient defines the gradient to remove
  85846. * @returns the current particle system
  85847. */
  85848. removeColorRemapGradient(gradient: number): IParticleSystem;
  85849. /**
  85850. * Adds a new alpha remap gradient
  85851. * @param gradient defines the gradient to use (between 0 and 1)
  85852. * @param min defines the alpha remap minimal range
  85853. * @param max defines the alpha remap maximal range
  85854. * @returns the current particle system
  85855. */
  85856. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85857. /**
  85858. * Remove a specific alpha remap gradient
  85859. * @param gradient defines the gradient to remove
  85860. * @returns the current particle system
  85861. */
  85862. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85863. /**
  85864. * Adds a new angular speed gradient
  85865. * @param gradient defines the gradient to use (between 0 and 1)
  85866. * @param factor defines the angular speed to affect to the specified gradient
  85867. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85868. * @returns the current particle system
  85869. */
  85870. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85871. /**
  85872. * Remove a specific angular speed gradient
  85873. * @param gradient defines the gradient to remove
  85874. * @returns the current particle system
  85875. */
  85876. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85877. /**
  85878. * Adds a new velocity gradient
  85879. * @param gradient defines the gradient to use (between 0 and 1)
  85880. * @param factor defines the velocity to affect to the specified gradient
  85881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85882. * @returns the current particle system
  85883. */
  85884. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85885. /**
  85886. * Remove a specific velocity gradient
  85887. * @param gradient defines the gradient to remove
  85888. * @returns the current particle system
  85889. */
  85890. removeVelocityGradient(gradient: number): IParticleSystem;
  85891. /**
  85892. * Adds a new limit velocity gradient
  85893. * @param gradient defines the gradient to use (between 0 and 1)
  85894. * @param factor defines the limit velocity value to affect to the specified gradient
  85895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85896. * @returns the current particle system
  85897. */
  85898. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85899. /**
  85900. * Remove a specific limit velocity gradient
  85901. * @param gradient defines the gradient to remove
  85902. * @returns the current particle system
  85903. */
  85904. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85905. /**
  85906. * Adds a new drag gradient
  85907. * @param gradient defines the gradient to use (between 0 and 1)
  85908. * @param factor defines the drag value to affect to the specified gradient
  85909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85910. * @returns the current particle system
  85911. */
  85912. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85913. /**
  85914. * Remove a specific drag gradient
  85915. * @param gradient defines the gradient to remove
  85916. * @returns the current particle system
  85917. */
  85918. removeDragGradient(gradient: number): IParticleSystem;
  85919. /**
  85920. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85921. * @param gradient defines the gradient to use (between 0 and 1)
  85922. * @param factor defines the emit rate value to affect to the specified gradient
  85923. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85924. * @returns the current particle system
  85925. */
  85926. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85927. /**
  85928. * Remove a specific emit rate gradient
  85929. * @param gradient defines the gradient to remove
  85930. * @returns the current particle system
  85931. */
  85932. removeEmitRateGradient(gradient: number): IParticleSystem;
  85933. /**
  85934. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85935. * @param gradient defines the gradient to use (between 0 and 1)
  85936. * @param factor defines the start size value to affect to the specified gradient
  85937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85938. * @returns the current particle system
  85939. */
  85940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85941. /**
  85942. * Remove a specific start size gradient
  85943. * @param gradient defines the gradient to remove
  85944. * @returns the current particle system
  85945. */
  85946. removeStartSizeGradient(gradient: number): IParticleSystem;
  85947. private _createRampGradientTexture;
  85948. /**
  85949. * Gets the current list of ramp gradients.
  85950. * You must use addRampGradient and removeRampGradient to udpate this list
  85951. * @returns the list of ramp gradients
  85952. */
  85953. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85954. /**
  85955. * Adds a new ramp gradient used to remap particle colors
  85956. * @param gradient defines the gradient to use (between 0 and 1)
  85957. * @param color defines the color to affect to the specified gradient
  85958. * @returns the current particle system
  85959. */
  85960. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85961. /**
  85962. * Remove a specific ramp gradient
  85963. * @param gradient defines the gradient to remove
  85964. * @returns the current particle system
  85965. */
  85966. removeRampGradient(gradient: number): ParticleSystem;
  85967. /**
  85968. * Adds a new color gradient
  85969. * @param gradient defines the gradient to use (between 0 and 1)
  85970. * @param color1 defines the color to affect to the specified gradient
  85971. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85972. * @returns this particle system
  85973. */
  85974. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85975. /**
  85976. * Remove a specific color gradient
  85977. * @param gradient defines the gradient to remove
  85978. * @returns this particle system
  85979. */
  85980. removeColorGradient(gradient: number): IParticleSystem;
  85981. private _fetchR;
  85982. protected _reset(): void;
  85983. private _resetEffect;
  85984. private _createVertexBuffers;
  85985. private _createIndexBuffer;
  85986. /**
  85987. * Gets the maximum number of particles active at the same time.
  85988. * @returns The max number of active particles.
  85989. */
  85990. getCapacity(): number;
  85991. /**
  85992. * Gets whether there are still active particles in the system.
  85993. * @returns True if it is alive, otherwise false.
  85994. */
  85995. isAlive(): boolean;
  85996. /**
  85997. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85998. * @returns True if it has been started, otherwise false.
  85999. */
  86000. isStarted(): boolean;
  86001. private _prepareSubEmitterInternalArray;
  86002. /**
  86003. * Starts the particle system and begins to emit
  86004. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86005. */
  86006. start(delay?: number): void;
  86007. /**
  86008. * Stops the particle system.
  86009. * @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.
  86010. */
  86011. stop(stopSubEmitters?: boolean): void;
  86012. /**
  86013. * Remove all active particles
  86014. */
  86015. reset(): void;
  86016. /**
  86017. * @hidden (for internal use only)
  86018. */
  86019. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86020. /**
  86021. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86022. * Its lifetime will start back at 0.
  86023. */
  86024. recycleParticle: (particle: Particle) => void;
  86025. private _stopSubEmitters;
  86026. private _createParticle;
  86027. private _removeFromRoot;
  86028. private _emitFromParticle;
  86029. private _update;
  86030. /** @hidden */
  86031. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86032. /** @hidden */
  86033. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86034. /** @hidden */
  86035. private _getEffect;
  86036. /**
  86037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86038. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86039. */
  86040. animate(preWarmOnly?: boolean): void;
  86041. private _appendParticleVertices;
  86042. /**
  86043. * Rebuilds the particle system.
  86044. */
  86045. rebuild(): void;
  86046. /**
  86047. * Is this system ready to be used/rendered
  86048. * @return true if the system is ready
  86049. */
  86050. isReady(): boolean;
  86051. private _render;
  86052. /**
  86053. * Renders the particle system in its current state.
  86054. * @returns the current number of particles
  86055. */
  86056. render(): number;
  86057. /**
  86058. * Disposes the particle system and free the associated resources
  86059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86060. */
  86061. dispose(disposeTexture?: boolean): void;
  86062. /**
  86063. * Clones the particle system.
  86064. * @param name The name of the cloned object
  86065. * @param newEmitter The new emitter to use
  86066. * @returns the cloned particle system
  86067. */
  86068. clone(name: string, newEmitter: any): ParticleSystem;
  86069. /**
  86070. * Serializes the particle system to a JSON object.
  86071. * @returns the JSON object
  86072. */
  86073. serialize(): any;
  86074. /** @hidden */
  86075. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86076. /** @hidden */
  86077. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86078. /**
  86079. * Parses a JSON object to create a particle system.
  86080. * @param parsedParticleSystem The JSON object to parse
  86081. * @param scene The scene to create the particle system in
  86082. * @param rootUrl The root url to use to load external dependencies like texture
  86083. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86084. * @returns the Parsed particle system
  86085. */
  86086. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86087. }
  86088. }
  86089. declare module BABYLON {
  86090. /**
  86091. * A particle represents one of the element emitted by a particle system.
  86092. * This is mainly define by its coordinates, direction, velocity and age.
  86093. */
  86094. export class Particle {
  86095. /**
  86096. * The particle system the particle belongs to.
  86097. */
  86098. particleSystem: ParticleSystem;
  86099. private static _Count;
  86100. /**
  86101. * Unique ID of the particle
  86102. */
  86103. id: number;
  86104. /**
  86105. * The world position of the particle in the scene.
  86106. */
  86107. position: Vector3;
  86108. /**
  86109. * The world direction of the particle in the scene.
  86110. */
  86111. direction: Vector3;
  86112. /**
  86113. * The color of the particle.
  86114. */
  86115. color: Color4;
  86116. /**
  86117. * The color change of the particle per step.
  86118. */
  86119. colorStep: Color4;
  86120. /**
  86121. * Defines how long will the life of the particle be.
  86122. */
  86123. lifeTime: number;
  86124. /**
  86125. * The current age of the particle.
  86126. */
  86127. age: number;
  86128. /**
  86129. * The current size of the particle.
  86130. */
  86131. size: number;
  86132. /**
  86133. * The current scale of the particle.
  86134. */
  86135. scale: Vector2;
  86136. /**
  86137. * The current angle of the particle.
  86138. */
  86139. angle: number;
  86140. /**
  86141. * Defines how fast is the angle changing.
  86142. */
  86143. angularSpeed: number;
  86144. /**
  86145. * Defines the cell index used by the particle to be rendered from a sprite.
  86146. */
  86147. cellIndex: number;
  86148. /**
  86149. * The information required to support color remapping
  86150. */
  86151. remapData: Vector4;
  86152. /** @hidden */
  86153. _randomCellOffset?: number;
  86154. /** @hidden */
  86155. _initialDirection: Nullable<Vector3>;
  86156. /** @hidden */
  86157. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86158. /** @hidden */
  86159. _initialStartSpriteCellID: number;
  86160. /** @hidden */
  86161. _initialEndSpriteCellID: number;
  86162. /** @hidden */
  86163. _currentColorGradient: Nullable<ColorGradient>;
  86164. /** @hidden */
  86165. _currentColor1: Color4;
  86166. /** @hidden */
  86167. _currentColor2: Color4;
  86168. /** @hidden */
  86169. _currentSizeGradient: Nullable<FactorGradient>;
  86170. /** @hidden */
  86171. _currentSize1: number;
  86172. /** @hidden */
  86173. _currentSize2: number;
  86174. /** @hidden */
  86175. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86176. /** @hidden */
  86177. _currentAngularSpeed1: number;
  86178. /** @hidden */
  86179. _currentAngularSpeed2: number;
  86180. /** @hidden */
  86181. _currentVelocityGradient: Nullable<FactorGradient>;
  86182. /** @hidden */
  86183. _currentVelocity1: number;
  86184. /** @hidden */
  86185. _currentVelocity2: number;
  86186. /** @hidden */
  86187. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86188. /** @hidden */
  86189. _currentLimitVelocity1: number;
  86190. /** @hidden */
  86191. _currentLimitVelocity2: number;
  86192. /** @hidden */
  86193. _currentDragGradient: Nullable<FactorGradient>;
  86194. /** @hidden */
  86195. _currentDrag1: number;
  86196. /** @hidden */
  86197. _currentDrag2: number;
  86198. /** @hidden */
  86199. _randomNoiseCoordinates1: Vector3;
  86200. /** @hidden */
  86201. _randomNoiseCoordinates2: Vector3;
  86202. /** @hidden */
  86203. _localPosition?: Vector3;
  86204. /**
  86205. * Creates a new instance Particle
  86206. * @param particleSystem the particle system the particle belongs to
  86207. */
  86208. constructor(
  86209. /**
  86210. * The particle system the particle belongs to.
  86211. */
  86212. particleSystem: ParticleSystem);
  86213. private updateCellInfoFromSystem;
  86214. /**
  86215. * Defines how the sprite cell index is updated for the particle
  86216. */
  86217. updateCellIndex(): void;
  86218. /** @hidden */
  86219. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86220. /** @hidden */
  86221. _inheritParticleInfoToSubEmitters(): void;
  86222. /** @hidden */
  86223. _reset(): void;
  86224. /**
  86225. * Copy the properties of particle to another one.
  86226. * @param other the particle to copy the information to.
  86227. */
  86228. copyTo(other: Particle): void;
  86229. }
  86230. }
  86231. declare module BABYLON {
  86232. /**
  86233. * Particle emitter represents a volume emitting particles.
  86234. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86235. */
  86236. export interface IParticleEmitterType {
  86237. /**
  86238. * Called by the particle System when the direction is computed for the created particle.
  86239. * @param worldMatrix is the world matrix of the particle system
  86240. * @param directionToUpdate is the direction vector to update with the result
  86241. * @param particle is the particle we are computed the direction for
  86242. * @param isLocal defines if the direction should be set in local space
  86243. */
  86244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86245. /**
  86246. * Called by the particle System when the position is computed for the created particle.
  86247. * @param worldMatrix is the world matrix of the particle system
  86248. * @param positionToUpdate is the position vector to update with the result
  86249. * @param particle is the particle we are computed the position for
  86250. * @param isLocal defines if the position should be set in local space
  86251. */
  86252. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86253. /**
  86254. * Clones the current emitter and returns a copy of it
  86255. * @returns the new emitter
  86256. */
  86257. clone(): IParticleEmitterType;
  86258. /**
  86259. * Called by the GPUParticleSystem to setup the update shader
  86260. * @param effect defines the update shader
  86261. */
  86262. applyToShader(effect: Effect): void;
  86263. /**
  86264. * Returns a string to use to update the GPU particles update shader
  86265. * @returns the effect defines string
  86266. */
  86267. getEffectDefines(): string;
  86268. /**
  86269. * Returns a string representing the class name
  86270. * @returns a string containing the class name
  86271. */
  86272. getClassName(): string;
  86273. /**
  86274. * Serializes the particle system to a JSON object.
  86275. * @returns the JSON object
  86276. */
  86277. serialize(): any;
  86278. /**
  86279. * Parse properties from a JSON object
  86280. * @param serializationObject defines the JSON object
  86281. * @param scene defines the hosting scene
  86282. */
  86283. parse(serializationObject: any, scene: Scene): void;
  86284. }
  86285. }
  86286. declare module BABYLON {
  86287. /**
  86288. * Particle emitter emitting particles from the inside of a box.
  86289. * It emits the particles randomly between 2 given directions.
  86290. */
  86291. export class BoxParticleEmitter implements IParticleEmitterType {
  86292. /**
  86293. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86294. */
  86295. direction1: Vector3;
  86296. /**
  86297. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86298. */
  86299. direction2: Vector3;
  86300. /**
  86301. * 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.
  86302. */
  86303. minEmitBox: Vector3;
  86304. /**
  86305. * 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.
  86306. */
  86307. maxEmitBox: Vector3;
  86308. /**
  86309. * Creates a new instance BoxParticleEmitter
  86310. */
  86311. constructor();
  86312. /**
  86313. * Called by the particle System when the direction is computed for the created particle.
  86314. * @param worldMatrix is the world matrix of the particle system
  86315. * @param directionToUpdate is the direction vector to update with the result
  86316. * @param particle is the particle we are computed the direction for
  86317. * @param isLocal defines if the direction should be set in local space
  86318. */
  86319. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86320. /**
  86321. * Called by the particle System when the position is computed for the created particle.
  86322. * @param worldMatrix is the world matrix of the particle system
  86323. * @param positionToUpdate is the position vector to update with the result
  86324. * @param particle is the particle we are computed the position for
  86325. * @param isLocal defines if the position should be set in local space
  86326. */
  86327. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86328. /**
  86329. * Clones the current emitter and returns a copy of it
  86330. * @returns the new emitter
  86331. */
  86332. clone(): BoxParticleEmitter;
  86333. /**
  86334. * Called by the GPUParticleSystem to setup the update shader
  86335. * @param effect defines the update shader
  86336. */
  86337. applyToShader(effect: Effect): void;
  86338. /**
  86339. * Returns a string to use to update the GPU particles update shader
  86340. * @returns a string containng the defines string
  86341. */
  86342. getEffectDefines(): string;
  86343. /**
  86344. * Returns the string "BoxParticleEmitter"
  86345. * @returns a string containing the class name
  86346. */
  86347. getClassName(): string;
  86348. /**
  86349. * Serializes the particle system to a JSON object.
  86350. * @returns the JSON object
  86351. */
  86352. serialize(): any;
  86353. /**
  86354. * Parse properties from a JSON object
  86355. * @param serializationObject defines the JSON object
  86356. */
  86357. parse(serializationObject: any): void;
  86358. }
  86359. }
  86360. declare module BABYLON {
  86361. /**
  86362. * Particle emitter emitting particles from the inside of a cone.
  86363. * It emits the particles alongside the cone volume from the base to the particle.
  86364. * The emission direction might be randomized.
  86365. */
  86366. export class ConeParticleEmitter implements IParticleEmitterType {
  86367. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86368. directionRandomizer: number;
  86369. private _radius;
  86370. private _angle;
  86371. private _height;
  86372. /**
  86373. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86374. */
  86375. radiusRange: number;
  86376. /**
  86377. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86378. */
  86379. heightRange: number;
  86380. /**
  86381. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86382. */
  86383. emitFromSpawnPointOnly: boolean;
  86384. /**
  86385. * Gets or sets the radius of the emission cone
  86386. */
  86387. get radius(): number;
  86388. set radius(value: number);
  86389. /**
  86390. * Gets or sets the angle of the emission cone
  86391. */
  86392. get angle(): number;
  86393. set angle(value: number);
  86394. private _buildHeight;
  86395. /**
  86396. * Creates a new instance ConeParticleEmitter
  86397. * @param radius the radius of the emission cone (1 by default)
  86398. * @param angle the cone base angle (PI by default)
  86399. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86400. */
  86401. constructor(radius?: number, angle?: number,
  86402. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86403. directionRandomizer?: number);
  86404. /**
  86405. * Called by the particle System when the direction is computed for the created particle.
  86406. * @param worldMatrix is the world matrix of the particle system
  86407. * @param directionToUpdate is the direction vector to update with the result
  86408. * @param particle is the particle we are computed the direction for
  86409. * @param isLocal defines if the direction should be set in local space
  86410. */
  86411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86412. /**
  86413. * Called by the particle System when the position is computed for the created particle.
  86414. * @param worldMatrix is the world matrix of the particle system
  86415. * @param positionToUpdate is the position vector to update with the result
  86416. * @param particle is the particle we are computed the position for
  86417. * @param isLocal defines if the position should be set in local space
  86418. */
  86419. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86420. /**
  86421. * Clones the current emitter and returns a copy of it
  86422. * @returns the new emitter
  86423. */
  86424. clone(): ConeParticleEmitter;
  86425. /**
  86426. * Called by the GPUParticleSystem to setup the update shader
  86427. * @param effect defines the update shader
  86428. */
  86429. applyToShader(effect: Effect): void;
  86430. /**
  86431. * Returns a string to use to update the GPU particles update shader
  86432. * @returns a string containng the defines string
  86433. */
  86434. getEffectDefines(): string;
  86435. /**
  86436. * Returns the string "ConeParticleEmitter"
  86437. * @returns a string containing the class name
  86438. */
  86439. getClassName(): string;
  86440. /**
  86441. * Serializes the particle system to a JSON object.
  86442. * @returns the JSON object
  86443. */
  86444. serialize(): any;
  86445. /**
  86446. * Parse properties from a JSON object
  86447. * @param serializationObject defines the JSON object
  86448. */
  86449. parse(serializationObject: any): void;
  86450. }
  86451. }
  86452. declare module BABYLON {
  86453. /**
  86454. * Particle emitter emitting particles from the inside of a cylinder.
  86455. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86456. */
  86457. export class CylinderParticleEmitter implements IParticleEmitterType {
  86458. /**
  86459. * The radius of the emission cylinder.
  86460. */
  86461. radius: number;
  86462. /**
  86463. * The height of the emission cylinder.
  86464. */
  86465. height: number;
  86466. /**
  86467. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86468. */
  86469. radiusRange: number;
  86470. /**
  86471. * How much to randomize the particle direction [0-1].
  86472. */
  86473. directionRandomizer: number;
  86474. /**
  86475. * Creates a new instance CylinderParticleEmitter
  86476. * @param radius the radius of the emission cylinder (1 by default)
  86477. * @param height the height of the emission cylinder (1 by default)
  86478. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86479. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86480. */
  86481. constructor(
  86482. /**
  86483. * The radius of the emission cylinder.
  86484. */
  86485. radius?: number,
  86486. /**
  86487. * The height of the emission cylinder.
  86488. */
  86489. height?: number,
  86490. /**
  86491. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86492. */
  86493. radiusRange?: number,
  86494. /**
  86495. * How much to randomize the particle direction [0-1].
  86496. */
  86497. directionRandomizer?: number);
  86498. /**
  86499. * Called by the particle System when the direction is computed for the created particle.
  86500. * @param worldMatrix is the world matrix of the particle system
  86501. * @param directionToUpdate is the direction vector to update with the result
  86502. * @param particle is the particle we are computed the direction for
  86503. * @param isLocal defines if the direction should be set in local space
  86504. */
  86505. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86506. /**
  86507. * Called by the particle System when the position is computed for the created particle.
  86508. * @param worldMatrix is the world matrix of the particle system
  86509. * @param positionToUpdate is the position vector to update with the result
  86510. * @param particle is the particle we are computed the position for
  86511. * @param isLocal defines if the position should be set in local space
  86512. */
  86513. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86514. /**
  86515. * Clones the current emitter and returns a copy of it
  86516. * @returns the new emitter
  86517. */
  86518. clone(): CylinderParticleEmitter;
  86519. /**
  86520. * Called by the GPUParticleSystem to setup the update shader
  86521. * @param effect defines the update shader
  86522. */
  86523. applyToShader(effect: Effect): void;
  86524. /**
  86525. * Returns a string to use to update the GPU particles update shader
  86526. * @returns a string containng the defines string
  86527. */
  86528. getEffectDefines(): string;
  86529. /**
  86530. * Returns the string "CylinderParticleEmitter"
  86531. * @returns a string containing the class name
  86532. */
  86533. getClassName(): string;
  86534. /**
  86535. * Serializes the particle system to a JSON object.
  86536. * @returns the JSON object
  86537. */
  86538. serialize(): any;
  86539. /**
  86540. * Parse properties from a JSON object
  86541. * @param serializationObject defines the JSON object
  86542. */
  86543. parse(serializationObject: any): void;
  86544. }
  86545. /**
  86546. * Particle emitter emitting particles from the inside of a cylinder.
  86547. * It emits the particles randomly between two vectors.
  86548. */
  86549. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86550. /**
  86551. * The min limit of the emission direction.
  86552. */
  86553. direction1: Vector3;
  86554. /**
  86555. * The max limit of the emission direction.
  86556. */
  86557. direction2: Vector3;
  86558. /**
  86559. * Creates a new instance CylinderDirectedParticleEmitter
  86560. * @param radius the radius of the emission cylinder (1 by default)
  86561. * @param height the height of the emission cylinder (1 by default)
  86562. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86563. * @param direction1 the min limit of the emission direction (up vector by default)
  86564. * @param direction2 the max limit of the emission direction (up vector by default)
  86565. */
  86566. constructor(radius?: number, height?: number, radiusRange?: number,
  86567. /**
  86568. * The min limit of the emission direction.
  86569. */
  86570. direction1?: Vector3,
  86571. /**
  86572. * The max limit of the emission direction.
  86573. */
  86574. direction2?: Vector3);
  86575. /**
  86576. * Called by the particle System when the direction is computed for the created particle.
  86577. * @param worldMatrix is the world matrix of the particle system
  86578. * @param directionToUpdate is the direction vector to update with the result
  86579. * @param particle is the particle we are computed the direction for
  86580. */
  86581. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86582. /**
  86583. * Clones the current emitter and returns a copy of it
  86584. * @returns the new emitter
  86585. */
  86586. clone(): CylinderDirectedParticleEmitter;
  86587. /**
  86588. * Called by the GPUParticleSystem to setup the update shader
  86589. * @param effect defines the update shader
  86590. */
  86591. applyToShader(effect: Effect): void;
  86592. /**
  86593. * Returns a string to use to update the GPU particles update shader
  86594. * @returns a string containng the defines string
  86595. */
  86596. getEffectDefines(): string;
  86597. /**
  86598. * Returns the string "CylinderDirectedParticleEmitter"
  86599. * @returns a string containing the class name
  86600. */
  86601. getClassName(): string;
  86602. /**
  86603. * Serializes the particle system to a JSON object.
  86604. * @returns the JSON object
  86605. */
  86606. serialize(): any;
  86607. /**
  86608. * Parse properties from a JSON object
  86609. * @param serializationObject defines the JSON object
  86610. */
  86611. parse(serializationObject: any): void;
  86612. }
  86613. }
  86614. declare module BABYLON {
  86615. /**
  86616. * Particle emitter emitting particles from the inside of a hemisphere.
  86617. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86618. */
  86619. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86620. /**
  86621. * The radius of the emission hemisphere.
  86622. */
  86623. radius: number;
  86624. /**
  86625. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86626. */
  86627. radiusRange: number;
  86628. /**
  86629. * How much to randomize the particle direction [0-1].
  86630. */
  86631. directionRandomizer: number;
  86632. /**
  86633. * Creates a new instance HemisphericParticleEmitter
  86634. * @param radius the radius of the emission hemisphere (1 by default)
  86635. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86636. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86637. */
  86638. constructor(
  86639. /**
  86640. * The radius of the emission hemisphere.
  86641. */
  86642. radius?: number,
  86643. /**
  86644. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86645. */
  86646. radiusRange?: number,
  86647. /**
  86648. * How much to randomize the particle direction [0-1].
  86649. */
  86650. directionRandomizer?: number);
  86651. /**
  86652. * Called by the particle System when the direction is computed for the created particle.
  86653. * @param worldMatrix is the world matrix of the particle system
  86654. * @param directionToUpdate is the direction vector to update with the result
  86655. * @param particle is the particle we are computed the direction for
  86656. * @param isLocal defines if the direction should be set in local space
  86657. */
  86658. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86659. /**
  86660. * Called by the particle System when the position is computed for the created particle.
  86661. * @param worldMatrix is the world matrix of the particle system
  86662. * @param positionToUpdate is the position vector to update with the result
  86663. * @param particle is the particle we are computed the position for
  86664. * @param isLocal defines if the position should be set in local space
  86665. */
  86666. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86667. /**
  86668. * Clones the current emitter and returns a copy of it
  86669. * @returns the new emitter
  86670. */
  86671. clone(): HemisphericParticleEmitter;
  86672. /**
  86673. * Called by the GPUParticleSystem to setup the update shader
  86674. * @param effect defines the update shader
  86675. */
  86676. applyToShader(effect: Effect): void;
  86677. /**
  86678. * Returns a string to use to update the GPU particles update shader
  86679. * @returns a string containng the defines string
  86680. */
  86681. getEffectDefines(): string;
  86682. /**
  86683. * Returns the string "HemisphericParticleEmitter"
  86684. * @returns a string containing the class name
  86685. */
  86686. getClassName(): string;
  86687. /**
  86688. * Serializes the particle system to a JSON object.
  86689. * @returns the JSON object
  86690. */
  86691. serialize(): any;
  86692. /**
  86693. * Parse properties from a JSON object
  86694. * @param serializationObject defines the JSON object
  86695. */
  86696. parse(serializationObject: any): void;
  86697. }
  86698. }
  86699. declare module BABYLON {
  86700. /**
  86701. * Particle emitter emitting particles from a point.
  86702. * It emits the particles randomly between 2 given directions.
  86703. */
  86704. export class PointParticleEmitter implements IParticleEmitterType {
  86705. /**
  86706. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86707. */
  86708. direction1: Vector3;
  86709. /**
  86710. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86711. */
  86712. direction2: Vector3;
  86713. /**
  86714. * Creates a new instance PointParticleEmitter
  86715. */
  86716. constructor();
  86717. /**
  86718. * Called by the particle System when the direction is computed for the created particle.
  86719. * @param worldMatrix is the world matrix of the particle system
  86720. * @param directionToUpdate is the direction vector to update with the result
  86721. * @param particle is the particle we are computed the direction for
  86722. * @param isLocal defines if the direction should be set in local space
  86723. */
  86724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86725. /**
  86726. * Called by the particle System when the position is computed for the created particle.
  86727. * @param worldMatrix is the world matrix of the particle system
  86728. * @param positionToUpdate is the position vector to update with the result
  86729. * @param particle is the particle we are computed the position for
  86730. * @param isLocal defines if the position should be set in local space
  86731. */
  86732. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86733. /**
  86734. * Clones the current emitter and returns a copy of it
  86735. * @returns the new emitter
  86736. */
  86737. clone(): PointParticleEmitter;
  86738. /**
  86739. * Called by the GPUParticleSystem to setup the update shader
  86740. * @param effect defines the update shader
  86741. */
  86742. applyToShader(effect: Effect): void;
  86743. /**
  86744. * Returns a string to use to update the GPU particles update shader
  86745. * @returns a string containng the defines string
  86746. */
  86747. getEffectDefines(): string;
  86748. /**
  86749. * Returns the string "PointParticleEmitter"
  86750. * @returns a string containing the class name
  86751. */
  86752. getClassName(): string;
  86753. /**
  86754. * Serializes the particle system to a JSON object.
  86755. * @returns the JSON object
  86756. */
  86757. serialize(): any;
  86758. /**
  86759. * Parse properties from a JSON object
  86760. * @param serializationObject defines the JSON object
  86761. */
  86762. parse(serializationObject: any): void;
  86763. }
  86764. }
  86765. declare module BABYLON {
  86766. /**
  86767. * Particle emitter emitting particles from the inside of a sphere.
  86768. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86769. */
  86770. export class SphereParticleEmitter implements IParticleEmitterType {
  86771. /**
  86772. * The radius of the emission sphere.
  86773. */
  86774. radius: number;
  86775. /**
  86776. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86777. */
  86778. radiusRange: number;
  86779. /**
  86780. * How much to randomize the particle direction [0-1].
  86781. */
  86782. directionRandomizer: number;
  86783. /**
  86784. * Creates a new instance SphereParticleEmitter
  86785. * @param radius the radius of the emission sphere (1 by default)
  86786. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86787. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86788. */
  86789. constructor(
  86790. /**
  86791. * The radius of the emission sphere.
  86792. */
  86793. radius?: number,
  86794. /**
  86795. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86796. */
  86797. radiusRange?: number,
  86798. /**
  86799. * How much to randomize the particle direction [0-1].
  86800. */
  86801. directionRandomizer?: number);
  86802. /**
  86803. * Called by the particle System when the direction is computed for the created particle.
  86804. * @param worldMatrix is the world matrix of the particle system
  86805. * @param directionToUpdate is the direction vector to update with the result
  86806. * @param particle is the particle we are computed the direction for
  86807. * @param isLocal defines if the direction should be set in local space
  86808. */
  86809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86810. /**
  86811. * Called by the particle System when the position is computed for the created particle.
  86812. * @param worldMatrix is the world matrix of the particle system
  86813. * @param positionToUpdate is the position vector to update with the result
  86814. * @param particle is the particle we are computed the position for
  86815. * @param isLocal defines if the position should be set in local space
  86816. */
  86817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86818. /**
  86819. * Clones the current emitter and returns a copy of it
  86820. * @returns the new emitter
  86821. */
  86822. clone(): SphereParticleEmitter;
  86823. /**
  86824. * Called by the GPUParticleSystem to setup the update shader
  86825. * @param effect defines the update shader
  86826. */
  86827. applyToShader(effect: Effect): void;
  86828. /**
  86829. * Returns a string to use to update the GPU particles update shader
  86830. * @returns a string containng the defines string
  86831. */
  86832. getEffectDefines(): string;
  86833. /**
  86834. * Returns the string "SphereParticleEmitter"
  86835. * @returns a string containing the class name
  86836. */
  86837. getClassName(): string;
  86838. /**
  86839. * Serializes the particle system to a JSON object.
  86840. * @returns the JSON object
  86841. */
  86842. serialize(): any;
  86843. /**
  86844. * Parse properties from a JSON object
  86845. * @param serializationObject defines the JSON object
  86846. */
  86847. parse(serializationObject: any): void;
  86848. }
  86849. /**
  86850. * Particle emitter emitting particles from the inside of a sphere.
  86851. * It emits the particles randomly between two vectors.
  86852. */
  86853. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86854. /**
  86855. * The min limit of the emission direction.
  86856. */
  86857. direction1: Vector3;
  86858. /**
  86859. * The max limit of the emission direction.
  86860. */
  86861. direction2: Vector3;
  86862. /**
  86863. * Creates a new instance SphereDirectedParticleEmitter
  86864. * @param radius the radius of the emission sphere (1 by default)
  86865. * @param direction1 the min limit of the emission direction (up vector by default)
  86866. * @param direction2 the max limit of the emission direction (up vector by default)
  86867. */
  86868. constructor(radius?: number,
  86869. /**
  86870. * The min limit of the emission direction.
  86871. */
  86872. direction1?: Vector3,
  86873. /**
  86874. * The max limit of the emission direction.
  86875. */
  86876. direction2?: Vector3);
  86877. /**
  86878. * Called by the particle System when the direction is computed for the created particle.
  86879. * @param worldMatrix is the world matrix of the particle system
  86880. * @param directionToUpdate is the direction vector to update with the result
  86881. * @param particle is the particle we are computed the direction for
  86882. */
  86883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86884. /**
  86885. * Clones the current emitter and returns a copy of it
  86886. * @returns the new emitter
  86887. */
  86888. clone(): SphereDirectedParticleEmitter;
  86889. /**
  86890. * Called by the GPUParticleSystem to setup the update shader
  86891. * @param effect defines the update shader
  86892. */
  86893. applyToShader(effect: Effect): void;
  86894. /**
  86895. * Returns a string to use to update the GPU particles update shader
  86896. * @returns a string containng the defines string
  86897. */
  86898. getEffectDefines(): string;
  86899. /**
  86900. * Returns the string "SphereDirectedParticleEmitter"
  86901. * @returns a string containing the class name
  86902. */
  86903. getClassName(): string;
  86904. /**
  86905. * Serializes the particle system to a JSON object.
  86906. * @returns the JSON object
  86907. */
  86908. serialize(): any;
  86909. /**
  86910. * Parse properties from a JSON object
  86911. * @param serializationObject defines the JSON object
  86912. */
  86913. parse(serializationObject: any): void;
  86914. }
  86915. }
  86916. declare module BABYLON {
  86917. /**
  86918. * Particle emitter emitting particles from a custom list of positions.
  86919. */
  86920. export class CustomParticleEmitter implements IParticleEmitterType {
  86921. /**
  86922. * Gets or sets the position generator that will create the inital position of each particle.
  86923. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86924. */
  86925. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86926. /**
  86927. * Gets or sets the destination generator that will create the final destination of each particle.
  86928. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86929. */
  86930. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86931. /**
  86932. * Creates a new instance CustomParticleEmitter
  86933. */
  86934. constructor();
  86935. /**
  86936. * Called by the particle System when the direction is computed for the created particle.
  86937. * @param worldMatrix is the world matrix of the particle system
  86938. * @param directionToUpdate is the direction vector to update with the result
  86939. * @param particle is the particle we are computed the direction for
  86940. * @param isLocal defines if the direction should be set in local space
  86941. */
  86942. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86943. /**
  86944. * Called by the particle System when the position is computed for the created particle.
  86945. * @param worldMatrix is the world matrix of the particle system
  86946. * @param positionToUpdate is the position vector to update with the result
  86947. * @param particle is the particle we are computed the position for
  86948. * @param isLocal defines if the position should be set in local space
  86949. */
  86950. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86951. /**
  86952. * Clones the current emitter and returns a copy of it
  86953. * @returns the new emitter
  86954. */
  86955. clone(): CustomParticleEmitter;
  86956. /**
  86957. * Called by the GPUParticleSystem to setup the update shader
  86958. * @param effect defines the update shader
  86959. */
  86960. applyToShader(effect: Effect): void;
  86961. /**
  86962. * Returns a string to use to update the GPU particles update shader
  86963. * @returns a string containng the defines string
  86964. */
  86965. getEffectDefines(): string;
  86966. /**
  86967. * Returns the string "PointParticleEmitter"
  86968. * @returns a string containing the class name
  86969. */
  86970. getClassName(): string;
  86971. /**
  86972. * Serializes the particle system to a JSON object.
  86973. * @returns the JSON object
  86974. */
  86975. serialize(): any;
  86976. /**
  86977. * Parse properties from a JSON object
  86978. * @param serializationObject defines the JSON object
  86979. */
  86980. parse(serializationObject: any): void;
  86981. }
  86982. }
  86983. declare module BABYLON {
  86984. /**
  86985. * Particle emitter emitting particles from the inside of a box.
  86986. * It emits the particles randomly between 2 given directions.
  86987. */
  86988. export class MeshParticleEmitter implements IParticleEmitterType {
  86989. private _indices;
  86990. private _positions;
  86991. private _normals;
  86992. private _storedNormal;
  86993. private _mesh;
  86994. /**
  86995. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86996. */
  86997. direction1: Vector3;
  86998. /**
  86999. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87000. */
  87001. direction2: Vector3;
  87002. /**
  87003. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  87004. */
  87005. useMeshNormalsForDirection: boolean;
  87006. /** Defines the mesh to use as source */
  87007. get mesh(): Nullable<AbstractMesh>;
  87008. set mesh(value: Nullable<AbstractMesh>);
  87009. /**
  87010. * Creates a new instance MeshParticleEmitter
  87011. * @param mesh defines the mesh to use as source
  87012. */
  87013. constructor(mesh?: Nullable<AbstractMesh>);
  87014. /**
  87015. * Called by the particle System when the direction is computed for the created particle.
  87016. * @param worldMatrix is the world matrix of the particle system
  87017. * @param directionToUpdate is the direction vector to update with the result
  87018. * @param particle is the particle we are computed the direction for
  87019. * @param isLocal defines if the direction should be set in local space
  87020. */
  87021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87022. /**
  87023. * Called by the particle System when the position is computed for the created particle.
  87024. * @param worldMatrix is the world matrix of the particle system
  87025. * @param positionToUpdate is the position vector to update with the result
  87026. * @param particle is the particle we are computed the position for
  87027. * @param isLocal defines if the position should be set in local space
  87028. */
  87029. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87030. /**
  87031. * Clones the current emitter and returns a copy of it
  87032. * @returns the new emitter
  87033. */
  87034. clone(): MeshParticleEmitter;
  87035. /**
  87036. * Called by the GPUParticleSystem to setup the update shader
  87037. * @param effect defines the update shader
  87038. */
  87039. applyToShader(effect: Effect): void;
  87040. /**
  87041. * Returns a string to use to update the GPU particles update shader
  87042. * @returns a string containng the defines string
  87043. */
  87044. getEffectDefines(): string;
  87045. /**
  87046. * Returns the string "BoxParticleEmitter"
  87047. * @returns a string containing the class name
  87048. */
  87049. getClassName(): string;
  87050. /**
  87051. * Serializes the particle system to a JSON object.
  87052. * @returns the JSON object
  87053. */
  87054. serialize(): any;
  87055. /**
  87056. * Parse properties from a JSON object
  87057. * @param serializationObject defines the JSON object
  87058. * @param scene defines the hosting scene
  87059. */
  87060. parse(serializationObject: any, scene: Scene): void;
  87061. }
  87062. }
  87063. declare module BABYLON {
  87064. /**
  87065. * Interface representing a particle system in Babylon.js.
  87066. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87067. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87068. */
  87069. export interface IParticleSystem {
  87070. /**
  87071. * List of animations used by the particle system.
  87072. */
  87073. animations: Animation[];
  87074. /**
  87075. * The id of the Particle system.
  87076. */
  87077. id: string;
  87078. /**
  87079. * The name of the Particle system.
  87080. */
  87081. name: string;
  87082. /**
  87083. * The emitter represents the Mesh or position we are attaching the particle system to.
  87084. */
  87085. emitter: Nullable<AbstractMesh | Vector3>;
  87086. /**
  87087. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87088. */
  87089. isBillboardBased: boolean;
  87090. /**
  87091. * The rendering group used by the Particle system to chose when to render.
  87092. */
  87093. renderingGroupId: number;
  87094. /**
  87095. * The layer mask we are rendering the particles through.
  87096. */
  87097. layerMask: number;
  87098. /**
  87099. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87100. */
  87101. updateSpeed: number;
  87102. /**
  87103. * The amount of time the particle system is running (depends of the overall update speed).
  87104. */
  87105. targetStopDuration: number;
  87106. /**
  87107. * The texture used to render each particle. (this can be a spritesheet)
  87108. */
  87109. particleTexture: Nullable<Texture>;
  87110. /**
  87111. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87112. */
  87113. blendMode: number;
  87114. /**
  87115. * Minimum life time of emitting particles.
  87116. */
  87117. minLifeTime: number;
  87118. /**
  87119. * Maximum life time of emitting particles.
  87120. */
  87121. maxLifeTime: number;
  87122. /**
  87123. * Minimum Size of emitting particles.
  87124. */
  87125. minSize: number;
  87126. /**
  87127. * Maximum Size of emitting particles.
  87128. */
  87129. maxSize: number;
  87130. /**
  87131. * Minimum scale of emitting particles on X axis.
  87132. */
  87133. minScaleX: number;
  87134. /**
  87135. * Maximum scale of emitting particles on X axis.
  87136. */
  87137. maxScaleX: number;
  87138. /**
  87139. * Minimum scale of emitting particles on Y axis.
  87140. */
  87141. minScaleY: number;
  87142. /**
  87143. * Maximum scale of emitting particles on Y axis.
  87144. */
  87145. maxScaleY: number;
  87146. /**
  87147. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87148. */
  87149. color1: Color4;
  87150. /**
  87151. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87152. */
  87153. color2: Color4;
  87154. /**
  87155. * Color the particle will have at the end of its lifetime.
  87156. */
  87157. colorDead: Color4;
  87158. /**
  87159. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87160. */
  87161. emitRate: number;
  87162. /**
  87163. * You can use gravity if you want to give an orientation to your particles.
  87164. */
  87165. gravity: Vector3;
  87166. /**
  87167. * Minimum power of emitting particles.
  87168. */
  87169. minEmitPower: number;
  87170. /**
  87171. * Maximum power of emitting particles.
  87172. */
  87173. maxEmitPower: number;
  87174. /**
  87175. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87176. */
  87177. minAngularSpeed: number;
  87178. /**
  87179. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87180. */
  87181. maxAngularSpeed: number;
  87182. /**
  87183. * Gets or sets the minimal initial rotation in radians.
  87184. */
  87185. minInitialRotation: number;
  87186. /**
  87187. * Gets or sets the maximal initial rotation in radians.
  87188. */
  87189. maxInitialRotation: number;
  87190. /**
  87191. * The particle emitter type defines the emitter used by the particle system.
  87192. * It can be for example box, sphere, or cone...
  87193. */
  87194. particleEmitterType: Nullable<IParticleEmitterType>;
  87195. /**
  87196. * Defines the delay in milliseconds before starting the system (0 by default)
  87197. */
  87198. startDelay: number;
  87199. /**
  87200. * 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
  87201. */
  87202. preWarmCycles: number;
  87203. /**
  87204. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87205. */
  87206. preWarmStepOffset: number;
  87207. /**
  87208. * 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)
  87209. */
  87210. spriteCellChangeSpeed: number;
  87211. /**
  87212. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87213. */
  87214. startSpriteCellID: number;
  87215. /**
  87216. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87217. */
  87218. endSpriteCellID: number;
  87219. /**
  87220. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87221. */
  87222. spriteCellWidth: number;
  87223. /**
  87224. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87225. */
  87226. spriteCellHeight: number;
  87227. /**
  87228. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87229. */
  87230. spriteRandomStartCell: boolean;
  87231. /**
  87232. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87233. */
  87234. isAnimationSheetEnabled: boolean;
  87235. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87236. translationPivot: Vector2;
  87237. /**
  87238. * Gets or sets a texture used to add random noise to particle positions
  87239. */
  87240. noiseTexture: Nullable<BaseTexture>;
  87241. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87242. noiseStrength: Vector3;
  87243. /**
  87244. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87245. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87246. */
  87247. billboardMode: number;
  87248. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87249. limitVelocityDamping: number;
  87250. /**
  87251. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87252. */
  87253. beginAnimationOnStart: boolean;
  87254. /**
  87255. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87256. */
  87257. beginAnimationFrom: number;
  87258. /**
  87259. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87260. */
  87261. beginAnimationTo: number;
  87262. /**
  87263. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87264. */
  87265. beginAnimationLoop: boolean;
  87266. /**
  87267. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87268. */
  87269. disposeOnStop: boolean;
  87270. /**
  87271. * Specifies if the particles are updated in emitter local space or world space
  87272. */
  87273. isLocal: boolean;
  87274. /**
  87275. * Gets the maximum number of particles active at the same time.
  87276. * @returns The max number of active particles.
  87277. */
  87278. getCapacity(): number;
  87279. /**
  87280. * Gets the number of particles active at the same time.
  87281. * @returns The number of active particles.
  87282. */
  87283. getActiveCount(): number;
  87284. /**
  87285. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87286. * @returns True if it has been started, otherwise false.
  87287. */
  87288. isStarted(): boolean;
  87289. /**
  87290. * Animates the particle system for this frame.
  87291. */
  87292. animate(): void;
  87293. /**
  87294. * Renders the particle system in its current state.
  87295. * @returns the current number of particles
  87296. */
  87297. render(): number;
  87298. /**
  87299. * Dispose the particle system and frees its associated resources.
  87300. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87301. */
  87302. dispose(disposeTexture?: boolean): void;
  87303. /**
  87304. * Clones the particle system.
  87305. * @param name The name of the cloned object
  87306. * @param newEmitter The new emitter to use
  87307. * @returns the cloned particle system
  87308. */
  87309. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87310. /**
  87311. * Serializes the particle system to a JSON object.
  87312. * @returns the JSON object
  87313. */
  87314. serialize(): any;
  87315. /**
  87316. * Rebuild the particle system
  87317. */
  87318. rebuild(): void;
  87319. /**
  87320. * Starts the particle system and begins to emit
  87321. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87322. */
  87323. start(delay?: number): void;
  87324. /**
  87325. * Stops the particle system.
  87326. */
  87327. stop(): void;
  87328. /**
  87329. * Remove all active particles
  87330. */
  87331. reset(): void;
  87332. /**
  87333. * Gets a boolean indicating that the system is stopping
  87334. * @returns true if the system is currently stopping
  87335. */
  87336. isStopping(): boolean;
  87337. /**
  87338. * Is this system ready to be used/rendered
  87339. * @return true if the system is ready
  87340. */
  87341. isReady(): boolean;
  87342. /**
  87343. * Returns the string "ParticleSystem"
  87344. * @returns a string containing the class name
  87345. */
  87346. getClassName(): string;
  87347. /**
  87348. * Adds a new color gradient
  87349. * @param gradient defines the gradient to use (between 0 and 1)
  87350. * @param color1 defines the color to affect to the specified gradient
  87351. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87352. * @returns the current particle system
  87353. */
  87354. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87355. /**
  87356. * Remove a specific color gradient
  87357. * @param gradient defines the gradient to remove
  87358. * @returns the current particle system
  87359. */
  87360. removeColorGradient(gradient: number): IParticleSystem;
  87361. /**
  87362. * Adds a new size gradient
  87363. * @param gradient defines the gradient to use (between 0 and 1)
  87364. * @param factor defines the size factor to affect to the specified gradient
  87365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87366. * @returns the current particle system
  87367. */
  87368. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87369. /**
  87370. * Remove a specific size gradient
  87371. * @param gradient defines the gradient to remove
  87372. * @returns the current particle system
  87373. */
  87374. removeSizeGradient(gradient: number): IParticleSystem;
  87375. /**
  87376. * Gets the current list of color gradients.
  87377. * You must use addColorGradient and removeColorGradient to udpate this list
  87378. * @returns the list of color gradients
  87379. */
  87380. getColorGradients(): Nullable<Array<ColorGradient>>;
  87381. /**
  87382. * Gets the current list of size gradients.
  87383. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87384. * @returns the list of size gradients
  87385. */
  87386. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87387. /**
  87388. * Gets the current list of angular speed gradients.
  87389. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87390. * @returns the list of angular speed gradients
  87391. */
  87392. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87393. /**
  87394. * Adds a new angular speed gradient
  87395. * @param gradient defines the gradient to use (between 0 and 1)
  87396. * @param factor defines the angular speed to affect to the specified gradient
  87397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87398. * @returns the current particle system
  87399. */
  87400. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87401. /**
  87402. * Remove a specific angular speed gradient
  87403. * @param gradient defines the gradient to remove
  87404. * @returns the current particle system
  87405. */
  87406. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87407. /**
  87408. * Gets the current list of velocity gradients.
  87409. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87410. * @returns the list of velocity gradients
  87411. */
  87412. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87413. /**
  87414. * Adds a new velocity gradient
  87415. * @param gradient defines the gradient to use (between 0 and 1)
  87416. * @param factor defines the velocity to affect to the specified gradient
  87417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87418. * @returns the current particle system
  87419. */
  87420. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87421. /**
  87422. * Remove a specific velocity gradient
  87423. * @param gradient defines the gradient to remove
  87424. * @returns the current particle system
  87425. */
  87426. removeVelocityGradient(gradient: number): IParticleSystem;
  87427. /**
  87428. * Gets the current list of limit velocity gradients.
  87429. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87430. * @returns the list of limit velocity gradients
  87431. */
  87432. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87433. /**
  87434. * Adds a new limit velocity gradient
  87435. * @param gradient defines the gradient to use (between 0 and 1)
  87436. * @param factor defines the limit velocity to affect to the specified gradient
  87437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87438. * @returns the current particle system
  87439. */
  87440. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87441. /**
  87442. * Remove a specific limit velocity gradient
  87443. * @param gradient defines the gradient to remove
  87444. * @returns the current particle system
  87445. */
  87446. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87447. /**
  87448. * Adds a new drag gradient
  87449. * @param gradient defines the gradient to use (between 0 and 1)
  87450. * @param factor defines the drag to affect to the specified gradient
  87451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87452. * @returns the current particle system
  87453. */
  87454. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87455. /**
  87456. * Remove a specific drag gradient
  87457. * @param gradient defines the gradient to remove
  87458. * @returns the current particle system
  87459. */
  87460. removeDragGradient(gradient: number): IParticleSystem;
  87461. /**
  87462. * Gets the current list of drag gradients.
  87463. * You must use addDragGradient and removeDragGradient to udpate this list
  87464. * @returns the list of drag gradients
  87465. */
  87466. getDragGradients(): Nullable<Array<FactorGradient>>;
  87467. /**
  87468. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87469. * @param gradient defines the gradient to use (between 0 and 1)
  87470. * @param factor defines the emit rate to affect to the specified gradient
  87471. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87472. * @returns the current particle system
  87473. */
  87474. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87475. /**
  87476. * Remove a specific emit rate gradient
  87477. * @param gradient defines the gradient to remove
  87478. * @returns the current particle system
  87479. */
  87480. removeEmitRateGradient(gradient: number): IParticleSystem;
  87481. /**
  87482. * Gets the current list of emit rate gradients.
  87483. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87484. * @returns the list of emit rate gradients
  87485. */
  87486. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87487. /**
  87488. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87489. * @param gradient defines the gradient to use (between 0 and 1)
  87490. * @param factor defines the start size to affect to the specified gradient
  87491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87492. * @returns the current particle system
  87493. */
  87494. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87495. /**
  87496. * Remove a specific start size gradient
  87497. * @param gradient defines the gradient to remove
  87498. * @returns the current particle system
  87499. */
  87500. removeStartSizeGradient(gradient: number): IParticleSystem;
  87501. /**
  87502. * Gets the current list of start size gradients.
  87503. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87504. * @returns the list of start size gradients
  87505. */
  87506. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87507. /**
  87508. * Adds a new life time gradient
  87509. * @param gradient defines the gradient to use (between 0 and 1)
  87510. * @param factor defines the life time factor to affect to the specified gradient
  87511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87512. * @returns the current particle system
  87513. */
  87514. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87515. /**
  87516. * Remove a specific life time gradient
  87517. * @param gradient defines the gradient to remove
  87518. * @returns the current particle system
  87519. */
  87520. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87521. /**
  87522. * Gets the current list of life time gradients.
  87523. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87524. * @returns the list of life time gradients
  87525. */
  87526. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87527. /**
  87528. * Gets the current list of color gradients.
  87529. * You must use addColorGradient and removeColorGradient to udpate this list
  87530. * @returns the list of color gradients
  87531. */
  87532. getColorGradients(): Nullable<Array<ColorGradient>>;
  87533. /**
  87534. * Adds a new ramp gradient used to remap particle colors
  87535. * @param gradient defines the gradient to use (between 0 and 1)
  87536. * @param color defines the color to affect to the specified gradient
  87537. * @returns the current particle system
  87538. */
  87539. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87540. /**
  87541. * Gets the current list of ramp gradients.
  87542. * You must use addRampGradient and removeRampGradient to udpate this list
  87543. * @returns the list of ramp gradients
  87544. */
  87545. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87546. /** Gets or sets a boolean indicating that ramp gradients must be used
  87547. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87548. */
  87549. useRampGradients: boolean;
  87550. /**
  87551. * Adds a new color remap gradient
  87552. * @param gradient defines the gradient to use (between 0 and 1)
  87553. * @param min defines the color remap minimal range
  87554. * @param max defines the color remap maximal range
  87555. * @returns the current particle system
  87556. */
  87557. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87558. /**
  87559. * Gets the current list of color remap gradients.
  87560. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87561. * @returns the list of color remap gradients
  87562. */
  87563. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87564. /**
  87565. * Adds a new alpha remap gradient
  87566. * @param gradient defines the gradient to use (between 0 and 1)
  87567. * @param min defines the alpha remap minimal range
  87568. * @param max defines the alpha remap maximal range
  87569. * @returns the current particle system
  87570. */
  87571. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87572. /**
  87573. * Gets the current list of alpha remap gradients.
  87574. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87575. * @returns the list of alpha remap gradients
  87576. */
  87577. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87578. /**
  87579. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87580. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87581. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87582. * @returns the emitter
  87583. */
  87584. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87585. /**
  87586. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87587. * @param radius The radius of the hemisphere to emit from
  87588. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87589. * @returns the emitter
  87590. */
  87591. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87592. /**
  87593. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87594. * @param radius The radius of the sphere to emit from
  87595. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87596. * @returns the emitter
  87597. */
  87598. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87599. /**
  87600. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87601. * @param radius The radius of the sphere to emit from
  87602. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87603. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87604. * @returns the emitter
  87605. */
  87606. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87607. /**
  87608. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87609. * @param radius The radius of the emission cylinder
  87610. * @param height The height of the emission cylinder
  87611. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87612. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87613. * @returns the emitter
  87614. */
  87615. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87616. /**
  87617. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87618. * @param radius The radius of the cylinder to emit from
  87619. * @param height The height of the emission cylinder
  87620. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87621. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87622. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87623. * @returns the emitter
  87624. */
  87625. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87626. /**
  87627. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87628. * @param radius The radius of the cone to emit from
  87629. * @param angle The base angle of the cone
  87630. * @returns the emitter
  87631. */
  87632. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87633. /**
  87634. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87635. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87636. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87637. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87638. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87639. * @returns the emitter
  87640. */
  87641. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87642. /**
  87643. * Get hosting scene
  87644. * @returns the scene
  87645. */
  87646. getScene(): Scene;
  87647. }
  87648. }
  87649. declare module BABYLON {
  87650. /**
  87651. * 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.
  87652. * @see https://doc.babylonjs.com/how_to/transformnode
  87653. */
  87654. export class TransformNode extends Node {
  87655. /**
  87656. * Object will not rotate to face the camera
  87657. */
  87658. static BILLBOARDMODE_NONE: number;
  87659. /**
  87660. * Object will rotate to face the camera but only on the x axis
  87661. */
  87662. static BILLBOARDMODE_X: number;
  87663. /**
  87664. * Object will rotate to face the camera but only on the y axis
  87665. */
  87666. static BILLBOARDMODE_Y: number;
  87667. /**
  87668. * Object will rotate to face the camera but only on the z axis
  87669. */
  87670. static BILLBOARDMODE_Z: number;
  87671. /**
  87672. * Object will rotate to face the camera
  87673. */
  87674. static BILLBOARDMODE_ALL: number;
  87675. /**
  87676. * Object will rotate to face the camera's position instead of orientation
  87677. */
  87678. static BILLBOARDMODE_USE_POSITION: number;
  87679. private _forward;
  87680. private _forwardInverted;
  87681. private _up;
  87682. private _right;
  87683. private _rightInverted;
  87684. private _position;
  87685. private _rotation;
  87686. private _rotationQuaternion;
  87687. protected _scaling: Vector3;
  87688. protected _isDirty: boolean;
  87689. private _transformToBoneReferal;
  87690. private _isAbsoluteSynced;
  87691. private _billboardMode;
  87692. /**
  87693. * Gets or sets the billboard mode. Default is 0.
  87694. *
  87695. * | Value | Type | Description |
  87696. * | --- | --- | --- |
  87697. * | 0 | BILLBOARDMODE_NONE | |
  87698. * | 1 | BILLBOARDMODE_X | |
  87699. * | 2 | BILLBOARDMODE_Y | |
  87700. * | 4 | BILLBOARDMODE_Z | |
  87701. * | 7 | BILLBOARDMODE_ALL | |
  87702. *
  87703. */
  87704. get billboardMode(): number;
  87705. set billboardMode(value: number);
  87706. private _preserveParentRotationForBillboard;
  87707. /**
  87708. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87709. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87710. */
  87711. get preserveParentRotationForBillboard(): boolean;
  87712. set preserveParentRotationForBillboard(value: boolean);
  87713. /**
  87714. * 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
  87715. */
  87716. scalingDeterminant: number;
  87717. private _infiniteDistance;
  87718. /**
  87719. * Gets or sets the distance of the object to max, often used by skybox
  87720. */
  87721. get infiniteDistance(): boolean;
  87722. set infiniteDistance(value: boolean);
  87723. /**
  87724. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87725. * By default the system will update normals to compensate
  87726. */
  87727. ignoreNonUniformScaling: boolean;
  87728. /**
  87729. * 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
  87730. */
  87731. reIntegrateRotationIntoRotationQuaternion: boolean;
  87732. /** @hidden */
  87733. _poseMatrix: Nullable<Matrix>;
  87734. /** @hidden */
  87735. _localMatrix: Matrix;
  87736. private _usePivotMatrix;
  87737. private _absolutePosition;
  87738. private _absoluteScaling;
  87739. private _absoluteRotationQuaternion;
  87740. private _pivotMatrix;
  87741. private _pivotMatrixInverse;
  87742. protected _postMultiplyPivotMatrix: boolean;
  87743. protected _isWorldMatrixFrozen: boolean;
  87744. /** @hidden */
  87745. _indexInSceneTransformNodesArray: number;
  87746. /**
  87747. * An event triggered after the world matrix is updated
  87748. */
  87749. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87750. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87751. /**
  87752. * Gets a string identifying the name of the class
  87753. * @returns "TransformNode" string
  87754. */
  87755. getClassName(): string;
  87756. /**
  87757. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87758. */
  87759. get position(): Vector3;
  87760. set position(newPosition: Vector3);
  87761. /**
  87762. * 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)).
  87763. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87764. */
  87765. get rotation(): Vector3;
  87766. set rotation(newRotation: Vector3);
  87767. /**
  87768. * 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)).
  87769. */
  87770. get scaling(): Vector3;
  87771. set scaling(newScaling: Vector3);
  87772. /**
  87773. * 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).
  87774. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87775. */
  87776. get rotationQuaternion(): Nullable<Quaternion>;
  87777. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87778. /**
  87779. * The forward direction of that transform in world space.
  87780. */
  87781. get forward(): Vector3;
  87782. /**
  87783. * The up direction of that transform in world space.
  87784. */
  87785. get up(): Vector3;
  87786. /**
  87787. * The right direction of that transform in world space.
  87788. */
  87789. get right(): Vector3;
  87790. /**
  87791. * Copies the parameter passed Matrix into the mesh Pose matrix.
  87792. * @param matrix the matrix to copy the pose from
  87793. * @returns this TransformNode.
  87794. */
  87795. updatePoseMatrix(matrix: Matrix): TransformNode;
  87796. /**
  87797. * Returns the mesh Pose matrix.
  87798. * @returns the pose matrix
  87799. */
  87800. getPoseMatrix(): Matrix;
  87801. /** @hidden */
  87802. _isSynchronized(): boolean;
  87803. /** @hidden */
  87804. _initCache(): void;
  87805. /**
  87806. * Flag the transform node as dirty (Forcing it to update everything)
  87807. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  87808. * @returns this transform node
  87809. */
  87810. markAsDirty(property: string): TransformNode;
  87811. /**
  87812. * Returns the current mesh absolute position.
  87813. * Returns a Vector3.
  87814. */
  87815. get absolutePosition(): Vector3;
  87816. /**
  87817. * Returns the current mesh absolute scaling.
  87818. * Returns a Vector3.
  87819. */
  87820. get absoluteScaling(): Vector3;
  87821. /**
  87822. * Returns the current mesh absolute rotation.
  87823. * Returns a Quaternion.
  87824. */
  87825. get absoluteRotationQuaternion(): Quaternion;
  87826. /**
  87827. * Sets a new matrix to apply before all other transformation
  87828. * @param matrix defines the transform matrix
  87829. * @returns the current TransformNode
  87830. */
  87831. setPreTransformMatrix(matrix: Matrix): TransformNode;
  87832. /**
  87833. * Sets a new pivot matrix to the current node
  87834. * @param matrix defines the new pivot matrix to use
  87835. * @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
  87836. * @returns the current TransformNode
  87837. */
  87838. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  87839. /**
  87840. * Returns the mesh pivot matrix.
  87841. * Default : Identity.
  87842. * @returns the matrix
  87843. */
  87844. getPivotMatrix(): Matrix;
  87845. /**
  87846. * Instantiate (when possible) or clone that node with its hierarchy
  87847. * @param newParent defines the new parent to use for the instance (or clone)
  87848. * @param options defines options to configure how copy is done
  87849. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  87850. * @returns an instance (or a clone) of the current node with its hiearchy
  87851. */
  87852. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  87853. doNotInstantiate: boolean;
  87854. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  87855. /**
  87856. * Prevents the World matrix to be computed any longer
  87857. * @param newWorldMatrix defines an optional matrix to use as world matrix
  87858. * @returns the TransformNode.
  87859. */
  87860. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  87861. /**
  87862. * Allows back the World matrix computation.
  87863. * @returns the TransformNode.
  87864. */
  87865. unfreezeWorldMatrix(): this;
  87866. /**
  87867. * True if the World matrix has been frozen.
  87868. */
  87869. get isWorldMatrixFrozen(): boolean;
  87870. /**
  87871. * Retuns the mesh absolute position in the World.
  87872. * @returns a Vector3.
  87873. */
  87874. getAbsolutePosition(): Vector3;
  87875. /**
  87876. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  87877. * @param absolutePosition the absolute position to set
  87878. * @returns the TransformNode.
  87879. */
  87880. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  87881. /**
  87882. * Sets the mesh position in its local space.
  87883. * @param vector3 the position to set in localspace
  87884. * @returns the TransformNode.
  87885. */
  87886. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  87887. /**
  87888. * Returns the mesh position in the local space from the current World matrix values.
  87889. * @returns a new Vector3.
  87890. */
  87891. getPositionExpressedInLocalSpace(): Vector3;
  87892. /**
  87893. * Translates the mesh along the passed Vector3 in its local space.
  87894. * @param vector3 the distance to translate in localspace
  87895. * @returns the TransformNode.
  87896. */
  87897. locallyTranslate(vector3: Vector3): TransformNode;
  87898. private static _lookAtVectorCache;
  87899. /**
  87900. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87901. * @param targetPoint the position (must be in same space as current mesh) to look at
  87902. * @param yawCor optional yaw (y-axis) correction in radians
  87903. * @param pitchCor optional pitch (x-axis) correction in radians
  87904. * @param rollCor optional roll (z-axis) correction in radians
  87905. * @param space the choosen space of the target
  87906. * @returns the TransformNode.
  87907. */
  87908. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87909. /**
  87910. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87911. * This Vector3 is expressed in the World space.
  87912. * @param localAxis axis to rotate
  87913. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87914. */
  87915. getDirection(localAxis: Vector3): Vector3;
  87916. /**
  87917. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87918. * localAxis is expressed in the mesh local space.
  87919. * result is computed in the Wordl space from the mesh World matrix.
  87920. * @param localAxis axis to rotate
  87921. * @param result the resulting transformnode
  87922. * @returns this TransformNode.
  87923. */
  87924. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87925. /**
  87926. * Sets this transform node rotation to the given local axis.
  87927. * @param localAxis the axis in local space
  87928. * @param yawCor optional yaw (y-axis) correction in radians
  87929. * @param pitchCor optional pitch (x-axis) correction in radians
  87930. * @param rollCor optional roll (z-axis) correction in radians
  87931. * @returns this TransformNode
  87932. */
  87933. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87934. /**
  87935. * Sets a new pivot point to the current node
  87936. * @param point defines the new pivot point to use
  87937. * @param space defines if the point is in world or local space (local by default)
  87938. * @returns the current TransformNode
  87939. */
  87940. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87941. /**
  87942. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87943. * @returns the pivot point
  87944. */
  87945. getPivotPoint(): Vector3;
  87946. /**
  87947. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87948. * @param result the vector3 to store the result
  87949. * @returns this TransformNode.
  87950. */
  87951. getPivotPointToRef(result: Vector3): TransformNode;
  87952. /**
  87953. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87954. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87955. */
  87956. getAbsolutePivotPoint(): Vector3;
  87957. /**
  87958. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87959. * @param result vector3 to store the result
  87960. * @returns this TransformNode.
  87961. */
  87962. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87963. /**
  87964. * Defines the passed node as the parent of the current node.
  87965. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87966. * @see https://doc.babylonjs.com/how_to/parenting
  87967. * @param node the node ot set as the parent
  87968. * @returns this TransformNode.
  87969. */
  87970. setParent(node: Nullable<Node>): TransformNode;
  87971. private _nonUniformScaling;
  87972. /**
  87973. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87974. */
  87975. get nonUniformScaling(): boolean;
  87976. /** @hidden */
  87977. _updateNonUniformScalingState(value: boolean): boolean;
  87978. /**
  87979. * Attach the current TransformNode to another TransformNode associated with a bone
  87980. * @param bone Bone affecting the TransformNode
  87981. * @param affectedTransformNode TransformNode associated with the bone
  87982. * @returns this object
  87983. */
  87984. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87985. /**
  87986. * Detach the transform node if its associated with a bone
  87987. * @returns this object
  87988. */
  87989. detachFromBone(): TransformNode;
  87990. private static _rotationAxisCache;
  87991. /**
  87992. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87993. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87994. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87995. * The passed axis is also normalized.
  87996. * @param axis the axis to rotate around
  87997. * @param amount the amount to rotate in radians
  87998. * @param space Space to rotate in (Default: local)
  87999. * @returns the TransformNode.
  88000. */
  88001. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88002. /**
  88003. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  88004. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88005. * The passed axis is also normalized. .
  88006. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  88007. * @param point the point to rotate around
  88008. * @param axis the axis to rotate around
  88009. * @param amount the amount to rotate in radians
  88010. * @returns the TransformNode
  88011. */
  88012. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  88013. /**
  88014. * Translates the mesh along the axis vector for the passed distance in the given space.
  88015. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88016. * @param axis the axis to translate in
  88017. * @param distance the distance to translate
  88018. * @param space Space to rotate in (Default: local)
  88019. * @returns the TransformNode.
  88020. */
  88021. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88022. /**
  88023. * Adds a rotation step to the mesh current rotation.
  88024. * x, y, z are Euler angles expressed in radians.
  88025. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  88026. * This means this rotation is made in the mesh local space only.
  88027. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  88028. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  88029. * ```javascript
  88030. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  88031. * ```
  88032. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  88033. * 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.
  88034. * @param x Rotation to add
  88035. * @param y Rotation to add
  88036. * @param z Rotation to add
  88037. * @returns the TransformNode.
  88038. */
  88039. addRotation(x: number, y: number, z: number): TransformNode;
  88040. /**
  88041. * @hidden
  88042. */
  88043. protected _getEffectiveParent(): Nullable<Node>;
  88044. /**
  88045. * Computes the world matrix of the node
  88046. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88047. * @returns the world matrix
  88048. */
  88049. computeWorldMatrix(force?: boolean): Matrix;
  88050. /**
  88051. * Resets this nodeTransform's local matrix to Matrix.Identity().
  88052. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  88053. */
  88054. resetLocalMatrix(independentOfChildren?: boolean): void;
  88055. protected _afterComputeWorldMatrix(): void;
  88056. /**
  88057. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  88058. * @param func callback function to add
  88059. *
  88060. * @returns the TransformNode.
  88061. */
  88062. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88063. /**
  88064. * Removes a registered callback function.
  88065. * @param func callback function to remove
  88066. * @returns the TransformNode.
  88067. */
  88068. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88069. /**
  88070. * Gets the position of the current mesh in camera space
  88071. * @param camera defines the camera to use
  88072. * @returns a position
  88073. */
  88074. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  88075. /**
  88076. * Returns the distance from the mesh to the active camera
  88077. * @param camera defines the camera to use
  88078. * @returns the distance
  88079. */
  88080. getDistanceToCamera(camera?: Nullable<Camera>): number;
  88081. /**
  88082. * Clone the current transform node
  88083. * @param name Name of the new clone
  88084. * @param newParent New parent for the clone
  88085. * @param doNotCloneChildren Do not clone children hierarchy
  88086. * @returns the new transform node
  88087. */
  88088. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  88089. /**
  88090. * Serializes the objects information.
  88091. * @param currentSerializationObject defines the object to serialize in
  88092. * @returns the serialized object
  88093. */
  88094. serialize(currentSerializationObject?: any): any;
  88095. /**
  88096. * Returns a new TransformNode object parsed from the source provided.
  88097. * @param parsedTransformNode is the source.
  88098. * @param scene the scne the object belongs to
  88099. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  88100. * @returns a new TransformNode object parsed from the source provided.
  88101. */
  88102. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  88103. /**
  88104. * Get all child-transformNodes of this node
  88105. * @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
  88106. * @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
  88107. * @returns an array of TransformNode
  88108. */
  88109. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  88110. /**
  88111. * Releases resources associated with this transform node.
  88112. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88113. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88114. */
  88115. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88116. /**
  88117. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  88118. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  88119. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  88120. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  88121. * @returns the current mesh
  88122. */
  88123. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  88124. private _syncAbsoluteScalingAndRotation;
  88125. }
  88126. }
  88127. declare module BABYLON {
  88128. /**
  88129. * Class used to override all child animations of a given target
  88130. */
  88131. export class AnimationPropertiesOverride {
  88132. /**
  88133. * Gets or sets a value indicating if animation blending must be used
  88134. */
  88135. enableBlending: boolean;
  88136. /**
  88137. * Gets or sets the blending speed to use when enableBlending is true
  88138. */
  88139. blendingSpeed: number;
  88140. /**
  88141. * Gets or sets the default loop mode to use
  88142. */
  88143. loopMode: number;
  88144. }
  88145. }
  88146. declare module BABYLON {
  88147. /**
  88148. * Class used to store bone information
  88149. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88150. */
  88151. export class Bone extends Node {
  88152. /**
  88153. * defines the bone name
  88154. */
  88155. name: string;
  88156. private static _tmpVecs;
  88157. private static _tmpQuat;
  88158. private static _tmpMats;
  88159. /**
  88160. * Gets the list of child bones
  88161. */
  88162. children: Bone[];
  88163. /** Gets the animations associated with this bone */
  88164. animations: Animation[];
  88165. /**
  88166. * Gets or sets bone length
  88167. */
  88168. length: number;
  88169. /**
  88170. * @hidden Internal only
  88171. * Set this value to map this bone to a different index in the transform matrices
  88172. * Set this value to -1 to exclude the bone from the transform matrices
  88173. */
  88174. _index: Nullable<number>;
  88175. private _skeleton;
  88176. private _localMatrix;
  88177. private _restPose;
  88178. private _baseMatrix;
  88179. private _absoluteTransform;
  88180. private _invertedAbsoluteTransform;
  88181. private _parent;
  88182. private _scalingDeterminant;
  88183. private _worldTransform;
  88184. private _localScaling;
  88185. private _localRotation;
  88186. private _localPosition;
  88187. private _needToDecompose;
  88188. private _needToCompose;
  88189. /** @hidden */
  88190. _linkedTransformNode: Nullable<TransformNode>;
  88191. /** @hidden */
  88192. _waitingTransformNodeId: Nullable<string>;
  88193. /** @hidden */
  88194. get _matrix(): Matrix;
  88195. /** @hidden */
  88196. set _matrix(value: Matrix);
  88197. /**
  88198. * Create a new bone
  88199. * @param name defines the bone name
  88200. * @param skeleton defines the parent skeleton
  88201. * @param parentBone defines the parent (can be null if the bone is the root)
  88202. * @param localMatrix defines the local matrix
  88203. * @param restPose defines the rest pose matrix
  88204. * @param baseMatrix defines the base matrix
  88205. * @param index defines index of the bone in the hiearchy
  88206. */
  88207. constructor(
  88208. /**
  88209. * defines the bone name
  88210. */
  88211. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  88212. /**
  88213. * Gets the current object class name.
  88214. * @return the class name
  88215. */
  88216. getClassName(): string;
  88217. /**
  88218. * Gets the parent skeleton
  88219. * @returns a skeleton
  88220. */
  88221. getSkeleton(): Skeleton;
  88222. /**
  88223. * Gets parent bone
  88224. * @returns a bone or null if the bone is the root of the bone hierarchy
  88225. */
  88226. getParent(): Nullable<Bone>;
  88227. /**
  88228. * Returns an array containing the root bones
  88229. * @returns an array containing the root bones
  88230. */
  88231. getChildren(): Array<Bone>;
  88232. /**
  88233. * Gets the node index in matrix array generated for rendering
  88234. * @returns the node index
  88235. */
  88236. getIndex(): number;
  88237. /**
  88238. * Sets the parent bone
  88239. * @param parent defines the parent (can be null if the bone is the root)
  88240. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88241. */
  88242. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  88243. /**
  88244. * Gets the local matrix
  88245. * @returns a matrix
  88246. */
  88247. getLocalMatrix(): Matrix;
  88248. /**
  88249. * Gets the base matrix (initial matrix which remains unchanged)
  88250. * @returns a matrix
  88251. */
  88252. getBaseMatrix(): Matrix;
  88253. /**
  88254. * Gets the rest pose matrix
  88255. * @returns a matrix
  88256. */
  88257. getRestPose(): Matrix;
  88258. /**
  88259. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  88260. */
  88261. getWorldMatrix(): Matrix;
  88262. /**
  88263. * Sets the local matrix to rest pose matrix
  88264. */
  88265. returnToRest(): void;
  88266. /**
  88267. * Gets the inverse of the absolute transform matrix.
  88268. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  88269. * @returns a matrix
  88270. */
  88271. getInvertedAbsoluteTransform(): Matrix;
  88272. /**
  88273. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  88274. * @returns a matrix
  88275. */
  88276. getAbsoluteTransform(): Matrix;
  88277. /**
  88278. * Links with the given transform node.
  88279. * The local matrix of this bone is copied from the transform node every frame.
  88280. * @param transformNode defines the transform node to link to
  88281. */
  88282. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  88283. /**
  88284. * Gets the node used to drive the bone's transformation
  88285. * @returns a transform node or null
  88286. */
  88287. getTransformNode(): Nullable<TransformNode>;
  88288. /** Gets or sets current position (in local space) */
  88289. get position(): Vector3;
  88290. set position(newPosition: Vector3);
  88291. /** Gets or sets current rotation (in local space) */
  88292. get rotation(): Vector3;
  88293. set rotation(newRotation: Vector3);
  88294. /** Gets or sets current rotation quaternion (in local space) */
  88295. get rotationQuaternion(): Quaternion;
  88296. set rotationQuaternion(newRotation: Quaternion);
  88297. /** Gets or sets current scaling (in local space) */
  88298. get scaling(): Vector3;
  88299. set scaling(newScaling: Vector3);
  88300. /**
  88301. * Gets the animation properties override
  88302. */
  88303. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88304. private _decompose;
  88305. private _compose;
  88306. /**
  88307. * Update the base and local matrices
  88308. * @param matrix defines the new base or local matrix
  88309. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88310. * @param updateLocalMatrix defines if the local matrix should be updated
  88311. */
  88312. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  88313. /** @hidden */
  88314. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  88315. /**
  88316. * Flag the bone as dirty (Forcing it to update everything)
  88317. */
  88318. markAsDirty(): void;
  88319. /** @hidden */
  88320. _markAsDirtyAndCompose(): void;
  88321. private _markAsDirtyAndDecompose;
  88322. /**
  88323. * Translate the bone in local or world space
  88324. * @param vec The amount to translate the bone
  88325. * @param space The space that the translation is in
  88326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88327. */
  88328. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88329. /**
  88330. * Set the postion of the bone in local or world space
  88331. * @param position The position to set the bone
  88332. * @param space The space that the position is in
  88333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88334. */
  88335. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88336. /**
  88337. * Set the absolute position of the bone (world space)
  88338. * @param position The position to set the bone
  88339. * @param mesh The mesh that this bone is attached to
  88340. */
  88341. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  88342. /**
  88343. * Scale the bone on the x, y and z axes (in local space)
  88344. * @param x The amount to scale the bone on the x axis
  88345. * @param y The amount to scale the bone on the y axis
  88346. * @param z The amount to scale the bone on the z axis
  88347. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  88348. */
  88349. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  88350. /**
  88351. * Set the bone scaling in local space
  88352. * @param scale defines the scaling vector
  88353. */
  88354. setScale(scale: Vector3): void;
  88355. /**
  88356. * Gets the current scaling in local space
  88357. * @returns the current scaling vector
  88358. */
  88359. getScale(): Vector3;
  88360. /**
  88361. * Gets the current scaling in local space and stores it in a target vector
  88362. * @param result defines the target vector
  88363. */
  88364. getScaleToRef(result: Vector3): void;
  88365. /**
  88366. * Set the yaw, pitch, and roll of the bone in local or world space
  88367. * @param yaw The rotation of the bone on the y axis
  88368. * @param pitch The rotation of the bone on the x axis
  88369. * @param roll The rotation of the bone on the z axis
  88370. * @param space The space that the axes of rotation are in
  88371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88372. */
  88373. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  88374. /**
  88375. * Add a rotation to the bone on an axis in local or world space
  88376. * @param axis The axis to rotate the bone on
  88377. * @param amount The amount to rotate the bone
  88378. * @param space The space that the axis is in
  88379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88380. */
  88381. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  88382. /**
  88383. * Set the rotation of the bone to a particular axis angle in local or world space
  88384. * @param axis The axis to rotate the bone on
  88385. * @param angle The angle that the bone should be rotated to
  88386. * @param space The space that the axis is in
  88387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88388. */
  88389. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  88390. /**
  88391. * Set the euler rotation of the bone in local of world space
  88392. * @param rotation The euler rotation that the bone should be set to
  88393. * @param space The space that the rotation is in
  88394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88395. */
  88396. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88397. /**
  88398. * Set the quaternion rotation of the bone in local of world space
  88399. * @param quat The quaternion rotation that the bone should be set to
  88400. * @param space The space that the rotation is in
  88401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88402. */
  88403. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  88404. /**
  88405. * Set the rotation matrix of the bone in local of world space
  88406. * @param rotMat The rotation matrix that the bone should be set to
  88407. * @param space The space that the rotation is in
  88408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88409. */
  88410. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  88411. private _rotateWithMatrix;
  88412. private _getNegativeRotationToRef;
  88413. /**
  88414. * Get the position of the bone in local or world space
  88415. * @param space The space that the returned position is in
  88416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88417. * @returns The position of the bone
  88418. */
  88419. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88420. /**
  88421. * Copy the position of the bone to a vector3 in local or world space
  88422. * @param space The space that the returned position is in
  88423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88424. * @param result The vector3 to copy the position to
  88425. */
  88426. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  88427. /**
  88428. * Get the absolute position of the bone (world space)
  88429. * @param mesh The mesh that this bone is attached to
  88430. * @returns The absolute position of the bone
  88431. */
  88432. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  88433. /**
  88434. * Copy the absolute position of the bone (world space) to the result param
  88435. * @param mesh The mesh that this bone is attached to
  88436. * @param result The vector3 to copy the absolute position to
  88437. */
  88438. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  88439. /**
  88440. * Compute the absolute transforms of this bone and its children
  88441. */
  88442. computeAbsoluteTransforms(): void;
  88443. /**
  88444. * Get the world direction from an axis that is in the local space of the bone
  88445. * @param localAxis The local direction that is used to compute the world direction
  88446. * @param mesh The mesh that this bone is attached to
  88447. * @returns The world direction
  88448. */
  88449. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88450. /**
  88451. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  88452. * @param localAxis The local direction that is used to compute the world direction
  88453. * @param mesh The mesh that this bone is attached to
  88454. * @param result The vector3 that the world direction will be copied to
  88455. */
  88456. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88457. /**
  88458. * Get the euler rotation of the bone in local or world space
  88459. * @param space The space that the rotation should be in
  88460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88461. * @returns The euler rotation
  88462. */
  88463. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88464. /**
  88465. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  88466. * @param space The space that the rotation should be in
  88467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88468. * @param result The vector3 that the rotation should be copied to
  88469. */
  88470. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88471. /**
  88472. * Get the quaternion rotation of the bone in either local or world space
  88473. * @param space The space that the rotation should be in
  88474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88475. * @returns The quaternion rotation
  88476. */
  88477. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  88478. /**
  88479. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  88480. * @param space The space that the rotation should be in
  88481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88482. * @param result The quaternion that the rotation should be copied to
  88483. */
  88484. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  88485. /**
  88486. * Get the rotation matrix of the bone in local or world space
  88487. * @param space The space that the rotation should be in
  88488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88489. * @returns The rotation matrix
  88490. */
  88491. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  88492. /**
  88493. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  88494. * @param space The space that the rotation should be in
  88495. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88496. * @param result The quaternion that the rotation should be copied to
  88497. */
  88498. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  88499. /**
  88500. * Get the world position of a point that is in the local space of the bone
  88501. * @param position The local position
  88502. * @param mesh The mesh that this bone is attached to
  88503. * @returns The world position
  88504. */
  88505. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88506. /**
  88507. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  88508. * @param position The local position
  88509. * @param mesh The mesh that this bone is attached to
  88510. * @param result The vector3 that the world position should be copied to
  88511. */
  88512. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88513. /**
  88514. * Get the local position of a point that is in world space
  88515. * @param position The world position
  88516. * @param mesh The mesh that this bone is attached to
  88517. * @returns The local position
  88518. */
  88519. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88520. /**
  88521. * Get the local position of a point that is in world space and copy it to the result param
  88522. * @param position The world position
  88523. * @param mesh The mesh that this bone is attached to
  88524. * @param result The vector3 that the local position should be copied to
  88525. */
  88526. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88527. }
  88528. }
  88529. declare module BABYLON {
  88530. /**
  88531. * Defines a runtime animation
  88532. */
  88533. export class RuntimeAnimation {
  88534. private _events;
  88535. /**
  88536. * The current frame of the runtime animation
  88537. */
  88538. private _currentFrame;
  88539. /**
  88540. * The animation used by the runtime animation
  88541. */
  88542. private _animation;
  88543. /**
  88544. * The target of the runtime animation
  88545. */
  88546. private _target;
  88547. /**
  88548. * The initiating animatable
  88549. */
  88550. private _host;
  88551. /**
  88552. * The original value of the runtime animation
  88553. */
  88554. private _originalValue;
  88555. /**
  88556. * The original blend value of the runtime animation
  88557. */
  88558. private _originalBlendValue;
  88559. /**
  88560. * The offsets cache of the runtime animation
  88561. */
  88562. private _offsetsCache;
  88563. /**
  88564. * The high limits cache of the runtime animation
  88565. */
  88566. private _highLimitsCache;
  88567. /**
  88568. * Specifies if the runtime animation has been stopped
  88569. */
  88570. private _stopped;
  88571. /**
  88572. * The blending factor of the runtime animation
  88573. */
  88574. private _blendingFactor;
  88575. /**
  88576. * The BabylonJS scene
  88577. */
  88578. private _scene;
  88579. /**
  88580. * The current value of the runtime animation
  88581. */
  88582. private _currentValue;
  88583. /** @hidden */
  88584. _animationState: _IAnimationState;
  88585. /**
  88586. * The active target of the runtime animation
  88587. */
  88588. private _activeTargets;
  88589. private _currentActiveTarget;
  88590. private _directTarget;
  88591. /**
  88592. * The target path of the runtime animation
  88593. */
  88594. private _targetPath;
  88595. /**
  88596. * The weight of the runtime animation
  88597. */
  88598. private _weight;
  88599. /**
  88600. * The ratio offset of the runtime animation
  88601. */
  88602. private _ratioOffset;
  88603. /**
  88604. * The previous delay of the runtime animation
  88605. */
  88606. private _previousDelay;
  88607. /**
  88608. * The previous ratio of the runtime animation
  88609. */
  88610. private _previousRatio;
  88611. private _enableBlending;
  88612. private _keys;
  88613. private _minFrame;
  88614. private _maxFrame;
  88615. private _minValue;
  88616. private _maxValue;
  88617. private _targetIsArray;
  88618. /**
  88619. * Gets the current frame of the runtime animation
  88620. */
  88621. get currentFrame(): number;
  88622. /**
  88623. * Gets the weight of the runtime animation
  88624. */
  88625. get weight(): number;
  88626. /**
  88627. * Gets the current value of the runtime animation
  88628. */
  88629. get currentValue(): any;
  88630. /**
  88631. * Gets the target path of the runtime animation
  88632. */
  88633. get targetPath(): string;
  88634. /**
  88635. * Gets the actual target of the runtime animation
  88636. */
  88637. get target(): any;
  88638. /**
  88639. * Gets the additive state of the runtime animation
  88640. */
  88641. get isAdditive(): boolean;
  88642. /** @hidden */
  88643. _onLoop: () => void;
  88644. /**
  88645. * Create a new RuntimeAnimation object
  88646. * @param target defines the target of the animation
  88647. * @param animation defines the source animation object
  88648. * @param scene defines the hosting scene
  88649. * @param host defines the initiating Animatable
  88650. */
  88651. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88652. private _preparePath;
  88653. /**
  88654. * Gets the animation from the runtime animation
  88655. */
  88656. get animation(): Animation;
  88657. /**
  88658. * Resets the runtime animation to the beginning
  88659. * @param restoreOriginal defines whether to restore the target property to the original value
  88660. */
  88661. reset(restoreOriginal?: boolean): void;
  88662. /**
  88663. * Specifies if the runtime animation is stopped
  88664. * @returns Boolean specifying if the runtime animation is stopped
  88665. */
  88666. isStopped(): boolean;
  88667. /**
  88668. * Disposes of the runtime animation
  88669. */
  88670. dispose(): void;
  88671. /**
  88672. * Apply the interpolated value to the target
  88673. * @param currentValue defines the value computed by the animation
  88674. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88675. */
  88676. setValue(currentValue: any, weight: number): void;
  88677. private _getOriginalValues;
  88678. private _setValue;
  88679. /**
  88680. * Gets the loop pmode of the runtime animation
  88681. * @returns Loop Mode
  88682. */
  88683. private _getCorrectLoopMode;
  88684. /**
  88685. * Move the current animation to a given frame
  88686. * @param frame defines the frame to move to
  88687. */
  88688. goToFrame(frame: number): void;
  88689. /**
  88690. * @hidden Internal use only
  88691. */
  88692. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88693. /**
  88694. * Execute the current animation
  88695. * @param delay defines the delay to add to the current frame
  88696. * @param from defines the lower bound of the animation range
  88697. * @param to defines the upper bound of the animation range
  88698. * @param loop defines if the current animation must loop
  88699. * @param speedRatio defines the current speed ratio
  88700. * @param weight defines the weight of the animation (default is -1 so no weight)
  88701. * @param onLoop optional callback called when animation loops
  88702. * @returns a boolean indicating if the animation is running
  88703. */
  88704. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88705. }
  88706. }
  88707. declare module BABYLON {
  88708. /**
  88709. * Class used to store an actual running animation
  88710. */
  88711. export class Animatable {
  88712. /** defines the target object */
  88713. target: any;
  88714. /** defines the starting frame number (default is 0) */
  88715. fromFrame: number;
  88716. /** defines the ending frame number (default is 100) */
  88717. toFrame: number;
  88718. /** defines if the animation must loop (default is false) */
  88719. loopAnimation: boolean;
  88720. /** defines a callback to call when animation ends if it is not looping */
  88721. onAnimationEnd?: (() => void) | null | undefined;
  88722. /** defines a callback to call when animation loops */
  88723. onAnimationLoop?: (() => void) | null | undefined;
  88724. /** defines whether the animation should be evaluated additively */
  88725. isAdditive: boolean;
  88726. private _localDelayOffset;
  88727. private _pausedDelay;
  88728. private _runtimeAnimations;
  88729. private _paused;
  88730. private _scene;
  88731. private _speedRatio;
  88732. private _weight;
  88733. private _syncRoot;
  88734. /**
  88735. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88736. * This will only apply for non looping animation (default is true)
  88737. */
  88738. disposeOnEnd: boolean;
  88739. /**
  88740. * Gets a boolean indicating if the animation has started
  88741. */
  88742. animationStarted: boolean;
  88743. /**
  88744. * Observer raised when the animation ends
  88745. */
  88746. onAnimationEndObservable: Observable<Animatable>;
  88747. /**
  88748. * Observer raised when the animation loops
  88749. */
  88750. onAnimationLoopObservable: Observable<Animatable>;
  88751. /**
  88752. * Gets the root Animatable used to synchronize and normalize animations
  88753. */
  88754. get syncRoot(): Nullable<Animatable>;
  88755. /**
  88756. * Gets the current frame of the first RuntimeAnimation
  88757. * Used to synchronize Animatables
  88758. */
  88759. get masterFrame(): number;
  88760. /**
  88761. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88762. */
  88763. get weight(): number;
  88764. set weight(value: number);
  88765. /**
  88766. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  88767. */
  88768. get speedRatio(): number;
  88769. set speedRatio(value: number);
  88770. /**
  88771. * Creates a new Animatable
  88772. * @param scene defines the hosting scene
  88773. * @param target defines the target object
  88774. * @param fromFrame defines the starting frame number (default is 0)
  88775. * @param toFrame defines the ending frame number (default is 100)
  88776. * @param loopAnimation defines if the animation must loop (default is false)
  88777. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  88778. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  88779. * @param animations defines a group of animation to add to the new Animatable
  88780. * @param onAnimationLoop defines a callback to call when animation loops
  88781. * @param isAdditive defines whether the animation should be evaluated additively
  88782. */
  88783. constructor(scene: Scene,
  88784. /** defines the target object */
  88785. target: any,
  88786. /** defines the starting frame number (default is 0) */
  88787. fromFrame?: number,
  88788. /** defines the ending frame number (default is 100) */
  88789. toFrame?: number,
  88790. /** defines if the animation must loop (default is false) */
  88791. loopAnimation?: boolean, speedRatio?: number,
  88792. /** defines a callback to call when animation ends if it is not looping */
  88793. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  88794. /** defines a callback to call when animation loops */
  88795. onAnimationLoop?: (() => void) | null | undefined,
  88796. /** defines whether the animation should be evaluated additively */
  88797. isAdditive?: boolean);
  88798. /**
  88799. * Synchronize and normalize current Animatable with a source Animatable
  88800. * This is useful when using animation weights and when animations are not of the same length
  88801. * @param root defines the root Animatable to synchronize with
  88802. * @returns the current Animatable
  88803. */
  88804. syncWith(root: Animatable): Animatable;
  88805. /**
  88806. * Gets the list of runtime animations
  88807. * @returns an array of RuntimeAnimation
  88808. */
  88809. getAnimations(): RuntimeAnimation[];
  88810. /**
  88811. * Adds more animations to the current animatable
  88812. * @param target defines the target of the animations
  88813. * @param animations defines the new animations to add
  88814. */
  88815. appendAnimations(target: any, animations: Animation[]): void;
  88816. /**
  88817. * Gets the source animation for a specific property
  88818. * @param property defines the propertyu to look for
  88819. * @returns null or the source animation for the given property
  88820. */
  88821. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  88822. /**
  88823. * Gets the runtime animation for a specific property
  88824. * @param property defines the propertyu to look for
  88825. * @returns null or the runtime animation for the given property
  88826. */
  88827. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  88828. /**
  88829. * Resets the animatable to its original state
  88830. */
  88831. reset(): void;
  88832. /**
  88833. * Allows the animatable to blend with current running animations
  88834. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88835. * @param blendingSpeed defines the blending speed to use
  88836. */
  88837. enableBlending(blendingSpeed: number): void;
  88838. /**
  88839. * Disable animation blending
  88840. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88841. */
  88842. disableBlending(): void;
  88843. /**
  88844. * Jump directly to a given frame
  88845. * @param frame defines the frame to jump to
  88846. */
  88847. goToFrame(frame: number): void;
  88848. /**
  88849. * Pause the animation
  88850. */
  88851. pause(): void;
  88852. /**
  88853. * Restart the animation
  88854. */
  88855. restart(): void;
  88856. private _raiseOnAnimationEnd;
  88857. /**
  88858. * Stop and delete the current animation
  88859. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  88860. * @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)
  88861. */
  88862. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  88863. /**
  88864. * Wait asynchronously for the animation to end
  88865. * @returns a promise which will be fullfilled when the animation ends
  88866. */
  88867. waitAsync(): Promise<Animatable>;
  88868. /** @hidden */
  88869. _animate(delay: number): boolean;
  88870. }
  88871. interface Scene {
  88872. /** @hidden */
  88873. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  88874. /** @hidden */
  88875. _processLateAnimationBindingsForMatrices(holder: {
  88876. totalWeight: number;
  88877. totalAdditiveWeight: number;
  88878. animations: RuntimeAnimation[];
  88879. additiveAnimations: RuntimeAnimation[];
  88880. originalValue: Matrix;
  88881. }): any;
  88882. /** @hidden */
  88883. _processLateAnimationBindingsForQuaternions(holder: {
  88884. totalWeight: number;
  88885. totalAdditiveWeight: number;
  88886. animations: RuntimeAnimation[];
  88887. additiveAnimations: RuntimeAnimation[];
  88888. originalValue: Quaternion;
  88889. }, refQuaternion: Quaternion): Quaternion;
  88890. /** @hidden */
  88891. _processLateAnimationBindings(): void;
  88892. /**
  88893. * Will start the animation sequence of a given target
  88894. * @param target defines the target
  88895. * @param from defines from which frame should animation start
  88896. * @param to defines until which frame should animation run.
  88897. * @param weight defines the weight to apply to the animation (1.0 by default)
  88898. * @param loop defines if the animation loops
  88899. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88900. * @param onAnimationEnd defines the function to be executed when the animation ends
  88901. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88902. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88903. * @param onAnimationLoop defines the callback to call when an animation loops
  88904. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  88905. * @returns the animatable object created for this animation
  88906. */
  88907. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  88908. /**
  88909. * Will start the animation sequence of a given target
  88910. * @param target defines the target
  88911. * @param from defines from which frame should animation start
  88912. * @param to defines until which frame should animation run.
  88913. * @param loop defines if the animation loops
  88914. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88915. * @param onAnimationEnd defines the function to be executed when the animation ends
  88916. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88917. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88918. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88919. * @param onAnimationLoop defines the callback to call when an animation loops
  88920. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  88921. * @returns the animatable object created for this animation
  88922. */
  88923. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  88924. /**
  88925. * Will start the animation sequence of a given target and its hierarchy
  88926. * @param target defines the target
  88927. * @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.
  88928. * @param from defines from which frame should animation start
  88929. * @param to defines until which frame should animation run.
  88930. * @param loop defines if the animation loops
  88931. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88932. * @param onAnimationEnd defines the function to be executed when the animation ends
  88933. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88934. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88935. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88936. * @param onAnimationLoop defines the callback to call when an animation loops
  88937. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  88938. * @returns the list of created animatables
  88939. */
  88940. 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, isAdditive?: boolean): Animatable[];
  88941. /**
  88942. * Begin a new animation on a given node
  88943. * @param target defines the target where the animation will take place
  88944. * @param animations defines the list of animations to start
  88945. * @param from defines the initial value
  88946. * @param to defines the final value
  88947. * @param loop defines if you want animation to loop (off by default)
  88948. * @param speedRatio defines the speed ratio to apply to all animations
  88949. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88950. * @param onAnimationLoop defines the callback to call when an animation loops
  88951. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  88952. * @returns the list of created animatables
  88953. */
  88954. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  88955. /**
  88956. * Begin a new animation on a given node and its hierarchy
  88957. * @param target defines the root node where the animation will take place
  88958. * @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.
  88959. * @param animations defines the list of animations to start
  88960. * @param from defines the initial value
  88961. * @param to defines the final value
  88962. * @param loop defines if you want animation to loop (off by default)
  88963. * @param speedRatio defines the speed ratio to apply to all animations
  88964. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88965. * @param onAnimationLoop defines the callback to call when an animation loops
  88966. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  88967. * @returns the list of animatables created for all nodes
  88968. */
  88969. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  88970. /**
  88971. * Gets the animatable associated with a specific target
  88972. * @param target defines the target of the animatable
  88973. * @returns the required animatable if found
  88974. */
  88975. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88976. /**
  88977. * Gets all animatables associated with a given target
  88978. * @param target defines the target to look animatables for
  88979. * @returns an array of Animatables
  88980. */
  88981. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88982. /**
  88983. * Stops and removes all animations that have been applied to the scene
  88984. */
  88985. stopAllAnimations(): void;
  88986. /**
  88987. * Gets the current delta time used by animation engine
  88988. */
  88989. deltaTime: number;
  88990. }
  88991. interface Bone {
  88992. /**
  88993. * Copy an animation range from another bone
  88994. * @param source defines the source bone
  88995. * @param rangeName defines the range name to copy
  88996. * @param frameOffset defines the frame offset
  88997. * @param rescaleAsRequired defines if rescaling must be applied if required
  88998. * @param skelDimensionsRatio defines the scaling ratio
  88999. * @returns true if operation was successful
  89000. */
  89001. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  89002. }
  89003. }
  89004. declare module BABYLON {
  89005. /**
  89006. * Class used to handle skinning animations
  89007. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89008. */
  89009. export class Skeleton implements IAnimatable {
  89010. /** defines the skeleton name */
  89011. name: string;
  89012. /** defines the skeleton Id */
  89013. id: string;
  89014. /**
  89015. * Defines the list of child bones
  89016. */
  89017. bones: Bone[];
  89018. /**
  89019. * Defines an estimate of the dimension of the skeleton at rest
  89020. */
  89021. dimensionsAtRest: Vector3;
  89022. /**
  89023. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  89024. */
  89025. needInitialSkinMatrix: boolean;
  89026. /**
  89027. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  89028. */
  89029. overrideMesh: Nullable<AbstractMesh>;
  89030. /**
  89031. * Gets the list of animations attached to this skeleton
  89032. */
  89033. animations: Array<Animation>;
  89034. private _scene;
  89035. private _isDirty;
  89036. private _transformMatrices;
  89037. private _transformMatrixTexture;
  89038. private _meshesWithPoseMatrix;
  89039. private _animatables;
  89040. private _identity;
  89041. private _synchronizedWithMesh;
  89042. private _ranges;
  89043. private _lastAbsoluteTransformsUpdateId;
  89044. private _canUseTextureForBones;
  89045. private _uniqueId;
  89046. /** @hidden */
  89047. _numBonesWithLinkedTransformNode: number;
  89048. /** @hidden */
  89049. _hasWaitingData: Nullable<boolean>;
  89050. /**
  89051. * Specifies if the skeleton should be serialized
  89052. */
  89053. doNotSerialize: boolean;
  89054. private _useTextureToStoreBoneMatrices;
  89055. /**
  89056. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  89057. * Please note that this option is not available if the hardware does not support it
  89058. */
  89059. get useTextureToStoreBoneMatrices(): boolean;
  89060. set useTextureToStoreBoneMatrices(value: boolean);
  89061. private _animationPropertiesOverride;
  89062. /**
  89063. * Gets or sets the animation properties override
  89064. */
  89065. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  89066. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  89067. /**
  89068. * List of inspectable custom properties (used by the Inspector)
  89069. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89070. */
  89071. inspectableCustomProperties: IInspectable[];
  89072. /**
  89073. * An observable triggered before computing the skeleton's matrices
  89074. */
  89075. onBeforeComputeObservable: Observable<Skeleton>;
  89076. /**
  89077. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  89078. */
  89079. get isUsingTextureForMatrices(): boolean;
  89080. /**
  89081. * Gets the unique ID of this skeleton
  89082. */
  89083. get uniqueId(): number;
  89084. /**
  89085. * Creates a new skeleton
  89086. * @param name defines the skeleton name
  89087. * @param id defines the skeleton Id
  89088. * @param scene defines the hosting scene
  89089. */
  89090. constructor(
  89091. /** defines the skeleton name */
  89092. name: string,
  89093. /** defines the skeleton Id */
  89094. id: string, scene: Scene);
  89095. /**
  89096. * Gets the current object class name.
  89097. * @return the class name
  89098. */
  89099. getClassName(): string;
  89100. /**
  89101. * Returns an array containing the root bones
  89102. * @returns an array containing the root bones
  89103. */
  89104. getChildren(): Array<Bone>;
  89105. /**
  89106. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  89107. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89108. * @returns a Float32Array containing matrices data
  89109. */
  89110. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  89111. /**
  89112. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  89113. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89114. * @returns a raw texture containing the data
  89115. */
  89116. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  89117. /**
  89118. * Gets the current hosting scene
  89119. * @returns a scene object
  89120. */
  89121. getScene(): Scene;
  89122. /**
  89123. * Gets a string representing the current skeleton data
  89124. * @param fullDetails defines a boolean indicating if we want a verbose version
  89125. * @returns a string representing the current skeleton data
  89126. */
  89127. toString(fullDetails?: boolean): string;
  89128. /**
  89129. * Get bone's index searching by name
  89130. * @param name defines bone's name to search for
  89131. * @return the indice of the bone. Returns -1 if not found
  89132. */
  89133. getBoneIndexByName(name: string): number;
  89134. /**
  89135. * Creater a new animation range
  89136. * @param name defines the name of the range
  89137. * @param from defines the start key
  89138. * @param to defines the end key
  89139. */
  89140. createAnimationRange(name: string, from: number, to: number): void;
  89141. /**
  89142. * Delete a specific animation range
  89143. * @param name defines the name of the range
  89144. * @param deleteFrames defines if frames must be removed as well
  89145. */
  89146. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  89147. /**
  89148. * Gets a specific animation range
  89149. * @param name defines the name of the range to look for
  89150. * @returns the requested animation range or null if not found
  89151. */
  89152. getAnimationRange(name: string): Nullable<AnimationRange>;
  89153. /**
  89154. * Gets the list of all animation ranges defined on this skeleton
  89155. * @returns an array
  89156. */
  89157. getAnimationRanges(): Nullable<AnimationRange>[];
  89158. /**
  89159. * Copy animation range from a source skeleton.
  89160. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  89161. * @param source defines the source skeleton
  89162. * @param name defines the name of the range to copy
  89163. * @param rescaleAsRequired defines if rescaling must be applied if required
  89164. * @returns true if operation was successful
  89165. */
  89166. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  89167. /**
  89168. * Forces the skeleton to go to rest pose
  89169. */
  89170. returnToRest(): void;
  89171. private _getHighestAnimationFrame;
  89172. /**
  89173. * Begin a specific animation range
  89174. * @param name defines the name of the range to start
  89175. * @param loop defines if looping must be turned on (false by default)
  89176. * @param speedRatio defines the speed ratio to apply (1 by default)
  89177. * @param onAnimationEnd defines a callback which will be called when animation will end
  89178. * @returns a new animatable
  89179. */
  89180. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  89181. /**
  89182. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  89183. * @param skeleton defines the Skeleton containing the animation range to convert
  89184. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  89185. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  89186. * @returns the original skeleton
  89187. */
  89188. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  89189. /** @hidden */
  89190. _markAsDirty(): void;
  89191. /** @hidden */
  89192. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89193. /** @hidden */
  89194. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89195. private _computeTransformMatrices;
  89196. /**
  89197. * Build all resources required to render a skeleton
  89198. */
  89199. prepare(): void;
  89200. /**
  89201. * Gets the list of animatables currently running for this skeleton
  89202. * @returns an array of animatables
  89203. */
  89204. getAnimatables(): IAnimatable[];
  89205. /**
  89206. * Clone the current skeleton
  89207. * @param name defines the name of the new skeleton
  89208. * @param id defines the id of the new skeleton
  89209. * @returns the new skeleton
  89210. */
  89211. clone(name: string, id?: string): Skeleton;
  89212. /**
  89213. * Enable animation blending for this skeleton
  89214. * @param blendingSpeed defines the blending speed to apply
  89215. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89216. */
  89217. enableBlending(blendingSpeed?: number): void;
  89218. /**
  89219. * Releases all resources associated with the current skeleton
  89220. */
  89221. dispose(): void;
  89222. /**
  89223. * Serialize the skeleton in a JSON object
  89224. * @returns a JSON object
  89225. */
  89226. serialize(): any;
  89227. /**
  89228. * Creates a new skeleton from serialized data
  89229. * @param parsedSkeleton defines the serialized data
  89230. * @param scene defines the hosting scene
  89231. * @returns a new skeleton
  89232. */
  89233. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  89234. /**
  89235. * Compute all node absolute transforms
  89236. * @param forceUpdate defines if computation must be done even if cache is up to date
  89237. */
  89238. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  89239. /**
  89240. * Gets the root pose matrix
  89241. * @returns a matrix
  89242. */
  89243. getPoseMatrix(): Nullable<Matrix>;
  89244. /**
  89245. * Sorts bones per internal index
  89246. */
  89247. sortBones(): void;
  89248. private _sortBones;
  89249. }
  89250. }
  89251. declare module BABYLON {
  89252. /**
  89253. * Creates an instance based on a source mesh.
  89254. */
  89255. export class InstancedMesh extends AbstractMesh {
  89256. private _sourceMesh;
  89257. private _currentLOD;
  89258. /** @hidden */
  89259. _indexInSourceMeshInstanceArray: number;
  89260. constructor(name: string, source: Mesh);
  89261. /**
  89262. * Returns the string "InstancedMesh".
  89263. */
  89264. getClassName(): string;
  89265. /** Gets the list of lights affecting that mesh */
  89266. get lightSources(): Light[];
  89267. _resyncLightSources(): void;
  89268. _resyncLightSource(light: Light): void;
  89269. _removeLightSource(light: Light, dispose: boolean): void;
  89270. /**
  89271. * If the source mesh receives shadows
  89272. */
  89273. get receiveShadows(): boolean;
  89274. /**
  89275. * The material of the source mesh
  89276. */
  89277. get material(): Nullable<Material>;
  89278. /**
  89279. * Visibility of the source mesh
  89280. */
  89281. get visibility(): number;
  89282. /**
  89283. * Skeleton of the source mesh
  89284. */
  89285. get skeleton(): Nullable<Skeleton>;
  89286. /**
  89287. * Rendering ground id of the source mesh
  89288. */
  89289. get renderingGroupId(): number;
  89290. set renderingGroupId(value: number);
  89291. /**
  89292. * Returns the total number of vertices (integer).
  89293. */
  89294. getTotalVertices(): number;
  89295. /**
  89296. * Returns a positive integer : the total number of indices in this mesh geometry.
  89297. * @returns the numner of indices or zero if the mesh has no geometry.
  89298. */
  89299. getTotalIndices(): number;
  89300. /**
  89301. * The source mesh of the instance
  89302. */
  89303. get sourceMesh(): Mesh;
  89304. /**
  89305. * Is this node ready to be used/rendered
  89306. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89307. * @return {boolean} is it ready
  89308. */
  89309. isReady(completeCheck?: boolean): boolean;
  89310. /**
  89311. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89312. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89313. * @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.
  89314. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89315. */
  89316. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89317. /**
  89318. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89319. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89320. * The `data` are either a numeric array either a Float32Array.
  89321. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89322. * 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).
  89323. * Note that a new underlying VertexBuffer object is created each call.
  89324. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89325. *
  89326. * Possible `kind` values :
  89327. * - VertexBuffer.PositionKind
  89328. * - VertexBuffer.UVKind
  89329. * - VertexBuffer.UV2Kind
  89330. * - VertexBuffer.UV3Kind
  89331. * - VertexBuffer.UV4Kind
  89332. * - VertexBuffer.UV5Kind
  89333. * - VertexBuffer.UV6Kind
  89334. * - VertexBuffer.ColorKind
  89335. * - VertexBuffer.MatricesIndicesKind
  89336. * - VertexBuffer.MatricesIndicesExtraKind
  89337. * - VertexBuffer.MatricesWeightsKind
  89338. * - VertexBuffer.MatricesWeightsExtraKind
  89339. *
  89340. * Returns the Mesh.
  89341. */
  89342. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89343. /**
  89344. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89345. * If the mesh has no geometry, it is simply returned as it is.
  89346. * The `data` are either a numeric array either a Float32Array.
  89347. * No new underlying VertexBuffer object is created.
  89348. * 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.
  89349. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89350. *
  89351. * Possible `kind` values :
  89352. * - VertexBuffer.PositionKind
  89353. * - VertexBuffer.UVKind
  89354. * - VertexBuffer.UV2Kind
  89355. * - VertexBuffer.UV3Kind
  89356. * - VertexBuffer.UV4Kind
  89357. * - VertexBuffer.UV5Kind
  89358. * - VertexBuffer.UV6Kind
  89359. * - VertexBuffer.ColorKind
  89360. * - VertexBuffer.MatricesIndicesKind
  89361. * - VertexBuffer.MatricesIndicesExtraKind
  89362. * - VertexBuffer.MatricesWeightsKind
  89363. * - VertexBuffer.MatricesWeightsExtraKind
  89364. *
  89365. * Returns the Mesh.
  89366. */
  89367. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89368. /**
  89369. * Sets the mesh indices.
  89370. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89371. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89372. * This method creates a new index buffer each call.
  89373. * Returns the Mesh.
  89374. */
  89375. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89376. /**
  89377. * Boolean : True if the mesh owns the requested kind of data.
  89378. */
  89379. isVerticesDataPresent(kind: string): boolean;
  89380. /**
  89381. * Returns an array of indices (IndicesArray).
  89382. */
  89383. getIndices(): Nullable<IndicesArray>;
  89384. get _positions(): Nullable<Vector3[]>;
  89385. /**
  89386. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89387. * This means the mesh underlying bounding box and sphere are recomputed.
  89388. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89389. * @returns the current mesh
  89390. */
  89391. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89392. /** @hidden */
  89393. _preActivate(): InstancedMesh;
  89394. /** @hidden */
  89395. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89396. /** @hidden */
  89397. _postActivate(): void;
  89398. getWorldMatrix(): Matrix;
  89399. get isAnInstance(): boolean;
  89400. /**
  89401. * Returns the current associated LOD AbstractMesh.
  89402. */
  89403. getLOD(camera: Camera): AbstractMesh;
  89404. /** @hidden */
  89405. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89406. /** @hidden */
  89407. _syncSubMeshes(): InstancedMesh;
  89408. /** @hidden */
  89409. _generatePointsArray(): boolean;
  89410. /**
  89411. * Creates a new InstancedMesh from the current mesh.
  89412. * - name (string) : the cloned mesh name
  89413. * - newParent (optional Node) : the optional Node to parent the clone to.
  89414. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89415. *
  89416. * Returns the clone.
  89417. */
  89418. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  89419. /**
  89420. * Disposes the InstancedMesh.
  89421. * Returns nothing.
  89422. */
  89423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89424. }
  89425. interface Mesh {
  89426. /**
  89427. * Register a custom buffer that will be instanced
  89428. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89429. * @param kind defines the buffer kind
  89430. * @param stride defines the stride in floats
  89431. */
  89432. registerInstancedBuffer(kind: string, stride: number): void;
  89433. /** @hidden */
  89434. _userInstancedBuffersStorage: {
  89435. data: {
  89436. [key: string]: Float32Array;
  89437. };
  89438. sizes: {
  89439. [key: string]: number;
  89440. };
  89441. vertexBuffers: {
  89442. [key: string]: Nullable<VertexBuffer>;
  89443. };
  89444. strides: {
  89445. [key: string]: number;
  89446. };
  89447. };
  89448. }
  89449. interface AbstractMesh {
  89450. /**
  89451. * Object used to store instanced buffers defined by user
  89452. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89453. */
  89454. instancedBuffers: {
  89455. [key: string]: any;
  89456. };
  89457. }
  89458. }
  89459. declare module BABYLON {
  89460. /**
  89461. * Defines the options associated with the creation of a shader material.
  89462. */
  89463. export interface IShaderMaterialOptions {
  89464. /**
  89465. * Does the material work in alpha blend mode
  89466. */
  89467. needAlphaBlending: boolean;
  89468. /**
  89469. * Does the material work in alpha test mode
  89470. */
  89471. needAlphaTesting: boolean;
  89472. /**
  89473. * The list of attribute names used in the shader
  89474. */
  89475. attributes: string[];
  89476. /**
  89477. * The list of unifrom names used in the shader
  89478. */
  89479. uniforms: string[];
  89480. /**
  89481. * The list of UBO names used in the shader
  89482. */
  89483. uniformBuffers: string[];
  89484. /**
  89485. * The list of sampler names used in the shader
  89486. */
  89487. samplers: string[];
  89488. /**
  89489. * The list of defines used in the shader
  89490. */
  89491. defines: string[];
  89492. }
  89493. /**
  89494. * 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.
  89495. *
  89496. * This returned material effects how the mesh will look based on the code in the shaders.
  89497. *
  89498. * @see http://doc.babylonjs.com/how_to/shader_material
  89499. */
  89500. export class ShaderMaterial extends Material {
  89501. private _shaderPath;
  89502. private _options;
  89503. private _textures;
  89504. private _textureArrays;
  89505. private _floats;
  89506. private _ints;
  89507. private _floatsArrays;
  89508. private _colors3;
  89509. private _colors3Arrays;
  89510. private _colors4;
  89511. private _colors4Arrays;
  89512. private _vectors2;
  89513. private _vectors3;
  89514. private _vectors4;
  89515. private _matrices;
  89516. private _matrixArrays;
  89517. private _matrices3x3;
  89518. private _matrices2x2;
  89519. private _vectors2Arrays;
  89520. private _vectors3Arrays;
  89521. private _vectors4Arrays;
  89522. private _cachedWorldViewMatrix;
  89523. private _cachedWorldViewProjectionMatrix;
  89524. private _renderId;
  89525. private _multiview;
  89526. /**
  89527. * Instantiate a new shader material.
  89528. * 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.
  89529. * This returned material effects how the mesh will look based on the code in the shaders.
  89530. * @see http://doc.babylonjs.com/how_to/shader_material
  89531. * @param name Define the name of the material in the scene
  89532. * @param scene Define the scene the material belongs to
  89533. * @param shaderPath Defines the route to the shader code in one of three ways:
  89534. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89535. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89536. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89537. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89538. * @param options Define the options used to create the shader
  89539. */
  89540. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89541. /**
  89542. * Gets the shader path used to define the shader code
  89543. * It can be modified to trigger a new compilation
  89544. */
  89545. get shaderPath(): any;
  89546. /**
  89547. * Sets the shader path used to define the shader code
  89548. * It can be modified to trigger a new compilation
  89549. */
  89550. set shaderPath(shaderPath: any);
  89551. /**
  89552. * Gets the options used to compile the shader.
  89553. * They can be modified to trigger a new compilation
  89554. */
  89555. get options(): IShaderMaterialOptions;
  89556. /**
  89557. * Gets the current class name of the material e.g. "ShaderMaterial"
  89558. * Mainly use in serialization.
  89559. * @returns the class name
  89560. */
  89561. getClassName(): string;
  89562. /**
  89563. * Specifies if the material will require alpha blending
  89564. * @returns a boolean specifying if alpha blending is needed
  89565. */
  89566. needAlphaBlending(): boolean;
  89567. /**
  89568. * Specifies if this material should be rendered in alpha test mode
  89569. * @returns a boolean specifying if an alpha test is needed.
  89570. */
  89571. needAlphaTesting(): boolean;
  89572. private _checkUniform;
  89573. /**
  89574. * Set a texture in the shader.
  89575. * @param name Define the name of the uniform samplers as defined in the shader
  89576. * @param texture Define the texture to bind to this sampler
  89577. * @return the material itself allowing "fluent" like uniform updates
  89578. */
  89579. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  89580. /**
  89581. * Set a texture array in the shader.
  89582. * @param name Define the name of the uniform sampler array as defined in the shader
  89583. * @param textures Define the list of textures to bind to this sampler
  89584. * @return the material itself allowing "fluent" like uniform updates
  89585. */
  89586. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  89587. /**
  89588. * Set a float in the shader.
  89589. * @param name Define the name of the uniform as defined in the shader
  89590. * @param value Define the value to give to the uniform
  89591. * @return the material itself allowing "fluent" like uniform updates
  89592. */
  89593. setFloat(name: string, value: number): ShaderMaterial;
  89594. /**
  89595. * Set a int in the shader.
  89596. * @param name Define the name of the uniform as defined in the shader
  89597. * @param value Define the value to give to the uniform
  89598. * @return the material itself allowing "fluent" like uniform updates
  89599. */
  89600. setInt(name: string, value: number): ShaderMaterial;
  89601. /**
  89602. * Set an array of floats in the shader.
  89603. * @param name Define the name of the uniform as defined in the shader
  89604. * @param value Define the value to give to the uniform
  89605. * @return the material itself allowing "fluent" like uniform updates
  89606. */
  89607. setFloats(name: string, value: number[]): ShaderMaterial;
  89608. /**
  89609. * Set a vec3 in the shader from a Color3.
  89610. * @param name Define the name of the uniform as defined in the shader
  89611. * @param value Define the value to give to the uniform
  89612. * @return the material itself allowing "fluent" like uniform updates
  89613. */
  89614. setColor3(name: string, value: Color3): ShaderMaterial;
  89615. /**
  89616. * Set a vec3 array in the shader from a Color3 array.
  89617. * @param name Define the name of the uniform as defined in the shader
  89618. * @param value Define the value to give to the uniform
  89619. * @return the material itself allowing "fluent" like uniform updates
  89620. */
  89621. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89622. /**
  89623. * Set a vec4 in the shader from a Color4.
  89624. * @param name Define the name of the uniform as defined in the shader
  89625. * @param value Define the value to give to the uniform
  89626. * @return the material itself allowing "fluent" like uniform updates
  89627. */
  89628. setColor4(name: string, value: Color4): ShaderMaterial;
  89629. /**
  89630. * Set a vec4 array in the shader from a Color4 array.
  89631. * @param name Define the name of the uniform as defined in the shader
  89632. * @param value Define the value to give to the uniform
  89633. * @return the material itself allowing "fluent" like uniform updates
  89634. */
  89635. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89636. /**
  89637. * Set a vec2 in the shader from a Vector2.
  89638. * @param name Define the name of the uniform as defined in the shader
  89639. * @param value Define the value to give to the uniform
  89640. * @return the material itself allowing "fluent" like uniform updates
  89641. */
  89642. setVector2(name: string, value: Vector2): ShaderMaterial;
  89643. /**
  89644. * Set a vec3 in the shader from a Vector3.
  89645. * @param name Define the name of the uniform as defined in the shader
  89646. * @param value Define the value to give to the uniform
  89647. * @return the material itself allowing "fluent" like uniform updates
  89648. */
  89649. setVector3(name: string, value: Vector3): ShaderMaterial;
  89650. /**
  89651. * Set a vec4 in the shader from a Vector4.
  89652. * @param name Define the name of the uniform as defined in the shader
  89653. * @param value Define the value to give to the uniform
  89654. * @return the material itself allowing "fluent" like uniform updates
  89655. */
  89656. setVector4(name: string, value: Vector4): ShaderMaterial;
  89657. /**
  89658. * Set a mat4 in the shader from a Matrix.
  89659. * @param name Define the name of the uniform as defined in the shader
  89660. * @param value Define the value to give to the uniform
  89661. * @return the material itself allowing "fluent" like uniform updates
  89662. */
  89663. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89664. /**
  89665. * Set a float32Array in the shader from a matrix array.
  89666. * @param name Define the name of the uniform as defined in the shader
  89667. * @param value Define the value to give to the uniform
  89668. * @return the material itself allowing "fluent" like uniform updates
  89669. */
  89670. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89671. /**
  89672. * Set a mat3 in the shader from a Float32Array.
  89673. * @param name Define the name of the uniform as defined in the shader
  89674. * @param value Define the value to give to the uniform
  89675. * @return the material itself allowing "fluent" like uniform updates
  89676. */
  89677. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89678. /**
  89679. * Set a mat2 in the shader from a Float32Array.
  89680. * @param name Define the name of the uniform as defined in the shader
  89681. * @param value Define the value to give to the uniform
  89682. * @return the material itself allowing "fluent" like uniform updates
  89683. */
  89684. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89685. /**
  89686. * Set a vec2 array in the shader from a number array.
  89687. * @param name Define the name of the uniform as defined in the shader
  89688. * @param value Define the value to give to the uniform
  89689. * @return the material itself allowing "fluent" like uniform updates
  89690. */
  89691. setArray2(name: string, value: number[]): ShaderMaterial;
  89692. /**
  89693. * Set a vec3 array in the shader from a number array.
  89694. * @param name Define the name of the uniform as defined in the shader
  89695. * @param value Define the value to give to the uniform
  89696. * @return the material itself allowing "fluent" like uniform updates
  89697. */
  89698. setArray3(name: string, value: number[]): ShaderMaterial;
  89699. /**
  89700. * Set a vec4 array in the shader from a number array.
  89701. * @param name Define the name of the uniform as defined in the shader
  89702. * @param value Define the value to give to the uniform
  89703. * @return the material itself allowing "fluent" like uniform updates
  89704. */
  89705. setArray4(name: string, value: number[]): ShaderMaterial;
  89706. private _checkCache;
  89707. /**
  89708. * Specifies that the submesh is ready to be used
  89709. * @param mesh defines the mesh to check
  89710. * @param subMesh defines which submesh to check
  89711. * @param useInstances specifies that instances should be used
  89712. * @returns a boolean indicating that the submesh is ready or not
  89713. */
  89714. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89715. /**
  89716. * Checks if the material is ready to render the requested mesh
  89717. * @param mesh Define the mesh to render
  89718. * @param useInstances Define whether or not the material is used with instances
  89719. * @returns true if ready, otherwise false
  89720. */
  89721. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89722. /**
  89723. * Binds the world matrix to the material
  89724. * @param world defines the world transformation matrix
  89725. */
  89726. bindOnlyWorldMatrix(world: Matrix): void;
  89727. /**
  89728. * Binds the material to the mesh
  89729. * @param world defines the world transformation matrix
  89730. * @param mesh defines the mesh to bind the material to
  89731. */
  89732. bind(world: Matrix, mesh?: Mesh): void;
  89733. /**
  89734. * Gets the active textures from the material
  89735. * @returns an array of textures
  89736. */
  89737. getActiveTextures(): BaseTexture[];
  89738. /**
  89739. * Specifies if the material uses a texture
  89740. * @param texture defines the texture to check against the material
  89741. * @returns a boolean specifying if the material uses the texture
  89742. */
  89743. hasTexture(texture: BaseTexture): boolean;
  89744. /**
  89745. * Makes a duplicate of the material, and gives it a new name
  89746. * @param name defines the new name for the duplicated material
  89747. * @returns the cloned material
  89748. */
  89749. clone(name: string): ShaderMaterial;
  89750. /**
  89751. * Disposes the material
  89752. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89753. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89754. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89755. */
  89756. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89757. /**
  89758. * Serializes this material in a JSON representation
  89759. * @returns the serialized material object
  89760. */
  89761. serialize(): any;
  89762. /**
  89763. * Creates a shader material from parsed shader material data
  89764. * @param source defines the JSON represnetation of the material
  89765. * @param scene defines the hosting scene
  89766. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89767. * @returns a new material
  89768. */
  89769. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  89770. }
  89771. }
  89772. declare module BABYLON {
  89773. /** @hidden */
  89774. export var colorPixelShader: {
  89775. name: string;
  89776. shader: string;
  89777. };
  89778. }
  89779. declare module BABYLON {
  89780. /** @hidden */
  89781. export var colorVertexShader: {
  89782. name: string;
  89783. shader: string;
  89784. };
  89785. }
  89786. declare module BABYLON {
  89787. /**
  89788. * Line mesh
  89789. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  89790. */
  89791. export class LinesMesh extends Mesh {
  89792. /**
  89793. * If vertex color should be applied to the mesh
  89794. */
  89795. readonly useVertexColor?: boolean | undefined;
  89796. /**
  89797. * If vertex alpha should be applied to the mesh
  89798. */
  89799. readonly useVertexAlpha?: boolean | undefined;
  89800. /**
  89801. * Color of the line (Default: White)
  89802. */
  89803. color: Color3;
  89804. /**
  89805. * Alpha of the line (Default: 1)
  89806. */
  89807. alpha: number;
  89808. /**
  89809. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89810. * This margin is expressed in world space coordinates, so its value may vary.
  89811. * Default value is 0.1
  89812. */
  89813. intersectionThreshold: number;
  89814. private _colorShader;
  89815. private color4;
  89816. /**
  89817. * Creates a new LinesMesh
  89818. * @param name defines the name
  89819. * @param scene defines the hosting scene
  89820. * @param parent defines the parent mesh if any
  89821. * @param source defines the optional source LinesMesh used to clone data from
  89822. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89823. * When false, achieved by calling a clone(), also passing False.
  89824. * This will make creation of children, recursive.
  89825. * @param useVertexColor defines if this LinesMesh supports vertex color
  89826. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  89827. */
  89828. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  89829. /**
  89830. * If vertex color should be applied to the mesh
  89831. */
  89832. useVertexColor?: boolean | undefined,
  89833. /**
  89834. * If vertex alpha should be applied to the mesh
  89835. */
  89836. useVertexAlpha?: boolean | undefined);
  89837. private _addClipPlaneDefine;
  89838. private _removeClipPlaneDefine;
  89839. isReady(): boolean;
  89840. /**
  89841. * Returns the string "LineMesh"
  89842. */
  89843. getClassName(): string;
  89844. /**
  89845. * @hidden
  89846. */
  89847. get material(): Material;
  89848. /**
  89849. * @hidden
  89850. */
  89851. set material(value: Material);
  89852. /**
  89853. * @hidden
  89854. */
  89855. get checkCollisions(): boolean;
  89856. /** @hidden */
  89857. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89858. /** @hidden */
  89859. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89860. /**
  89861. * Disposes of the line mesh
  89862. * @param doNotRecurse If children should be disposed
  89863. */
  89864. dispose(doNotRecurse?: boolean): void;
  89865. /**
  89866. * Returns a new LineMesh object cloned from the current one.
  89867. */
  89868. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  89869. /**
  89870. * Creates a new InstancedLinesMesh object from the mesh model.
  89871. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89872. * @param name defines the name of the new instance
  89873. * @returns a new InstancedLinesMesh
  89874. */
  89875. createInstance(name: string): InstancedLinesMesh;
  89876. }
  89877. /**
  89878. * Creates an instance based on a source LinesMesh
  89879. */
  89880. export class InstancedLinesMesh extends InstancedMesh {
  89881. /**
  89882. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89883. * This margin is expressed in world space coordinates, so its value may vary.
  89884. * Initilized with the intersectionThreshold value of the source LinesMesh
  89885. */
  89886. intersectionThreshold: number;
  89887. constructor(name: string, source: LinesMesh);
  89888. /**
  89889. * Returns the string "InstancedLinesMesh".
  89890. */
  89891. getClassName(): string;
  89892. }
  89893. }
  89894. declare module BABYLON {
  89895. /** @hidden */
  89896. export var linePixelShader: {
  89897. name: string;
  89898. shader: string;
  89899. };
  89900. }
  89901. declare module BABYLON {
  89902. /** @hidden */
  89903. export var lineVertexShader: {
  89904. name: string;
  89905. shader: string;
  89906. };
  89907. }
  89908. declare module BABYLON {
  89909. interface AbstractMesh {
  89910. /**
  89911. * Gets the edgesRenderer associated with the mesh
  89912. */
  89913. edgesRenderer: Nullable<EdgesRenderer>;
  89914. }
  89915. interface LinesMesh {
  89916. /**
  89917. * Enables the edge rendering mode on the mesh.
  89918. * This mode makes the mesh edges visible
  89919. * @param epsilon defines the maximal distance between two angles to detect a face
  89920. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89921. * @returns the currentAbstractMesh
  89922. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89923. */
  89924. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89925. }
  89926. interface InstancedLinesMesh {
  89927. /**
  89928. * Enables the edge rendering mode on the mesh.
  89929. * This mode makes the mesh edges visible
  89930. * @param epsilon defines the maximal distance between two angles to detect a face
  89931. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89932. * @returns the current InstancedLinesMesh
  89933. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89934. */
  89935. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89936. }
  89937. /**
  89938. * Defines the minimum contract an Edges renderer should follow.
  89939. */
  89940. export interface IEdgesRenderer extends IDisposable {
  89941. /**
  89942. * Gets or sets a boolean indicating if the edgesRenderer is active
  89943. */
  89944. isEnabled: boolean;
  89945. /**
  89946. * Renders the edges of the attached mesh,
  89947. */
  89948. render(): void;
  89949. /**
  89950. * Checks wether or not the edges renderer is ready to render.
  89951. * @return true if ready, otherwise false.
  89952. */
  89953. isReady(): boolean;
  89954. }
  89955. /**
  89956. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89957. */
  89958. export class EdgesRenderer implements IEdgesRenderer {
  89959. /**
  89960. * Define the size of the edges with an orthographic camera
  89961. */
  89962. edgesWidthScalerForOrthographic: number;
  89963. /**
  89964. * Define the size of the edges with a perspective camera
  89965. */
  89966. edgesWidthScalerForPerspective: number;
  89967. protected _source: AbstractMesh;
  89968. protected _linesPositions: number[];
  89969. protected _linesNormals: number[];
  89970. protected _linesIndices: number[];
  89971. protected _epsilon: number;
  89972. protected _indicesCount: number;
  89973. protected _lineShader: ShaderMaterial;
  89974. protected _ib: DataBuffer;
  89975. protected _buffers: {
  89976. [key: string]: Nullable<VertexBuffer>;
  89977. };
  89978. protected _checkVerticesInsteadOfIndices: boolean;
  89979. private _meshRebuildObserver;
  89980. private _meshDisposeObserver;
  89981. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89982. isEnabled: boolean;
  89983. /**
  89984. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89985. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89986. * @param source Mesh used to create edges
  89987. * @param epsilon sum of angles in adjacency to check for edge
  89988. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89989. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89990. */
  89991. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89992. protected _prepareRessources(): void;
  89993. /** @hidden */
  89994. _rebuild(): void;
  89995. /**
  89996. * Releases the required resources for the edges renderer
  89997. */
  89998. dispose(): void;
  89999. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90000. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90001. /**
  90002. * Checks if the pair of p0 and p1 is en edge
  90003. * @param faceIndex
  90004. * @param edge
  90005. * @param faceNormals
  90006. * @param p0
  90007. * @param p1
  90008. * @private
  90009. */
  90010. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90011. /**
  90012. * push line into the position, normal and index buffer
  90013. * @protected
  90014. */
  90015. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90016. /**
  90017. * Generates lines edges from adjacencjes
  90018. * @private
  90019. */
  90020. _generateEdgesLines(): void;
  90021. /**
  90022. * Checks wether or not the edges renderer is ready to render.
  90023. * @return true if ready, otherwise false.
  90024. */
  90025. isReady(): boolean;
  90026. /**
  90027. * Renders the edges of the attached mesh,
  90028. */
  90029. render(): void;
  90030. }
  90031. /**
  90032. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90033. */
  90034. export class LineEdgesRenderer extends EdgesRenderer {
  90035. /**
  90036. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90037. * @param source LineMesh used to generate edges
  90038. * @param epsilon not important (specified angle for edge detection)
  90039. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90040. */
  90041. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90042. /**
  90043. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90044. */
  90045. _generateEdgesLines(): void;
  90046. }
  90047. }
  90048. declare module BABYLON {
  90049. /**
  90050. * This represents the object necessary to create a rendering group.
  90051. * This is exclusively used and created by the rendering manager.
  90052. * To modify the behavior, you use the available helpers in your scene or meshes.
  90053. * @hidden
  90054. */
  90055. export class RenderingGroup {
  90056. index: number;
  90057. private static _zeroVector;
  90058. private _scene;
  90059. private _opaqueSubMeshes;
  90060. private _transparentSubMeshes;
  90061. private _alphaTestSubMeshes;
  90062. private _depthOnlySubMeshes;
  90063. private _particleSystems;
  90064. private _spriteManagers;
  90065. private _opaqueSortCompareFn;
  90066. private _alphaTestSortCompareFn;
  90067. private _transparentSortCompareFn;
  90068. private _renderOpaque;
  90069. private _renderAlphaTest;
  90070. private _renderTransparent;
  90071. /** @hidden */
  90072. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90073. onBeforeTransparentRendering: () => void;
  90074. /**
  90075. * Set the opaque sort comparison function.
  90076. * If null the sub meshes will be render in the order they were created
  90077. */
  90078. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90079. /**
  90080. * Set the alpha test sort comparison function.
  90081. * If null the sub meshes will be render in the order they were created
  90082. */
  90083. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90084. /**
  90085. * Set the transparent sort comparison function.
  90086. * If null the sub meshes will be render in the order they were created
  90087. */
  90088. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90089. /**
  90090. * Creates a new rendering group.
  90091. * @param index The rendering group index
  90092. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90093. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90094. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90095. */
  90096. 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>);
  90097. /**
  90098. * Render all the sub meshes contained in the group.
  90099. * @param customRenderFunction Used to override the default render behaviour of the group.
  90100. * @returns true if rendered some submeshes.
  90101. */
  90102. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90103. /**
  90104. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90105. * @param subMeshes The submeshes to render
  90106. */
  90107. private renderOpaqueSorted;
  90108. /**
  90109. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90110. * @param subMeshes The submeshes to render
  90111. */
  90112. private renderAlphaTestSorted;
  90113. /**
  90114. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90115. * @param subMeshes The submeshes to render
  90116. */
  90117. private renderTransparentSorted;
  90118. /**
  90119. * Renders the submeshes in a specified order.
  90120. * @param subMeshes The submeshes to sort before render
  90121. * @param sortCompareFn The comparison function use to sort
  90122. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90123. * @param transparent Specifies to activate blending if true
  90124. */
  90125. private static renderSorted;
  90126. /**
  90127. * Renders the submeshes in the order they were dispatched (no sort applied).
  90128. * @param subMeshes The submeshes to render
  90129. */
  90130. private static renderUnsorted;
  90131. /**
  90132. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90133. * are rendered back to front if in the same alpha index.
  90134. *
  90135. * @param a The first submesh
  90136. * @param b The second submesh
  90137. * @returns The result of the comparison
  90138. */
  90139. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90140. /**
  90141. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90142. * are rendered back to front.
  90143. *
  90144. * @param a The first submesh
  90145. * @param b The second submesh
  90146. * @returns The result of the comparison
  90147. */
  90148. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90149. /**
  90150. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90151. * are rendered front to back (prevent overdraw).
  90152. *
  90153. * @param a The first submesh
  90154. * @param b The second submesh
  90155. * @returns The result of the comparison
  90156. */
  90157. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90158. /**
  90159. * Resets the different lists of submeshes to prepare a new frame.
  90160. */
  90161. prepare(): void;
  90162. dispose(): void;
  90163. /**
  90164. * Inserts the submesh in its correct queue depending on its material.
  90165. * @param subMesh The submesh to dispatch
  90166. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90167. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90168. */
  90169. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90170. dispatchSprites(spriteManager: ISpriteManager): void;
  90171. dispatchParticles(particleSystem: IParticleSystem): void;
  90172. private _renderParticles;
  90173. private _renderSprites;
  90174. }
  90175. }
  90176. declare module BABYLON {
  90177. /**
  90178. * Interface describing the different options available in the rendering manager
  90179. * regarding Auto Clear between groups.
  90180. */
  90181. export interface IRenderingManagerAutoClearSetup {
  90182. /**
  90183. * Defines whether or not autoclear is enable.
  90184. */
  90185. autoClear: boolean;
  90186. /**
  90187. * Defines whether or not to autoclear the depth buffer.
  90188. */
  90189. depth: boolean;
  90190. /**
  90191. * Defines whether or not to autoclear the stencil buffer.
  90192. */
  90193. stencil: boolean;
  90194. }
  90195. /**
  90196. * This class is used by the onRenderingGroupObservable
  90197. */
  90198. export class RenderingGroupInfo {
  90199. /**
  90200. * The Scene that being rendered
  90201. */
  90202. scene: Scene;
  90203. /**
  90204. * The camera currently used for the rendering pass
  90205. */
  90206. camera: Nullable<Camera>;
  90207. /**
  90208. * The ID of the renderingGroup being processed
  90209. */
  90210. renderingGroupId: number;
  90211. }
  90212. /**
  90213. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90214. * It is enable to manage the different groups as well as the different necessary sort functions.
  90215. * This should not be used directly aside of the few static configurations
  90216. */
  90217. export class RenderingManager {
  90218. /**
  90219. * The max id used for rendering groups (not included)
  90220. */
  90221. static MAX_RENDERINGGROUPS: number;
  90222. /**
  90223. * The min id used for rendering groups (included)
  90224. */
  90225. static MIN_RENDERINGGROUPS: number;
  90226. /**
  90227. * Used to globally prevent autoclearing scenes.
  90228. */
  90229. static AUTOCLEAR: boolean;
  90230. /**
  90231. * @hidden
  90232. */
  90233. _useSceneAutoClearSetup: boolean;
  90234. private _scene;
  90235. private _renderingGroups;
  90236. private _depthStencilBufferAlreadyCleaned;
  90237. private _autoClearDepthStencil;
  90238. private _customOpaqueSortCompareFn;
  90239. private _customAlphaTestSortCompareFn;
  90240. private _customTransparentSortCompareFn;
  90241. private _renderingGroupInfo;
  90242. /**
  90243. * Instantiates a new rendering group for a particular scene
  90244. * @param scene Defines the scene the groups belongs to
  90245. */
  90246. constructor(scene: Scene);
  90247. private _clearDepthStencilBuffer;
  90248. /**
  90249. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90250. * @hidden
  90251. */
  90252. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90253. /**
  90254. * Resets the different information of the group to prepare a new frame
  90255. * @hidden
  90256. */
  90257. reset(): void;
  90258. /**
  90259. * Dispose and release the group and its associated resources.
  90260. * @hidden
  90261. */
  90262. dispose(): void;
  90263. /**
  90264. * Clear the info related to rendering groups preventing retention points during dispose.
  90265. */
  90266. freeRenderingGroups(): void;
  90267. private _prepareRenderingGroup;
  90268. /**
  90269. * Add a sprite manager to the rendering manager in order to render it this frame.
  90270. * @param spriteManager Define the sprite manager to render
  90271. */
  90272. dispatchSprites(spriteManager: ISpriteManager): void;
  90273. /**
  90274. * Add a particle system to the rendering manager in order to render it this frame.
  90275. * @param particleSystem Define the particle system to render
  90276. */
  90277. dispatchParticles(particleSystem: IParticleSystem): void;
  90278. /**
  90279. * Add a submesh to the manager in order to render it this frame
  90280. * @param subMesh The submesh to dispatch
  90281. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90282. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90283. */
  90284. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90285. /**
  90286. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90287. * This allowed control for front to back rendering or reversly depending of the special needs.
  90288. *
  90289. * @param renderingGroupId The rendering group id corresponding to its index
  90290. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90291. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90292. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90293. */
  90294. 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;
  90295. /**
  90296. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90297. *
  90298. * @param renderingGroupId The rendering group id corresponding to its index
  90299. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90300. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90301. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90302. */
  90303. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90304. /**
  90305. * Gets the current auto clear configuration for one rendering group of the rendering
  90306. * manager.
  90307. * @param index the rendering group index to get the information for
  90308. * @returns The auto clear setup for the requested rendering group
  90309. */
  90310. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90311. }
  90312. }
  90313. declare module BABYLON {
  90314. /**
  90315. * Defines the options associated with the creation of a custom shader for a shadow generator.
  90316. */
  90317. export interface ICustomShaderOptions {
  90318. /**
  90319. * Gets or sets the custom shader name to use
  90320. */
  90321. shaderName: string;
  90322. /**
  90323. * The list of attribute names used in the shader
  90324. */
  90325. attributes?: string[];
  90326. /**
  90327. * The list of unifrom names used in the shader
  90328. */
  90329. uniforms?: string[];
  90330. /**
  90331. * The list of sampler names used in the shader
  90332. */
  90333. samplers?: string[];
  90334. /**
  90335. * The list of defines used in the shader
  90336. */
  90337. defines?: string[];
  90338. }
  90339. /**
  90340. * Interface to implement to create a shadow generator compatible with BJS.
  90341. */
  90342. export interface IShadowGenerator {
  90343. /**
  90344. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90345. * @returns The render target texture if present otherwise, null
  90346. */
  90347. getShadowMap(): Nullable<RenderTargetTexture>;
  90348. /**
  90349. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90350. * @param subMesh The submesh we want to render in the shadow map
  90351. * @param useInstances Defines wether will draw in the map using instances
  90352. * @returns true if ready otherwise, false
  90353. */
  90354. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90355. /**
  90356. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90357. * @param defines Defines of the material we want to update
  90358. * @param lightIndex Index of the light in the enabled light list of the material
  90359. */
  90360. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  90361. /**
  90362. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90363. * defined in the generator but impacting the effect).
  90364. * It implies the unifroms available on the materials are the standard BJS ones.
  90365. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90366. * @param effect The effect we are binfing the information for
  90367. */
  90368. bindShadowLight(lightIndex: string, effect: Effect): void;
  90369. /**
  90370. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90371. * (eq to shadow prjection matrix * light transform matrix)
  90372. * @returns The transform matrix used to create the shadow map
  90373. */
  90374. getTransformMatrix(): Matrix;
  90375. /**
  90376. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90377. * Cube and 2D textures for instance.
  90378. */
  90379. recreateShadowMap(): void;
  90380. /**
  90381. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90382. * @param onCompiled Callback triggered at the and of the effects compilation
  90383. * @param options Sets of optional options forcing the compilation with different modes
  90384. */
  90385. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90386. useInstances: boolean;
  90387. }>): void;
  90388. /**
  90389. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90390. * @param options Sets of optional options forcing the compilation with different modes
  90391. * @returns A promise that resolves when the compilation completes
  90392. */
  90393. forceCompilationAsync(options?: Partial<{
  90394. useInstances: boolean;
  90395. }>): Promise<void>;
  90396. /**
  90397. * Serializes the shadow generator setup to a json object.
  90398. * @returns The serialized JSON object
  90399. */
  90400. serialize(): any;
  90401. /**
  90402. * Disposes the Shadow map and related Textures and effects.
  90403. */
  90404. dispose(): void;
  90405. }
  90406. /**
  90407. * Default implementation IShadowGenerator.
  90408. * This is the main object responsible of generating shadows in the framework.
  90409. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  90410. */
  90411. export class ShadowGenerator implements IShadowGenerator {
  90412. /**
  90413. * Name of the shadow generator class
  90414. */
  90415. static CLASSNAME: string;
  90416. /**
  90417. * Shadow generator mode None: no filtering applied.
  90418. */
  90419. static readonly FILTER_NONE: number;
  90420. /**
  90421. * Shadow generator mode ESM: Exponential Shadow Mapping.
  90422. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90423. */
  90424. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  90425. /**
  90426. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  90427. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  90428. */
  90429. static readonly FILTER_POISSONSAMPLING: number;
  90430. /**
  90431. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  90432. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90433. */
  90434. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  90435. /**
  90436. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  90437. * edge artifacts on steep falloff.
  90438. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90439. */
  90440. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  90441. /**
  90442. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  90443. * edge artifacts on steep falloff.
  90444. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90445. */
  90446. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  90447. /**
  90448. * Shadow generator mode PCF: Percentage Closer Filtering
  90449. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90450. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  90451. */
  90452. static readonly FILTER_PCF: number;
  90453. /**
  90454. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  90455. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90456. * Contact Hardening
  90457. */
  90458. static readonly FILTER_PCSS: number;
  90459. /**
  90460. * Reserved for PCF and PCSS
  90461. * Highest Quality.
  90462. *
  90463. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  90464. *
  90465. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  90466. */
  90467. static readonly QUALITY_HIGH: number;
  90468. /**
  90469. * Reserved for PCF and PCSS
  90470. * Good tradeoff for quality/perf cross devices
  90471. *
  90472. * Execute PCF on a 3*3 kernel.
  90473. *
  90474. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  90475. */
  90476. static readonly QUALITY_MEDIUM: number;
  90477. /**
  90478. * Reserved for PCF and PCSS
  90479. * The lowest quality but the fastest.
  90480. *
  90481. * Execute PCF on a 1*1 kernel.
  90482. *
  90483. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  90484. */
  90485. static readonly QUALITY_LOW: number;
  90486. /** Gets or sets the custom shader name to use */
  90487. customShaderOptions: ICustomShaderOptions;
  90488. /**
  90489. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  90490. */
  90491. onBeforeShadowMapRenderObservable: Observable<Effect>;
  90492. /**
  90493. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  90494. */
  90495. onAfterShadowMapRenderObservable: Observable<Effect>;
  90496. /**
  90497. * Observable triggered before a mesh is rendered in the shadow map.
  90498. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  90499. */
  90500. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  90501. /**
  90502. * Observable triggered after a mesh is rendered in the shadow map.
  90503. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  90504. */
  90505. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  90506. protected _bias: number;
  90507. /**
  90508. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  90509. */
  90510. get bias(): number;
  90511. /**
  90512. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  90513. */
  90514. set bias(bias: number);
  90515. protected _normalBias: number;
  90516. /**
  90517. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90518. */
  90519. get normalBias(): number;
  90520. /**
  90521. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90522. */
  90523. set normalBias(normalBias: number);
  90524. protected _blurBoxOffset: number;
  90525. /**
  90526. * Gets the blur box offset: offset applied during the blur pass.
  90527. * Only useful if useKernelBlur = false
  90528. */
  90529. get blurBoxOffset(): number;
  90530. /**
  90531. * Sets the blur box offset: offset applied during the blur pass.
  90532. * Only useful if useKernelBlur = false
  90533. */
  90534. set blurBoxOffset(value: number);
  90535. protected _blurScale: number;
  90536. /**
  90537. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  90538. * 2 means half of the size.
  90539. */
  90540. get blurScale(): number;
  90541. /**
  90542. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  90543. * 2 means half of the size.
  90544. */
  90545. set blurScale(value: number);
  90546. protected _blurKernel: number;
  90547. /**
  90548. * Gets the blur kernel: kernel size of the blur pass.
  90549. * Only useful if useKernelBlur = true
  90550. */
  90551. get blurKernel(): number;
  90552. /**
  90553. * Sets the blur kernel: kernel size of the blur pass.
  90554. * Only useful if useKernelBlur = true
  90555. */
  90556. set blurKernel(value: number);
  90557. protected _useKernelBlur: boolean;
  90558. /**
  90559. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  90560. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90561. */
  90562. get useKernelBlur(): boolean;
  90563. /**
  90564. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  90565. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90566. */
  90567. set useKernelBlur(value: boolean);
  90568. protected _depthScale: number;
  90569. /**
  90570. * Gets the depth scale used in ESM mode.
  90571. */
  90572. get depthScale(): number;
  90573. /**
  90574. * Sets the depth scale used in ESM mode.
  90575. * This can override the scale stored on the light.
  90576. */
  90577. set depthScale(value: number);
  90578. protected _validateFilter(filter: number): number;
  90579. protected _filter: number;
  90580. /**
  90581. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  90582. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90583. */
  90584. get filter(): number;
  90585. /**
  90586. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  90587. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90588. */
  90589. set filter(value: number);
  90590. /**
  90591. * Gets if the current filter is set to Poisson Sampling.
  90592. */
  90593. get usePoissonSampling(): boolean;
  90594. /**
  90595. * Sets the current filter to Poisson Sampling.
  90596. */
  90597. set usePoissonSampling(value: boolean);
  90598. /**
  90599. * Gets if the current filter is set to ESM.
  90600. */
  90601. get useExponentialShadowMap(): boolean;
  90602. /**
  90603. * Sets the current filter is to ESM.
  90604. */
  90605. set useExponentialShadowMap(value: boolean);
  90606. /**
  90607. * Gets if the current filter is set to filtered ESM.
  90608. */
  90609. get useBlurExponentialShadowMap(): boolean;
  90610. /**
  90611. * Gets if the current filter is set to filtered ESM.
  90612. */
  90613. set useBlurExponentialShadowMap(value: boolean);
  90614. /**
  90615. * Gets if the current filter is set to "close ESM" (using the inverse of the
  90616. * exponential to prevent steep falloff artifacts).
  90617. */
  90618. get useCloseExponentialShadowMap(): boolean;
  90619. /**
  90620. * Sets the current filter to "close ESM" (using the inverse of the
  90621. * exponential to prevent steep falloff artifacts).
  90622. */
  90623. set useCloseExponentialShadowMap(value: boolean);
  90624. /**
  90625. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  90626. * exponential to prevent steep falloff artifacts).
  90627. */
  90628. get useBlurCloseExponentialShadowMap(): boolean;
  90629. /**
  90630. * Sets the current filter to filtered "close ESM" (using the inverse of the
  90631. * exponential to prevent steep falloff artifacts).
  90632. */
  90633. set useBlurCloseExponentialShadowMap(value: boolean);
  90634. /**
  90635. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  90636. */
  90637. get usePercentageCloserFiltering(): boolean;
  90638. /**
  90639. * Sets the current filter to "PCF" (percentage closer filtering).
  90640. */
  90641. set usePercentageCloserFiltering(value: boolean);
  90642. protected _filteringQuality: number;
  90643. /**
  90644. * Gets the PCF or PCSS Quality.
  90645. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90646. */
  90647. get filteringQuality(): number;
  90648. /**
  90649. * Sets the PCF or PCSS Quality.
  90650. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90651. */
  90652. set filteringQuality(filteringQuality: number);
  90653. /**
  90654. * Gets if the current filter is set to "PCSS" (contact hardening).
  90655. */
  90656. get useContactHardeningShadow(): boolean;
  90657. /**
  90658. * Sets the current filter to "PCSS" (contact hardening).
  90659. */
  90660. set useContactHardeningShadow(value: boolean);
  90661. protected _contactHardeningLightSizeUVRatio: number;
  90662. /**
  90663. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90664. * Using a ratio helps keeping shape stability independently of the map size.
  90665. *
  90666. * It does not account for the light projection as it was having too much
  90667. * instability during the light setup or during light position changes.
  90668. *
  90669. * Only valid if useContactHardeningShadow is true.
  90670. */
  90671. get contactHardeningLightSizeUVRatio(): number;
  90672. /**
  90673. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90674. * Using a ratio helps keeping shape stability independently of the map size.
  90675. *
  90676. * It does not account for the light projection as it was having too much
  90677. * instability during the light setup or during light position changes.
  90678. *
  90679. * Only valid if useContactHardeningShadow is true.
  90680. */
  90681. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90682. protected _darkness: number;
  90683. /** Gets or sets the actual darkness of a shadow */
  90684. get darkness(): number;
  90685. set darkness(value: number);
  90686. /**
  90687. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90688. * 0 means strongest and 1 would means no shadow.
  90689. * @returns the darkness.
  90690. */
  90691. getDarkness(): number;
  90692. /**
  90693. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90694. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90695. * @returns the shadow generator allowing fluent coding.
  90696. */
  90697. setDarkness(darkness: number): ShadowGenerator;
  90698. protected _transparencyShadow: boolean;
  90699. /** Gets or sets the ability to have transparent shadow */
  90700. get transparencyShadow(): boolean;
  90701. set transparencyShadow(value: boolean);
  90702. /**
  90703. * Sets the ability to have transparent shadow (boolean).
  90704. * @param transparent True if transparent else False
  90705. * @returns the shadow generator allowing fluent coding
  90706. */
  90707. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90708. protected _shadowMap: Nullable<RenderTargetTexture>;
  90709. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90710. /**
  90711. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90712. * @returns The render target texture if present otherwise, null
  90713. */
  90714. getShadowMap(): Nullable<RenderTargetTexture>;
  90715. /**
  90716. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90717. * @returns The render target texture if the shadow map is present otherwise, null
  90718. */
  90719. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90720. /**
  90721. * Gets the class name of that object
  90722. * @returns "ShadowGenerator"
  90723. */
  90724. getClassName(): string;
  90725. /**
  90726. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90727. * @param mesh Mesh to add
  90728. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90729. * @returns the Shadow Generator itself
  90730. */
  90731. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90732. /**
  90733. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90734. * @param mesh Mesh to remove
  90735. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90736. * @returns the Shadow Generator itself
  90737. */
  90738. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90739. /**
  90740. * Controls the extent to which the shadows fade out at the edge of the frustum
  90741. */
  90742. frustumEdgeFalloff: number;
  90743. protected _light: IShadowLight;
  90744. /**
  90745. * Returns the associated light object.
  90746. * @returns the light generating the shadow
  90747. */
  90748. getLight(): IShadowLight;
  90749. /**
  90750. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90751. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90752. * It might on the other hand introduce peter panning.
  90753. */
  90754. forceBackFacesOnly: boolean;
  90755. protected _scene: Scene;
  90756. protected _lightDirection: Vector3;
  90757. protected _effect: Effect;
  90758. protected _viewMatrix: Matrix;
  90759. protected _projectionMatrix: Matrix;
  90760. protected _transformMatrix: Matrix;
  90761. protected _cachedPosition: Vector3;
  90762. protected _cachedDirection: Vector3;
  90763. protected _cachedDefines: string;
  90764. protected _currentRenderID: number;
  90765. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90766. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  90767. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  90768. protected _blurPostProcesses: PostProcess[];
  90769. protected _mapSize: number;
  90770. protected _currentFaceIndex: number;
  90771. protected _currentFaceIndexCache: number;
  90772. protected _textureType: number;
  90773. protected _defaultTextureMatrix: Matrix;
  90774. protected _storedUniqueId: Nullable<number>;
  90775. /** @hidden */
  90776. static _SceneComponentInitialization: (scene: Scene) => void;
  90777. /**
  90778. * Creates a ShadowGenerator object.
  90779. * A ShadowGenerator is the required tool to use the shadows.
  90780. * Each light casting shadows needs to use its own ShadowGenerator.
  90781. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  90782. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  90783. * @param light The light object generating the shadows.
  90784. * @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.
  90785. */
  90786. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  90787. protected _initializeGenerator(): void;
  90788. protected _createTargetRenderTexture(): void;
  90789. protected _initializeShadowMap(): void;
  90790. protected _initializeBlurRTTAndPostProcesses(): void;
  90791. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  90792. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  90793. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  90794. protected _applyFilterValues(): void;
  90795. /**
  90796. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90797. * @param onCompiled Callback triggered at the and of the effects compilation
  90798. * @param options Sets of optional options forcing the compilation with different modes
  90799. */
  90800. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90801. useInstances: boolean;
  90802. }>): void;
  90803. /**
  90804. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90805. * @param options Sets of optional options forcing the compilation with different modes
  90806. * @returns A promise that resolves when the compilation completes
  90807. */
  90808. forceCompilationAsync(options?: Partial<{
  90809. useInstances: boolean;
  90810. }>): Promise<void>;
  90811. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  90812. /**
  90813. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90814. * @param subMesh The submesh we want to render in the shadow map
  90815. * @param useInstances Defines wether will draw in the map using instances
  90816. * @returns true if ready otherwise, false
  90817. */
  90818. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90819. /**
  90820. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90821. * @param defines Defines of the material we want to update
  90822. * @param lightIndex Index of the light in the enabled light list of the material
  90823. */
  90824. prepareDefines(defines: any, lightIndex: number): void;
  90825. /**
  90826. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90827. * defined in the generator but impacting the effect).
  90828. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90829. * @param effect The effect we are binfing the information for
  90830. */
  90831. bindShadowLight(lightIndex: string, effect: Effect): void;
  90832. /**
  90833. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90834. * (eq to shadow prjection matrix * light transform matrix)
  90835. * @returns The transform matrix used to create the shadow map
  90836. */
  90837. getTransformMatrix(): Matrix;
  90838. /**
  90839. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90840. * Cube and 2D textures for instance.
  90841. */
  90842. recreateShadowMap(): void;
  90843. protected _disposeBlurPostProcesses(): void;
  90844. protected _disposeRTTandPostProcesses(): void;
  90845. /**
  90846. * Disposes the ShadowGenerator.
  90847. * Returns nothing.
  90848. */
  90849. dispose(): void;
  90850. /**
  90851. * Serializes the shadow generator setup to a json object.
  90852. * @returns The serialized JSON object
  90853. */
  90854. serialize(): any;
  90855. /**
  90856. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  90857. * @param parsedShadowGenerator The JSON object to parse
  90858. * @param scene The scene to create the shadow map for
  90859. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  90860. * @returns The parsed shadow generator
  90861. */
  90862. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  90863. }
  90864. }
  90865. declare module BABYLON {
  90866. /**
  90867. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  90868. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  90869. * 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.
  90870. */
  90871. export abstract class Light extends Node {
  90872. /**
  90873. * Falloff Default: light is falling off following the material specification:
  90874. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  90875. */
  90876. static readonly FALLOFF_DEFAULT: number;
  90877. /**
  90878. * Falloff Physical: light is falling off following the inverse squared distance law.
  90879. */
  90880. static readonly FALLOFF_PHYSICAL: number;
  90881. /**
  90882. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  90883. * to enhance interoperability with other engines.
  90884. */
  90885. static readonly FALLOFF_GLTF: number;
  90886. /**
  90887. * Falloff Standard: light is falling off like in the standard material
  90888. * to enhance interoperability with other materials.
  90889. */
  90890. static readonly FALLOFF_STANDARD: number;
  90891. /**
  90892. * If every light affecting the material is in this lightmapMode,
  90893. * material.lightmapTexture adds or multiplies
  90894. * (depends on material.useLightmapAsShadowmap)
  90895. * after every other light calculations.
  90896. */
  90897. static readonly LIGHTMAP_DEFAULT: number;
  90898. /**
  90899. * material.lightmapTexture as only diffuse lighting from this light
  90900. * adds only specular lighting from this light
  90901. * adds dynamic shadows
  90902. */
  90903. static readonly LIGHTMAP_SPECULAR: number;
  90904. /**
  90905. * material.lightmapTexture as only lighting
  90906. * no light calculation from this light
  90907. * only adds dynamic shadows from this light
  90908. */
  90909. static readonly LIGHTMAP_SHADOWSONLY: number;
  90910. /**
  90911. * Each light type uses the default quantity according to its type:
  90912. * point/spot lights use luminous intensity
  90913. * directional lights use illuminance
  90914. */
  90915. static readonly INTENSITYMODE_AUTOMATIC: number;
  90916. /**
  90917. * lumen (lm)
  90918. */
  90919. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90920. /**
  90921. * candela (lm/sr)
  90922. */
  90923. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90924. /**
  90925. * lux (lm/m^2)
  90926. */
  90927. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90928. /**
  90929. * nit (cd/m^2)
  90930. */
  90931. static readonly INTENSITYMODE_LUMINANCE: number;
  90932. /**
  90933. * Light type const id of the point light.
  90934. */
  90935. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90936. /**
  90937. * Light type const id of the directional light.
  90938. */
  90939. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90940. /**
  90941. * Light type const id of the spot light.
  90942. */
  90943. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90944. /**
  90945. * Light type const id of the hemispheric light.
  90946. */
  90947. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90948. /**
  90949. * Diffuse gives the basic color to an object.
  90950. */
  90951. diffuse: Color3;
  90952. /**
  90953. * Specular produces a highlight color on an object.
  90954. * Note: This is note affecting PBR materials.
  90955. */
  90956. specular: Color3;
  90957. /**
  90958. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90959. * falling off base on range or angle.
  90960. * This can be set to any values in Light.FALLOFF_x.
  90961. *
  90962. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90963. * other types of materials.
  90964. */
  90965. falloffType: number;
  90966. /**
  90967. * Strength of the light.
  90968. * Note: By default it is define in the framework own unit.
  90969. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90970. */
  90971. intensity: number;
  90972. private _range;
  90973. protected _inverseSquaredRange: number;
  90974. /**
  90975. * Defines how far from the source the light is impacting in scene units.
  90976. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90977. */
  90978. get range(): number;
  90979. /**
  90980. * Defines how far from the source the light is impacting in scene units.
  90981. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90982. */
  90983. set range(value: number);
  90984. /**
  90985. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90986. * of light.
  90987. */
  90988. private _photometricScale;
  90989. private _intensityMode;
  90990. /**
  90991. * Gets the photometric scale used to interpret the intensity.
  90992. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90993. */
  90994. get intensityMode(): number;
  90995. /**
  90996. * Sets the photometric scale used to interpret the intensity.
  90997. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90998. */
  90999. set intensityMode(value: number);
  91000. private _radius;
  91001. /**
  91002. * Gets the light radius used by PBR Materials to simulate soft area lights.
  91003. */
  91004. get radius(): number;
  91005. /**
  91006. * sets the light radius used by PBR Materials to simulate soft area lights.
  91007. */
  91008. set radius(value: number);
  91009. private _renderPriority;
  91010. /**
  91011. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  91012. * exceeding the number allowed of the materials.
  91013. */
  91014. renderPriority: number;
  91015. private _shadowEnabled;
  91016. /**
  91017. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91018. * the current shadow generator.
  91019. */
  91020. get shadowEnabled(): boolean;
  91021. /**
  91022. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91023. * the current shadow generator.
  91024. */
  91025. set shadowEnabled(value: boolean);
  91026. private _includedOnlyMeshes;
  91027. /**
  91028. * Gets the only meshes impacted by this light.
  91029. */
  91030. get includedOnlyMeshes(): AbstractMesh[];
  91031. /**
  91032. * Sets the only meshes impacted by this light.
  91033. */
  91034. set includedOnlyMeshes(value: AbstractMesh[]);
  91035. private _excludedMeshes;
  91036. /**
  91037. * Gets the meshes not impacted by this light.
  91038. */
  91039. get excludedMeshes(): AbstractMesh[];
  91040. /**
  91041. * Sets the meshes not impacted by this light.
  91042. */
  91043. set excludedMeshes(value: AbstractMesh[]);
  91044. private _excludeWithLayerMask;
  91045. /**
  91046. * Gets the layer id use to find what meshes are not impacted by the light.
  91047. * Inactive if 0
  91048. */
  91049. get excludeWithLayerMask(): number;
  91050. /**
  91051. * Sets the layer id use to find what meshes are not impacted by the light.
  91052. * Inactive if 0
  91053. */
  91054. set excludeWithLayerMask(value: number);
  91055. private _includeOnlyWithLayerMask;
  91056. /**
  91057. * Gets the layer id use to find what meshes are impacted by the light.
  91058. * Inactive if 0
  91059. */
  91060. get includeOnlyWithLayerMask(): number;
  91061. /**
  91062. * Sets the layer id use to find what meshes are impacted by the light.
  91063. * Inactive if 0
  91064. */
  91065. set includeOnlyWithLayerMask(value: number);
  91066. private _lightmapMode;
  91067. /**
  91068. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91069. */
  91070. get lightmapMode(): number;
  91071. /**
  91072. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91073. */
  91074. set lightmapMode(value: number);
  91075. /**
  91076. * Shadow generator associted to the light.
  91077. * @hidden Internal use only.
  91078. */
  91079. _shadowGenerator: Nullable<IShadowGenerator>;
  91080. /**
  91081. * @hidden Internal use only.
  91082. */
  91083. _excludedMeshesIds: string[];
  91084. /**
  91085. * @hidden Internal use only.
  91086. */
  91087. _includedOnlyMeshesIds: string[];
  91088. /**
  91089. * The current light unifom buffer.
  91090. * @hidden Internal use only.
  91091. */
  91092. _uniformBuffer: UniformBuffer;
  91093. /** @hidden */
  91094. _renderId: number;
  91095. /**
  91096. * Creates a Light object in the scene.
  91097. * Documentation : https://doc.babylonjs.com/babylon101/lights
  91098. * @param name The firendly name of the light
  91099. * @param scene The scene the light belongs too
  91100. */
  91101. constructor(name: string, scene: Scene);
  91102. protected abstract _buildUniformLayout(): void;
  91103. /**
  91104. * Sets the passed Effect "effect" with the Light information.
  91105. * @param effect The effect to update
  91106. * @param lightIndex The index of the light in the effect to update
  91107. * @returns The light
  91108. */
  91109. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  91110. /**
  91111. * Sets the passed Effect "effect" with the Light textures.
  91112. * @param effect The effect to update
  91113. * @param lightIndex The index of the light in the effect to update
  91114. * @returns The light
  91115. */
  91116. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  91117. /**
  91118. * Binds the lights information from the scene to the effect for the given mesh.
  91119. * @param lightIndex Light index
  91120. * @param scene The scene where the light belongs to
  91121. * @param effect The effect we are binding the data to
  91122. * @param useSpecular Defines if specular is supported
  91123. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  91124. */
  91125. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  91126. /**
  91127. * Sets the passed Effect "effect" with the Light information.
  91128. * @param effect The effect to update
  91129. * @param lightDataUniformName The uniform used to store light data (position or direction)
  91130. * @returns The light
  91131. */
  91132. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  91133. /**
  91134. * Returns the string "Light".
  91135. * @returns the class name
  91136. */
  91137. getClassName(): string;
  91138. /** @hidden */
  91139. readonly _isLight: boolean;
  91140. /**
  91141. * Converts the light information to a readable string for debug purpose.
  91142. * @param fullDetails Supports for multiple levels of logging within scene loading
  91143. * @returns the human readable light info
  91144. */
  91145. toString(fullDetails?: boolean): string;
  91146. /** @hidden */
  91147. protected _syncParentEnabledState(): void;
  91148. /**
  91149. * Set the enabled state of this node.
  91150. * @param value - the new enabled state
  91151. */
  91152. setEnabled(value: boolean): void;
  91153. /**
  91154. * Returns the Light associated shadow generator if any.
  91155. * @return the associated shadow generator.
  91156. */
  91157. getShadowGenerator(): Nullable<IShadowGenerator>;
  91158. /**
  91159. * Returns a Vector3, the absolute light position in the World.
  91160. * @returns the world space position of the light
  91161. */
  91162. getAbsolutePosition(): Vector3;
  91163. /**
  91164. * Specifies if the light will affect the passed mesh.
  91165. * @param mesh The mesh to test against the light
  91166. * @return true the mesh is affected otherwise, false.
  91167. */
  91168. canAffectMesh(mesh: AbstractMesh): boolean;
  91169. /**
  91170. * Sort function to order lights for rendering.
  91171. * @param a First Light object to compare to second.
  91172. * @param b Second Light object to compare first.
  91173. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  91174. */
  91175. static CompareLightsPriority(a: Light, b: Light): number;
  91176. /**
  91177. * Releases resources associated with this node.
  91178. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91179. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91180. */
  91181. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91182. /**
  91183. * Returns the light type ID (integer).
  91184. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  91185. */
  91186. getTypeID(): number;
  91187. /**
  91188. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  91189. * @returns the scaled intensity in intensity mode unit
  91190. */
  91191. getScaledIntensity(): number;
  91192. /**
  91193. * Returns a new Light object, named "name", from the current one.
  91194. * @param name The name of the cloned light
  91195. * @returns the new created light
  91196. */
  91197. clone(name: string): Nullable<Light>;
  91198. /**
  91199. * Serializes the current light into a Serialization object.
  91200. * @returns the serialized object.
  91201. */
  91202. serialize(): any;
  91203. /**
  91204. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  91205. * This new light is named "name" and added to the passed scene.
  91206. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  91207. * @param name The friendly name of the light
  91208. * @param scene The scene the new light will belong to
  91209. * @returns the constructor function
  91210. */
  91211. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  91212. /**
  91213. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  91214. * @param parsedLight The JSON representation of the light
  91215. * @param scene The scene to create the parsed light in
  91216. * @returns the created light after parsing
  91217. */
  91218. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  91219. private _hookArrayForExcluded;
  91220. private _hookArrayForIncludedOnly;
  91221. private _resyncMeshes;
  91222. /**
  91223. * Forces the meshes to update their light related information in their rendering used effects
  91224. * @hidden Internal Use Only
  91225. */
  91226. _markMeshesAsLightDirty(): void;
  91227. /**
  91228. * Recomputes the cached photometric scale if needed.
  91229. */
  91230. private _computePhotometricScale;
  91231. /**
  91232. * Returns the Photometric Scale according to the light type and intensity mode.
  91233. */
  91234. private _getPhotometricScale;
  91235. /**
  91236. * Reorder the light in the scene according to their defined priority.
  91237. * @hidden Internal Use Only
  91238. */
  91239. _reorderLightsInScene(): void;
  91240. /**
  91241. * Prepares the list of defines specific to the light type.
  91242. * @param defines the list of defines
  91243. * @param lightIndex defines the index of the light for the effect
  91244. */
  91245. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  91246. }
  91247. }
  91248. declare module BABYLON {
  91249. /**
  91250. * Interface used to define Action
  91251. */
  91252. export interface IAction {
  91253. /**
  91254. * Trigger for the action
  91255. */
  91256. trigger: number;
  91257. /** Options of the trigger */
  91258. triggerOptions: any;
  91259. /**
  91260. * Gets the trigger parameters
  91261. * @returns the trigger parameters
  91262. */
  91263. getTriggerParameter(): any;
  91264. /**
  91265. * Internal only - executes current action event
  91266. * @hidden
  91267. */
  91268. _executeCurrent(evt?: ActionEvent): void;
  91269. /**
  91270. * Serialize placeholder for child classes
  91271. * @param parent of child
  91272. * @returns the serialized object
  91273. */
  91274. serialize(parent: any): any;
  91275. /**
  91276. * Internal only
  91277. * @hidden
  91278. */
  91279. _prepare(): void;
  91280. /**
  91281. * Internal only - manager for action
  91282. * @hidden
  91283. */
  91284. _actionManager: AbstractActionManager;
  91285. /**
  91286. * Adds action to chain of actions, may be a DoNothingAction
  91287. * @param action defines the next action to execute
  91288. * @returns The action passed in
  91289. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91290. */
  91291. then(action: IAction): IAction;
  91292. }
  91293. /**
  91294. * The action to be carried out following a trigger
  91295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91296. */
  91297. export class Action implements IAction {
  91298. /** the trigger, with or without parameters, for the action */
  91299. triggerOptions: any;
  91300. /**
  91301. * Trigger for the action
  91302. */
  91303. trigger: number;
  91304. /**
  91305. * Internal only - manager for action
  91306. * @hidden
  91307. */
  91308. _actionManager: ActionManager;
  91309. private _nextActiveAction;
  91310. private _child;
  91311. private _condition?;
  91312. private _triggerParameter;
  91313. /**
  91314. * An event triggered prior to action being executed.
  91315. */
  91316. onBeforeExecuteObservable: Observable<Action>;
  91317. /**
  91318. * Creates a new Action
  91319. * @param triggerOptions the trigger, with or without parameters, for the action
  91320. * @param condition an optional determinant of action
  91321. */
  91322. constructor(
  91323. /** the trigger, with or without parameters, for the action */
  91324. triggerOptions: any, condition?: Condition);
  91325. /**
  91326. * Internal only
  91327. * @hidden
  91328. */
  91329. _prepare(): void;
  91330. /**
  91331. * Gets the trigger parameters
  91332. * @returns the trigger parameters
  91333. */
  91334. getTriggerParameter(): any;
  91335. /**
  91336. * Internal only - executes current action event
  91337. * @hidden
  91338. */
  91339. _executeCurrent(evt?: ActionEvent): void;
  91340. /**
  91341. * Execute placeholder for child classes
  91342. * @param evt optional action event
  91343. */
  91344. execute(evt?: ActionEvent): void;
  91345. /**
  91346. * Skips to next active action
  91347. */
  91348. skipToNextActiveAction(): void;
  91349. /**
  91350. * Adds action to chain of actions, may be a DoNothingAction
  91351. * @param action defines the next action to execute
  91352. * @returns The action passed in
  91353. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91354. */
  91355. then(action: Action): Action;
  91356. /**
  91357. * Internal only
  91358. * @hidden
  91359. */
  91360. _getProperty(propertyPath: string): string;
  91361. /**
  91362. * Internal only
  91363. * @hidden
  91364. */
  91365. _getEffectiveTarget(target: any, propertyPath: string): any;
  91366. /**
  91367. * Serialize placeholder for child classes
  91368. * @param parent of child
  91369. * @returns the serialized object
  91370. */
  91371. serialize(parent: any): any;
  91372. /**
  91373. * Internal only called by serialize
  91374. * @hidden
  91375. */
  91376. protected _serialize(serializedAction: any, parent?: any): any;
  91377. /**
  91378. * Internal only
  91379. * @hidden
  91380. */
  91381. static _SerializeValueAsString: (value: any) => string;
  91382. /**
  91383. * Internal only
  91384. * @hidden
  91385. */
  91386. static _GetTargetProperty: (target: Node | Scene) => {
  91387. name: string;
  91388. targetType: string;
  91389. value: string;
  91390. };
  91391. }
  91392. }
  91393. declare module BABYLON {
  91394. /**
  91395. * A Condition applied to an Action
  91396. */
  91397. export class Condition {
  91398. /**
  91399. * Internal only - manager for action
  91400. * @hidden
  91401. */
  91402. _actionManager: ActionManager;
  91403. /**
  91404. * Internal only
  91405. * @hidden
  91406. */
  91407. _evaluationId: number;
  91408. /**
  91409. * Internal only
  91410. * @hidden
  91411. */
  91412. _currentResult: boolean;
  91413. /**
  91414. * Creates a new Condition
  91415. * @param actionManager the manager of the action the condition is applied to
  91416. */
  91417. constructor(actionManager: ActionManager);
  91418. /**
  91419. * Check if the current condition is valid
  91420. * @returns a boolean
  91421. */
  91422. isValid(): boolean;
  91423. /**
  91424. * Internal only
  91425. * @hidden
  91426. */
  91427. _getProperty(propertyPath: string): string;
  91428. /**
  91429. * Internal only
  91430. * @hidden
  91431. */
  91432. _getEffectiveTarget(target: any, propertyPath: string): any;
  91433. /**
  91434. * Serialize placeholder for child classes
  91435. * @returns the serialized object
  91436. */
  91437. serialize(): any;
  91438. /**
  91439. * Internal only
  91440. * @hidden
  91441. */
  91442. protected _serialize(serializedCondition: any): any;
  91443. }
  91444. /**
  91445. * Defines specific conditional operators as extensions of Condition
  91446. */
  91447. export class ValueCondition extends Condition {
  91448. /** path to specify the property of the target the conditional operator uses */
  91449. propertyPath: string;
  91450. /** the value compared by the conditional operator against the current value of the property */
  91451. value: any;
  91452. /** the conditional operator, default ValueCondition.IsEqual */
  91453. operator: number;
  91454. /**
  91455. * Internal only
  91456. * @hidden
  91457. */
  91458. private static _IsEqual;
  91459. /**
  91460. * Internal only
  91461. * @hidden
  91462. */
  91463. private static _IsDifferent;
  91464. /**
  91465. * Internal only
  91466. * @hidden
  91467. */
  91468. private static _IsGreater;
  91469. /**
  91470. * Internal only
  91471. * @hidden
  91472. */
  91473. private static _IsLesser;
  91474. /**
  91475. * returns the number for IsEqual
  91476. */
  91477. static get IsEqual(): number;
  91478. /**
  91479. * Returns the number for IsDifferent
  91480. */
  91481. static get IsDifferent(): number;
  91482. /**
  91483. * Returns the number for IsGreater
  91484. */
  91485. static get IsGreater(): number;
  91486. /**
  91487. * Returns the number for IsLesser
  91488. */
  91489. static get IsLesser(): number;
  91490. /**
  91491. * Internal only The action manager for the condition
  91492. * @hidden
  91493. */
  91494. _actionManager: ActionManager;
  91495. /**
  91496. * Internal only
  91497. * @hidden
  91498. */
  91499. private _target;
  91500. /**
  91501. * Internal only
  91502. * @hidden
  91503. */
  91504. private _effectiveTarget;
  91505. /**
  91506. * Internal only
  91507. * @hidden
  91508. */
  91509. private _property;
  91510. /**
  91511. * Creates a new ValueCondition
  91512. * @param actionManager manager for the action the condition applies to
  91513. * @param target for the action
  91514. * @param propertyPath path to specify the property of the target the conditional operator uses
  91515. * @param value the value compared by the conditional operator against the current value of the property
  91516. * @param operator the conditional operator, default ValueCondition.IsEqual
  91517. */
  91518. constructor(actionManager: ActionManager, target: any,
  91519. /** path to specify the property of the target the conditional operator uses */
  91520. propertyPath: string,
  91521. /** the value compared by the conditional operator against the current value of the property */
  91522. value: any,
  91523. /** the conditional operator, default ValueCondition.IsEqual */
  91524. operator?: number);
  91525. /**
  91526. * Compares the given value with the property value for the specified conditional operator
  91527. * @returns the result of the comparison
  91528. */
  91529. isValid(): boolean;
  91530. /**
  91531. * Serialize the ValueCondition into a JSON compatible object
  91532. * @returns serialization object
  91533. */
  91534. serialize(): any;
  91535. /**
  91536. * Gets the name of the conditional operator for the ValueCondition
  91537. * @param operator the conditional operator
  91538. * @returns the name
  91539. */
  91540. static GetOperatorName(operator: number): string;
  91541. }
  91542. /**
  91543. * Defines a predicate condition as an extension of Condition
  91544. */
  91545. export class PredicateCondition extends Condition {
  91546. /** defines the predicate function used to validate the condition */
  91547. predicate: () => boolean;
  91548. /**
  91549. * Internal only - manager for action
  91550. * @hidden
  91551. */
  91552. _actionManager: ActionManager;
  91553. /**
  91554. * Creates a new PredicateCondition
  91555. * @param actionManager manager for the action the condition applies to
  91556. * @param predicate defines the predicate function used to validate the condition
  91557. */
  91558. constructor(actionManager: ActionManager,
  91559. /** defines the predicate function used to validate the condition */
  91560. predicate: () => boolean);
  91561. /**
  91562. * @returns the validity of the predicate condition
  91563. */
  91564. isValid(): boolean;
  91565. }
  91566. /**
  91567. * Defines a state condition as an extension of Condition
  91568. */
  91569. export class StateCondition extends Condition {
  91570. /** Value to compare with target state */
  91571. value: string;
  91572. /**
  91573. * Internal only - manager for action
  91574. * @hidden
  91575. */
  91576. _actionManager: ActionManager;
  91577. /**
  91578. * Internal only
  91579. * @hidden
  91580. */
  91581. private _target;
  91582. /**
  91583. * Creates a new StateCondition
  91584. * @param actionManager manager for the action the condition applies to
  91585. * @param target of the condition
  91586. * @param value to compare with target state
  91587. */
  91588. constructor(actionManager: ActionManager, target: any,
  91589. /** Value to compare with target state */
  91590. value: string);
  91591. /**
  91592. * Gets a boolean indicating if the current condition is met
  91593. * @returns the validity of the state
  91594. */
  91595. isValid(): boolean;
  91596. /**
  91597. * Serialize the StateCondition into a JSON compatible object
  91598. * @returns serialization object
  91599. */
  91600. serialize(): any;
  91601. }
  91602. }
  91603. declare module BABYLON {
  91604. /**
  91605. * This defines an action responsible to toggle a boolean once triggered.
  91606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91607. */
  91608. export class SwitchBooleanAction extends Action {
  91609. /**
  91610. * The path to the boolean property in the target object
  91611. */
  91612. propertyPath: string;
  91613. private _target;
  91614. private _effectiveTarget;
  91615. private _property;
  91616. /**
  91617. * Instantiate the action
  91618. * @param triggerOptions defines the trigger options
  91619. * @param target defines the object containing the boolean
  91620. * @param propertyPath defines the path to the boolean property in the target object
  91621. * @param condition defines the trigger related conditions
  91622. */
  91623. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91624. /** @hidden */
  91625. _prepare(): void;
  91626. /**
  91627. * Execute the action toggle the boolean value.
  91628. */
  91629. execute(): void;
  91630. /**
  91631. * Serializes the actions and its related information.
  91632. * @param parent defines the object to serialize in
  91633. * @returns the serialized object
  91634. */
  91635. serialize(parent: any): any;
  91636. }
  91637. /**
  91638. * This defines an action responsible to set a the state field of the target
  91639. * to a desired value once triggered.
  91640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91641. */
  91642. export class SetStateAction extends Action {
  91643. /**
  91644. * The value to store in the state field.
  91645. */
  91646. value: string;
  91647. private _target;
  91648. /**
  91649. * Instantiate the action
  91650. * @param triggerOptions defines the trigger options
  91651. * @param target defines the object containing the state property
  91652. * @param value defines the value to store in the state field
  91653. * @param condition defines the trigger related conditions
  91654. */
  91655. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91656. /**
  91657. * Execute the action and store the value on the target state property.
  91658. */
  91659. execute(): void;
  91660. /**
  91661. * Serializes the actions and its related information.
  91662. * @param parent defines the object to serialize in
  91663. * @returns the serialized object
  91664. */
  91665. serialize(parent: any): any;
  91666. }
  91667. /**
  91668. * This defines an action responsible to set a property of the target
  91669. * to a desired value once triggered.
  91670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91671. */
  91672. export class SetValueAction extends Action {
  91673. /**
  91674. * The path of the property to set in the target.
  91675. */
  91676. propertyPath: string;
  91677. /**
  91678. * The value to set in the property
  91679. */
  91680. value: any;
  91681. private _target;
  91682. private _effectiveTarget;
  91683. private _property;
  91684. /**
  91685. * Instantiate the action
  91686. * @param triggerOptions defines the trigger options
  91687. * @param target defines the object containing the property
  91688. * @param propertyPath defines the path of the property to set in the target
  91689. * @param value defines the value to set in the property
  91690. * @param condition defines the trigger related conditions
  91691. */
  91692. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91693. /** @hidden */
  91694. _prepare(): void;
  91695. /**
  91696. * Execute the action and set the targetted property to the desired value.
  91697. */
  91698. execute(): void;
  91699. /**
  91700. * Serializes the actions and its related information.
  91701. * @param parent defines the object to serialize in
  91702. * @returns the serialized object
  91703. */
  91704. serialize(parent: any): any;
  91705. }
  91706. /**
  91707. * This defines an action responsible to increment the target value
  91708. * to a desired value once triggered.
  91709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91710. */
  91711. export class IncrementValueAction extends Action {
  91712. /**
  91713. * The path of the property to increment in the target.
  91714. */
  91715. propertyPath: string;
  91716. /**
  91717. * The value we should increment the property by.
  91718. */
  91719. value: any;
  91720. private _target;
  91721. private _effectiveTarget;
  91722. private _property;
  91723. /**
  91724. * Instantiate the action
  91725. * @param triggerOptions defines the trigger options
  91726. * @param target defines the object containing the property
  91727. * @param propertyPath defines the path of the property to increment in the target
  91728. * @param value defines the value value we should increment the property by
  91729. * @param condition defines the trigger related conditions
  91730. */
  91731. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91732. /** @hidden */
  91733. _prepare(): void;
  91734. /**
  91735. * Execute the action and increment the target of the value amount.
  91736. */
  91737. execute(): void;
  91738. /**
  91739. * Serializes the actions and its related information.
  91740. * @param parent defines the object to serialize in
  91741. * @returns the serialized object
  91742. */
  91743. serialize(parent: any): any;
  91744. }
  91745. /**
  91746. * This defines an action responsible to start an animation once triggered.
  91747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91748. */
  91749. export class PlayAnimationAction extends Action {
  91750. /**
  91751. * Where the animation should start (animation frame)
  91752. */
  91753. from: number;
  91754. /**
  91755. * Where the animation should stop (animation frame)
  91756. */
  91757. to: number;
  91758. /**
  91759. * Define if the animation should loop or stop after the first play.
  91760. */
  91761. loop?: boolean;
  91762. private _target;
  91763. /**
  91764. * Instantiate the action
  91765. * @param triggerOptions defines the trigger options
  91766. * @param target defines the target animation or animation name
  91767. * @param from defines from where the animation should start (animation frame)
  91768. * @param end defines where the animation should stop (animation frame)
  91769. * @param loop defines if the animation should loop or stop after the first play
  91770. * @param condition defines the trigger related conditions
  91771. */
  91772. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91773. /** @hidden */
  91774. _prepare(): void;
  91775. /**
  91776. * Execute the action and play the animation.
  91777. */
  91778. execute(): void;
  91779. /**
  91780. * Serializes the actions and its related information.
  91781. * @param parent defines the object to serialize in
  91782. * @returns the serialized object
  91783. */
  91784. serialize(parent: any): any;
  91785. }
  91786. /**
  91787. * This defines an action responsible to stop an animation once triggered.
  91788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91789. */
  91790. export class StopAnimationAction extends Action {
  91791. private _target;
  91792. /**
  91793. * Instantiate the action
  91794. * @param triggerOptions defines the trigger options
  91795. * @param target defines the target animation or animation name
  91796. * @param condition defines the trigger related conditions
  91797. */
  91798. constructor(triggerOptions: any, target: any, condition?: Condition);
  91799. /** @hidden */
  91800. _prepare(): void;
  91801. /**
  91802. * Execute the action and stop the animation.
  91803. */
  91804. execute(): void;
  91805. /**
  91806. * Serializes the actions and its related information.
  91807. * @param parent defines the object to serialize in
  91808. * @returns the serialized object
  91809. */
  91810. serialize(parent: any): any;
  91811. }
  91812. /**
  91813. * This defines an action responsible that does nothing once triggered.
  91814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91815. */
  91816. export class DoNothingAction extends Action {
  91817. /**
  91818. * Instantiate the action
  91819. * @param triggerOptions defines the trigger options
  91820. * @param condition defines the trigger related conditions
  91821. */
  91822. constructor(triggerOptions?: any, condition?: Condition);
  91823. /**
  91824. * Execute the action and do nothing.
  91825. */
  91826. execute(): void;
  91827. /**
  91828. * Serializes the actions and its related information.
  91829. * @param parent defines the object to serialize in
  91830. * @returns the serialized object
  91831. */
  91832. serialize(parent: any): any;
  91833. }
  91834. /**
  91835. * This defines an action responsible to trigger several actions once triggered.
  91836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91837. */
  91838. export class CombineAction extends Action {
  91839. /**
  91840. * The list of aggregated animations to run.
  91841. */
  91842. children: Action[];
  91843. /**
  91844. * Instantiate the action
  91845. * @param triggerOptions defines the trigger options
  91846. * @param children defines the list of aggregated animations to run
  91847. * @param condition defines the trigger related conditions
  91848. */
  91849. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91850. /** @hidden */
  91851. _prepare(): void;
  91852. /**
  91853. * Execute the action and executes all the aggregated actions.
  91854. */
  91855. execute(evt: ActionEvent): void;
  91856. /**
  91857. * Serializes the actions and its related information.
  91858. * @param parent defines the object to serialize in
  91859. * @returns the serialized object
  91860. */
  91861. serialize(parent: any): any;
  91862. }
  91863. /**
  91864. * This defines an action responsible to run code (external event) once triggered.
  91865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91866. */
  91867. export class ExecuteCodeAction extends Action {
  91868. /**
  91869. * The callback function to run.
  91870. */
  91871. func: (evt: ActionEvent) => void;
  91872. /**
  91873. * Instantiate the action
  91874. * @param triggerOptions defines the trigger options
  91875. * @param func defines the callback function to run
  91876. * @param condition defines the trigger related conditions
  91877. */
  91878. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91879. /**
  91880. * Execute the action and run the attached code.
  91881. */
  91882. execute(evt: ActionEvent): void;
  91883. }
  91884. /**
  91885. * This defines an action responsible to set the parent property of the target once triggered.
  91886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91887. */
  91888. export class SetParentAction extends Action {
  91889. private _parent;
  91890. private _target;
  91891. /**
  91892. * Instantiate the action
  91893. * @param triggerOptions defines the trigger options
  91894. * @param target defines the target containing the parent property
  91895. * @param parent defines from where the animation should start (animation frame)
  91896. * @param condition defines the trigger related conditions
  91897. */
  91898. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91899. /** @hidden */
  91900. _prepare(): void;
  91901. /**
  91902. * Execute the action and set the parent property.
  91903. */
  91904. execute(): void;
  91905. /**
  91906. * Serializes the actions and its related information.
  91907. * @param parent defines the object to serialize in
  91908. * @returns the serialized object
  91909. */
  91910. serialize(parent: any): any;
  91911. }
  91912. }
  91913. declare module BABYLON {
  91914. /**
  91915. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91916. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91918. */
  91919. export class ActionManager extends AbstractActionManager {
  91920. /**
  91921. * Nothing
  91922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91923. */
  91924. static readonly NothingTrigger: number;
  91925. /**
  91926. * On pick
  91927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91928. */
  91929. static readonly OnPickTrigger: number;
  91930. /**
  91931. * On left pick
  91932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91933. */
  91934. static readonly OnLeftPickTrigger: number;
  91935. /**
  91936. * On right pick
  91937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91938. */
  91939. static readonly OnRightPickTrigger: number;
  91940. /**
  91941. * On center pick
  91942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91943. */
  91944. static readonly OnCenterPickTrigger: number;
  91945. /**
  91946. * On pick down
  91947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91948. */
  91949. static readonly OnPickDownTrigger: number;
  91950. /**
  91951. * On double pick
  91952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91953. */
  91954. static readonly OnDoublePickTrigger: number;
  91955. /**
  91956. * On pick up
  91957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91958. */
  91959. static readonly OnPickUpTrigger: number;
  91960. /**
  91961. * On pick out.
  91962. * This trigger will only be raised if you also declared a OnPickDown
  91963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91964. */
  91965. static readonly OnPickOutTrigger: number;
  91966. /**
  91967. * On long press
  91968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91969. */
  91970. static readonly OnLongPressTrigger: number;
  91971. /**
  91972. * On pointer over
  91973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91974. */
  91975. static readonly OnPointerOverTrigger: number;
  91976. /**
  91977. * On pointer out
  91978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91979. */
  91980. static readonly OnPointerOutTrigger: number;
  91981. /**
  91982. * On every frame
  91983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91984. */
  91985. static readonly OnEveryFrameTrigger: number;
  91986. /**
  91987. * On intersection enter
  91988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91989. */
  91990. static readonly OnIntersectionEnterTrigger: number;
  91991. /**
  91992. * On intersection exit
  91993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91994. */
  91995. static readonly OnIntersectionExitTrigger: number;
  91996. /**
  91997. * On key down
  91998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91999. */
  92000. static readonly OnKeyDownTrigger: number;
  92001. /**
  92002. * On key up
  92003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92004. */
  92005. static readonly OnKeyUpTrigger: number;
  92006. private _scene;
  92007. /**
  92008. * Creates a new action manager
  92009. * @param scene defines the hosting scene
  92010. */
  92011. constructor(scene: Scene);
  92012. /**
  92013. * Releases all associated resources
  92014. */
  92015. dispose(): void;
  92016. /**
  92017. * Gets hosting scene
  92018. * @returns the hosting scene
  92019. */
  92020. getScene(): Scene;
  92021. /**
  92022. * Does this action manager handles actions of any of the given triggers
  92023. * @param triggers defines the triggers to be tested
  92024. * @return a boolean indicating whether one (or more) of the triggers is handled
  92025. */
  92026. hasSpecificTriggers(triggers: number[]): boolean;
  92027. /**
  92028. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92029. * speed.
  92030. * @param triggerA defines the trigger to be tested
  92031. * @param triggerB defines the trigger to be tested
  92032. * @return a boolean indicating whether one (or more) of the triggers is handled
  92033. */
  92034. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92035. /**
  92036. * Does this action manager handles actions of a given trigger
  92037. * @param trigger defines the trigger to be tested
  92038. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92039. * @return whether the trigger is handled
  92040. */
  92041. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92042. /**
  92043. * Does this action manager has pointer triggers
  92044. */
  92045. get hasPointerTriggers(): boolean;
  92046. /**
  92047. * Does this action manager has pick triggers
  92048. */
  92049. get hasPickTriggers(): boolean;
  92050. /**
  92051. * Registers an action to this action manager
  92052. * @param action defines the action to be registered
  92053. * @return the action amended (prepared) after registration
  92054. */
  92055. registerAction(action: IAction): Nullable<IAction>;
  92056. /**
  92057. * Unregisters an action to this action manager
  92058. * @param action defines the action to be unregistered
  92059. * @return a boolean indicating whether the action has been unregistered
  92060. */
  92061. unregisterAction(action: IAction): Boolean;
  92062. /**
  92063. * Process a specific trigger
  92064. * @param trigger defines the trigger to process
  92065. * @param evt defines the event details to be processed
  92066. */
  92067. processTrigger(trigger: number, evt?: IActionEvent): void;
  92068. /** @hidden */
  92069. _getEffectiveTarget(target: any, propertyPath: string): any;
  92070. /** @hidden */
  92071. _getProperty(propertyPath: string): string;
  92072. /**
  92073. * Serialize this manager to a JSON object
  92074. * @param name defines the property name to store this manager
  92075. * @returns a JSON representation of this manager
  92076. */
  92077. serialize(name: string): any;
  92078. /**
  92079. * Creates a new ActionManager from a JSON data
  92080. * @param parsedActions defines the JSON data to read from
  92081. * @param object defines the hosting mesh
  92082. * @param scene defines the hosting scene
  92083. */
  92084. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  92085. /**
  92086. * Get a trigger name by index
  92087. * @param trigger defines the trigger index
  92088. * @returns a trigger name
  92089. */
  92090. static GetTriggerName(trigger: number): string;
  92091. }
  92092. }
  92093. declare module BABYLON {
  92094. /**
  92095. * Class used to represent a sprite
  92096. * @see http://doc.babylonjs.com/babylon101/sprites
  92097. */
  92098. export class Sprite {
  92099. /** defines the name */
  92100. name: string;
  92101. /** Gets or sets the current world position */
  92102. position: Vector3;
  92103. /** Gets or sets the main color */
  92104. color: Color4;
  92105. /** Gets or sets the width */
  92106. width: number;
  92107. /** Gets or sets the height */
  92108. height: number;
  92109. /** Gets or sets rotation angle */
  92110. angle: number;
  92111. /** Gets or sets the cell index in the sprite sheet */
  92112. cellIndex: number;
  92113. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  92114. cellRef: string;
  92115. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  92116. invertU: number;
  92117. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  92118. invertV: number;
  92119. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  92120. disposeWhenFinishedAnimating: boolean;
  92121. /** Gets the list of attached animations */
  92122. animations: Animation[];
  92123. /** Gets or sets a boolean indicating if the sprite can be picked */
  92124. isPickable: boolean;
  92125. /**
  92126. * Gets or sets the associated action manager
  92127. */
  92128. actionManager: Nullable<ActionManager>;
  92129. private _animationStarted;
  92130. private _loopAnimation;
  92131. private _fromIndex;
  92132. private _toIndex;
  92133. private _delay;
  92134. private _direction;
  92135. private _manager;
  92136. private _time;
  92137. private _onAnimationEnd;
  92138. /**
  92139. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  92140. */
  92141. isVisible: boolean;
  92142. /**
  92143. * Gets or sets the sprite size
  92144. */
  92145. get size(): number;
  92146. set size(value: number);
  92147. /**
  92148. * Creates a new Sprite
  92149. * @param name defines the name
  92150. * @param manager defines the manager
  92151. */
  92152. constructor(
  92153. /** defines the name */
  92154. name: string, manager: ISpriteManager);
  92155. /**
  92156. * Starts an animation
  92157. * @param from defines the initial key
  92158. * @param to defines the end key
  92159. * @param loop defines if the animation must loop
  92160. * @param delay defines the start delay (in ms)
  92161. * @param onAnimationEnd defines a callback to call when animation ends
  92162. */
  92163. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  92164. /** Stops current animation (if any) */
  92165. stopAnimation(): void;
  92166. /** @hidden */
  92167. _animate(deltaTime: number): void;
  92168. /** Release associated resources */
  92169. dispose(): void;
  92170. }
  92171. }
  92172. declare module BABYLON {
  92173. /**
  92174. * Information about the result of picking within a scene
  92175. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  92176. */
  92177. export class PickingInfo {
  92178. /** @hidden */
  92179. _pickingUnavailable: boolean;
  92180. /**
  92181. * If the pick collided with an object
  92182. */
  92183. hit: boolean;
  92184. /**
  92185. * Distance away where the pick collided
  92186. */
  92187. distance: number;
  92188. /**
  92189. * The location of pick collision
  92190. */
  92191. pickedPoint: Nullable<Vector3>;
  92192. /**
  92193. * The mesh corresponding the the pick collision
  92194. */
  92195. pickedMesh: Nullable<AbstractMesh>;
  92196. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  92197. bu: number;
  92198. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  92199. bv: number;
  92200. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  92201. faceId: number;
  92202. /** Id of the the submesh that was picked */
  92203. subMeshId: number;
  92204. /** If a sprite was picked, this will be the sprite the pick collided with */
  92205. pickedSprite: Nullable<Sprite>;
  92206. /**
  92207. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  92208. */
  92209. originMesh: Nullable<AbstractMesh>;
  92210. /**
  92211. * The ray that was used to perform the picking.
  92212. */
  92213. ray: Nullable<Ray>;
  92214. /**
  92215. * Gets the normal correspodning to the face the pick collided with
  92216. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  92217. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  92218. * @returns The normal correspodning to the face the pick collided with
  92219. */
  92220. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  92221. /**
  92222. * Gets the texture coordinates of where the pick occured
  92223. * @returns the vector containing the coordnates of the texture
  92224. */
  92225. getTextureCoordinates(): Nullable<Vector2>;
  92226. }
  92227. }
  92228. declare module BABYLON {
  92229. /**
  92230. * Gather the list of pointer event types as constants.
  92231. */
  92232. export class PointerEventTypes {
  92233. /**
  92234. * 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.
  92235. */
  92236. static readonly POINTERDOWN: number;
  92237. /**
  92238. * The pointerup event is fired when a pointer is no longer active.
  92239. */
  92240. static readonly POINTERUP: number;
  92241. /**
  92242. * The pointermove event is fired when a pointer changes coordinates.
  92243. */
  92244. static readonly POINTERMOVE: number;
  92245. /**
  92246. * The pointerwheel event is fired when a mouse wheel has been rotated.
  92247. */
  92248. static readonly POINTERWHEEL: number;
  92249. /**
  92250. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  92251. */
  92252. static readonly POINTERPICK: number;
  92253. /**
  92254. * The pointertap event is fired when a the object has been touched and released without drag.
  92255. */
  92256. static readonly POINTERTAP: number;
  92257. /**
  92258. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  92259. */
  92260. static readonly POINTERDOUBLETAP: number;
  92261. }
  92262. /**
  92263. * Base class of pointer info types.
  92264. */
  92265. export class PointerInfoBase {
  92266. /**
  92267. * Defines the type of event (PointerEventTypes)
  92268. */
  92269. type: number;
  92270. /**
  92271. * Defines the related dom event
  92272. */
  92273. event: PointerEvent | MouseWheelEvent;
  92274. /**
  92275. * Instantiates the base class of pointers info.
  92276. * @param type Defines the type of event (PointerEventTypes)
  92277. * @param event Defines the related dom event
  92278. */
  92279. constructor(
  92280. /**
  92281. * Defines the type of event (PointerEventTypes)
  92282. */
  92283. type: number,
  92284. /**
  92285. * Defines the related dom event
  92286. */
  92287. event: PointerEvent | MouseWheelEvent);
  92288. }
  92289. /**
  92290. * This class is used to store pointer related info for the onPrePointerObservable event.
  92291. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  92292. */
  92293. export class PointerInfoPre extends PointerInfoBase {
  92294. /**
  92295. * Ray from a pointer if availible (eg. 6dof controller)
  92296. */
  92297. ray: Nullable<Ray>;
  92298. /**
  92299. * Defines the local position of the pointer on the canvas.
  92300. */
  92301. localPosition: Vector2;
  92302. /**
  92303. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  92304. */
  92305. skipOnPointerObservable: boolean;
  92306. /**
  92307. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  92308. * @param type Defines the type of event (PointerEventTypes)
  92309. * @param event Defines the related dom event
  92310. * @param localX Defines the local x coordinates of the pointer when the event occured
  92311. * @param localY Defines the local y coordinates of the pointer when the event occured
  92312. */
  92313. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  92314. }
  92315. /**
  92316. * This type contains all the data related to a pointer event in Babylon.js.
  92317. * 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.
  92318. */
  92319. export class PointerInfo extends PointerInfoBase {
  92320. /**
  92321. * Defines the picking info associated to the info (if any)\
  92322. */
  92323. pickInfo: Nullable<PickingInfo>;
  92324. /**
  92325. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  92326. * @param type Defines the type of event (PointerEventTypes)
  92327. * @param event Defines the related dom event
  92328. * @param pickInfo Defines the picking info associated to the info (if any)\
  92329. */
  92330. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  92331. /**
  92332. * Defines the picking info associated to the info (if any)\
  92333. */
  92334. pickInfo: Nullable<PickingInfo>);
  92335. }
  92336. /**
  92337. * Data relating to a touch event on the screen.
  92338. */
  92339. export interface PointerTouch {
  92340. /**
  92341. * X coordinate of touch.
  92342. */
  92343. x: number;
  92344. /**
  92345. * Y coordinate of touch.
  92346. */
  92347. y: number;
  92348. /**
  92349. * Id of touch. Unique for each finger.
  92350. */
  92351. pointerId: number;
  92352. /**
  92353. * Event type passed from DOM.
  92354. */
  92355. type: any;
  92356. }
  92357. }
  92358. declare module BABYLON {
  92359. /**
  92360. * Manage the mouse inputs to control the movement of a free camera.
  92361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92362. */
  92363. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  92364. /**
  92365. * Define if touch is enabled in the mouse input
  92366. */
  92367. touchEnabled: boolean;
  92368. /**
  92369. * Defines the camera the input is attached to.
  92370. */
  92371. camera: FreeCamera;
  92372. /**
  92373. * Defines the buttons associated with the input to handle camera move.
  92374. */
  92375. buttons: number[];
  92376. /**
  92377. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  92378. */
  92379. angularSensibility: number;
  92380. private _pointerInput;
  92381. private _onMouseMove;
  92382. private _observer;
  92383. private previousPosition;
  92384. /**
  92385. * Observable for when a pointer move event occurs containing the move offset
  92386. */
  92387. onPointerMovedObservable: Observable<{
  92388. offsetX: number;
  92389. offsetY: number;
  92390. }>;
  92391. /**
  92392. * @hidden
  92393. * If the camera should be rotated automatically based on pointer movement
  92394. */
  92395. _allowCameraRotation: boolean;
  92396. /**
  92397. * Manage the mouse inputs to control the movement of a free camera.
  92398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92399. * @param touchEnabled Defines if touch is enabled or not
  92400. */
  92401. constructor(
  92402. /**
  92403. * Define if touch is enabled in the mouse input
  92404. */
  92405. touchEnabled?: boolean);
  92406. /**
  92407. * Attach the input controls to a specific dom element to get the input from.
  92408. * @param element Defines the element the controls should be listened from
  92409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92410. */
  92411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92412. /**
  92413. * Called on JS contextmenu event.
  92414. * Override this method to provide functionality.
  92415. */
  92416. protected onContextMenu(evt: PointerEvent): void;
  92417. /**
  92418. * Detach the current controls from the specified dom element.
  92419. * @param element Defines the element to stop listening the inputs from
  92420. */
  92421. detachControl(element: Nullable<HTMLElement>): void;
  92422. /**
  92423. * Gets the class name of the current intput.
  92424. * @returns the class name
  92425. */
  92426. getClassName(): string;
  92427. /**
  92428. * Get the friendly name associated with the input class.
  92429. * @returns the input friendly name
  92430. */
  92431. getSimpleName(): string;
  92432. }
  92433. }
  92434. declare module BABYLON {
  92435. /**
  92436. * Manage the touch inputs to control the movement of a free camera.
  92437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92438. */
  92439. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  92440. /**
  92441. * Defines the camera the input is attached to.
  92442. */
  92443. camera: FreeCamera;
  92444. /**
  92445. * Defines the touch sensibility for rotation.
  92446. * The higher the faster.
  92447. */
  92448. touchAngularSensibility: number;
  92449. /**
  92450. * Defines the touch sensibility for move.
  92451. * The higher the faster.
  92452. */
  92453. touchMoveSensibility: number;
  92454. private _offsetX;
  92455. private _offsetY;
  92456. private _pointerPressed;
  92457. private _pointerInput;
  92458. private _observer;
  92459. private _onLostFocus;
  92460. /**
  92461. * Attach the input controls to a specific dom element to get the input from.
  92462. * @param element Defines the element the controls should be listened from
  92463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92464. */
  92465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92466. /**
  92467. * Detach the current controls from the specified dom element.
  92468. * @param element Defines the element to stop listening the inputs from
  92469. */
  92470. detachControl(element: Nullable<HTMLElement>): void;
  92471. /**
  92472. * Update the current camera state depending on the inputs that have been used this frame.
  92473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92474. */
  92475. checkInputs(): void;
  92476. /**
  92477. * Gets the class name of the current intput.
  92478. * @returns the class name
  92479. */
  92480. getClassName(): string;
  92481. /**
  92482. * Get the friendly name associated with the input class.
  92483. * @returns the input friendly name
  92484. */
  92485. getSimpleName(): string;
  92486. }
  92487. }
  92488. declare module BABYLON {
  92489. /**
  92490. * Default Inputs manager for the FreeCamera.
  92491. * It groups all the default supported inputs for ease of use.
  92492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92493. */
  92494. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  92495. /**
  92496. * @hidden
  92497. */
  92498. _mouseInput: Nullable<FreeCameraMouseInput>;
  92499. /**
  92500. * Instantiates a new FreeCameraInputsManager.
  92501. * @param camera Defines the camera the inputs belong to
  92502. */
  92503. constructor(camera: FreeCamera);
  92504. /**
  92505. * Add keyboard input support to the input manager.
  92506. * @returns the current input manager
  92507. */
  92508. addKeyboard(): FreeCameraInputsManager;
  92509. /**
  92510. * Add mouse input support to the input manager.
  92511. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  92512. * @returns the current input manager
  92513. */
  92514. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  92515. /**
  92516. * Removes the mouse input support from the manager
  92517. * @returns the current input manager
  92518. */
  92519. removeMouse(): FreeCameraInputsManager;
  92520. /**
  92521. * Add touch input support to the input manager.
  92522. * @returns the current input manager
  92523. */
  92524. addTouch(): FreeCameraInputsManager;
  92525. /**
  92526. * Remove all attached input methods from a camera
  92527. */
  92528. clear(): void;
  92529. }
  92530. }
  92531. declare module BABYLON {
  92532. /**
  92533. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92534. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  92535. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92536. */
  92537. export class FreeCamera extends TargetCamera {
  92538. /**
  92539. * Define the collision ellipsoid of the camera.
  92540. * This is helpful to simulate a camera body like the player body around the camera
  92541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92542. */
  92543. ellipsoid: Vector3;
  92544. /**
  92545. * Define an offset for the position of the ellipsoid around the camera.
  92546. * This can be helpful to determine the center of the body near the gravity center of the body
  92547. * instead of its head.
  92548. */
  92549. ellipsoidOffset: Vector3;
  92550. /**
  92551. * Enable or disable collisions of the camera with the rest of the scene objects.
  92552. */
  92553. checkCollisions: boolean;
  92554. /**
  92555. * Enable or disable gravity on the camera.
  92556. */
  92557. applyGravity: boolean;
  92558. /**
  92559. * Define the input manager associated to the camera.
  92560. */
  92561. inputs: FreeCameraInputsManager;
  92562. /**
  92563. * Gets the input sensibility for a mouse input. (default is 2000.0)
  92564. * Higher values reduce sensitivity.
  92565. */
  92566. get angularSensibility(): number;
  92567. /**
  92568. * Sets the input sensibility for a mouse input. (default is 2000.0)
  92569. * Higher values reduce sensitivity.
  92570. */
  92571. set angularSensibility(value: number);
  92572. /**
  92573. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  92574. */
  92575. get keysUp(): number[];
  92576. set keysUp(value: number[]);
  92577. /**
  92578. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  92579. */
  92580. get keysUpward(): number[];
  92581. set keysUpward(value: number[]);
  92582. /**
  92583. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  92584. */
  92585. get keysDown(): number[];
  92586. set keysDown(value: number[]);
  92587. /**
  92588. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  92589. */
  92590. get keysDownward(): number[];
  92591. set keysDownward(value: number[]);
  92592. /**
  92593. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  92594. */
  92595. get keysLeft(): number[];
  92596. set keysLeft(value: number[]);
  92597. /**
  92598. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  92599. */
  92600. get keysRight(): number[];
  92601. set keysRight(value: number[]);
  92602. /**
  92603. * Event raised when the camera collide with a mesh in the scene.
  92604. */
  92605. onCollide: (collidedMesh: AbstractMesh) => void;
  92606. private _collider;
  92607. private _needMoveForGravity;
  92608. private _oldPosition;
  92609. private _diffPosition;
  92610. private _newPosition;
  92611. /** @hidden */
  92612. _localDirection: Vector3;
  92613. /** @hidden */
  92614. _transformedDirection: Vector3;
  92615. /**
  92616. * Instantiates a Free Camera.
  92617. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92618. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  92619. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92620. * @param name Define the name of the camera in the scene
  92621. * @param position Define the start position of the camera in the scene
  92622. * @param scene Define the scene the camera belongs to
  92623. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92624. */
  92625. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92626. /**
  92627. * Attached controls to the current camera.
  92628. * @param element Defines the element the controls should be listened from
  92629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92630. */
  92631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92632. /**
  92633. * Detach the current controls from the camera.
  92634. * The camera will stop reacting to inputs.
  92635. * @param element Defines the element to stop listening the inputs from
  92636. */
  92637. detachControl(element: HTMLElement): void;
  92638. private _collisionMask;
  92639. /**
  92640. * Define a collision mask to limit the list of object the camera can collide with
  92641. */
  92642. get collisionMask(): number;
  92643. set collisionMask(mask: number);
  92644. /** @hidden */
  92645. _collideWithWorld(displacement: Vector3): void;
  92646. private _onCollisionPositionChange;
  92647. /** @hidden */
  92648. _checkInputs(): void;
  92649. /** @hidden */
  92650. _decideIfNeedsToMove(): boolean;
  92651. /** @hidden */
  92652. _updatePosition(): void;
  92653. /**
  92654. * Destroy the camera and release the current resources hold by it.
  92655. */
  92656. dispose(): void;
  92657. /**
  92658. * Gets the current object class name.
  92659. * @return the class name
  92660. */
  92661. getClassName(): string;
  92662. }
  92663. }
  92664. declare module BABYLON {
  92665. /**
  92666. * Represents a gamepad control stick position
  92667. */
  92668. export class StickValues {
  92669. /**
  92670. * The x component of the control stick
  92671. */
  92672. x: number;
  92673. /**
  92674. * The y component of the control stick
  92675. */
  92676. y: number;
  92677. /**
  92678. * Initializes the gamepad x and y control stick values
  92679. * @param x The x component of the gamepad control stick value
  92680. * @param y The y component of the gamepad control stick value
  92681. */
  92682. constructor(
  92683. /**
  92684. * The x component of the control stick
  92685. */
  92686. x: number,
  92687. /**
  92688. * The y component of the control stick
  92689. */
  92690. y: number);
  92691. }
  92692. /**
  92693. * An interface which manages callbacks for gamepad button changes
  92694. */
  92695. export interface GamepadButtonChanges {
  92696. /**
  92697. * Called when a gamepad has been changed
  92698. */
  92699. changed: boolean;
  92700. /**
  92701. * Called when a gamepad press event has been triggered
  92702. */
  92703. pressChanged: boolean;
  92704. /**
  92705. * Called when a touch event has been triggered
  92706. */
  92707. touchChanged: boolean;
  92708. /**
  92709. * Called when a value has changed
  92710. */
  92711. valueChanged: boolean;
  92712. }
  92713. /**
  92714. * Represents a gamepad
  92715. */
  92716. export class Gamepad {
  92717. /**
  92718. * The id of the gamepad
  92719. */
  92720. id: string;
  92721. /**
  92722. * The index of the gamepad
  92723. */
  92724. index: number;
  92725. /**
  92726. * The browser gamepad
  92727. */
  92728. browserGamepad: any;
  92729. /**
  92730. * Specifies what type of gamepad this represents
  92731. */
  92732. type: number;
  92733. private _leftStick;
  92734. private _rightStick;
  92735. /** @hidden */
  92736. _isConnected: boolean;
  92737. private _leftStickAxisX;
  92738. private _leftStickAxisY;
  92739. private _rightStickAxisX;
  92740. private _rightStickAxisY;
  92741. /**
  92742. * Triggered when the left control stick has been changed
  92743. */
  92744. private _onleftstickchanged;
  92745. /**
  92746. * Triggered when the right control stick has been changed
  92747. */
  92748. private _onrightstickchanged;
  92749. /**
  92750. * Represents a gamepad controller
  92751. */
  92752. static GAMEPAD: number;
  92753. /**
  92754. * Represents a generic controller
  92755. */
  92756. static GENERIC: number;
  92757. /**
  92758. * Represents an XBox controller
  92759. */
  92760. static XBOX: number;
  92761. /**
  92762. * Represents a pose-enabled controller
  92763. */
  92764. static POSE_ENABLED: number;
  92765. /**
  92766. * Represents an Dual Shock controller
  92767. */
  92768. static DUALSHOCK: number;
  92769. /**
  92770. * Specifies whether the left control stick should be Y-inverted
  92771. */
  92772. protected _invertLeftStickY: boolean;
  92773. /**
  92774. * Specifies if the gamepad has been connected
  92775. */
  92776. get isConnected(): boolean;
  92777. /**
  92778. * Initializes the gamepad
  92779. * @param id The id of the gamepad
  92780. * @param index The index of the gamepad
  92781. * @param browserGamepad The browser gamepad
  92782. * @param leftStickX The x component of the left joystick
  92783. * @param leftStickY The y component of the left joystick
  92784. * @param rightStickX The x component of the right joystick
  92785. * @param rightStickY The y component of the right joystick
  92786. */
  92787. constructor(
  92788. /**
  92789. * The id of the gamepad
  92790. */
  92791. id: string,
  92792. /**
  92793. * The index of the gamepad
  92794. */
  92795. index: number,
  92796. /**
  92797. * The browser gamepad
  92798. */
  92799. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  92800. /**
  92801. * Callback triggered when the left joystick has changed
  92802. * @param callback
  92803. */
  92804. onleftstickchanged(callback: (values: StickValues) => void): void;
  92805. /**
  92806. * Callback triggered when the right joystick has changed
  92807. * @param callback
  92808. */
  92809. onrightstickchanged(callback: (values: StickValues) => void): void;
  92810. /**
  92811. * Gets the left joystick
  92812. */
  92813. get leftStick(): StickValues;
  92814. /**
  92815. * Sets the left joystick values
  92816. */
  92817. set leftStick(newValues: StickValues);
  92818. /**
  92819. * Gets the right joystick
  92820. */
  92821. get rightStick(): StickValues;
  92822. /**
  92823. * Sets the right joystick value
  92824. */
  92825. set rightStick(newValues: StickValues);
  92826. /**
  92827. * Updates the gamepad joystick positions
  92828. */
  92829. update(): void;
  92830. /**
  92831. * Disposes the gamepad
  92832. */
  92833. dispose(): void;
  92834. }
  92835. /**
  92836. * Represents a generic gamepad
  92837. */
  92838. export class GenericPad extends Gamepad {
  92839. private _buttons;
  92840. private _onbuttondown;
  92841. private _onbuttonup;
  92842. /**
  92843. * Observable triggered when a button has been pressed
  92844. */
  92845. onButtonDownObservable: Observable<number>;
  92846. /**
  92847. * Observable triggered when a button has been released
  92848. */
  92849. onButtonUpObservable: Observable<number>;
  92850. /**
  92851. * Callback triggered when a button has been pressed
  92852. * @param callback Called when a button has been pressed
  92853. */
  92854. onbuttondown(callback: (buttonPressed: number) => void): void;
  92855. /**
  92856. * Callback triggered when a button has been released
  92857. * @param callback Called when a button has been released
  92858. */
  92859. onbuttonup(callback: (buttonReleased: number) => void): void;
  92860. /**
  92861. * Initializes the generic gamepad
  92862. * @param id The id of the generic gamepad
  92863. * @param index The index of the generic gamepad
  92864. * @param browserGamepad The browser gamepad
  92865. */
  92866. constructor(id: string, index: number, browserGamepad: any);
  92867. private _setButtonValue;
  92868. /**
  92869. * Updates the generic gamepad
  92870. */
  92871. update(): void;
  92872. /**
  92873. * Disposes the generic gamepad
  92874. */
  92875. dispose(): void;
  92876. }
  92877. }
  92878. declare module BABYLON {
  92879. /**
  92880. * Defines the types of pose enabled controllers that are supported
  92881. */
  92882. export enum PoseEnabledControllerType {
  92883. /**
  92884. * HTC Vive
  92885. */
  92886. VIVE = 0,
  92887. /**
  92888. * Oculus Rift
  92889. */
  92890. OCULUS = 1,
  92891. /**
  92892. * Windows mixed reality
  92893. */
  92894. WINDOWS = 2,
  92895. /**
  92896. * Samsung gear VR
  92897. */
  92898. GEAR_VR = 3,
  92899. /**
  92900. * Google Daydream
  92901. */
  92902. DAYDREAM = 4,
  92903. /**
  92904. * Generic
  92905. */
  92906. GENERIC = 5
  92907. }
  92908. /**
  92909. * Defines the MutableGamepadButton interface for the state of a gamepad button
  92910. */
  92911. export interface MutableGamepadButton {
  92912. /**
  92913. * Value of the button/trigger
  92914. */
  92915. value: number;
  92916. /**
  92917. * If the button/trigger is currently touched
  92918. */
  92919. touched: boolean;
  92920. /**
  92921. * If the button/trigger is currently pressed
  92922. */
  92923. pressed: boolean;
  92924. }
  92925. /**
  92926. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92927. * @hidden
  92928. */
  92929. export interface ExtendedGamepadButton extends GamepadButton {
  92930. /**
  92931. * If the button/trigger is currently pressed
  92932. */
  92933. readonly pressed: boolean;
  92934. /**
  92935. * If the button/trigger is currently touched
  92936. */
  92937. readonly touched: boolean;
  92938. /**
  92939. * Value of the button/trigger
  92940. */
  92941. readonly value: number;
  92942. }
  92943. /** @hidden */
  92944. export interface _GamePadFactory {
  92945. /**
  92946. * Returns whether or not the current gamepad can be created for this type of controller.
  92947. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92948. * @returns true if it can be created, otherwise false
  92949. */
  92950. canCreate(gamepadInfo: any): boolean;
  92951. /**
  92952. * Creates a new instance of the Gamepad.
  92953. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92954. * @returns the new gamepad instance
  92955. */
  92956. create(gamepadInfo: any): Gamepad;
  92957. }
  92958. /**
  92959. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92960. */
  92961. export class PoseEnabledControllerHelper {
  92962. /** @hidden */
  92963. static _ControllerFactories: _GamePadFactory[];
  92964. /** @hidden */
  92965. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92966. /**
  92967. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92968. * @param vrGamepad the gamepad to initialized
  92969. * @returns a vr controller of the type the gamepad identified as
  92970. */
  92971. static InitiateController(vrGamepad: any): Gamepad;
  92972. }
  92973. /**
  92974. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92975. */
  92976. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92977. /**
  92978. * If the controller is used in a webXR session
  92979. */
  92980. isXR: boolean;
  92981. private _deviceRoomPosition;
  92982. private _deviceRoomRotationQuaternion;
  92983. /**
  92984. * The device position in babylon space
  92985. */
  92986. devicePosition: Vector3;
  92987. /**
  92988. * The device rotation in babylon space
  92989. */
  92990. deviceRotationQuaternion: Quaternion;
  92991. /**
  92992. * The scale factor of the device in babylon space
  92993. */
  92994. deviceScaleFactor: number;
  92995. /**
  92996. * (Likely devicePosition should be used instead) The device position in its room space
  92997. */
  92998. position: Vector3;
  92999. /**
  93000. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  93001. */
  93002. rotationQuaternion: Quaternion;
  93003. /**
  93004. * The type of controller (Eg. Windows mixed reality)
  93005. */
  93006. controllerType: PoseEnabledControllerType;
  93007. protected _calculatedPosition: Vector3;
  93008. private _calculatedRotation;
  93009. /**
  93010. * The raw pose from the device
  93011. */
  93012. rawPose: DevicePose;
  93013. private _trackPosition;
  93014. private _maxRotationDistFromHeadset;
  93015. private _draggedRoomRotation;
  93016. /**
  93017. * @hidden
  93018. */
  93019. _disableTrackPosition(fixedPosition: Vector3): void;
  93020. /**
  93021. * Internal, the mesh attached to the controller
  93022. * @hidden
  93023. */
  93024. _mesh: Nullable<AbstractMesh>;
  93025. private _poseControlledCamera;
  93026. private _leftHandSystemQuaternion;
  93027. /**
  93028. * Internal, matrix used to convert room space to babylon space
  93029. * @hidden
  93030. */
  93031. _deviceToWorld: Matrix;
  93032. /**
  93033. * Node to be used when casting a ray from the controller
  93034. * @hidden
  93035. */
  93036. _pointingPoseNode: Nullable<TransformNode>;
  93037. /**
  93038. * Name of the child mesh that can be used to cast a ray from the controller
  93039. */
  93040. static readonly POINTING_POSE: string;
  93041. /**
  93042. * Creates a new PoseEnabledController from a gamepad
  93043. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  93044. */
  93045. constructor(browserGamepad: any);
  93046. private _workingMatrix;
  93047. /**
  93048. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  93049. */
  93050. update(): void;
  93051. /**
  93052. * Updates only the pose device and mesh without doing any button event checking
  93053. */
  93054. protected _updatePoseAndMesh(): void;
  93055. /**
  93056. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  93057. * @param poseData raw pose fromthe device
  93058. */
  93059. updateFromDevice(poseData: DevicePose): void;
  93060. /**
  93061. * @hidden
  93062. */
  93063. _meshAttachedObservable: Observable<AbstractMesh>;
  93064. /**
  93065. * Attaches a mesh to the controller
  93066. * @param mesh the mesh to be attached
  93067. */
  93068. attachToMesh(mesh: AbstractMesh): void;
  93069. /**
  93070. * Attaches the controllers mesh to a camera
  93071. * @param camera the camera the mesh should be attached to
  93072. */
  93073. attachToPoseControlledCamera(camera: TargetCamera): void;
  93074. /**
  93075. * Disposes of the controller
  93076. */
  93077. dispose(): void;
  93078. /**
  93079. * The mesh that is attached to the controller
  93080. */
  93081. get mesh(): Nullable<AbstractMesh>;
  93082. /**
  93083. * Gets the ray of the controller in the direction the controller is pointing
  93084. * @param length the length the resulting ray should be
  93085. * @returns a ray in the direction the controller is pointing
  93086. */
  93087. getForwardRay(length?: number): Ray;
  93088. }
  93089. }
  93090. declare module BABYLON {
  93091. /**
  93092. * Defines the WebVRController object that represents controllers tracked in 3D space
  93093. */
  93094. export abstract class WebVRController extends PoseEnabledController {
  93095. /**
  93096. * Internal, the default controller model for the controller
  93097. */
  93098. protected _defaultModel: Nullable<AbstractMesh>;
  93099. /**
  93100. * Fired when the trigger state has changed
  93101. */
  93102. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  93103. /**
  93104. * Fired when the main button state has changed
  93105. */
  93106. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93107. /**
  93108. * Fired when the secondary button state has changed
  93109. */
  93110. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93111. /**
  93112. * Fired when the pad state has changed
  93113. */
  93114. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  93115. /**
  93116. * Fired when controllers stick values have changed
  93117. */
  93118. onPadValuesChangedObservable: Observable<StickValues>;
  93119. /**
  93120. * Array of button availible on the controller
  93121. */
  93122. protected _buttons: Array<MutableGamepadButton>;
  93123. private _onButtonStateChange;
  93124. /**
  93125. * Fired when a controller button's state has changed
  93126. * @param callback the callback containing the button that was modified
  93127. */
  93128. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  93129. /**
  93130. * X and Y axis corresponding to the controllers joystick
  93131. */
  93132. pad: StickValues;
  93133. /**
  93134. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  93135. */
  93136. hand: string;
  93137. /**
  93138. * The default controller model for the controller
  93139. */
  93140. get defaultModel(): Nullable<AbstractMesh>;
  93141. /**
  93142. * Creates a new WebVRController from a gamepad
  93143. * @param vrGamepad the gamepad that the WebVRController should be created from
  93144. */
  93145. constructor(vrGamepad: any);
  93146. /**
  93147. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  93148. */
  93149. update(): void;
  93150. /**
  93151. * Function to be called when a button is modified
  93152. */
  93153. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  93154. /**
  93155. * Loads a mesh and attaches it to the controller
  93156. * @param scene the scene the mesh should be added to
  93157. * @param meshLoaded callback for when the mesh has been loaded
  93158. */
  93159. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  93160. private _setButtonValue;
  93161. private _changes;
  93162. private _checkChanges;
  93163. /**
  93164. * Disposes of th webVRCOntroller
  93165. */
  93166. dispose(): void;
  93167. }
  93168. }
  93169. declare module BABYLON {
  93170. /**
  93171. * The HemisphericLight simulates the ambient environment light,
  93172. * so the passed direction is the light reflection direction, not the incoming direction.
  93173. */
  93174. export class HemisphericLight extends Light {
  93175. /**
  93176. * The groundColor is the light in the opposite direction to the one specified during creation.
  93177. * 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.
  93178. */
  93179. groundColor: Color3;
  93180. /**
  93181. * The light reflection direction, not the incoming direction.
  93182. */
  93183. direction: Vector3;
  93184. /**
  93185. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  93186. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  93187. * The HemisphericLight can't cast shadows.
  93188. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93189. * @param name The friendly name of the light
  93190. * @param direction The direction of the light reflection
  93191. * @param scene The scene the light belongs to
  93192. */
  93193. constructor(name: string, direction: Vector3, scene: Scene);
  93194. protected _buildUniformLayout(): void;
  93195. /**
  93196. * Returns the string "HemisphericLight".
  93197. * @return The class name
  93198. */
  93199. getClassName(): string;
  93200. /**
  93201. * Sets the HemisphericLight direction towards the passed target (Vector3).
  93202. * Returns the updated direction.
  93203. * @param target The target the direction should point to
  93204. * @return The computed direction
  93205. */
  93206. setDirectionToTarget(target: Vector3): Vector3;
  93207. /**
  93208. * Returns the shadow generator associated to the light.
  93209. * @returns Always null for hemispheric lights because it does not support shadows.
  93210. */
  93211. getShadowGenerator(): Nullable<IShadowGenerator>;
  93212. /**
  93213. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  93214. * @param effect The effect to update
  93215. * @param lightIndex The index of the light in the effect to update
  93216. * @returns The hemispheric light
  93217. */
  93218. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  93219. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  93220. /**
  93221. * Computes the world matrix of the node
  93222. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93223. * @param useWasUpdatedFlag defines a reserved property
  93224. * @returns the world matrix
  93225. */
  93226. computeWorldMatrix(): Matrix;
  93227. /**
  93228. * Returns the integer 3.
  93229. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93230. */
  93231. getTypeID(): number;
  93232. /**
  93233. * Prepares the list of defines specific to the light type.
  93234. * @param defines the list of defines
  93235. * @param lightIndex defines the index of the light for the effect
  93236. */
  93237. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93238. }
  93239. }
  93240. declare module BABYLON {
  93241. /** @hidden */
  93242. export var vrMultiviewToSingleviewPixelShader: {
  93243. name: string;
  93244. shader: string;
  93245. };
  93246. }
  93247. declare module BABYLON {
  93248. /**
  93249. * Renders to multiple views with a single draw call
  93250. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  93251. */
  93252. export class MultiviewRenderTarget extends RenderTargetTexture {
  93253. /**
  93254. * Creates a multiview render target
  93255. * @param scene scene used with the render target
  93256. * @param size the size of the render target (used for each view)
  93257. */
  93258. constructor(scene: Scene, size?: number | {
  93259. width: number;
  93260. height: number;
  93261. } | {
  93262. ratio: number;
  93263. });
  93264. /**
  93265. * @hidden
  93266. * @param faceIndex the face index, if its a cube texture
  93267. */
  93268. _bindFrameBuffer(faceIndex?: number): void;
  93269. /**
  93270. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93271. * @returns the view count
  93272. */
  93273. getViewCount(): number;
  93274. }
  93275. }
  93276. declare module BABYLON {
  93277. /**
  93278. * Represents a camera frustum
  93279. */
  93280. export class Frustum {
  93281. /**
  93282. * Gets the planes representing the frustum
  93283. * @param transform matrix to be applied to the returned planes
  93284. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93285. */
  93286. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93287. /**
  93288. * Gets the near frustum plane transformed by the transform matrix
  93289. * @param transform transformation matrix to be applied to the resulting frustum plane
  93290. * @param frustumPlane the resuling frustum plane
  93291. */
  93292. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93293. /**
  93294. * Gets the far frustum plane transformed by the transform matrix
  93295. * @param transform transformation matrix to be applied to the resulting frustum plane
  93296. * @param frustumPlane the resuling frustum plane
  93297. */
  93298. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93299. /**
  93300. * Gets the left frustum plane transformed by the transform matrix
  93301. * @param transform transformation matrix to be applied to the resulting frustum plane
  93302. * @param frustumPlane the resuling frustum plane
  93303. */
  93304. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93305. /**
  93306. * Gets the right frustum plane transformed by the transform matrix
  93307. * @param transform transformation matrix to be applied to the resulting frustum plane
  93308. * @param frustumPlane the resuling frustum plane
  93309. */
  93310. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93311. /**
  93312. * Gets the top frustum plane transformed by the transform matrix
  93313. * @param transform transformation matrix to be applied to the resulting frustum plane
  93314. * @param frustumPlane the resuling frustum plane
  93315. */
  93316. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93317. /**
  93318. * Gets the bottom frustum plane transformed by the transform matrix
  93319. * @param transform transformation matrix to be applied to the resulting frustum plane
  93320. * @param frustumPlane the resuling frustum plane
  93321. */
  93322. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93323. /**
  93324. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93325. * @param transform transformation matrix to be applied to the resulting frustum planes
  93326. * @param frustumPlanes the resuling frustum planes
  93327. */
  93328. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93329. }
  93330. }
  93331. declare module BABYLON {
  93332. interface Engine {
  93333. /**
  93334. * Creates a new multiview render target
  93335. * @param width defines the width of the texture
  93336. * @param height defines the height of the texture
  93337. * @returns the created multiview texture
  93338. */
  93339. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  93340. /**
  93341. * Binds a multiview framebuffer to be drawn to
  93342. * @param multiviewTexture texture to bind
  93343. */
  93344. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  93345. }
  93346. interface Camera {
  93347. /**
  93348. * @hidden
  93349. * 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)
  93350. */
  93351. _useMultiviewToSingleView: boolean;
  93352. /**
  93353. * @hidden
  93354. * 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)
  93355. */
  93356. _multiviewTexture: Nullable<RenderTargetTexture>;
  93357. /**
  93358. * @hidden
  93359. * ensures the multiview texture of the camera exists and has the specified width/height
  93360. * @param width height to set on the multiview texture
  93361. * @param height width to set on the multiview texture
  93362. */
  93363. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  93364. }
  93365. interface Scene {
  93366. /** @hidden */
  93367. _transformMatrixR: Matrix;
  93368. /** @hidden */
  93369. _multiviewSceneUbo: Nullable<UniformBuffer>;
  93370. /** @hidden */
  93371. _createMultiviewUbo(): void;
  93372. /** @hidden */
  93373. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  93374. /** @hidden */
  93375. _renderMultiviewToSingleView(camera: Camera): void;
  93376. }
  93377. }
  93378. declare module BABYLON {
  93379. /**
  93380. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  93381. * This will not be used for webXR as it supports displaying texture arrays directly
  93382. */
  93383. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  93384. /**
  93385. * Initializes a VRMultiviewToSingleview
  93386. * @param name name of the post process
  93387. * @param camera camera to be applied to
  93388. * @param scaleFactor scaling factor to the size of the output texture
  93389. */
  93390. constructor(name: string, camera: Camera, scaleFactor: number);
  93391. }
  93392. }
  93393. declare module BABYLON {
  93394. /**
  93395. * Interface used to define additional presentation attributes
  93396. */
  93397. export interface IVRPresentationAttributes {
  93398. /**
  93399. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  93400. */
  93401. highRefreshRate: boolean;
  93402. /**
  93403. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  93404. */
  93405. foveationLevel: number;
  93406. }
  93407. interface Engine {
  93408. /** @hidden */
  93409. _vrDisplay: any;
  93410. /** @hidden */
  93411. _vrSupported: boolean;
  93412. /** @hidden */
  93413. _oldSize: Size;
  93414. /** @hidden */
  93415. _oldHardwareScaleFactor: number;
  93416. /** @hidden */
  93417. _vrExclusivePointerMode: boolean;
  93418. /** @hidden */
  93419. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  93420. /** @hidden */
  93421. _onVRDisplayPointerRestricted: () => void;
  93422. /** @hidden */
  93423. _onVRDisplayPointerUnrestricted: () => void;
  93424. /** @hidden */
  93425. _onVrDisplayConnect: Nullable<(display: any) => void>;
  93426. /** @hidden */
  93427. _onVrDisplayDisconnect: Nullable<() => void>;
  93428. /** @hidden */
  93429. _onVrDisplayPresentChange: Nullable<() => void>;
  93430. /**
  93431. * Observable signaled when VR display mode changes
  93432. */
  93433. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  93434. /**
  93435. * Observable signaled when VR request present is complete
  93436. */
  93437. onVRRequestPresentComplete: Observable<boolean>;
  93438. /**
  93439. * Observable signaled when VR request present starts
  93440. */
  93441. onVRRequestPresentStart: Observable<Engine>;
  93442. /**
  93443. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  93444. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  93445. */
  93446. isInVRExclusivePointerMode: boolean;
  93447. /**
  93448. * Gets a boolean indicating if a webVR device was detected
  93449. * @returns true if a webVR device was detected
  93450. */
  93451. isVRDevicePresent(): boolean;
  93452. /**
  93453. * Gets the current webVR device
  93454. * @returns the current webVR device (or null)
  93455. */
  93456. getVRDevice(): any;
  93457. /**
  93458. * Initializes a webVR display and starts listening to display change events
  93459. * The onVRDisplayChangedObservable will be notified upon these changes
  93460. * @returns A promise containing a VRDisplay and if vr is supported
  93461. */
  93462. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  93463. /** @hidden */
  93464. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  93465. /**
  93466. * Gets or sets the presentation attributes used to configure VR rendering
  93467. */
  93468. vrPresentationAttributes?: IVRPresentationAttributes;
  93469. /**
  93470. * Call this function to switch to webVR mode
  93471. * Will do nothing if webVR is not supported or if there is no webVR device
  93472. * @param options the webvr options provided to the camera. mainly used for multiview
  93473. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93474. */
  93475. enableVR(options: WebVROptions): void;
  93476. /** @hidden */
  93477. _onVRFullScreenTriggered(): void;
  93478. }
  93479. }
  93480. declare module BABYLON {
  93481. /**
  93482. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  93483. * IMPORTANT!! The data is right-hand data.
  93484. * @export
  93485. * @interface DevicePose
  93486. */
  93487. export interface DevicePose {
  93488. /**
  93489. * The position of the device, values in array are [x,y,z].
  93490. */
  93491. readonly position: Nullable<Float32Array>;
  93492. /**
  93493. * The linearVelocity of the device, values in array are [x,y,z].
  93494. */
  93495. readonly linearVelocity: Nullable<Float32Array>;
  93496. /**
  93497. * The linearAcceleration of the device, values in array are [x,y,z].
  93498. */
  93499. readonly linearAcceleration: Nullable<Float32Array>;
  93500. /**
  93501. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  93502. */
  93503. readonly orientation: Nullable<Float32Array>;
  93504. /**
  93505. * The angularVelocity of the device, values in array are [x,y,z].
  93506. */
  93507. readonly angularVelocity: Nullable<Float32Array>;
  93508. /**
  93509. * The angularAcceleration of the device, values in array are [x,y,z].
  93510. */
  93511. readonly angularAcceleration: Nullable<Float32Array>;
  93512. }
  93513. /**
  93514. * Interface representing a pose controlled object in Babylon.
  93515. * A pose controlled object has both regular pose values as well as pose values
  93516. * from an external device such as a VR head mounted display
  93517. */
  93518. export interface PoseControlled {
  93519. /**
  93520. * The position of the object in babylon space.
  93521. */
  93522. position: Vector3;
  93523. /**
  93524. * The rotation quaternion of the object in babylon space.
  93525. */
  93526. rotationQuaternion: Quaternion;
  93527. /**
  93528. * The position of the device in babylon space.
  93529. */
  93530. devicePosition?: Vector3;
  93531. /**
  93532. * The rotation quaternion of the device in babylon space.
  93533. */
  93534. deviceRotationQuaternion: Quaternion;
  93535. /**
  93536. * The raw pose coming from the device.
  93537. */
  93538. rawPose: Nullable<DevicePose>;
  93539. /**
  93540. * The scale of the device to be used when translating from device space to babylon space.
  93541. */
  93542. deviceScaleFactor: number;
  93543. /**
  93544. * Updates the poseControlled values based on the input device pose.
  93545. * @param poseData the pose data to update the object with
  93546. */
  93547. updateFromDevice(poseData: DevicePose): void;
  93548. }
  93549. /**
  93550. * Set of options to customize the webVRCamera
  93551. */
  93552. export interface WebVROptions {
  93553. /**
  93554. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  93555. */
  93556. trackPosition?: boolean;
  93557. /**
  93558. * Sets the scale of the vrDevice in babylon space. (default: 1)
  93559. */
  93560. positionScale?: number;
  93561. /**
  93562. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  93563. */
  93564. displayName?: string;
  93565. /**
  93566. * Should the native controller meshes be initialized. (default: true)
  93567. */
  93568. controllerMeshes?: boolean;
  93569. /**
  93570. * Creating a default HemiLight only on controllers. (default: true)
  93571. */
  93572. defaultLightingOnControllers?: boolean;
  93573. /**
  93574. * If you don't want to use the default VR button of the helper. (default: false)
  93575. */
  93576. useCustomVRButton?: boolean;
  93577. /**
  93578. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  93579. */
  93580. customVRButton?: HTMLButtonElement;
  93581. /**
  93582. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  93583. */
  93584. rayLength?: number;
  93585. /**
  93586. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  93587. */
  93588. defaultHeight?: number;
  93589. /**
  93590. * If multiview should be used if availible (default: false)
  93591. */
  93592. useMultiview?: boolean;
  93593. }
  93594. /**
  93595. * This represents a WebVR camera.
  93596. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  93597. * @example http://doc.babylonjs.com/how_to/webvr_camera
  93598. */
  93599. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  93600. private webVROptions;
  93601. /**
  93602. * @hidden
  93603. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  93604. */
  93605. _vrDevice: any;
  93606. /**
  93607. * The rawPose of the vrDevice.
  93608. */
  93609. rawPose: Nullable<DevicePose>;
  93610. private _onVREnabled;
  93611. private _specsVersion;
  93612. private _attached;
  93613. private _frameData;
  93614. protected _descendants: Array<Node>;
  93615. private _deviceRoomPosition;
  93616. /** @hidden */
  93617. _deviceRoomRotationQuaternion: Quaternion;
  93618. private _standingMatrix;
  93619. /**
  93620. * Represents device position in babylon space.
  93621. */
  93622. devicePosition: Vector3;
  93623. /**
  93624. * Represents device rotation in babylon space.
  93625. */
  93626. deviceRotationQuaternion: Quaternion;
  93627. /**
  93628. * The scale of the device to be used when translating from device space to babylon space.
  93629. */
  93630. deviceScaleFactor: number;
  93631. private _deviceToWorld;
  93632. private _worldToDevice;
  93633. /**
  93634. * References to the webVR controllers for the vrDevice.
  93635. */
  93636. controllers: Array<WebVRController>;
  93637. /**
  93638. * Emits an event when a controller is attached.
  93639. */
  93640. onControllersAttachedObservable: Observable<WebVRController[]>;
  93641. /**
  93642. * Emits an event when a controller's mesh has been loaded;
  93643. */
  93644. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93645. /**
  93646. * Emits an event when the HMD's pose has been updated.
  93647. */
  93648. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93649. private _poseSet;
  93650. /**
  93651. * If the rig cameras be used as parent instead of this camera.
  93652. */
  93653. rigParenting: boolean;
  93654. private _lightOnControllers;
  93655. private _defaultHeight?;
  93656. /**
  93657. * Instantiates a WebVRFreeCamera.
  93658. * @param name The name of the WebVRFreeCamera
  93659. * @param position The starting anchor position for the camera
  93660. * @param scene The scene the camera belongs to
  93661. * @param webVROptions a set of customizable options for the webVRCamera
  93662. */
  93663. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93664. /**
  93665. * Gets the device distance from the ground in meters.
  93666. * @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.
  93667. */
  93668. deviceDistanceToRoomGround(): number;
  93669. /**
  93670. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93671. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93672. */
  93673. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93674. /**
  93675. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93676. * @returns A promise with a boolean set to if the standing matrix is supported.
  93677. */
  93678. useStandingMatrixAsync(): Promise<boolean>;
  93679. /**
  93680. * Disposes the camera
  93681. */
  93682. dispose(): void;
  93683. /**
  93684. * Gets a vrController by name.
  93685. * @param name The name of the controller to retreive
  93686. * @returns the controller matching the name specified or null if not found
  93687. */
  93688. getControllerByName(name: string): Nullable<WebVRController>;
  93689. private _leftController;
  93690. /**
  93691. * The controller corresponding to the users left hand.
  93692. */
  93693. get leftController(): Nullable<WebVRController>;
  93694. private _rightController;
  93695. /**
  93696. * The controller corresponding to the users right hand.
  93697. */
  93698. get rightController(): Nullable<WebVRController>;
  93699. /**
  93700. * Casts a ray forward from the vrCamera's gaze.
  93701. * @param length Length of the ray (default: 100)
  93702. * @returns the ray corresponding to the gaze
  93703. */
  93704. getForwardRay(length?: number): Ray;
  93705. /**
  93706. * @hidden
  93707. * Updates the camera based on device's frame data
  93708. */
  93709. _checkInputs(): void;
  93710. /**
  93711. * Updates the poseControlled values based on the input device pose.
  93712. * @param poseData Pose coming from the device
  93713. */
  93714. updateFromDevice(poseData: DevicePose): void;
  93715. private _htmlElementAttached;
  93716. private _detachIfAttached;
  93717. /**
  93718. * WebVR's attach control will start broadcasting frames to the device.
  93719. * Note that in certain browsers (chrome for example) this function must be called
  93720. * within a user-interaction callback. Example:
  93721. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93722. *
  93723. * @param element html element to attach the vrDevice to
  93724. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93725. */
  93726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93727. /**
  93728. * Detaches the camera from the html element and disables VR
  93729. *
  93730. * @param element html element to detach from
  93731. */
  93732. detachControl(element: HTMLElement): void;
  93733. /**
  93734. * @returns the name of this class
  93735. */
  93736. getClassName(): string;
  93737. /**
  93738. * Calls resetPose on the vrDisplay
  93739. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93740. */
  93741. resetToCurrentRotation(): void;
  93742. /**
  93743. * @hidden
  93744. * Updates the rig cameras (left and right eye)
  93745. */
  93746. _updateRigCameras(): void;
  93747. private _workingVector;
  93748. private _oneVector;
  93749. private _workingMatrix;
  93750. private updateCacheCalled;
  93751. private _correctPositionIfNotTrackPosition;
  93752. /**
  93753. * @hidden
  93754. * Updates the cached values of the camera
  93755. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93756. */
  93757. _updateCache(ignoreParentClass?: boolean): void;
  93758. /**
  93759. * @hidden
  93760. * Get current device position in babylon world
  93761. */
  93762. _computeDevicePosition(): void;
  93763. /**
  93764. * Updates the current device position and rotation in the babylon world
  93765. */
  93766. update(): void;
  93767. /**
  93768. * @hidden
  93769. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  93770. * @returns an identity matrix
  93771. */
  93772. _getViewMatrix(): Matrix;
  93773. private _tmpMatrix;
  93774. /**
  93775. * This function is called by the two RIG cameras.
  93776. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  93777. * @hidden
  93778. */
  93779. _getWebVRViewMatrix(): Matrix;
  93780. /** @hidden */
  93781. _getWebVRProjectionMatrix(): Matrix;
  93782. private _onGamepadConnectedObserver;
  93783. private _onGamepadDisconnectedObserver;
  93784. private _updateCacheWhenTrackingDisabledObserver;
  93785. /**
  93786. * Initializes the controllers and their meshes
  93787. */
  93788. initControllers(): void;
  93789. }
  93790. }
  93791. declare module BABYLON {
  93792. /**
  93793. * Size options for a post process
  93794. */
  93795. export type PostProcessOptions = {
  93796. width: number;
  93797. height: number;
  93798. };
  93799. /**
  93800. * PostProcess can be used to apply a shader to a texture after it has been rendered
  93801. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93802. */
  93803. export class PostProcess {
  93804. /** Name of the PostProcess. */
  93805. name: string;
  93806. /**
  93807. * Gets or sets the unique id of the post process
  93808. */
  93809. uniqueId: number;
  93810. /**
  93811. * Width of the texture to apply the post process on
  93812. */
  93813. width: number;
  93814. /**
  93815. * Height of the texture to apply the post process on
  93816. */
  93817. height: number;
  93818. /**
  93819. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  93820. * @hidden
  93821. */
  93822. _outputTexture: Nullable<InternalTexture>;
  93823. /**
  93824. * Sampling mode used by the shader
  93825. * See https://doc.babylonjs.com/classes/3.1/texture
  93826. */
  93827. renderTargetSamplingMode: number;
  93828. /**
  93829. * Clear color to use when screen clearing
  93830. */
  93831. clearColor: Color4;
  93832. /**
  93833. * If the buffer needs to be cleared before applying the post process. (default: true)
  93834. * Should be set to false if shader will overwrite all previous pixels.
  93835. */
  93836. autoClear: boolean;
  93837. /**
  93838. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  93839. */
  93840. alphaMode: number;
  93841. /**
  93842. * Sets the setAlphaBlendConstants of the babylon engine
  93843. */
  93844. alphaConstants: Color4;
  93845. /**
  93846. * Animations to be used for the post processing
  93847. */
  93848. animations: Animation[];
  93849. /**
  93850. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  93851. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  93852. */
  93853. enablePixelPerfectMode: boolean;
  93854. /**
  93855. * Force the postprocess to be applied without taking in account viewport
  93856. */
  93857. forceFullscreenViewport: boolean;
  93858. /**
  93859. * List of inspectable custom properties (used by the Inspector)
  93860. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93861. */
  93862. inspectableCustomProperties: IInspectable[];
  93863. /**
  93864. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  93865. *
  93866. * | Value | Type | Description |
  93867. * | ----- | ----------------------------------- | ----------- |
  93868. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  93869. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  93870. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  93871. *
  93872. */
  93873. scaleMode: number;
  93874. /**
  93875. * Force textures to be a power of two (default: false)
  93876. */
  93877. alwaysForcePOT: boolean;
  93878. private _samples;
  93879. /**
  93880. * Number of sample textures (default: 1)
  93881. */
  93882. get samples(): number;
  93883. set samples(n: number);
  93884. /**
  93885. * Modify the scale of the post process to be the same as the viewport (default: false)
  93886. */
  93887. adaptScaleToCurrentViewport: boolean;
  93888. private _camera;
  93889. private _scene;
  93890. private _engine;
  93891. private _options;
  93892. private _reusable;
  93893. private _textureType;
  93894. private _textureFormat;
  93895. /**
  93896. * Smart array of input and output textures for the post process.
  93897. * @hidden
  93898. */
  93899. _textures: SmartArray<InternalTexture>;
  93900. /**
  93901. * The index in _textures that corresponds to the output texture.
  93902. * @hidden
  93903. */
  93904. _currentRenderTextureInd: number;
  93905. private _effect;
  93906. private _samplers;
  93907. private _fragmentUrl;
  93908. private _vertexUrl;
  93909. private _parameters;
  93910. private _scaleRatio;
  93911. protected _indexParameters: any;
  93912. private _shareOutputWithPostProcess;
  93913. private _texelSize;
  93914. private _forcedOutputTexture;
  93915. /**
  93916. * Returns the fragment url or shader name used in the post process.
  93917. * @returns the fragment url or name in the shader store.
  93918. */
  93919. getEffectName(): string;
  93920. /**
  93921. * An event triggered when the postprocess is activated.
  93922. */
  93923. onActivateObservable: Observable<Camera>;
  93924. private _onActivateObserver;
  93925. /**
  93926. * A function that is added to the onActivateObservable
  93927. */
  93928. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93929. /**
  93930. * An event triggered when the postprocess changes its size.
  93931. */
  93932. onSizeChangedObservable: Observable<PostProcess>;
  93933. private _onSizeChangedObserver;
  93934. /**
  93935. * A function that is added to the onSizeChangedObservable
  93936. */
  93937. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93938. /**
  93939. * An event triggered when the postprocess applies its effect.
  93940. */
  93941. onApplyObservable: Observable<Effect>;
  93942. private _onApplyObserver;
  93943. /**
  93944. * A function that is added to the onApplyObservable
  93945. */
  93946. set onApply(callback: (effect: Effect) => void);
  93947. /**
  93948. * An event triggered before rendering the postprocess
  93949. */
  93950. onBeforeRenderObservable: Observable<Effect>;
  93951. private _onBeforeRenderObserver;
  93952. /**
  93953. * A function that is added to the onBeforeRenderObservable
  93954. */
  93955. set onBeforeRender(callback: (effect: Effect) => void);
  93956. /**
  93957. * An event triggered after rendering the postprocess
  93958. */
  93959. onAfterRenderObservable: Observable<Effect>;
  93960. private _onAfterRenderObserver;
  93961. /**
  93962. * A function that is added to the onAfterRenderObservable
  93963. */
  93964. set onAfterRender(callback: (efect: Effect) => void);
  93965. /**
  93966. * 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
  93967. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93968. */
  93969. get inputTexture(): InternalTexture;
  93970. set inputTexture(value: InternalTexture);
  93971. /**
  93972. * Gets the camera which post process is applied to.
  93973. * @returns The camera the post process is applied to.
  93974. */
  93975. getCamera(): Camera;
  93976. /**
  93977. * Gets the texel size of the postprocess.
  93978. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93979. */
  93980. get texelSize(): Vector2;
  93981. /**
  93982. * Creates a new instance PostProcess
  93983. * @param name The name of the PostProcess.
  93984. * @param fragmentUrl The url of the fragment shader to be used.
  93985. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93986. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93987. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93988. * @param camera The camera to apply the render pass to.
  93989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93990. * @param engine The engine which the post process will be applied. (default: current engine)
  93991. * @param reusable If the post process can be reused on the same frame. (default: false)
  93992. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93993. * @param textureType Type of textures used when performing the post process. (default: 0)
  93994. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93995. * @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
  93996. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93997. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93998. */
  93999. constructor(
  94000. /** Name of the PostProcess. */
  94001. 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);
  94002. /**
  94003. * Gets a string idenfifying the name of the class
  94004. * @returns "PostProcess" string
  94005. */
  94006. getClassName(): string;
  94007. /**
  94008. * Gets the engine which this post process belongs to.
  94009. * @returns The engine the post process was enabled with.
  94010. */
  94011. getEngine(): Engine;
  94012. /**
  94013. * The effect that is created when initializing the post process.
  94014. * @returns The created effect corresponding the the postprocess.
  94015. */
  94016. getEffect(): Effect;
  94017. /**
  94018. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  94019. * @param postProcess The post process to share the output with.
  94020. * @returns This post process.
  94021. */
  94022. shareOutputWith(postProcess: PostProcess): PostProcess;
  94023. /**
  94024. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  94025. * This should be called if the post process that shares output with this post process is disabled/disposed.
  94026. */
  94027. useOwnOutput(): void;
  94028. /**
  94029. * Updates the effect with the current post process compile time values and recompiles the shader.
  94030. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94031. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94032. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94033. * @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
  94034. * @param onCompiled Called when the shader has been compiled.
  94035. * @param onError Called if there is an error when compiling a shader.
  94036. */
  94037. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94038. /**
  94039. * The post process is reusable if it can be used multiple times within one frame.
  94040. * @returns If the post process is reusable
  94041. */
  94042. isReusable(): boolean;
  94043. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  94044. markTextureDirty(): void;
  94045. /**
  94046. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  94047. * 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.
  94048. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  94049. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  94050. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  94051. * @returns The target texture that was bound to be written to.
  94052. */
  94053. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  94054. /**
  94055. * If the post process is supported.
  94056. */
  94057. get isSupported(): boolean;
  94058. /**
  94059. * The aspect ratio of the output texture.
  94060. */
  94061. get aspectRatio(): number;
  94062. /**
  94063. * Get a value indicating if the post-process is ready to be used
  94064. * @returns true if the post-process is ready (shader is compiled)
  94065. */
  94066. isReady(): boolean;
  94067. /**
  94068. * Binds all textures and uniforms to the shader, this will be run on every pass.
  94069. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  94070. */
  94071. apply(): Nullable<Effect>;
  94072. private _disposeTextures;
  94073. /**
  94074. * Disposes the post process.
  94075. * @param camera The camera to dispose the post process on.
  94076. */
  94077. dispose(camera?: Camera): void;
  94078. }
  94079. }
  94080. declare module BABYLON {
  94081. /** @hidden */
  94082. export var kernelBlurVaryingDeclaration: {
  94083. name: string;
  94084. shader: string;
  94085. };
  94086. }
  94087. declare module BABYLON {
  94088. /** @hidden */
  94089. export var kernelBlurFragment: {
  94090. name: string;
  94091. shader: string;
  94092. };
  94093. }
  94094. declare module BABYLON {
  94095. /** @hidden */
  94096. export var kernelBlurFragment2: {
  94097. name: string;
  94098. shader: string;
  94099. };
  94100. }
  94101. declare module BABYLON {
  94102. /** @hidden */
  94103. export var kernelBlurPixelShader: {
  94104. name: string;
  94105. shader: string;
  94106. };
  94107. }
  94108. declare module BABYLON {
  94109. /** @hidden */
  94110. export var kernelBlurVertex: {
  94111. name: string;
  94112. shader: string;
  94113. };
  94114. }
  94115. declare module BABYLON {
  94116. /** @hidden */
  94117. export var kernelBlurVertexShader: {
  94118. name: string;
  94119. shader: string;
  94120. };
  94121. }
  94122. declare module BABYLON {
  94123. /**
  94124. * The Blur Post Process which blurs an image based on a kernel and direction.
  94125. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  94126. */
  94127. export class BlurPostProcess extends PostProcess {
  94128. /** The direction in which to blur the image. */
  94129. direction: Vector2;
  94130. private blockCompilation;
  94131. protected _kernel: number;
  94132. protected _idealKernel: number;
  94133. protected _packedFloat: boolean;
  94134. private _staticDefines;
  94135. /**
  94136. * Sets the length in pixels of the blur sample region
  94137. */
  94138. set kernel(v: number);
  94139. /**
  94140. * Gets the length in pixels of the blur sample region
  94141. */
  94142. get kernel(): number;
  94143. /**
  94144. * Sets wether or not the blur needs to unpack/repack floats
  94145. */
  94146. set packedFloat(v: boolean);
  94147. /**
  94148. * Gets wether or not the blur is unpacking/repacking floats
  94149. */
  94150. get packedFloat(): boolean;
  94151. /**
  94152. * Creates a new instance BlurPostProcess
  94153. * @param name The name of the effect.
  94154. * @param direction The direction in which to blur the image.
  94155. * @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.
  94156. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94157. * @param camera The camera to apply the render pass to.
  94158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94159. * @param engine The engine which the post process will be applied. (default: current engine)
  94160. * @param reusable If the post process can be reused on the same frame. (default: false)
  94161. * @param textureType Type of textures used when performing the post process. (default: 0)
  94162. * @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)
  94163. */
  94164. constructor(name: string,
  94165. /** The direction in which to blur the image. */
  94166. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  94167. /**
  94168. * Updates the effect with the current post process compile time values and recompiles the shader.
  94169. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94170. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94171. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94172. * @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
  94173. * @param onCompiled Called when the shader has been compiled.
  94174. * @param onError Called if there is an error when compiling a shader.
  94175. */
  94176. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94177. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94178. /**
  94179. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  94180. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  94181. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  94182. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  94183. * The gaps between physical kernels are compensated for in the weighting of the samples
  94184. * @param idealKernel Ideal blur kernel.
  94185. * @return Nearest best kernel.
  94186. */
  94187. protected _nearestBestKernel(idealKernel: number): number;
  94188. /**
  94189. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  94190. * @param x The point on the Gaussian distribution to sample.
  94191. * @return the value of the Gaussian function at x.
  94192. */
  94193. protected _gaussianWeight(x: number): number;
  94194. /**
  94195. * Generates a string that can be used as a floating point number in GLSL.
  94196. * @param x Value to print.
  94197. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  94198. * @return GLSL float string.
  94199. */
  94200. protected _glslFloat(x: number, decimalFigures?: number): string;
  94201. }
  94202. }
  94203. declare module BABYLON {
  94204. /**
  94205. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94206. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94207. * You can then easily use it as a reflectionTexture on a flat surface.
  94208. * In case the surface is not a plane, please consider relying on reflection probes.
  94209. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94210. */
  94211. export class MirrorTexture extends RenderTargetTexture {
  94212. private scene;
  94213. /**
  94214. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  94215. * 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.
  94216. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94217. */
  94218. mirrorPlane: Plane;
  94219. /**
  94220. * Define the blur ratio used to blur the reflection if needed.
  94221. */
  94222. set blurRatio(value: number);
  94223. get blurRatio(): number;
  94224. /**
  94225. * Define the adaptive blur kernel used to blur the reflection if needed.
  94226. * This will autocompute the closest best match for the `blurKernel`
  94227. */
  94228. set adaptiveBlurKernel(value: number);
  94229. /**
  94230. * Define the blur kernel used to blur the reflection if needed.
  94231. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94232. */
  94233. set blurKernel(value: number);
  94234. /**
  94235. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  94236. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94237. */
  94238. set blurKernelX(value: number);
  94239. get blurKernelX(): number;
  94240. /**
  94241. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  94242. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94243. */
  94244. set blurKernelY(value: number);
  94245. get blurKernelY(): number;
  94246. private _autoComputeBlurKernel;
  94247. protected _onRatioRescale(): void;
  94248. private _updateGammaSpace;
  94249. private _imageProcessingConfigChangeObserver;
  94250. private _transformMatrix;
  94251. private _mirrorMatrix;
  94252. private _savedViewMatrix;
  94253. private _blurX;
  94254. private _blurY;
  94255. private _adaptiveBlurKernel;
  94256. private _blurKernelX;
  94257. private _blurKernelY;
  94258. private _blurRatio;
  94259. /**
  94260. * Instantiates a Mirror Texture.
  94261. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94262. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94263. * You can then easily use it as a reflectionTexture on a flat surface.
  94264. * In case the surface is not a plane, please consider relying on reflection probes.
  94265. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94266. * @param name
  94267. * @param size
  94268. * @param scene
  94269. * @param generateMipMaps
  94270. * @param type
  94271. * @param samplingMode
  94272. * @param generateDepthBuffer
  94273. */
  94274. constructor(name: string, size: number | {
  94275. width: number;
  94276. height: number;
  94277. } | {
  94278. ratio: number;
  94279. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  94280. private _preparePostProcesses;
  94281. /**
  94282. * Clone the mirror texture.
  94283. * @returns the cloned texture
  94284. */
  94285. clone(): MirrorTexture;
  94286. /**
  94287. * Serialize the texture to a JSON representation you could use in Parse later on
  94288. * @returns the serialized JSON representation
  94289. */
  94290. serialize(): any;
  94291. /**
  94292. * Dispose the texture and release its associated resources.
  94293. */
  94294. dispose(): void;
  94295. }
  94296. }
  94297. declare module BABYLON {
  94298. /**
  94299. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94300. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94301. */
  94302. export class Texture extends BaseTexture {
  94303. /**
  94304. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  94305. */
  94306. static SerializeBuffers: boolean;
  94307. /** @hidden */
  94308. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  94309. /** @hidden */
  94310. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  94311. /** @hidden */
  94312. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  94313. /** nearest is mag = nearest and min = nearest and mip = linear */
  94314. static readonly NEAREST_SAMPLINGMODE: number;
  94315. /** nearest is mag = nearest and min = nearest and mip = linear */
  94316. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  94317. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94318. static readonly BILINEAR_SAMPLINGMODE: number;
  94319. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94320. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  94321. /** Trilinear is mag = linear and min = linear and mip = linear */
  94322. static readonly TRILINEAR_SAMPLINGMODE: number;
  94323. /** Trilinear is mag = linear and min = linear and mip = linear */
  94324. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  94325. /** mag = nearest and min = nearest and mip = nearest */
  94326. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  94327. /** mag = nearest and min = linear and mip = nearest */
  94328. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  94329. /** mag = nearest and min = linear and mip = linear */
  94330. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  94331. /** mag = nearest and min = linear and mip = none */
  94332. static readonly NEAREST_LINEAR: number;
  94333. /** mag = nearest and min = nearest and mip = none */
  94334. static readonly NEAREST_NEAREST: number;
  94335. /** mag = linear and min = nearest and mip = nearest */
  94336. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  94337. /** mag = linear and min = nearest and mip = linear */
  94338. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  94339. /** mag = linear and min = linear and mip = none */
  94340. static readonly LINEAR_LINEAR: number;
  94341. /** mag = linear and min = nearest and mip = none */
  94342. static readonly LINEAR_NEAREST: number;
  94343. /** Explicit coordinates mode */
  94344. static readonly EXPLICIT_MODE: number;
  94345. /** Spherical coordinates mode */
  94346. static readonly SPHERICAL_MODE: number;
  94347. /** Planar coordinates mode */
  94348. static readonly PLANAR_MODE: number;
  94349. /** Cubic coordinates mode */
  94350. static readonly CUBIC_MODE: number;
  94351. /** Projection coordinates mode */
  94352. static readonly PROJECTION_MODE: number;
  94353. /** Inverse Cubic coordinates mode */
  94354. static readonly SKYBOX_MODE: number;
  94355. /** Inverse Cubic coordinates mode */
  94356. static readonly INVCUBIC_MODE: number;
  94357. /** Equirectangular coordinates mode */
  94358. static readonly EQUIRECTANGULAR_MODE: number;
  94359. /** Equirectangular Fixed coordinates mode */
  94360. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  94361. /** Equirectangular Fixed Mirrored coordinates mode */
  94362. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94363. /** Texture is not repeating outside of 0..1 UVs */
  94364. static readonly CLAMP_ADDRESSMODE: number;
  94365. /** Texture is repeating outside of 0..1 UVs */
  94366. static readonly WRAP_ADDRESSMODE: number;
  94367. /** Texture is repeating and mirrored */
  94368. static readonly MIRROR_ADDRESSMODE: number;
  94369. /**
  94370. * 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
  94371. */
  94372. static UseSerializedUrlIfAny: boolean;
  94373. /**
  94374. * Define the url of the texture.
  94375. */
  94376. url: Nullable<string>;
  94377. /**
  94378. * Define an offset on the texture to offset the u coordinates of the UVs
  94379. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94380. */
  94381. uOffset: number;
  94382. /**
  94383. * Define an offset on the texture to offset the v coordinates of the UVs
  94384. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94385. */
  94386. vOffset: number;
  94387. /**
  94388. * Define an offset on the texture to scale the u coordinates of the UVs
  94389. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94390. */
  94391. uScale: number;
  94392. /**
  94393. * Define an offset on the texture to scale the v coordinates of the UVs
  94394. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94395. */
  94396. vScale: number;
  94397. /**
  94398. * Define an offset on the texture to rotate around the u coordinates of the UVs
  94399. * @see http://doc.babylonjs.com/how_to/more_materials
  94400. */
  94401. uAng: number;
  94402. /**
  94403. * Define an offset on the texture to rotate around the v coordinates of the UVs
  94404. * @see http://doc.babylonjs.com/how_to/more_materials
  94405. */
  94406. vAng: number;
  94407. /**
  94408. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  94409. * @see http://doc.babylonjs.com/how_to/more_materials
  94410. */
  94411. wAng: number;
  94412. /**
  94413. * Defines the center of rotation (U)
  94414. */
  94415. uRotationCenter: number;
  94416. /**
  94417. * Defines the center of rotation (V)
  94418. */
  94419. vRotationCenter: number;
  94420. /**
  94421. * Defines the center of rotation (W)
  94422. */
  94423. wRotationCenter: number;
  94424. /**
  94425. * Are mip maps generated for this texture or not.
  94426. */
  94427. get noMipmap(): boolean;
  94428. /**
  94429. * List of inspectable custom properties (used by the Inspector)
  94430. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94431. */
  94432. inspectableCustomProperties: Nullable<IInspectable[]>;
  94433. private _noMipmap;
  94434. /** @hidden */
  94435. _invertY: boolean;
  94436. private _rowGenerationMatrix;
  94437. private _cachedTextureMatrix;
  94438. private _projectionModeMatrix;
  94439. private _t0;
  94440. private _t1;
  94441. private _t2;
  94442. private _cachedUOffset;
  94443. private _cachedVOffset;
  94444. private _cachedUScale;
  94445. private _cachedVScale;
  94446. private _cachedUAng;
  94447. private _cachedVAng;
  94448. private _cachedWAng;
  94449. private _cachedProjectionMatrixId;
  94450. private _cachedCoordinatesMode;
  94451. /** @hidden */
  94452. protected _initialSamplingMode: number;
  94453. /** @hidden */
  94454. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  94455. private _deleteBuffer;
  94456. protected _format: Nullable<number>;
  94457. private _delayedOnLoad;
  94458. private _delayedOnError;
  94459. private _mimeType?;
  94460. /**
  94461. * Observable triggered once the texture has been loaded.
  94462. */
  94463. onLoadObservable: Observable<Texture>;
  94464. protected _isBlocking: boolean;
  94465. /**
  94466. * Is the texture preventing material to render while loading.
  94467. * If false, a default texture will be used instead of the loading one during the preparation step.
  94468. */
  94469. set isBlocking(value: boolean);
  94470. get isBlocking(): boolean;
  94471. /**
  94472. * Get the current sampling mode associated with the texture.
  94473. */
  94474. get samplingMode(): number;
  94475. /**
  94476. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  94477. */
  94478. get invertY(): boolean;
  94479. /**
  94480. * Instantiates a new texture.
  94481. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94482. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94483. * @param url defines the url of the picture to load as a texture
  94484. * @param scene defines the scene or engine the texture will belong to
  94485. * @param noMipmap defines if the texture will require mip maps or not
  94486. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  94487. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94488. * @param onLoad defines a callback triggered when the texture has been loaded
  94489. * @param onError defines a callback triggered when an error occurred during the loading session
  94490. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  94491. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  94492. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94493. * @param mimeType defines an optional mime type information
  94494. */
  94495. 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);
  94496. /**
  94497. * Update the url (and optional buffer) of this texture if url was null during construction.
  94498. * @param url the url of the texture
  94499. * @param buffer the buffer of the texture (defaults to null)
  94500. * @param onLoad callback called when the texture is loaded (defaults to null)
  94501. */
  94502. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  94503. /**
  94504. * Finish the loading sequence of a texture flagged as delayed load.
  94505. * @hidden
  94506. */
  94507. delayLoad(): void;
  94508. private _prepareRowForTextureGeneration;
  94509. /**
  94510. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  94511. * @returns the transform matrix of the texture.
  94512. */
  94513. getTextureMatrix(uBase?: number): Matrix;
  94514. /**
  94515. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  94516. * @returns The reflection texture transform
  94517. */
  94518. getReflectionTextureMatrix(): Matrix;
  94519. /**
  94520. * Clones the texture.
  94521. * @returns the cloned texture
  94522. */
  94523. clone(): Texture;
  94524. /**
  94525. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94526. * @returns The JSON representation of the texture
  94527. */
  94528. serialize(): any;
  94529. /**
  94530. * Get the current class name of the texture useful for serialization or dynamic coding.
  94531. * @returns "Texture"
  94532. */
  94533. getClassName(): string;
  94534. /**
  94535. * Dispose the texture and release its associated resources.
  94536. */
  94537. dispose(): void;
  94538. /**
  94539. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  94540. * @param parsedTexture Define the JSON representation of the texture
  94541. * @param scene Define the scene the parsed texture should be instantiated in
  94542. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  94543. * @returns The parsed texture if successful
  94544. */
  94545. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  94546. /**
  94547. * Creates a texture from its base 64 representation.
  94548. * @param data Define the base64 payload without the data: prefix
  94549. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94550. * @param scene Define the scene the texture should belong to
  94551. * @param noMipmap Forces the texture to not create mip map information if true
  94552. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94553. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94554. * @param onLoad define a callback triggered when the texture has been loaded
  94555. * @param onError define a callback triggered when an error occurred during the loading session
  94556. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94557. * @returns the created texture
  94558. */
  94559. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  94560. /**
  94561. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  94562. * @param data Define the base64 payload without the data: prefix
  94563. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94564. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  94565. * @param scene Define the scene the texture should belong to
  94566. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  94567. * @param noMipmap Forces the texture to not create mip map information if true
  94568. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94569. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94570. * @param onLoad define a callback triggered when the texture has been loaded
  94571. * @param onError define a callback triggered when an error occurred during the loading session
  94572. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94573. * @returns the created texture
  94574. */
  94575. 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;
  94576. }
  94577. }
  94578. declare module BABYLON {
  94579. /**
  94580. * PostProcessManager is used to manage one or more post processes or post process pipelines
  94581. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94582. */
  94583. export class PostProcessManager {
  94584. private _scene;
  94585. private _indexBuffer;
  94586. private _vertexBuffers;
  94587. /**
  94588. * Creates a new instance PostProcess
  94589. * @param scene The scene that the post process is associated with.
  94590. */
  94591. constructor(scene: Scene);
  94592. private _prepareBuffers;
  94593. private _buildIndexBuffer;
  94594. /**
  94595. * Rebuilds the vertex buffers of the manager.
  94596. * @hidden
  94597. */
  94598. _rebuild(): void;
  94599. /**
  94600. * Prepares a frame to be run through a post process.
  94601. * @param sourceTexture The input texture to the post procesess. (default: null)
  94602. * @param postProcesses An array of post processes to be run. (default: null)
  94603. * @returns True if the post processes were able to be run.
  94604. * @hidden
  94605. */
  94606. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  94607. /**
  94608. * Manually render a set of post processes to a texture.
  94609. * @param postProcesses An array of post processes to be run.
  94610. * @param targetTexture The target texture to render to.
  94611. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  94612. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  94613. * @param lodLevel defines which lod of the texture to render to
  94614. */
  94615. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  94616. /**
  94617. * Finalize the result of the output of the postprocesses.
  94618. * @param doNotPresent If true the result will not be displayed to the screen.
  94619. * @param targetTexture The target texture to render to.
  94620. * @param faceIndex The index of the face to bind the target texture to.
  94621. * @param postProcesses The array of post processes to render.
  94622. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  94623. * @hidden
  94624. */
  94625. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  94626. /**
  94627. * Disposes of the post process manager.
  94628. */
  94629. dispose(): void;
  94630. }
  94631. }
  94632. declare module BABYLON {
  94633. /**
  94634. * This Helps creating a texture that will be created from a camera in your scene.
  94635. * It is basically a dynamic texture that could be used to create special effects for instance.
  94636. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94637. */
  94638. export class RenderTargetTexture extends Texture {
  94639. isCube: boolean;
  94640. /**
  94641. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94642. */
  94643. static readonly REFRESHRATE_RENDER_ONCE: number;
  94644. /**
  94645. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94646. */
  94647. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94648. /**
  94649. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94650. * the central point of your effect and can save a lot of performances.
  94651. */
  94652. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94653. /**
  94654. * Use this predicate to dynamically define the list of mesh you want to render.
  94655. * If set, the renderList property will be overwritten.
  94656. */
  94657. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94658. private _renderList;
  94659. /**
  94660. * Use this list to define the list of mesh you want to render.
  94661. */
  94662. get renderList(): Nullable<Array<AbstractMesh>>;
  94663. set renderList(value: Nullable<Array<AbstractMesh>>);
  94664. /**
  94665. * Use this function to overload the renderList array at rendering time.
  94666. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94667. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94668. * the cube (if the RTT is a cube, else layerOrFace=0).
  94669. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94670. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94671. * hold dummy elements!
  94672. */
  94673. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94674. private _hookArray;
  94675. /**
  94676. * Define if particles should be rendered in your texture.
  94677. */
  94678. renderParticles: boolean;
  94679. /**
  94680. * Define if sprites should be rendered in your texture.
  94681. */
  94682. renderSprites: boolean;
  94683. /**
  94684. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94685. */
  94686. coordinatesMode: number;
  94687. /**
  94688. * Define the camera used to render the texture.
  94689. */
  94690. activeCamera: Nullable<Camera>;
  94691. /**
  94692. * Override the mesh isReady function with your own one.
  94693. */
  94694. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  94695. /**
  94696. * Override the render function of the texture with your own one.
  94697. */
  94698. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94699. /**
  94700. * Define if camera post processes should be use while rendering the texture.
  94701. */
  94702. useCameraPostProcesses: boolean;
  94703. /**
  94704. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94705. */
  94706. ignoreCameraViewport: boolean;
  94707. private _postProcessManager;
  94708. private _postProcesses;
  94709. private _resizeObserver;
  94710. /**
  94711. * An event triggered when the texture is unbind.
  94712. */
  94713. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94714. /**
  94715. * An event triggered when the texture is unbind.
  94716. */
  94717. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94718. private _onAfterUnbindObserver;
  94719. /**
  94720. * Set a after unbind callback in the texture.
  94721. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94722. */
  94723. set onAfterUnbind(callback: () => void);
  94724. /**
  94725. * An event triggered before rendering the texture
  94726. */
  94727. onBeforeRenderObservable: Observable<number>;
  94728. private _onBeforeRenderObserver;
  94729. /**
  94730. * Set a before render callback in the texture.
  94731. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94732. */
  94733. set onBeforeRender(callback: (faceIndex: number) => void);
  94734. /**
  94735. * An event triggered after rendering the texture
  94736. */
  94737. onAfterRenderObservable: Observable<number>;
  94738. private _onAfterRenderObserver;
  94739. /**
  94740. * Set a after render callback in the texture.
  94741. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94742. */
  94743. set onAfterRender(callback: (faceIndex: number) => void);
  94744. /**
  94745. * An event triggered after the texture clear
  94746. */
  94747. onClearObservable: Observable<Engine>;
  94748. private _onClearObserver;
  94749. /**
  94750. * Set a clear callback in the texture.
  94751. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94752. */
  94753. set onClear(callback: (Engine: Engine) => void);
  94754. /**
  94755. * An event triggered when the texture is resized.
  94756. */
  94757. onResizeObservable: Observable<RenderTargetTexture>;
  94758. /**
  94759. * Define the clear color of the Render Target if it should be different from the scene.
  94760. */
  94761. clearColor: Color4;
  94762. protected _size: number | {
  94763. width: number;
  94764. height: number;
  94765. layers?: number;
  94766. };
  94767. protected _initialSizeParameter: number | {
  94768. width: number;
  94769. height: number;
  94770. } | {
  94771. ratio: number;
  94772. };
  94773. protected _sizeRatio: Nullable<number>;
  94774. /** @hidden */
  94775. _generateMipMaps: boolean;
  94776. protected _renderingManager: RenderingManager;
  94777. /** @hidden */
  94778. _waitingRenderList: string[];
  94779. protected _doNotChangeAspectRatio: boolean;
  94780. protected _currentRefreshId: number;
  94781. protected _refreshRate: number;
  94782. protected _textureMatrix: Matrix;
  94783. protected _samples: number;
  94784. protected _renderTargetOptions: RenderTargetCreationOptions;
  94785. /**
  94786. * Gets render target creation options that were used.
  94787. */
  94788. get renderTargetOptions(): RenderTargetCreationOptions;
  94789. protected _engine: Engine;
  94790. protected _onRatioRescale(): void;
  94791. /**
  94792. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  94793. * It must define where the camera used to render the texture is set
  94794. */
  94795. boundingBoxPosition: Vector3;
  94796. private _boundingBoxSize;
  94797. /**
  94798. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  94799. * When defined, the cubemap will switch to local mode
  94800. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  94801. * @example https://www.babylonjs-playground.com/#RNASML
  94802. */
  94803. set boundingBoxSize(value: Vector3);
  94804. get boundingBoxSize(): Vector3;
  94805. /**
  94806. * In case the RTT has been created with a depth texture, get the associated
  94807. * depth texture.
  94808. * Otherwise, return null.
  94809. */
  94810. get depthStencilTexture(): Nullable<InternalTexture>;
  94811. /**
  94812. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  94813. * or used a shadow, depth texture...
  94814. * @param name The friendly name of the texture
  94815. * @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)
  94816. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  94817. * @param generateMipMaps True if mip maps need to be generated after render.
  94818. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  94819. * @param type The type of the buffer in the RTT (int, half float, float...)
  94820. * @param isCube True if a cube texture needs to be created
  94821. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  94822. * @param generateDepthBuffer True to generate a depth buffer
  94823. * @param generateStencilBuffer True to generate a stencil buffer
  94824. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  94825. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  94826. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94827. */
  94828. constructor(name: string, size: number | {
  94829. width: number;
  94830. height: number;
  94831. layers?: number;
  94832. } | {
  94833. ratio: number;
  94834. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  94835. /**
  94836. * Creates a depth stencil texture.
  94837. * This is only available in WebGL 2 or with the depth texture extension available.
  94838. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  94839. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  94840. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  94841. */
  94842. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  94843. private _processSizeParameter;
  94844. /**
  94845. * Define the number of samples to use in case of MSAA.
  94846. * It defaults to one meaning no MSAA has been enabled.
  94847. */
  94848. get samples(): number;
  94849. set samples(value: number);
  94850. /**
  94851. * Resets the refresh counter of the texture and start bak from scratch.
  94852. * Could be useful to regenerate the texture if it is setup to render only once.
  94853. */
  94854. resetRefreshCounter(): void;
  94855. /**
  94856. * Define the refresh rate of the texture or the rendering frequency.
  94857. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  94858. */
  94859. get refreshRate(): number;
  94860. set refreshRate(value: number);
  94861. /**
  94862. * Adds a post process to the render target rendering passes.
  94863. * @param postProcess define the post process to add
  94864. */
  94865. addPostProcess(postProcess: PostProcess): void;
  94866. /**
  94867. * Clear all the post processes attached to the render target
  94868. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  94869. */
  94870. clearPostProcesses(dispose?: boolean): void;
  94871. /**
  94872. * Remove one of the post process from the list of attached post processes to the texture
  94873. * @param postProcess define the post process to remove from the list
  94874. */
  94875. removePostProcess(postProcess: PostProcess): void;
  94876. /** @hidden */
  94877. _shouldRender(): boolean;
  94878. /**
  94879. * Gets the actual render size of the texture.
  94880. * @returns the width of the render size
  94881. */
  94882. getRenderSize(): number;
  94883. /**
  94884. * Gets the actual render width of the texture.
  94885. * @returns the width of the render size
  94886. */
  94887. getRenderWidth(): number;
  94888. /**
  94889. * Gets the actual render height of the texture.
  94890. * @returns the height of the render size
  94891. */
  94892. getRenderHeight(): number;
  94893. /**
  94894. * Gets the actual number of layers of the texture.
  94895. * @returns the number of layers
  94896. */
  94897. getRenderLayers(): number;
  94898. /**
  94899. * Get if the texture can be rescaled or not.
  94900. */
  94901. get canRescale(): boolean;
  94902. /**
  94903. * Resize the texture using a ratio.
  94904. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  94905. */
  94906. scale(ratio: number): void;
  94907. /**
  94908. * Get the texture reflection matrix used to rotate/transform the reflection.
  94909. * @returns the reflection matrix
  94910. */
  94911. getReflectionTextureMatrix(): Matrix;
  94912. /**
  94913. * Resize the texture to a new desired size.
  94914. * Be carrefull as it will recreate all the data in the new texture.
  94915. * @param size Define the new size. It can be:
  94916. * - a number for squared texture,
  94917. * - an object containing { width: number, height: number }
  94918. * - or an object containing a ratio { ratio: number }
  94919. */
  94920. resize(size: number | {
  94921. width: number;
  94922. height: number;
  94923. } | {
  94924. ratio: number;
  94925. }): void;
  94926. private _defaultRenderListPrepared;
  94927. /**
  94928. * Renders all the objects from the render list into the texture.
  94929. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  94930. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  94931. */
  94932. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94933. private _bestReflectionRenderTargetDimension;
  94934. private _prepareRenderingManager;
  94935. /**
  94936. * @hidden
  94937. * @param faceIndex face index to bind to if this is a cubetexture
  94938. * @param layer defines the index of the texture to bind in the array
  94939. */
  94940. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94941. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94942. private renderToTarget;
  94943. /**
  94944. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94945. * This allowed control for front to back rendering or reversly depending of the special needs.
  94946. *
  94947. * @param renderingGroupId The rendering group id corresponding to its index
  94948. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94949. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94950. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94951. */
  94952. 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;
  94953. /**
  94954. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94955. *
  94956. * @param renderingGroupId The rendering group id corresponding to its index
  94957. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94958. */
  94959. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94960. /**
  94961. * Clones the texture.
  94962. * @returns the cloned texture
  94963. */
  94964. clone(): RenderTargetTexture;
  94965. /**
  94966. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94967. * @returns The JSON representation of the texture
  94968. */
  94969. serialize(): any;
  94970. /**
  94971. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94972. */
  94973. disposeFramebufferObjects(): void;
  94974. /**
  94975. * Dispose the texture and release its associated resources.
  94976. */
  94977. dispose(): void;
  94978. /** @hidden */
  94979. _rebuild(): void;
  94980. /**
  94981. * Clear the info related to rendering groups preventing retention point in material dispose.
  94982. */
  94983. freeRenderingGroups(): void;
  94984. /**
  94985. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94986. * @returns the view count
  94987. */
  94988. getViewCount(): number;
  94989. }
  94990. }
  94991. declare module BABYLON {
  94992. /**
  94993. * Options for compiling materials.
  94994. */
  94995. export interface IMaterialCompilationOptions {
  94996. /**
  94997. * Defines whether clip planes are enabled.
  94998. */
  94999. clipPlane: boolean;
  95000. /**
  95001. * Defines whether instances are enabled.
  95002. */
  95003. useInstances: boolean;
  95004. }
  95005. /**
  95006. * Base class for the main features of a material in Babylon.js
  95007. */
  95008. export class Material implements IAnimatable {
  95009. /**
  95010. * Returns the triangle fill mode
  95011. */
  95012. static readonly TriangleFillMode: number;
  95013. /**
  95014. * Returns the wireframe mode
  95015. */
  95016. static readonly WireFrameFillMode: number;
  95017. /**
  95018. * Returns the point fill mode
  95019. */
  95020. static readonly PointFillMode: number;
  95021. /**
  95022. * Returns the point list draw mode
  95023. */
  95024. static readonly PointListDrawMode: number;
  95025. /**
  95026. * Returns the line list draw mode
  95027. */
  95028. static readonly LineListDrawMode: number;
  95029. /**
  95030. * Returns the line loop draw mode
  95031. */
  95032. static readonly LineLoopDrawMode: number;
  95033. /**
  95034. * Returns the line strip draw mode
  95035. */
  95036. static readonly LineStripDrawMode: number;
  95037. /**
  95038. * Returns the triangle strip draw mode
  95039. */
  95040. static readonly TriangleStripDrawMode: number;
  95041. /**
  95042. * Returns the triangle fan draw mode
  95043. */
  95044. static readonly TriangleFanDrawMode: number;
  95045. /**
  95046. * Stores the clock-wise side orientation
  95047. */
  95048. static readonly ClockWiseSideOrientation: number;
  95049. /**
  95050. * Stores the counter clock-wise side orientation
  95051. */
  95052. static readonly CounterClockWiseSideOrientation: number;
  95053. /**
  95054. * The dirty texture flag value
  95055. */
  95056. static readonly TextureDirtyFlag: number;
  95057. /**
  95058. * The dirty light flag value
  95059. */
  95060. static readonly LightDirtyFlag: number;
  95061. /**
  95062. * The dirty fresnel flag value
  95063. */
  95064. static readonly FresnelDirtyFlag: number;
  95065. /**
  95066. * The dirty attribute flag value
  95067. */
  95068. static readonly AttributesDirtyFlag: number;
  95069. /**
  95070. * The dirty misc flag value
  95071. */
  95072. static readonly MiscDirtyFlag: number;
  95073. /**
  95074. * The all dirty flag value
  95075. */
  95076. static readonly AllDirtyFlag: number;
  95077. /**
  95078. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  95079. */
  95080. static readonly MATERIAL_OPAQUE: number;
  95081. /**
  95082. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  95083. */
  95084. static readonly MATERIAL_ALPHATEST: number;
  95085. /**
  95086. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95087. */
  95088. static readonly MATERIAL_ALPHABLEND: number;
  95089. /**
  95090. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95091. * They are also discarded below the alpha cutoff threshold to improve performances.
  95092. */
  95093. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  95094. /**
  95095. * The ID of the material
  95096. */
  95097. id: string;
  95098. /**
  95099. * Gets or sets the unique id of the material
  95100. */
  95101. uniqueId: number;
  95102. /**
  95103. * The name of the material
  95104. */
  95105. name: string;
  95106. /**
  95107. * Gets or sets user defined metadata
  95108. */
  95109. metadata: any;
  95110. /**
  95111. * For internal use only. Please do not use.
  95112. */
  95113. reservedDataStore: any;
  95114. /**
  95115. * Specifies if the ready state should be checked on each call
  95116. */
  95117. checkReadyOnEveryCall: boolean;
  95118. /**
  95119. * Specifies if the ready state should be checked once
  95120. */
  95121. checkReadyOnlyOnce: boolean;
  95122. /**
  95123. * The state of the material
  95124. */
  95125. state: string;
  95126. /**
  95127. * The alpha value of the material
  95128. */
  95129. protected _alpha: number;
  95130. /**
  95131. * List of inspectable custom properties (used by the Inspector)
  95132. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95133. */
  95134. inspectableCustomProperties: IInspectable[];
  95135. /**
  95136. * Sets the alpha value of the material
  95137. */
  95138. set alpha(value: number);
  95139. /**
  95140. * Gets the alpha value of the material
  95141. */
  95142. get alpha(): number;
  95143. /**
  95144. * Specifies if back face culling is enabled
  95145. */
  95146. protected _backFaceCulling: boolean;
  95147. /**
  95148. * Sets the back-face culling state
  95149. */
  95150. set backFaceCulling(value: boolean);
  95151. /**
  95152. * Gets the back-face culling state
  95153. */
  95154. get backFaceCulling(): boolean;
  95155. /**
  95156. * Stores the value for side orientation
  95157. */
  95158. sideOrientation: number;
  95159. /**
  95160. * Callback triggered when the material is compiled
  95161. */
  95162. onCompiled: Nullable<(effect: Effect) => void>;
  95163. /**
  95164. * Callback triggered when an error occurs
  95165. */
  95166. onError: Nullable<(effect: Effect, errors: string) => void>;
  95167. /**
  95168. * Callback triggered to get the render target textures
  95169. */
  95170. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  95171. /**
  95172. * Gets a boolean indicating that current material needs to register RTT
  95173. */
  95174. get hasRenderTargetTextures(): boolean;
  95175. /**
  95176. * Specifies if the material should be serialized
  95177. */
  95178. doNotSerialize: boolean;
  95179. /**
  95180. * @hidden
  95181. */
  95182. _storeEffectOnSubMeshes: boolean;
  95183. /**
  95184. * Stores the animations for the material
  95185. */
  95186. animations: Nullable<Array<Animation>>;
  95187. /**
  95188. * An event triggered when the material is disposed
  95189. */
  95190. onDisposeObservable: Observable<Material>;
  95191. /**
  95192. * An observer which watches for dispose events
  95193. */
  95194. private _onDisposeObserver;
  95195. private _onUnBindObservable;
  95196. /**
  95197. * Called during a dispose event
  95198. */
  95199. set onDispose(callback: () => void);
  95200. private _onBindObservable;
  95201. /**
  95202. * An event triggered when the material is bound
  95203. */
  95204. get onBindObservable(): Observable<AbstractMesh>;
  95205. /**
  95206. * An observer which watches for bind events
  95207. */
  95208. private _onBindObserver;
  95209. /**
  95210. * Called during a bind event
  95211. */
  95212. set onBind(callback: (Mesh: AbstractMesh) => void);
  95213. /**
  95214. * An event triggered when the material is unbound
  95215. */
  95216. get onUnBindObservable(): Observable<Material>;
  95217. /**
  95218. * Stores the value of the alpha mode
  95219. */
  95220. private _alphaMode;
  95221. /**
  95222. * Sets the value of the alpha mode.
  95223. *
  95224. * | Value | Type | Description |
  95225. * | --- | --- | --- |
  95226. * | 0 | ALPHA_DISABLE | |
  95227. * | 1 | ALPHA_ADD | |
  95228. * | 2 | ALPHA_COMBINE | |
  95229. * | 3 | ALPHA_SUBTRACT | |
  95230. * | 4 | ALPHA_MULTIPLY | |
  95231. * | 5 | ALPHA_MAXIMIZED | |
  95232. * | 6 | ALPHA_ONEONE | |
  95233. * | 7 | ALPHA_PREMULTIPLIED | |
  95234. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  95235. * | 9 | ALPHA_INTERPOLATE | |
  95236. * | 10 | ALPHA_SCREENMODE | |
  95237. *
  95238. */
  95239. set alphaMode(value: number);
  95240. /**
  95241. * Gets the value of the alpha mode
  95242. */
  95243. get alphaMode(): number;
  95244. /**
  95245. * Stores the state of the need depth pre-pass value
  95246. */
  95247. private _needDepthPrePass;
  95248. /**
  95249. * Sets the need depth pre-pass value
  95250. */
  95251. set needDepthPrePass(value: boolean);
  95252. /**
  95253. * Gets the depth pre-pass value
  95254. */
  95255. get needDepthPrePass(): boolean;
  95256. /**
  95257. * Specifies if depth writing should be disabled
  95258. */
  95259. disableDepthWrite: boolean;
  95260. /**
  95261. * Specifies if depth writing should be forced
  95262. */
  95263. forceDepthWrite: boolean;
  95264. /**
  95265. * Specifies the depth function that should be used. 0 means the default engine function
  95266. */
  95267. depthFunction: number;
  95268. /**
  95269. * Specifies if there should be a separate pass for culling
  95270. */
  95271. separateCullingPass: boolean;
  95272. /**
  95273. * Stores the state specifing if fog should be enabled
  95274. */
  95275. private _fogEnabled;
  95276. /**
  95277. * Sets the state for enabling fog
  95278. */
  95279. set fogEnabled(value: boolean);
  95280. /**
  95281. * Gets the value of the fog enabled state
  95282. */
  95283. get fogEnabled(): boolean;
  95284. /**
  95285. * Stores the size of points
  95286. */
  95287. pointSize: number;
  95288. /**
  95289. * Stores the z offset value
  95290. */
  95291. zOffset: number;
  95292. /**
  95293. * Gets a value specifying if wireframe mode is enabled
  95294. */
  95295. get wireframe(): boolean;
  95296. /**
  95297. * Sets the state of wireframe mode
  95298. */
  95299. set wireframe(value: boolean);
  95300. /**
  95301. * Gets the value specifying if point clouds are enabled
  95302. */
  95303. get pointsCloud(): boolean;
  95304. /**
  95305. * Sets the state of point cloud mode
  95306. */
  95307. set pointsCloud(value: boolean);
  95308. /**
  95309. * Gets the material fill mode
  95310. */
  95311. get fillMode(): number;
  95312. /**
  95313. * Sets the material fill mode
  95314. */
  95315. set fillMode(value: number);
  95316. /**
  95317. * @hidden
  95318. * Stores the effects for the material
  95319. */
  95320. _effect: Nullable<Effect>;
  95321. /**
  95322. * Specifies if uniform buffers should be used
  95323. */
  95324. private _useUBO;
  95325. /**
  95326. * Stores a reference to the scene
  95327. */
  95328. private _scene;
  95329. /**
  95330. * Stores the fill mode state
  95331. */
  95332. private _fillMode;
  95333. /**
  95334. * Specifies if the depth write state should be cached
  95335. */
  95336. private _cachedDepthWriteState;
  95337. /**
  95338. * Specifies if the depth function state should be cached
  95339. */
  95340. private _cachedDepthFunctionState;
  95341. /**
  95342. * Stores the uniform buffer
  95343. */
  95344. protected _uniformBuffer: UniformBuffer;
  95345. /** @hidden */
  95346. _indexInSceneMaterialArray: number;
  95347. /** @hidden */
  95348. meshMap: Nullable<{
  95349. [id: string]: AbstractMesh | undefined;
  95350. }>;
  95351. /**
  95352. * Creates a material instance
  95353. * @param name defines the name of the material
  95354. * @param scene defines the scene to reference
  95355. * @param doNotAdd specifies if the material should be added to the scene
  95356. */
  95357. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  95358. /**
  95359. * Returns a string representation of the current material
  95360. * @param fullDetails defines a boolean indicating which levels of logging is desired
  95361. * @returns a string with material information
  95362. */
  95363. toString(fullDetails?: boolean): string;
  95364. /**
  95365. * Gets the class name of the material
  95366. * @returns a string with the class name of the material
  95367. */
  95368. getClassName(): string;
  95369. /**
  95370. * Specifies if updates for the material been locked
  95371. */
  95372. get isFrozen(): boolean;
  95373. /**
  95374. * Locks updates for the material
  95375. */
  95376. freeze(): void;
  95377. /**
  95378. * Unlocks updates for the material
  95379. */
  95380. unfreeze(): void;
  95381. /**
  95382. * Specifies if the material is ready to be used
  95383. * @param mesh defines the mesh to check
  95384. * @param useInstances specifies if instances should be used
  95385. * @returns a boolean indicating if the material is ready to be used
  95386. */
  95387. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95388. /**
  95389. * Specifies that the submesh is ready to be used
  95390. * @param mesh defines the mesh to check
  95391. * @param subMesh defines which submesh to check
  95392. * @param useInstances specifies that instances should be used
  95393. * @returns a boolean indicating that the submesh is ready or not
  95394. */
  95395. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95396. /**
  95397. * Returns the material effect
  95398. * @returns the effect associated with the material
  95399. */
  95400. getEffect(): Nullable<Effect>;
  95401. /**
  95402. * Returns the current scene
  95403. * @returns a Scene
  95404. */
  95405. getScene(): Scene;
  95406. /**
  95407. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  95408. */
  95409. protected _forceAlphaTest: boolean;
  95410. /**
  95411. * The transparency mode of the material.
  95412. */
  95413. protected _transparencyMode: Nullable<number>;
  95414. /**
  95415. * Gets the current transparency mode.
  95416. */
  95417. get transparencyMode(): Nullable<number>;
  95418. /**
  95419. * Sets the transparency mode of the material.
  95420. *
  95421. * | Value | Type | Description |
  95422. * | ----- | ----------------------------------- | ----------- |
  95423. * | 0 | OPAQUE | |
  95424. * | 1 | ALPHATEST | |
  95425. * | 2 | ALPHABLEND | |
  95426. * | 3 | ALPHATESTANDBLEND | |
  95427. *
  95428. */
  95429. set transparencyMode(value: Nullable<number>);
  95430. /**
  95431. * Returns true if alpha blending should be disabled.
  95432. */
  95433. protected get _disableAlphaBlending(): boolean;
  95434. /**
  95435. * Specifies whether or not this material should be rendered in alpha blend mode.
  95436. * @returns a boolean specifying if alpha blending is needed
  95437. */
  95438. needAlphaBlending(): boolean;
  95439. /**
  95440. * Specifies if the mesh will require alpha blending
  95441. * @param mesh defines the mesh to check
  95442. * @returns a boolean specifying if alpha blending is needed for the mesh
  95443. */
  95444. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  95445. /**
  95446. * Specifies whether or not this material should be rendered in alpha test mode.
  95447. * @returns a boolean specifying if an alpha test is needed.
  95448. */
  95449. needAlphaTesting(): boolean;
  95450. /**
  95451. * Specifies if material alpha testing should be turned on for the mesh
  95452. * @param mesh defines the mesh to check
  95453. */
  95454. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  95455. /**
  95456. * Gets the texture used for the alpha test
  95457. * @returns the texture to use for alpha testing
  95458. */
  95459. getAlphaTestTexture(): Nullable<BaseTexture>;
  95460. /**
  95461. * Marks the material to indicate that it needs to be re-calculated
  95462. */
  95463. markDirty(): void;
  95464. /** @hidden */
  95465. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  95466. /**
  95467. * Binds the material to the mesh
  95468. * @param world defines the world transformation matrix
  95469. * @param mesh defines the mesh to bind the material to
  95470. */
  95471. bind(world: Matrix, mesh?: Mesh): void;
  95472. /**
  95473. * Binds the submesh to the material
  95474. * @param world defines the world transformation matrix
  95475. * @param mesh defines the mesh containing the submesh
  95476. * @param subMesh defines the submesh to bind the material to
  95477. */
  95478. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95479. /**
  95480. * Binds the world matrix to the material
  95481. * @param world defines the world transformation matrix
  95482. */
  95483. bindOnlyWorldMatrix(world: Matrix): void;
  95484. /**
  95485. * Binds the scene's uniform buffer to the effect.
  95486. * @param effect defines the effect to bind to the scene uniform buffer
  95487. * @param sceneUbo defines the uniform buffer storing scene data
  95488. */
  95489. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  95490. /**
  95491. * Binds the view matrix to the effect
  95492. * @param effect defines the effect to bind the view matrix to
  95493. */
  95494. bindView(effect: Effect): void;
  95495. /**
  95496. * Binds the view projection matrix to the effect
  95497. * @param effect defines the effect to bind the view projection matrix to
  95498. */
  95499. bindViewProjection(effect: Effect): void;
  95500. /**
  95501. * Processes to execute after binding the material to a mesh
  95502. * @param mesh defines the rendered mesh
  95503. */
  95504. protected _afterBind(mesh?: Mesh): void;
  95505. /**
  95506. * Unbinds the material from the mesh
  95507. */
  95508. unbind(): void;
  95509. /**
  95510. * Gets the active textures from the material
  95511. * @returns an array of textures
  95512. */
  95513. getActiveTextures(): BaseTexture[];
  95514. /**
  95515. * Specifies if the material uses a texture
  95516. * @param texture defines the texture to check against the material
  95517. * @returns a boolean specifying if the material uses the texture
  95518. */
  95519. hasTexture(texture: BaseTexture): boolean;
  95520. /**
  95521. * Makes a duplicate of the material, and gives it a new name
  95522. * @param name defines the new name for the duplicated material
  95523. * @returns the cloned material
  95524. */
  95525. clone(name: string): Nullable<Material>;
  95526. /**
  95527. * Gets the meshes bound to the material
  95528. * @returns an array of meshes bound to the material
  95529. */
  95530. getBindedMeshes(): AbstractMesh[];
  95531. /**
  95532. * Force shader compilation
  95533. * @param mesh defines the mesh associated with this material
  95534. * @param onCompiled defines a function to execute once the material is compiled
  95535. * @param options defines the options to configure the compilation
  95536. * @param onError defines a function to execute if the material fails compiling
  95537. */
  95538. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  95539. /**
  95540. * Force shader compilation
  95541. * @param mesh defines the mesh that will use this material
  95542. * @param options defines additional options for compiling the shaders
  95543. * @returns a promise that resolves when the compilation completes
  95544. */
  95545. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  95546. private static readonly _AllDirtyCallBack;
  95547. private static readonly _ImageProcessingDirtyCallBack;
  95548. private static readonly _TextureDirtyCallBack;
  95549. private static readonly _FresnelDirtyCallBack;
  95550. private static readonly _MiscDirtyCallBack;
  95551. private static readonly _LightsDirtyCallBack;
  95552. private static readonly _AttributeDirtyCallBack;
  95553. private static _FresnelAndMiscDirtyCallBack;
  95554. private static _TextureAndMiscDirtyCallBack;
  95555. private static readonly _DirtyCallbackArray;
  95556. private static readonly _RunDirtyCallBacks;
  95557. /**
  95558. * Marks a define in the material to indicate that it needs to be re-computed
  95559. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  95560. */
  95561. markAsDirty(flag: number): void;
  95562. /**
  95563. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  95564. * @param func defines a function which checks material defines against the submeshes
  95565. */
  95566. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  95567. /**
  95568. * Indicates that we need to re-calculated for all submeshes
  95569. */
  95570. protected _markAllSubMeshesAsAllDirty(): void;
  95571. /**
  95572. * Indicates that image processing needs to be re-calculated for all submeshes
  95573. */
  95574. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  95575. /**
  95576. * Indicates that textures need to be re-calculated for all submeshes
  95577. */
  95578. protected _markAllSubMeshesAsTexturesDirty(): void;
  95579. /**
  95580. * Indicates that fresnel needs to be re-calculated for all submeshes
  95581. */
  95582. protected _markAllSubMeshesAsFresnelDirty(): void;
  95583. /**
  95584. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  95585. */
  95586. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  95587. /**
  95588. * Indicates that lights need to be re-calculated for all submeshes
  95589. */
  95590. protected _markAllSubMeshesAsLightsDirty(): void;
  95591. /**
  95592. * Indicates that attributes need to be re-calculated for all submeshes
  95593. */
  95594. protected _markAllSubMeshesAsAttributesDirty(): void;
  95595. /**
  95596. * Indicates that misc needs to be re-calculated for all submeshes
  95597. */
  95598. protected _markAllSubMeshesAsMiscDirty(): void;
  95599. /**
  95600. * Indicates that textures and misc need to be re-calculated for all submeshes
  95601. */
  95602. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  95603. /**
  95604. * Disposes the material
  95605. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95606. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95607. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95608. */
  95609. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95610. /** @hidden */
  95611. private releaseVertexArrayObject;
  95612. /**
  95613. * Serializes this material
  95614. * @returns the serialized material object
  95615. */
  95616. serialize(): any;
  95617. /**
  95618. * Creates a material from parsed material data
  95619. * @param parsedMaterial defines parsed material data
  95620. * @param scene defines the hosting scene
  95621. * @param rootUrl defines the root URL to use to load textures
  95622. * @returns a new material
  95623. */
  95624. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  95625. }
  95626. }
  95627. declare module BABYLON {
  95628. /**
  95629. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95630. * separate meshes. This can be use to improve performances.
  95631. * @see http://doc.babylonjs.com/how_to/multi_materials
  95632. */
  95633. export class MultiMaterial extends Material {
  95634. private _subMaterials;
  95635. /**
  95636. * Gets or Sets the list of Materials used within the multi material.
  95637. * They need to be ordered according to the submeshes order in the associated mesh
  95638. */
  95639. get subMaterials(): Nullable<Material>[];
  95640. set subMaterials(value: Nullable<Material>[]);
  95641. /**
  95642. * Function used to align with Node.getChildren()
  95643. * @returns the list of Materials used within the multi material
  95644. */
  95645. getChildren(): Nullable<Material>[];
  95646. /**
  95647. * Instantiates a new Multi Material
  95648. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95649. * separate meshes. This can be use to improve performances.
  95650. * @see http://doc.babylonjs.com/how_to/multi_materials
  95651. * @param name Define the name in the scene
  95652. * @param scene Define the scene the material belongs to
  95653. */
  95654. constructor(name: string, scene: Scene);
  95655. private _hookArray;
  95656. /**
  95657. * Get one of the submaterial by its index in the submaterials array
  95658. * @param index The index to look the sub material at
  95659. * @returns The Material if the index has been defined
  95660. */
  95661. getSubMaterial(index: number): Nullable<Material>;
  95662. /**
  95663. * Get the list of active textures for the whole sub materials list.
  95664. * @returns All the textures that will be used during the rendering
  95665. */
  95666. getActiveTextures(): BaseTexture[];
  95667. /**
  95668. * Gets the current class name of the material e.g. "MultiMaterial"
  95669. * Mainly use in serialization.
  95670. * @returns the class name
  95671. */
  95672. getClassName(): string;
  95673. /**
  95674. * Checks if the material is ready to render the requested sub mesh
  95675. * @param mesh Define the mesh the submesh belongs to
  95676. * @param subMesh Define the sub mesh to look readyness for
  95677. * @param useInstances Define whether or not the material is used with instances
  95678. * @returns true if ready, otherwise false
  95679. */
  95680. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95681. /**
  95682. * Clones the current material and its related sub materials
  95683. * @param name Define the name of the newly cloned material
  95684. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95685. * @returns the cloned material
  95686. */
  95687. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95688. /**
  95689. * Serializes the materials into a JSON representation.
  95690. * @returns the JSON representation
  95691. */
  95692. serialize(): any;
  95693. /**
  95694. * Dispose the material and release its associated resources
  95695. * @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)
  95696. * @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)
  95697. * @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)
  95698. */
  95699. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95700. /**
  95701. * Creates a MultiMaterial from parsed MultiMaterial data.
  95702. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95703. * @param scene defines the hosting scene
  95704. * @returns a new MultiMaterial
  95705. */
  95706. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95707. }
  95708. }
  95709. declare module BABYLON {
  95710. /**
  95711. * Base class for submeshes
  95712. */
  95713. export class BaseSubMesh {
  95714. /** @hidden */
  95715. _materialDefines: Nullable<MaterialDefines>;
  95716. /** @hidden */
  95717. _materialEffect: Nullable<Effect>;
  95718. /**
  95719. * Gets material defines used by the effect associated to the sub mesh
  95720. */
  95721. get materialDefines(): Nullable<MaterialDefines>;
  95722. /**
  95723. * Sets material defines used by the effect associated to the sub mesh
  95724. */
  95725. set materialDefines(defines: Nullable<MaterialDefines>);
  95726. /**
  95727. * Gets associated effect
  95728. */
  95729. get effect(): Nullable<Effect>;
  95730. /**
  95731. * Sets associated effect (effect used to render this submesh)
  95732. * @param effect defines the effect to associate with
  95733. * @param defines defines the set of defines used to compile this effect
  95734. */
  95735. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95736. }
  95737. /**
  95738. * Defines a subdivision inside a mesh
  95739. */
  95740. export class SubMesh extends BaseSubMesh implements ICullable {
  95741. /** the material index to use */
  95742. materialIndex: number;
  95743. /** vertex index start */
  95744. verticesStart: number;
  95745. /** vertices count */
  95746. verticesCount: number;
  95747. /** index start */
  95748. indexStart: number;
  95749. /** indices count */
  95750. indexCount: number;
  95751. /** @hidden */
  95752. _linesIndexCount: number;
  95753. private _mesh;
  95754. private _renderingMesh;
  95755. private _boundingInfo;
  95756. private _linesIndexBuffer;
  95757. /** @hidden */
  95758. _lastColliderWorldVertices: Nullable<Vector3[]>;
  95759. /** @hidden */
  95760. _trianglePlanes: Plane[];
  95761. /** @hidden */
  95762. _lastColliderTransformMatrix: Nullable<Matrix>;
  95763. /** @hidden */
  95764. _renderId: number;
  95765. /** @hidden */
  95766. _alphaIndex: number;
  95767. /** @hidden */
  95768. _distanceToCamera: number;
  95769. /** @hidden */
  95770. _id: number;
  95771. private _currentMaterial;
  95772. /**
  95773. * Add a new submesh to a mesh
  95774. * @param materialIndex defines the material index to use
  95775. * @param verticesStart defines vertex index start
  95776. * @param verticesCount defines vertices count
  95777. * @param indexStart defines index start
  95778. * @param indexCount defines indices count
  95779. * @param mesh defines the parent mesh
  95780. * @param renderingMesh defines an optional rendering mesh
  95781. * @param createBoundingBox defines if bounding box should be created for this submesh
  95782. * @returns the new submesh
  95783. */
  95784. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  95785. /**
  95786. * Creates a new submesh
  95787. * @param materialIndex defines the material index to use
  95788. * @param verticesStart defines vertex index start
  95789. * @param verticesCount defines vertices count
  95790. * @param indexStart defines index start
  95791. * @param indexCount defines indices count
  95792. * @param mesh defines the parent mesh
  95793. * @param renderingMesh defines an optional rendering mesh
  95794. * @param createBoundingBox defines if bounding box should be created for this submesh
  95795. */
  95796. constructor(
  95797. /** the material index to use */
  95798. materialIndex: number,
  95799. /** vertex index start */
  95800. verticesStart: number,
  95801. /** vertices count */
  95802. verticesCount: number,
  95803. /** index start */
  95804. indexStart: number,
  95805. /** indices count */
  95806. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  95807. /**
  95808. * Returns true if this submesh covers the entire parent mesh
  95809. * @ignorenaming
  95810. */
  95811. get IsGlobal(): boolean;
  95812. /**
  95813. * Returns the submesh BoudingInfo object
  95814. * @returns current bounding info (or mesh's one if the submesh is global)
  95815. */
  95816. getBoundingInfo(): BoundingInfo;
  95817. /**
  95818. * Sets the submesh BoundingInfo
  95819. * @param boundingInfo defines the new bounding info to use
  95820. * @returns the SubMesh
  95821. */
  95822. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  95823. /**
  95824. * Returns the mesh of the current submesh
  95825. * @return the parent mesh
  95826. */
  95827. getMesh(): AbstractMesh;
  95828. /**
  95829. * Returns the rendering mesh of the submesh
  95830. * @returns the rendering mesh (could be different from parent mesh)
  95831. */
  95832. getRenderingMesh(): Mesh;
  95833. /**
  95834. * Returns the submesh material
  95835. * @returns null or the current material
  95836. */
  95837. getMaterial(): Nullable<Material>;
  95838. /**
  95839. * Sets a new updated BoundingInfo object to the submesh
  95840. * @param data defines an optional position array to use to determine the bounding info
  95841. * @returns the SubMesh
  95842. */
  95843. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  95844. /** @hidden */
  95845. _checkCollision(collider: Collider): boolean;
  95846. /**
  95847. * Updates the submesh BoundingInfo
  95848. * @param world defines the world matrix to use to update the bounding info
  95849. * @returns the submesh
  95850. */
  95851. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  95852. /**
  95853. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  95854. * @param frustumPlanes defines the frustum planes
  95855. * @returns true if the submesh is intersecting with the frustum
  95856. */
  95857. isInFrustum(frustumPlanes: Plane[]): boolean;
  95858. /**
  95859. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  95860. * @param frustumPlanes defines the frustum planes
  95861. * @returns true if the submesh is inside the frustum
  95862. */
  95863. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95864. /**
  95865. * Renders the submesh
  95866. * @param enableAlphaMode defines if alpha needs to be used
  95867. * @returns the submesh
  95868. */
  95869. render(enableAlphaMode: boolean): SubMesh;
  95870. /**
  95871. * @hidden
  95872. */
  95873. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  95874. /**
  95875. * Checks if the submesh intersects with a ray
  95876. * @param ray defines the ray to test
  95877. * @returns true is the passed ray intersects the submesh bounding box
  95878. */
  95879. canIntersects(ray: Ray): boolean;
  95880. /**
  95881. * Intersects current submesh with a ray
  95882. * @param ray defines the ray to test
  95883. * @param positions defines mesh's positions array
  95884. * @param indices defines mesh's indices array
  95885. * @param fastCheck defines if only bounding info should be used
  95886. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95887. * @returns intersection info or null if no intersection
  95888. */
  95889. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  95890. /** @hidden */
  95891. private _intersectLines;
  95892. /** @hidden */
  95893. private _intersectUnIndexedLines;
  95894. /** @hidden */
  95895. private _intersectTriangles;
  95896. /** @hidden */
  95897. private _intersectUnIndexedTriangles;
  95898. /** @hidden */
  95899. _rebuild(): void;
  95900. /**
  95901. * Creates a new submesh from the passed mesh
  95902. * @param newMesh defines the new hosting mesh
  95903. * @param newRenderingMesh defines an optional rendering mesh
  95904. * @returns the new submesh
  95905. */
  95906. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  95907. /**
  95908. * Release associated resources
  95909. */
  95910. dispose(): void;
  95911. /**
  95912. * Gets the class name
  95913. * @returns the string "SubMesh".
  95914. */
  95915. getClassName(): string;
  95916. /**
  95917. * Creates a new submesh from indices data
  95918. * @param materialIndex the index of the main mesh material
  95919. * @param startIndex the index where to start the copy in the mesh indices array
  95920. * @param indexCount the number of indices to copy then from the startIndex
  95921. * @param mesh the main mesh to create the submesh from
  95922. * @param renderingMesh the optional rendering mesh
  95923. * @returns a new submesh
  95924. */
  95925. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  95926. }
  95927. }
  95928. declare module BABYLON {
  95929. /**
  95930. * Class used to represent data loading progression
  95931. */
  95932. export class SceneLoaderFlags {
  95933. private static _ForceFullSceneLoadingForIncremental;
  95934. private static _ShowLoadingScreen;
  95935. private static _CleanBoneMatrixWeights;
  95936. private static _loggingLevel;
  95937. /**
  95938. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  95939. */
  95940. static get ForceFullSceneLoadingForIncremental(): boolean;
  95941. static set ForceFullSceneLoadingForIncremental(value: boolean);
  95942. /**
  95943. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  95944. */
  95945. static get ShowLoadingScreen(): boolean;
  95946. static set ShowLoadingScreen(value: boolean);
  95947. /**
  95948. * Defines the current logging level (while loading the scene)
  95949. * @ignorenaming
  95950. */
  95951. static get loggingLevel(): number;
  95952. static set loggingLevel(value: number);
  95953. /**
  95954. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  95955. */
  95956. static get CleanBoneMatrixWeights(): boolean;
  95957. static set CleanBoneMatrixWeights(value: boolean);
  95958. }
  95959. }
  95960. declare module BABYLON {
  95961. /**
  95962. * Class used to store geometry data (vertex buffers + index buffer)
  95963. */
  95964. export class Geometry implements IGetSetVerticesData {
  95965. /**
  95966. * Gets or sets the ID of the geometry
  95967. */
  95968. id: string;
  95969. /**
  95970. * Gets or sets the unique ID of the geometry
  95971. */
  95972. uniqueId: number;
  95973. /**
  95974. * Gets the delay loading state of the geometry (none by default which means not delayed)
  95975. */
  95976. delayLoadState: number;
  95977. /**
  95978. * Gets the file containing the data to load when running in delay load state
  95979. */
  95980. delayLoadingFile: Nullable<string>;
  95981. /**
  95982. * Callback called when the geometry is updated
  95983. */
  95984. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95985. private _scene;
  95986. private _engine;
  95987. private _meshes;
  95988. private _totalVertices;
  95989. /** @hidden */
  95990. _indices: IndicesArray;
  95991. /** @hidden */
  95992. _vertexBuffers: {
  95993. [key: string]: VertexBuffer;
  95994. };
  95995. private _isDisposed;
  95996. private _extend;
  95997. private _boundingBias;
  95998. /** @hidden */
  95999. _delayInfo: Array<string>;
  96000. private _indexBuffer;
  96001. private _indexBufferIsUpdatable;
  96002. /** @hidden */
  96003. _boundingInfo: Nullable<BoundingInfo>;
  96004. /** @hidden */
  96005. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  96006. /** @hidden */
  96007. _softwareSkinningFrameId: number;
  96008. private _vertexArrayObjects;
  96009. private _updatable;
  96010. /** @hidden */
  96011. _positions: Nullable<Vector3[]>;
  96012. /**
  96013. * 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
  96014. */
  96015. get boundingBias(): Vector2;
  96016. /**
  96017. * 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
  96018. */
  96019. set boundingBias(value: Vector2);
  96020. /**
  96021. * Static function used to attach a new empty geometry to a mesh
  96022. * @param mesh defines the mesh to attach the geometry to
  96023. * @returns the new Geometry
  96024. */
  96025. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  96026. /**
  96027. * Creates a new geometry
  96028. * @param id defines the unique ID
  96029. * @param scene defines the hosting scene
  96030. * @param vertexData defines the VertexData used to get geometry data
  96031. * @param updatable defines if geometry must be updatable (false by default)
  96032. * @param mesh defines the mesh that will be associated with the geometry
  96033. */
  96034. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  96035. /**
  96036. * Gets the current extend of the geometry
  96037. */
  96038. get extend(): {
  96039. minimum: Vector3;
  96040. maximum: Vector3;
  96041. };
  96042. /**
  96043. * Gets the hosting scene
  96044. * @returns the hosting Scene
  96045. */
  96046. getScene(): Scene;
  96047. /**
  96048. * Gets the hosting engine
  96049. * @returns the hosting Engine
  96050. */
  96051. getEngine(): Engine;
  96052. /**
  96053. * Defines if the geometry is ready to use
  96054. * @returns true if the geometry is ready to be used
  96055. */
  96056. isReady(): boolean;
  96057. /**
  96058. * Gets a value indicating that the geometry should not be serialized
  96059. */
  96060. get doNotSerialize(): boolean;
  96061. /** @hidden */
  96062. _rebuild(): void;
  96063. /**
  96064. * Affects all geometry data in one call
  96065. * @param vertexData defines the geometry data
  96066. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  96067. */
  96068. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  96069. /**
  96070. * Set specific vertex data
  96071. * @param kind defines the data kind (Position, normal, etc...)
  96072. * @param data defines the vertex data to use
  96073. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96074. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96075. */
  96076. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  96077. /**
  96078. * Removes a specific vertex data
  96079. * @param kind defines the data kind (Position, normal, etc...)
  96080. */
  96081. removeVerticesData(kind: string): void;
  96082. /**
  96083. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  96084. * @param buffer defines the vertex buffer to use
  96085. * @param totalVertices defines the total number of vertices for position kind (could be null)
  96086. */
  96087. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  96088. /**
  96089. * Update a specific vertex buffer
  96090. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  96091. * It will do nothing if the buffer is not updatable
  96092. * @param kind defines the data kind (Position, normal, etc...)
  96093. * @param data defines the data to use
  96094. * @param offset defines the offset in the target buffer where to store the data
  96095. * @param useBytes set to true if the offset is in bytes
  96096. */
  96097. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  96098. /**
  96099. * Update a specific vertex buffer
  96100. * This function will create a new buffer if the current one is not updatable
  96101. * @param kind defines the data kind (Position, normal, etc...)
  96102. * @param data defines the data to use
  96103. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  96104. */
  96105. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  96106. private _updateBoundingInfo;
  96107. /** @hidden */
  96108. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  96109. /**
  96110. * Gets total number of vertices
  96111. * @returns the total number of vertices
  96112. */
  96113. getTotalVertices(): number;
  96114. /**
  96115. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96116. * @param kind defines the data kind (Position, normal, etc...)
  96117. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96118. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96119. * @returns a float array containing vertex data
  96120. */
  96121. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96122. /**
  96123. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  96124. * @param kind defines the data kind (Position, normal, etc...)
  96125. * @returns true if the vertex buffer with the specified kind is updatable
  96126. */
  96127. isVertexBufferUpdatable(kind: string): boolean;
  96128. /**
  96129. * Gets a specific vertex buffer
  96130. * @param kind defines the data kind (Position, normal, etc...)
  96131. * @returns a VertexBuffer
  96132. */
  96133. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96134. /**
  96135. * Returns all vertex buffers
  96136. * @return an object holding all vertex buffers indexed by kind
  96137. */
  96138. getVertexBuffers(): Nullable<{
  96139. [key: string]: VertexBuffer;
  96140. }>;
  96141. /**
  96142. * Gets a boolean indicating if specific vertex buffer is present
  96143. * @param kind defines the data kind (Position, normal, etc...)
  96144. * @returns true if data is present
  96145. */
  96146. isVerticesDataPresent(kind: string): boolean;
  96147. /**
  96148. * Gets a list of all attached data kinds (Position, normal, etc...)
  96149. * @returns a list of string containing all kinds
  96150. */
  96151. getVerticesDataKinds(): string[];
  96152. /**
  96153. * Update index buffer
  96154. * @param indices defines the indices to store in the index buffer
  96155. * @param offset defines the offset in the target buffer where to store the data
  96156. * @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)
  96157. */
  96158. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  96159. /**
  96160. * Creates a new index buffer
  96161. * @param indices defines the indices to store in the index buffer
  96162. * @param totalVertices defines the total number of vertices (could be null)
  96163. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96164. */
  96165. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  96166. /**
  96167. * Return the total number of indices
  96168. * @returns the total number of indices
  96169. */
  96170. getTotalIndices(): number;
  96171. /**
  96172. * Gets the index buffer array
  96173. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96174. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96175. * @returns the index buffer array
  96176. */
  96177. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96178. /**
  96179. * Gets the index buffer
  96180. * @return the index buffer
  96181. */
  96182. getIndexBuffer(): Nullable<DataBuffer>;
  96183. /** @hidden */
  96184. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  96185. /**
  96186. * Release the associated resources for a specific mesh
  96187. * @param mesh defines the source mesh
  96188. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  96189. */
  96190. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  96191. /**
  96192. * Apply current geometry to a given mesh
  96193. * @param mesh defines the mesh to apply geometry to
  96194. */
  96195. applyToMesh(mesh: Mesh): void;
  96196. private _updateExtend;
  96197. private _applyToMesh;
  96198. private notifyUpdate;
  96199. /**
  96200. * Load the geometry if it was flagged as delay loaded
  96201. * @param scene defines the hosting scene
  96202. * @param onLoaded defines a callback called when the geometry is loaded
  96203. */
  96204. load(scene: Scene, onLoaded?: () => void): void;
  96205. private _queueLoad;
  96206. /**
  96207. * Invert the geometry to move from a right handed system to a left handed one.
  96208. */
  96209. toLeftHanded(): void;
  96210. /** @hidden */
  96211. _resetPointsArrayCache(): void;
  96212. /** @hidden */
  96213. _generatePointsArray(): boolean;
  96214. /**
  96215. * Gets a value indicating if the geometry is disposed
  96216. * @returns true if the geometry was disposed
  96217. */
  96218. isDisposed(): boolean;
  96219. private _disposeVertexArrayObjects;
  96220. /**
  96221. * Free all associated resources
  96222. */
  96223. dispose(): void;
  96224. /**
  96225. * Clone the current geometry into a new geometry
  96226. * @param id defines the unique ID of the new geometry
  96227. * @returns a new geometry object
  96228. */
  96229. copy(id: string): Geometry;
  96230. /**
  96231. * Serialize the current geometry info (and not the vertices data) into a JSON object
  96232. * @return a JSON representation of the current geometry data (without the vertices data)
  96233. */
  96234. serialize(): any;
  96235. private toNumberArray;
  96236. /**
  96237. * Serialize all vertices data into a JSON oject
  96238. * @returns a JSON representation of the current geometry data
  96239. */
  96240. serializeVerticeData(): any;
  96241. /**
  96242. * Extracts a clone of a mesh geometry
  96243. * @param mesh defines the source mesh
  96244. * @param id defines the unique ID of the new geometry object
  96245. * @returns the new geometry object
  96246. */
  96247. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  96248. /**
  96249. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  96250. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96251. * Be aware Math.random() could cause collisions, but:
  96252. * "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"
  96253. * @returns a string containing a new GUID
  96254. */
  96255. static RandomId(): string;
  96256. /** @hidden */
  96257. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  96258. private static _CleanMatricesWeights;
  96259. /**
  96260. * Create a new geometry from persisted data (Using .babylon file format)
  96261. * @param parsedVertexData defines the persisted data
  96262. * @param scene defines the hosting scene
  96263. * @param rootUrl defines the root url to use to load assets (like delayed data)
  96264. * @returns the new geometry object
  96265. */
  96266. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  96267. }
  96268. }
  96269. declare module BABYLON {
  96270. /**
  96271. * Define an interface for all classes that will get and set the data on vertices
  96272. */
  96273. export interface IGetSetVerticesData {
  96274. /**
  96275. * Gets a boolean indicating if specific vertex data is present
  96276. * @param kind defines the vertex data kind to use
  96277. * @returns true is data kind is present
  96278. */
  96279. isVerticesDataPresent(kind: string): boolean;
  96280. /**
  96281. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96282. * @param kind defines the data kind (Position, normal, etc...)
  96283. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96284. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96285. * @returns a float array containing vertex data
  96286. */
  96287. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96288. /**
  96289. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96290. * @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.
  96291. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96292. * @returns the indices array or an empty array if the mesh has no geometry
  96293. */
  96294. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96295. /**
  96296. * Set specific vertex data
  96297. * @param kind defines the data kind (Position, normal, etc...)
  96298. * @param data defines the vertex data to use
  96299. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96300. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96301. */
  96302. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  96303. /**
  96304. * Update a specific associated vertex buffer
  96305. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96306. * - VertexBuffer.PositionKind
  96307. * - VertexBuffer.UVKind
  96308. * - VertexBuffer.UV2Kind
  96309. * - VertexBuffer.UV3Kind
  96310. * - VertexBuffer.UV4Kind
  96311. * - VertexBuffer.UV5Kind
  96312. * - VertexBuffer.UV6Kind
  96313. * - VertexBuffer.ColorKind
  96314. * - VertexBuffer.MatricesIndicesKind
  96315. * - VertexBuffer.MatricesIndicesExtraKind
  96316. * - VertexBuffer.MatricesWeightsKind
  96317. * - VertexBuffer.MatricesWeightsExtraKind
  96318. * @param data defines the data source
  96319. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  96320. * @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)
  96321. */
  96322. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  96323. /**
  96324. * Creates a new index buffer
  96325. * @param indices defines the indices to store in the index buffer
  96326. * @param totalVertices defines the total number of vertices (could be null)
  96327. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96328. */
  96329. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  96330. }
  96331. /**
  96332. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  96333. */
  96334. export class VertexData {
  96335. /**
  96336. * Mesh side orientation : usually the external or front surface
  96337. */
  96338. static readonly FRONTSIDE: number;
  96339. /**
  96340. * Mesh side orientation : usually the internal or back surface
  96341. */
  96342. static readonly BACKSIDE: number;
  96343. /**
  96344. * Mesh side orientation : both internal and external or front and back surfaces
  96345. */
  96346. static readonly DOUBLESIDE: number;
  96347. /**
  96348. * Mesh side orientation : by default, `FRONTSIDE`
  96349. */
  96350. static readonly DEFAULTSIDE: number;
  96351. /**
  96352. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  96353. */
  96354. positions: Nullable<FloatArray>;
  96355. /**
  96356. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  96357. */
  96358. normals: Nullable<FloatArray>;
  96359. /**
  96360. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  96361. */
  96362. tangents: Nullable<FloatArray>;
  96363. /**
  96364. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96365. */
  96366. uvs: Nullable<FloatArray>;
  96367. /**
  96368. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96369. */
  96370. uvs2: Nullable<FloatArray>;
  96371. /**
  96372. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96373. */
  96374. uvs3: Nullable<FloatArray>;
  96375. /**
  96376. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96377. */
  96378. uvs4: Nullable<FloatArray>;
  96379. /**
  96380. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96381. */
  96382. uvs5: Nullable<FloatArray>;
  96383. /**
  96384. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96385. */
  96386. uvs6: Nullable<FloatArray>;
  96387. /**
  96388. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  96389. */
  96390. colors: Nullable<FloatArray>;
  96391. /**
  96392. * 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).
  96393. */
  96394. matricesIndices: Nullable<FloatArray>;
  96395. /**
  96396. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  96397. */
  96398. matricesWeights: Nullable<FloatArray>;
  96399. /**
  96400. * An array extending the number of possible indices
  96401. */
  96402. matricesIndicesExtra: Nullable<FloatArray>;
  96403. /**
  96404. * An array extending the number of possible weights when the number of indices is extended
  96405. */
  96406. matricesWeightsExtra: Nullable<FloatArray>;
  96407. /**
  96408. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  96409. */
  96410. indices: Nullable<IndicesArray>;
  96411. /**
  96412. * Uses the passed data array to set the set the values for the specified kind of data
  96413. * @param data a linear array of floating numbers
  96414. * @param kind the type of data that is being set, eg positions, colors etc
  96415. */
  96416. set(data: FloatArray, kind: string): void;
  96417. /**
  96418. * Associates the vertexData to the passed Mesh.
  96419. * Sets it as updatable or not (default `false`)
  96420. * @param mesh the mesh the vertexData is applied to
  96421. * @param updatable when used and having the value true allows new data to update the vertexData
  96422. * @returns the VertexData
  96423. */
  96424. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  96425. /**
  96426. * Associates the vertexData to the passed Geometry.
  96427. * Sets it as updatable or not (default `false`)
  96428. * @param geometry the geometry the vertexData is applied to
  96429. * @param updatable when used and having the value true allows new data to update the vertexData
  96430. * @returns VertexData
  96431. */
  96432. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  96433. /**
  96434. * Updates the associated mesh
  96435. * @param mesh the mesh to be updated
  96436. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96437. * @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
  96438. * @returns VertexData
  96439. */
  96440. updateMesh(mesh: Mesh): VertexData;
  96441. /**
  96442. * Updates the associated geometry
  96443. * @param geometry the geometry to be updated
  96444. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96445. * @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
  96446. * @returns VertexData.
  96447. */
  96448. updateGeometry(geometry: Geometry): VertexData;
  96449. private _applyTo;
  96450. private _update;
  96451. /**
  96452. * Transforms each position and each normal of the vertexData according to the passed Matrix
  96453. * @param matrix the transforming matrix
  96454. * @returns the VertexData
  96455. */
  96456. transform(matrix: Matrix): VertexData;
  96457. /**
  96458. * Merges the passed VertexData into the current one
  96459. * @param other the VertexData to be merged into the current one
  96460. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  96461. * @returns the modified VertexData
  96462. */
  96463. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  96464. private _mergeElement;
  96465. private _validate;
  96466. /**
  96467. * Serializes the VertexData
  96468. * @returns a serialized object
  96469. */
  96470. serialize(): any;
  96471. /**
  96472. * Extracts the vertexData from a mesh
  96473. * @param mesh the mesh from which to extract the VertexData
  96474. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  96475. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96476. * @returns the object VertexData associated to the passed mesh
  96477. */
  96478. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96479. /**
  96480. * Extracts the vertexData from the geometry
  96481. * @param geometry the geometry from which to extract the VertexData
  96482. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  96483. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96484. * @returns the object VertexData associated to the passed mesh
  96485. */
  96486. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96487. private static _ExtractFrom;
  96488. /**
  96489. * Creates the VertexData for a Ribbon
  96490. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  96491. * * pathArray array of paths, each of which an array of successive Vector3
  96492. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  96493. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  96494. * * 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
  96495. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96496. * * 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)
  96497. * * 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)
  96498. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  96499. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  96500. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  96501. * @returns the VertexData of the ribbon
  96502. */
  96503. static CreateRibbon(options: {
  96504. pathArray: Vector3[][];
  96505. closeArray?: boolean;
  96506. closePath?: boolean;
  96507. offset?: number;
  96508. sideOrientation?: number;
  96509. frontUVs?: Vector4;
  96510. backUVs?: Vector4;
  96511. invertUV?: boolean;
  96512. uvs?: Vector2[];
  96513. colors?: Color4[];
  96514. }): VertexData;
  96515. /**
  96516. * Creates the VertexData for a box
  96517. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96518. * * size sets the width, height and depth of the box to the value of size, optional default 1
  96519. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  96520. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  96521. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  96522. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96523. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96525. * * 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)
  96526. * * 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)
  96527. * @returns the VertexData of the box
  96528. */
  96529. static CreateBox(options: {
  96530. size?: number;
  96531. width?: number;
  96532. height?: number;
  96533. depth?: number;
  96534. faceUV?: Vector4[];
  96535. faceColors?: Color4[];
  96536. sideOrientation?: number;
  96537. frontUVs?: Vector4;
  96538. backUVs?: Vector4;
  96539. }): VertexData;
  96540. /**
  96541. * Creates the VertexData for a tiled box
  96542. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96543. * * faceTiles sets the pattern, tile size and number of tiles for a face
  96544. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96545. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96547. * @returns the VertexData of the box
  96548. */
  96549. static CreateTiledBox(options: {
  96550. pattern?: number;
  96551. width?: number;
  96552. height?: number;
  96553. depth?: number;
  96554. tileSize?: number;
  96555. tileWidth?: number;
  96556. tileHeight?: number;
  96557. alignHorizontal?: number;
  96558. alignVertical?: number;
  96559. faceUV?: Vector4[];
  96560. faceColors?: Color4[];
  96561. sideOrientation?: number;
  96562. }): VertexData;
  96563. /**
  96564. * Creates the VertexData for a tiled plane
  96565. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96566. * * pattern a limited pattern arrangement depending on the number
  96567. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  96568. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  96569. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  96570. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96571. * * 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)
  96572. * * 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)
  96573. * @returns the VertexData of the tiled plane
  96574. */
  96575. static CreateTiledPlane(options: {
  96576. pattern?: number;
  96577. tileSize?: number;
  96578. tileWidth?: number;
  96579. tileHeight?: number;
  96580. size?: number;
  96581. width?: number;
  96582. height?: number;
  96583. alignHorizontal?: number;
  96584. alignVertical?: number;
  96585. sideOrientation?: number;
  96586. frontUVs?: Vector4;
  96587. backUVs?: Vector4;
  96588. }): VertexData;
  96589. /**
  96590. * Creates the VertexData for an ellipsoid, defaults to a sphere
  96591. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96592. * * segments sets the number of horizontal strips optional, default 32
  96593. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  96594. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  96595. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  96596. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  96597. * * 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
  96598. * * 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
  96599. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96600. * * 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)
  96601. * * 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)
  96602. * @returns the VertexData of the ellipsoid
  96603. */
  96604. static CreateSphere(options: {
  96605. segments?: number;
  96606. diameter?: number;
  96607. diameterX?: number;
  96608. diameterY?: number;
  96609. diameterZ?: number;
  96610. arc?: number;
  96611. slice?: number;
  96612. sideOrientation?: number;
  96613. frontUVs?: Vector4;
  96614. backUVs?: Vector4;
  96615. }): VertexData;
  96616. /**
  96617. * Creates the VertexData for a cylinder, cone or prism
  96618. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96619. * * height sets the height (y direction) of the cylinder, optional, default 2
  96620. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  96621. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  96622. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  96623. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96624. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  96625. * * 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
  96626. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96627. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96628. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  96629. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  96630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96631. * * 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)
  96632. * * 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)
  96633. * @returns the VertexData of the cylinder, cone or prism
  96634. */
  96635. static CreateCylinder(options: {
  96636. height?: number;
  96637. diameterTop?: number;
  96638. diameterBottom?: number;
  96639. diameter?: number;
  96640. tessellation?: number;
  96641. subdivisions?: number;
  96642. arc?: number;
  96643. faceColors?: Color4[];
  96644. faceUV?: Vector4[];
  96645. hasRings?: boolean;
  96646. enclose?: boolean;
  96647. sideOrientation?: number;
  96648. frontUVs?: Vector4;
  96649. backUVs?: Vector4;
  96650. }): VertexData;
  96651. /**
  96652. * Creates the VertexData for a torus
  96653. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96654. * * diameter the diameter of the torus, optional default 1
  96655. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96656. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96657. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96658. * * 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)
  96659. * * 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)
  96660. * @returns the VertexData of the torus
  96661. */
  96662. static CreateTorus(options: {
  96663. diameter?: number;
  96664. thickness?: number;
  96665. tessellation?: number;
  96666. sideOrientation?: number;
  96667. frontUVs?: Vector4;
  96668. backUVs?: Vector4;
  96669. }): VertexData;
  96670. /**
  96671. * Creates the VertexData of the LineSystem
  96672. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96673. * - lines an array of lines, each line being an array of successive Vector3
  96674. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96675. * @returns the VertexData of the LineSystem
  96676. */
  96677. static CreateLineSystem(options: {
  96678. lines: Vector3[][];
  96679. colors?: Nullable<Color4[][]>;
  96680. }): VertexData;
  96681. /**
  96682. * Create the VertexData for a DashedLines
  96683. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96684. * - points an array successive Vector3
  96685. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96686. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96687. * - dashNb the intended total number of dashes, optional, default 200
  96688. * @returns the VertexData for the DashedLines
  96689. */
  96690. static CreateDashedLines(options: {
  96691. points: Vector3[];
  96692. dashSize?: number;
  96693. gapSize?: number;
  96694. dashNb?: number;
  96695. }): VertexData;
  96696. /**
  96697. * Creates the VertexData for a Ground
  96698. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96699. * - width the width (x direction) of the ground, optional, default 1
  96700. * - height the height (z direction) of the ground, optional, default 1
  96701. * - subdivisions the number of subdivisions per side, optional, default 1
  96702. * @returns the VertexData of the Ground
  96703. */
  96704. static CreateGround(options: {
  96705. width?: number;
  96706. height?: number;
  96707. subdivisions?: number;
  96708. subdivisionsX?: number;
  96709. subdivisionsY?: number;
  96710. }): VertexData;
  96711. /**
  96712. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96713. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96714. * * xmin the ground minimum X coordinate, optional, default -1
  96715. * * zmin the ground minimum Z coordinate, optional, default -1
  96716. * * xmax the ground maximum X coordinate, optional, default 1
  96717. * * zmax the ground maximum Z coordinate, optional, default 1
  96718. * * 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}
  96719. * * 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}
  96720. * @returns the VertexData of the TiledGround
  96721. */
  96722. static CreateTiledGround(options: {
  96723. xmin: number;
  96724. zmin: number;
  96725. xmax: number;
  96726. zmax: number;
  96727. subdivisions?: {
  96728. w: number;
  96729. h: number;
  96730. };
  96731. precision?: {
  96732. w: number;
  96733. h: number;
  96734. };
  96735. }): VertexData;
  96736. /**
  96737. * Creates the VertexData of the Ground designed from a heightmap
  96738. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96739. * * width the width (x direction) of the ground
  96740. * * height the height (z direction) of the ground
  96741. * * subdivisions the number of subdivisions per side
  96742. * * minHeight the minimum altitude on the ground, optional, default 0
  96743. * * maxHeight the maximum altitude on the ground, optional default 1
  96744. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96745. * * buffer the array holding the image color data
  96746. * * bufferWidth the width of image
  96747. * * bufferHeight the height of image
  96748. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96749. * @returns the VertexData of the Ground designed from a heightmap
  96750. */
  96751. static CreateGroundFromHeightMap(options: {
  96752. width: number;
  96753. height: number;
  96754. subdivisions: number;
  96755. minHeight: number;
  96756. maxHeight: number;
  96757. colorFilter: Color3;
  96758. buffer: Uint8Array;
  96759. bufferWidth: number;
  96760. bufferHeight: number;
  96761. alphaFilter: number;
  96762. }): VertexData;
  96763. /**
  96764. * Creates the VertexData for a Plane
  96765. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  96766. * * size sets the width and height of the plane to the value of size, optional default 1
  96767. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  96768. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  96769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96770. * * 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)
  96771. * * 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)
  96772. * @returns the VertexData of the box
  96773. */
  96774. static CreatePlane(options: {
  96775. size?: number;
  96776. width?: number;
  96777. height?: number;
  96778. sideOrientation?: number;
  96779. frontUVs?: Vector4;
  96780. backUVs?: Vector4;
  96781. }): VertexData;
  96782. /**
  96783. * Creates the VertexData of the Disc or regular Polygon
  96784. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  96785. * * radius the radius of the disc, optional default 0.5
  96786. * * tessellation the number of polygon sides, optional, default 64
  96787. * * 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
  96788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96789. * * 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)
  96790. * * 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)
  96791. * @returns the VertexData of the box
  96792. */
  96793. static CreateDisc(options: {
  96794. radius?: number;
  96795. tessellation?: number;
  96796. arc?: number;
  96797. sideOrientation?: number;
  96798. frontUVs?: Vector4;
  96799. backUVs?: Vector4;
  96800. }): VertexData;
  96801. /**
  96802. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  96803. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  96804. * @param polygon a mesh built from polygonTriangulation.build()
  96805. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96806. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96807. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96808. * @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)
  96809. * @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)
  96810. * @returns the VertexData of the Polygon
  96811. */
  96812. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  96813. /**
  96814. * Creates the VertexData of the IcoSphere
  96815. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  96816. * * radius the radius of the IcoSphere, optional default 1
  96817. * * radiusX allows stretching in the x direction, optional, default radius
  96818. * * radiusY allows stretching in the y direction, optional, default radius
  96819. * * radiusZ allows stretching in the z direction, optional, default radius
  96820. * * flat when true creates a flat shaded mesh, optional, default true
  96821. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96822. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96823. * * 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)
  96824. * * 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)
  96825. * @returns the VertexData of the IcoSphere
  96826. */
  96827. static CreateIcoSphere(options: {
  96828. radius?: number;
  96829. radiusX?: number;
  96830. radiusY?: number;
  96831. radiusZ?: number;
  96832. flat?: boolean;
  96833. subdivisions?: number;
  96834. sideOrientation?: number;
  96835. frontUVs?: Vector4;
  96836. backUVs?: Vector4;
  96837. }): VertexData;
  96838. /**
  96839. * Creates the VertexData for a Polyhedron
  96840. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  96841. * * type provided types are:
  96842. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  96843. * * 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)
  96844. * * size the size of the IcoSphere, optional default 1
  96845. * * sizeX allows stretching in the x direction, optional, default size
  96846. * * sizeY allows stretching in the y direction, optional, default size
  96847. * * sizeZ allows stretching in the z direction, optional, default size
  96848. * * 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
  96849. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96850. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96851. * * flat when true creates a flat shaded mesh, optional, default true
  96852. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  96853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96854. * * 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)
  96855. * * 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)
  96856. * @returns the VertexData of the Polyhedron
  96857. */
  96858. static CreatePolyhedron(options: {
  96859. type?: number;
  96860. size?: number;
  96861. sizeX?: number;
  96862. sizeY?: number;
  96863. sizeZ?: number;
  96864. custom?: any;
  96865. faceUV?: Vector4[];
  96866. faceColors?: Color4[];
  96867. flat?: boolean;
  96868. sideOrientation?: number;
  96869. frontUVs?: Vector4;
  96870. backUVs?: Vector4;
  96871. }): VertexData;
  96872. /**
  96873. * Creates the VertexData for a TorusKnot
  96874. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  96875. * * radius the radius of the torus knot, optional, default 2
  96876. * * tube the thickness of the tube, optional, default 0.5
  96877. * * radialSegments the number of sides on each tube segments, optional, default 32
  96878. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  96879. * * p the number of windings around the z axis, optional, default 2
  96880. * * q the number of windings around the x axis, optional, default 3
  96881. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96882. * * 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)
  96883. * * 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)
  96884. * @returns the VertexData of the Torus Knot
  96885. */
  96886. static CreateTorusKnot(options: {
  96887. radius?: number;
  96888. tube?: number;
  96889. radialSegments?: number;
  96890. tubularSegments?: number;
  96891. p?: number;
  96892. q?: number;
  96893. sideOrientation?: number;
  96894. frontUVs?: Vector4;
  96895. backUVs?: Vector4;
  96896. }): VertexData;
  96897. /**
  96898. * Compute normals for given positions and indices
  96899. * @param positions an array of vertex positions, [...., x, y, z, ......]
  96900. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  96901. * @param normals an array of vertex normals, [...., x, y, z, ......]
  96902. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  96903. * * facetNormals : optional array of facet normals (vector3)
  96904. * * facetPositions : optional array of facet positions (vector3)
  96905. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  96906. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  96907. * * bInfo : optional bounding info, required for facetPartitioning computation
  96908. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  96909. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  96910. * * useRightHandedSystem: optional boolean to for right handed system computation
  96911. * * depthSort : optional boolean to enable the facet depth sort computation
  96912. * * distanceTo : optional Vector3 to compute the facet depth from this location
  96913. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  96914. */
  96915. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  96916. facetNormals?: any;
  96917. facetPositions?: any;
  96918. facetPartitioning?: any;
  96919. ratio?: number;
  96920. bInfo?: any;
  96921. bbSize?: Vector3;
  96922. subDiv?: any;
  96923. useRightHandedSystem?: boolean;
  96924. depthSort?: boolean;
  96925. distanceTo?: Vector3;
  96926. depthSortedFacets?: any;
  96927. }): void;
  96928. /** @hidden */
  96929. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  96930. /**
  96931. * Applies VertexData created from the imported parameters to the geometry
  96932. * @param parsedVertexData the parsed data from an imported file
  96933. * @param geometry the geometry to apply the VertexData to
  96934. */
  96935. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  96936. }
  96937. }
  96938. declare module BABYLON {
  96939. /**
  96940. * Defines a target to use with MorphTargetManager
  96941. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96942. */
  96943. export class MorphTarget implements IAnimatable {
  96944. /** defines the name of the target */
  96945. name: string;
  96946. /**
  96947. * Gets or sets the list of animations
  96948. */
  96949. animations: Animation[];
  96950. private _scene;
  96951. private _positions;
  96952. private _normals;
  96953. private _tangents;
  96954. private _uvs;
  96955. private _influence;
  96956. private _uniqueId;
  96957. /**
  96958. * Observable raised when the influence changes
  96959. */
  96960. onInfluenceChanged: Observable<boolean>;
  96961. /** @hidden */
  96962. _onDataLayoutChanged: Observable<void>;
  96963. /**
  96964. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  96965. */
  96966. get influence(): number;
  96967. set influence(influence: number);
  96968. /**
  96969. * Gets or sets the id of the morph Target
  96970. */
  96971. id: string;
  96972. private _animationPropertiesOverride;
  96973. /**
  96974. * Gets or sets the animation properties override
  96975. */
  96976. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96977. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96978. /**
  96979. * Creates a new MorphTarget
  96980. * @param name defines the name of the target
  96981. * @param influence defines the influence to use
  96982. * @param scene defines the scene the morphtarget belongs to
  96983. */
  96984. constructor(
  96985. /** defines the name of the target */
  96986. name: string, influence?: number, scene?: Nullable<Scene>);
  96987. /**
  96988. * Gets the unique ID of this manager
  96989. */
  96990. get uniqueId(): number;
  96991. /**
  96992. * Gets a boolean defining if the target contains position data
  96993. */
  96994. get hasPositions(): boolean;
  96995. /**
  96996. * Gets a boolean defining if the target contains normal data
  96997. */
  96998. get hasNormals(): boolean;
  96999. /**
  97000. * Gets a boolean defining if the target contains tangent data
  97001. */
  97002. get hasTangents(): boolean;
  97003. /**
  97004. * Gets a boolean defining if the target contains texture coordinates data
  97005. */
  97006. get hasUVs(): boolean;
  97007. /**
  97008. * Affects position data to this target
  97009. * @param data defines the position data to use
  97010. */
  97011. setPositions(data: Nullable<FloatArray>): void;
  97012. /**
  97013. * Gets the position data stored in this target
  97014. * @returns a FloatArray containing the position data (or null if not present)
  97015. */
  97016. getPositions(): Nullable<FloatArray>;
  97017. /**
  97018. * Affects normal data to this target
  97019. * @param data defines the normal data to use
  97020. */
  97021. setNormals(data: Nullable<FloatArray>): void;
  97022. /**
  97023. * Gets the normal data stored in this target
  97024. * @returns a FloatArray containing the normal data (or null if not present)
  97025. */
  97026. getNormals(): Nullable<FloatArray>;
  97027. /**
  97028. * Affects tangent data to this target
  97029. * @param data defines the tangent data to use
  97030. */
  97031. setTangents(data: Nullable<FloatArray>): void;
  97032. /**
  97033. * Gets the tangent data stored in this target
  97034. * @returns a FloatArray containing the tangent data (or null if not present)
  97035. */
  97036. getTangents(): Nullable<FloatArray>;
  97037. /**
  97038. * Affects texture coordinates data to this target
  97039. * @param data defines the texture coordinates data to use
  97040. */
  97041. setUVs(data: Nullable<FloatArray>): void;
  97042. /**
  97043. * Gets the texture coordinates data stored in this target
  97044. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  97045. */
  97046. getUVs(): Nullable<FloatArray>;
  97047. /**
  97048. * Clone the current target
  97049. * @returns a new MorphTarget
  97050. */
  97051. clone(): MorphTarget;
  97052. /**
  97053. * Serializes the current target into a Serialization object
  97054. * @returns the serialized object
  97055. */
  97056. serialize(): any;
  97057. /**
  97058. * Returns the string "MorphTarget"
  97059. * @returns "MorphTarget"
  97060. */
  97061. getClassName(): string;
  97062. /**
  97063. * Creates a new target from serialized data
  97064. * @param serializationObject defines the serialized data to use
  97065. * @returns a new MorphTarget
  97066. */
  97067. static Parse(serializationObject: any): MorphTarget;
  97068. /**
  97069. * Creates a MorphTarget from mesh data
  97070. * @param mesh defines the source mesh
  97071. * @param name defines the name to use for the new target
  97072. * @param influence defines the influence to attach to the target
  97073. * @returns a new MorphTarget
  97074. */
  97075. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  97076. }
  97077. }
  97078. declare module BABYLON {
  97079. /**
  97080. * This class is used to deform meshes using morphing between different targets
  97081. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97082. */
  97083. export class MorphTargetManager {
  97084. private _targets;
  97085. private _targetInfluenceChangedObservers;
  97086. private _targetDataLayoutChangedObservers;
  97087. private _activeTargets;
  97088. private _scene;
  97089. private _influences;
  97090. private _supportsNormals;
  97091. private _supportsTangents;
  97092. private _supportsUVs;
  97093. private _vertexCount;
  97094. private _uniqueId;
  97095. private _tempInfluences;
  97096. /**
  97097. * Gets or sets a boolean indicating if normals must be morphed
  97098. */
  97099. enableNormalMorphing: boolean;
  97100. /**
  97101. * Gets or sets a boolean indicating if tangents must be morphed
  97102. */
  97103. enableTangentMorphing: boolean;
  97104. /**
  97105. * Gets or sets a boolean indicating if UV must be morphed
  97106. */
  97107. enableUVMorphing: boolean;
  97108. /**
  97109. * Creates a new MorphTargetManager
  97110. * @param scene defines the current scene
  97111. */
  97112. constructor(scene?: Nullable<Scene>);
  97113. /**
  97114. * Gets the unique ID of this manager
  97115. */
  97116. get uniqueId(): number;
  97117. /**
  97118. * Gets the number of vertices handled by this manager
  97119. */
  97120. get vertexCount(): number;
  97121. /**
  97122. * Gets a boolean indicating if this manager supports morphing of normals
  97123. */
  97124. get supportsNormals(): boolean;
  97125. /**
  97126. * Gets a boolean indicating if this manager supports morphing of tangents
  97127. */
  97128. get supportsTangents(): boolean;
  97129. /**
  97130. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  97131. */
  97132. get supportsUVs(): boolean;
  97133. /**
  97134. * Gets the number of targets stored in this manager
  97135. */
  97136. get numTargets(): number;
  97137. /**
  97138. * Gets the number of influencers (ie. the number of targets with influences > 0)
  97139. */
  97140. get numInfluencers(): number;
  97141. /**
  97142. * Gets the list of influences (one per target)
  97143. */
  97144. get influences(): Float32Array;
  97145. /**
  97146. * Gets the active target at specified index. An active target is a target with an influence > 0
  97147. * @param index defines the index to check
  97148. * @returns the requested target
  97149. */
  97150. getActiveTarget(index: number): MorphTarget;
  97151. /**
  97152. * Gets the target at specified index
  97153. * @param index defines the index to check
  97154. * @returns the requested target
  97155. */
  97156. getTarget(index: number): MorphTarget;
  97157. /**
  97158. * Add a new target to this manager
  97159. * @param target defines the target to add
  97160. */
  97161. addTarget(target: MorphTarget): void;
  97162. /**
  97163. * Removes a target from the manager
  97164. * @param target defines the target to remove
  97165. */
  97166. removeTarget(target: MorphTarget): void;
  97167. /**
  97168. * Clone the current manager
  97169. * @returns a new MorphTargetManager
  97170. */
  97171. clone(): MorphTargetManager;
  97172. /**
  97173. * Serializes the current manager into a Serialization object
  97174. * @returns the serialized object
  97175. */
  97176. serialize(): any;
  97177. private _syncActiveTargets;
  97178. /**
  97179. * Syncrhonize the targets with all the meshes using this morph target manager
  97180. */
  97181. synchronize(): void;
  97182. /**
  97183. * Creates a new MorphTargetManager from serialized data
  97184. * @param serializationObject defines the serialized data
  97185. * @param scene defines the hosting scene
  97186. * @returns the new MorphTargetManager
  97187. */
  97188. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  97189. }
  97190. }
  97191. declare module BABYLON {
  97192. /**
  97193. * Class used to represent a specific level of detail of a mesh
  97194. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97195. */
  97196. export class MeshLODLevel {
  97197. /** Defines the distance where this level should start being displayed */
  97198. distance: number;
  97199. /** Defines the mesh to use to render this level */
  97200. mesh: Nullable<Mesh>;
  97201. /**
  97202. * Creates a new LOD level
  97203. * @param distance defines the distance where this level should star being displayed
  97204. * @param mesh defines the mesh to use to render this level
  97205. */
  97206. constructor(
  97207. /** Defines the distance where this level should start being displayed */
  97208. distance: number,
  97209. /** Defines the mesh to use to render this level */
  97210. mesh: Nullable<Mesh>);
  97211. }
  97212. }
  97213. declare module BABYLON {
  97214. /**
  97215. * Mesh representing the gorund
  97216. */
  97217. export class GroundMesh extends Mesh {
  97218. /** If octree should be generated */
  97219. generateOctree: boolean;
  97220. private _heightQuads;
  97221. /** @hidden */
  97222. _subdivisionsX: number;
  97223. /** @hidden */
  97224. _subdivisionsY: number;
  97225. /** @hidden */
  97226. _width: number;
  97227. /** @hidden */
  97228. _height: number;
  97229. /** @hidden */
  97230. _minX: number;
  97231. /** @hidden */
  97232. _maxX: number;
  97233. /** @hidden */
  97234. _minZ: number;
  97235. /** @hidden */
  97236. _maxZ: number;
  97237. constructor(name: string, scene: Scene);
  97238. /**
  97239. * "GroundMesh"
  97240. * @returns "GroundMesh"
  97241. */
  97242. getClassName(): string;
  97243. /**
  97244. * The minimum of x and y subdivisions
  97245. */
  97246. get subdivisions(): number;
  97247. /**
  97248. * X subdivisions
  97249. */
  97250. get subdivisionsX(): number;
  97251. /**
  97252. * Y subdivisions
  97253. */
  97254. get subdivisionsY(): number;
  97255. /**
  97256. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  97257. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97258. * @param chunksCount the number of subdivisions for x and y
  97259. * @param octreeBlocksSize (Default: 32)
  97260. */
  97261. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  97262. /**
  97263. * Returns a height (y) value in the Worl system :
  97264. * the ground altitude at the coordinates (x, z) expressed in the World system.
  97265. * @param x x coordinate
  97266. * @param z z coordinate
  97267. * @returns the ground y position if (x, z) are outside the ground surface.
  97268. */
  97269. getHeightAtCoordinates(x: number, z: number): number;
  97270. /**
  97271. * Returns a normalized vector (Vector3) orthogonal to the ground
  97272. * at the ground coordinates (x, z) expressed in the World system.
  97273. * @param x x coordinate
  97274. * @param z z coordinate
  97275. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  97276. */
  97277. getNormalAtCoordinates(x: number, z: number): Vector3;
  97278. /**
  97279. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  97280. * at the ground coordinates (x, z) expressed in the World system.
  97281. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  97282. * @param x x coordinate
  97283. * @param z z coordinate
  97284. * @param ref vector to store the result
  97285. * @returns the GroundMesh.
  97286. */
  97287. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  97288. /**
  97289. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  97290. * if the ground has been updated.
  97291. * This can be used in the render loop.
  97292. * @returns the GroundMesh.
  97293. */
  97294. updateCoordinateHeights(): GroundMesh;
  97295. private _getFacetAt;
  97296. private _initHeightQuads;
  97297. private _computeHeightQuads;
  97298. /**
  97299. * Serializes this ground mesh
  97300. * @param serializationObject object to write serialization to
  97301. */
  97302. serialize(serializationObject: any): void;
  97303. /**
  97304. * Parses a serialized ground mesh
  97305. * @param parsedMesh the serialized mesh
  97306. * @param scene the scene to create the ground mesh in
  97307. * @returns the created ground mesh
  97308. */
  97309. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  97310. }
  97311. }
  97312. declare module BABYLON {
  97313. /**
  97314. * Interface for Physics-Joint data
  97315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97316. */
  97317. export interface PhysicsJointData {
  97318. /**
  97319. * The main pivot of the joint
  97320. */
  97321. mainPivot?: Vector3;
  97322. /**
  97323. * The connected pivot of the joint
  97324. */
  97325. connectedPivot?: Vector3;
  97326. /**
  97327. * The main axis of the joint
  97328. */
  97329. mainAxis?: Vector3;
  97330. /**
  97331. * The connected axis of the joint
  97332. */
  97333. connectedAxis?: Vector3;
  97334. /**
  97335. * The collision of the joint
  97336. */
  97337. collision?: boolean;
  97338. /**
  97339. * Native Oimo/Cannon/Energy data
  97340. */
  97341. nativeParams?: any;
  97342. }
  97343. /**
  97344. * This is a holder class for the physics joint created by the physics plugin
  97345. * It holds a set of functions to control the underlying joint
  97346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97347. */
  97348. export class PhysicsJoint {
  97349. /**
  97350. * The type of the physics joint
  97351. */
  97352. type: number;
  97353. /**
  97354. * The data for the physics joint
  97355. */
  97356. jointData: PhysicsJointData;
  97357. private _physicsJoint;
  97358. protected _physicsPlugin: IPhysicsEnginePlugin;
  97359. /**
  97360. * Initializes the physics joint
  97361. * @param type The type of the physics joint
  97362. * @param jointData The data for the physics joint
  97363. */
  97364. constructor(
  97365. /**
  97366. * The type of the physics joint
  97367. */
  97368. type: number,
  97369. /**
  97370. * The data for the physics joint
  97371. */
  97372. jointData: PhysicsJointData);
  97373. /**
  97374. * Gets the physics joint
  97375. */
  97376. get physicsJoint(): any;
  97377. /**
  97378. * Sets the physics joint
  97379. */
  97380. set physicsJoint(newJoint: any);
  97381. /**
  97382. * Sets the physics plugin
  97383. */
  97384. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  97385. /**
  97386. * Execute a function that is physics-plugin specific.
  97387. * @param {Function} func the function that will be executed.
  97388. * It accepts two parameters: the physics world and the physics joint
  97389. */
  97390. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  97391. /**
  97392. * Distance-Joint type
  97393. */
  97394. static DistanceJoint: number;
  97395. /**
  97396. * Hinge-Joint type
  97397. */
  97398. static HingeJoint: number;
  97399. /**
  97400. * Ball-and-Socket joint type
  97401. */
  97402. static BallAndSocketJoint: number;
  97403. /**
  97404. * Wheel-Joint type
  97405. */
  97406. static WheelJoint: number;
  97407. /**
  97408. * Slider-Joint type
  97409. */
  97410. static SliderJoint: number;
  97411. /**
  97412. * Prismatic-Joint type
  97413. */
  97414. static PrismaticJoint: number;
  97415. /**
  97416. * Universal-Joint type
  97417. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  97418. */
  97419. static UniversalJoint: number;
  97420. /**
  97421. * Hinge-Joint 2 type
  97422. */
  97423. static Hinge2Joint: number;
  97424. /**
  97425. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  97426. */
  97427. static PointToPointJoint: number;
  97428. /**
  97429. * Spring-Joint type
  97430. */
  97431. static SpringJoint: number;
  97432. /**
  97433. * Lock-Joint type
  97434. */
  97435. static LockJoint: number;
  97436. }
  97437. /**
  97438. * A class representing a physics distance joint
  97439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97440. */
  97441. export class DistanceJoint extends PhysicsJoint {
  97442. /**
  97443. *
  97444. * @param jointData The data for the Distance-Joint
  97445. */
  97446. constructor(jointData: DistanceJointData);
  97447. /**
  97448. * Update the predefined distance.
  97449. * @param maxDistance The maximum preferred distance
  97450. * @param minDistance The minimum preferred distance
  97451. */
  97452. updateDistance(maxDistance: number, minDistance?: number): void;
  97453. }
  97454. /**
  97455. * Represents a Motor-Enabled Joint
  97456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97457. */
  97458. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  97459. /**
  97460. * Initializes the Motor-Enabled Joint
  97461. * @param type The type of the joint
  97462. * @param jointData The physica joint data for the joint
  97463. */
  97464. constructor(type: number, jointData: PhysicsJointData);
  97465. /**
  97466. * Set the motor values.
  97467. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97468. * @param force the force to apply
  97469. * @param maxForce max force for this motor.
  97470. */
  97471. setMotor(force?: number, maxForce?: number): void;
  97472. /**
  97473. * Set the motor's limits.
  97474. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97475. * @param upperLimit The upper limit of the motor
  97476. * @param lowerLimit The lower limit of the motor
  97477. */
  97478. setLimit(upperLimit: number, lowerLimit?: number): void;
  97479. }
  97480. /**
  97481. * This class represents a single physics Hinge-Joint
  97482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97483. */
  97484. export class HingeJoint extends MotorEnabledJoint {
  97485. /**
  97486. * Initializes the Hinge-Joint
  97487. * @param jointData The joint data for the Hinge-Joint
  97488. */
  97489. constructor(jointData: PhysicsJointData);
  97490. /**
  97491. * Set the motor values.
  97492. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97493. * @param {number} force the force to apply
  97494. * @param {number} maxForce max force for this motor.
  97495. */
  97496. setMotor(force?: number, maxForce?: number): void;
  97497. /**
  97498. * Set the motor's limits.
  97499. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97500. * @param upperLimit The upper limit of the motor
  97501. * @param lowerLimit The lower limit of the motor
  97502. */
  97503. setLimit(upperLimit: number, lowerLimit?: number): void;
  97504. }
  97505. /**
  97506. * This class represents a dual hinge physics joint (same as wheel joint)
  97507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97508. */
  97509. export class Hinge2Joint extends MotorEnabledJoint {
  97510. /**
  97511. * Initializes the Hinge2-Joint
  97512. * @param jointData The joint data for the Hinge2-Joint
  97513. */
  97514. constructor(jointData: PhysicsJointData);
  97515. /**
  97516. * Set the motor values.
  97517. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97518. * @param {number} targetSpeed the speed the motor is to reach
  97519. * @param {number} maxForce max force for this motor.
  97520. * @param {motorIndex} the motor's index, 0 or 1.
  97521. */
  97522. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  97523. /**
  97524. * Set the motor limits.
  97525. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97526. * @param {number} upperLimit the upper limit
  97527. * @param {number} lowerLimit lower limit
  97528. * @param {motorIndex} the motor's index, 0 or 1.
  97529. */
  97530. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97531. }
  97532. /**
  97533. * Interface for a motor enabled joint
  97534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97535. */
  97536. export interface IMotorEnabledJoint {
  97537. /**
  97538. * Physics joint
  97539. */
  97540. physicsJoint: any;
  97541. /**
  97542. * Sets the motor of the motor-enabled joint
  97543. * @param force The force of the motor
  97544. * @param maxForce The maximum force of the motor
  97545. * @param motorIndex The index of the motor
  97546. */
  97547. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  97548. /**
  97549. * Sets the limit of the motor
  97550. * @param upperLimit The upper limit of the motor
  97551. * @param lowerLimit The lower limit of the motor
  97552. * @param motorIndex The index of the motor
  97553. */
  97554. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97555. }
  97556. /**
  97557. * Joint data for a Distance-Joint
  97558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97559. */
  97560. export interface DistanceJointData extends PhysicsJointData {
  97561. /**
  97562. * Max distance the 2 joint objects can be apart
  97563. */
  97564. maxDistance: number;
  97565. }
  97566. /**
  97567. * Joint data from a spring joint
  97568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97569. */
  97570. export interface SpringJointData extends PhysicsJointData {
  97571. /**
  97572. * Length of the spring
  97573. */
  97574. length: number;
  97575. /**
  97576. * Stiffness of the spring
  97577. */
  97578. stiffness: number;
  97579. /**
  97580. * Damping of the spring
  97581. */
  97582. damping: number;
  97583. /** this callback will be called when applying the force to the impostors. */
  97584. forceApplicationCallback: () => void;
  97585. }
  97586. }
  97587. declare module BABYLON {
  97588. /**
  97589. * Holds the data for the raycast result
  97590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97591. */
  97592. export class PhysicsRaycastResult {
  97593. private _hasHit;
  97594. private _hitDistance;
  97595. private _hitNormalWorld;
  97596. private _hitPointWorld;
  97597. private _rayFromWorld;
  97598. private _rayToWorld;
  97599. /**
  97600. * Gets if there was a hit
  97601. */
  97602. get hasHit(): boolean;
  97603. /**
  97604. * Gets the distance from the hit
  97605. */
  97606. get hitDistance(): number;
  97607. /**
  97608. * Gets the hit normal/direction in the world
  97609. */
  97610. get hitNormalWorld(): Vector3;
  97611. /**
  97612. * Gets the hit point in the world
  97613. */
  97614. get hitPointWorld(): Vector3;
  97615. /**
  97616. * Gets the ray "start point" of the ray in the world
  97617. */
  97618. get rayFromWorld(): Vector3;
  97619. /**
  97620. * Gets the ray "end point" of the ray in the world
  97621. */
  97622. get rayToWorld(): Vector3;
  97623. /**
  97624. * Sets the hit data (normal & point in world space)
  97625. * @param hitNormalWorld defines the normal in world space
  97626. * @param hitPointWorld defines the point in world space
  97627. */
  97628. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  97629. /**
  97630. * Sets the distance from the start point to the hit point
  97631. * @param distance
  97632. */
  97633. setHitDistance(distance: number): void;
  97634. /**
  97635. * Calculates the distance manually
  97636. */
  97637. calculateHitDistance(): void;
  97638. /**
  97639. * Resets all the values to default
  97640. * @param from The from point on world space
  97641. * @param to The to point on world space
  97642. */
  97643. reset(from?: Vector3, to?: Vector3): void;
  97644. }
  97645. /**
  97646. * Interface for the size containing width and height
  97647. */
  97648. interface IXYZ {
  97649. /**
  97650. * X
  97651. */
  97652. x: number;
  97653. /**
  97654. * Y
  97655. */
  97656. y: number;
  97657. /**
  97658. * Z
  97659. */
  97660. z: number;
  97661. }
  97662. }
  97663. declare module BABYLON {
  97664. /**
  97665. * Interface used to describe a physics joint
  97666. */
  97667. export interface PhysicsImpostorJoint {
  97668. /** Defines the main impostor to which the joint is linked */
  97669. mainImpostor: PhysicsImpostor;
  97670. /** Defines the impostor that is connected to the main impostor using this joint */
  97671. connectedImpostor: PhysicsImpostor;
  97672. /** Defines the joint itself */
  97673. joint: PhysicsJoint;
  97674. }
  97675. /** @hidden */
  97676. export interface IPhysicsEnginePlugin {
  97677. world: any;
  97678. name: string;
  97679. setGravity(gravity: Vector3): void;
  97680. setTimeStep(timeStep: number): void;
  97681. getTimeStep(): number;
  97682. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97683. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97684. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97685. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97686. removePhysicsBody(impostor: PhysicsImpostor): void;
  97687. generateJoint(joint: PhysicsImpostorJoint): void;
  97688. removeJoint(joint: PhysicsImpostorJoint): void;
  97689. isSupported(): boolean;
  97690. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97691. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97692. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97693. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97694. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97695. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97696. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97697. getBodyMass(impostor: PhysicsImpostor): number;
  97698. getBodyFriction(impostor: PhysicsImpostor): number;
  97699. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97700. getBodyRestitution(impostor: PhysicsImpostor): number;
  97701. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97702. getBodyPressure?(impostor: PhysicsImpostor): number;
  97703. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97704. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97705. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97706. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97707. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97708. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97709. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97710. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97711. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97712. sleepBody(impostor: PhysicsImpostor): void;
  97713. wakeUpBody(impostor: PhysicsImpostor): void;
  97714. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97715. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97716. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97717. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97718. getRadius(impostor: PhysicsImpostor): number;
  97719. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97720. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97721. dispose(): void;
  97722. }
  97723. /**
  97724. * Interface used to define a physics engine
  97725. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97726. */
  97727. export interface IPhysicsEngine {
  97728. /**
  97729. * Gets the gravity vector used by the simulation
  97730. */
  97731. gravity: Vector3;
  97732. /**
  97733. * Sets the gravity vector used by the simulation
  97734. * @param gravity defines the gravity vector to use
  97735. */
  97736. setGravity(gravity: Vector3): void;
  97737. /**
  97738. * Set the time step of the physics engine.
  97739. * Default is 1/60.
  97740. * To slow it down, enter 1/600 for example.
  97741. * To speed it up, 1/30
  97742. * @param newTimeStep the new timestep to apply to this world.
  97743. */
  97744. setTimeStep(newTimeStep: number): void;
  97745. /**
  97746. * Get the time step of the physics engine.
  97747. * @returns the current time step
  97748. */
  97749. getTimeStep(): number;
  97750. /**
  97751. * Set the sub time step of the physics engine.
  97752. * Default is 0 meaning there is no sub steps
  97753. * To increase physics resolution precision, set a small value (like 1 ms)
  97754. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97755. */
  97756. setSubTimeStep(subTimeStep: number): void;
  97757. /**
  97758. * Get the sub time step of the physics engine.
  97759. * @returns the current sub time step
  97760. */
  97761. getSubTimeStep(): number;
  97762. /**
  97763. * Release all resources
  97764. */
  97765. dispose(): void;
  97766. /**
  97767. * Gets the name of the current physics plugin
  97768. * @returns the name of the plugin
  97769. */
  97770. getPhysicsPluginName(): string;
  97771. /**
  97772. * Adding a new impostor for the impostor tracking.
  97773. * This will be done by the impostor itself.
  97774. * @param impostor the impostor to add
  97775. */
  97776. addImpostor(impostor: PhysicsImpostor): void;
  97777. /**
  97778. * Remove an impostor from the engine.
  97779. * This impostor and its mesh will not longer be updated by the physics engine.
  97780. * @param impostor the impostor to remove
  97781. */
  97782. removeImpostor(impostor: PhysicsImpostor): void;
  97783. /**
  97784. * Add a joint to the physics engine
  97785. * @param mainImpostor defines the main impostor to which the joint is added.
  97786. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  97787. * @param joint defines the joint that will connect both impostors.
  97788. */
  97789. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97790. /**
  97791. * Removes a joint from the simulation
  97792. * @param mainImpostor defines the impostor used with the joint
  97793. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  97794. * @param joint defines the joint to remove
  97795. */
  97796. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  97797. /**
  97798. * Gets the current plugin used to run the simulation
  97799. * @returns current plugin
  97800. */
  97801. getPhysicsPlugin(): IPhysicsEnginePlugin;
  97802. /**
  97803. * Gets the list of physic impostors
  97804. * @returns an array of PhysicsImpostor
  97805. */
  97806. getImpostors(): Array<PhysicsImpostor>;
  97807. /**
  97808. * Gets the impostor for a physics enabled object
  97809. * @param object defines the object impersonated by the impostor
  97810. * @returns the PhysicsImpostor or null if not found
  97811. */
  97812. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97813. /**
  97814. * Gets the impostor for a physics body object
  97815. * @param body defines physics body used by the impostor
  97816. * @returns the PhysicsImpostor or null if not found
  97817. */
  97818. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  97819. /**
  97820. * Does a raycast in the physics world
  97821. * @param from when should the ray start?
  97822. * @param to when should the ray end?
  97823. * @returns PhysicsRaycastResult
  97824. */
  97825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97826. /**
  97827. * Called by the scene. No need to call it.
  97828. * @param delta defines the timespam between frames
  97829. */
  97830. _step(delta: number): void;
  97831. }
  97832. }
  97833. declare module BABYLON {
  97834. /**
  97835. * The interface for the physics imposter parameters
  97836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97837. */
  97838. export interface PhysicsImpostorParameters {
  97839. /**
  97840. * The mass of the physics imposter
  97841. */
  97842. mass: number;
  97843. /**
  97844. * The friction of the physics imposter
  97845. */
  97846. friction?: number;
  97847. /**
  97848. * The coefficient of restitution of the physics imposter
  97849. */
  97850. restitution?: number;
  97851. /**
  97852. * The native options of the physics imposter
  97853. */
  97854. nativeOptions?: any;
  97855. /**
  97856. * Specifies if the parent should be ignored
  97857. */
  97858. ignoreParent?: boolean;
  97859. /**
  97860. * Specifies if bi-directional transformations should be disabled
  97861. */
  97862. disableBidirectionalTransformation?: boolean;
  97863. /**
  97864. * The pressure inside the physics imposter, soft object only
  97865. */
  97866. pressure?: number;
  97867. /**
  97868. * The stiffness the physics imposter, soft object only
  97869. */
  97870. stiffness?: number;
  97871. /**
  97872. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  97873. */
  97874. velocityIterations?: number;
  97875. /**
  97876. * The number of iterations used in maintaining consistent vertex positions, soft object only
  97877. */
  97878. positionIterations?: number;
  97879. /**
  97880. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  97881. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  97882. * Add to fix multiple points
  97883. */
  97884. fixedPoints?: number;
  97885. /**
  97886. * The collision margin around a soft object
  97887. */
  97888. margin?: number;
  97889. /**
  97890. * The collision margin around a soft object
  97891. */
  97892. damping?: number;
  97893. /**
  97894. * The path for a rope based on an extrusion
  97895. */
  97896. path?: any;
  97897. /**
  97898. * The shape of an extrusion used for a rope based on an extrusion
  97899. */
  97900. shape?: any;
  97901. }
  97902. /**
  97903. * Interface for a physics-enabled object
  97904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97905. */
  97906. export interface IPhysicsEnabledObject {
  97907. /**
  97908. * The position of the physics-enabled object
  97909. */
  97910. position: Vector3;
  97911. /**
  97912. * The rotation of the physics-enabled object
  97913. */
  97914. rotationQuaternion: Nullable<Quaternion>;
  97915. /**
  97916. * The scale of the physics-enabled object
  97917. */
  97918. scaling: Vector3;
  97919. /**
  97920. * The rotation of the physics-enabled object
  97921. */
  97922. rotation?: Vector3;
  97923. /**
  97924. * The parent of the physics-enabled object
  97925. */
  97926. parent?: any;
  97927. /**
  97928. * The bounding info of the physics-enabled object
  97929. * @returns The bounding info of the physics-enabled object
  97930. */
  97931. getBoundingInfo(): BoundingInfo;
  97932. /**
  97933. * Computes the world matrix
  97934. * @param force Specifies if the world matrix should be computed by force
  97935. * @returns A world matrix
  97936. */
  97937. computeWorldMatrix(force: boolean): Matrix;
  97938. /**
  97939. * Gets the world matrix
  97940. * @returns A world matrix
  97941. */
  97942. getWorldMatrix?(): Matrix;
  97943. /**
  97944. * Gets the child meshes
  97945. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  97946. * @returns An array of abstract meshes
  97947. */
  97948. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  97949. /**
  97950. * Gets the vertex data
  97951. * @param kind The type of vertex data
  97952. * @returns A nullable array of numbers, or a float32 array
  97953. */
  97954. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  97955. /**
  97956. * Gets the indices from the mesh
  97957. * @returns A nullable array of index arrays
  97958. */
  97959. getIndices?(): Nullable<IndicesArray>;
  97960. /**
  97961. * Gets the scene from the mesh
  97962. * @returns the indices array or null
  97963. */
  97964. getScene?(): Scene;
  97965. /**
  97966. * Gets the absolute position from the mesh
  97967. * @returns the absolute position
  97968. */
  97969. getAbsolutePosition(): Vector3;
  97970. /**
  97971. * Gets the absolute pivot point from the mesh
  97972. * @returns the absolute pivot point
  97973. */
  97974. getAbsolutePivotPoint(): Vector3;
  97975. /**
  97976. * Rotates the mesh
  97977. * @param axis The axis of rotation
  97978. * @param amount The amount of rotation
  97979. * @param space The space of the rotation
  97980. * @returns The rotation transform node
  97981. */
  97982. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97983. /**
  97984. * Translates the mesh
  97985. * @param axis The axis of translation
  97986. * @param distance The distance of translation
  97987. * @param space The space of the translation
  97988. * @returns The transform node
  97989. */
  97990. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97991. /**
  97992. * Sets the absolute position of the mesh
  97993. * @param absolutePosition The absolute position of the mesh
  97994. * @returns The transform node
  97995. */
  97996. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97997. /**
  97998. * Gets the class name of the mesh
  97999. * @returns The class name
  98000. */
  98001. getClassName(): string;
  98002. }
  98003. /**
  98004. * Represents a physics imposter
  98005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98006. */
  98007. export class PhysicsImpostor {
  98008. /**
  98009. * The physics-enabled object used as the physics imposter
  98010. */
  98011. object: IPhysicsEnabledObject;
  98012. /**
  98013. * The type of the physics imposter
  98014. */
  98015. type: number;
  98016. private _options;
  98017. private _scene?;
  98018. /**
  98019. * The default object size of the imposter
  98020. */
  98021. static DEFAULT_OBJECT_SIZE: Vector3;
  98022. /**
  98023. * The identity quaternion of the imposter
  98024. */
  98025. static IDENTITY_QUATERNION: Quaternion;
  98026. /** @hidden */
  98027. _pluginData: any;
  98028. private _physicsEngine;
  98029. private _physicsBody;
  98030. private _bodyUpdateRequired;
  98031. private _onBeforePhysicsStepCallbacks;
  98032. private _onAfterPhysicsStepCallbacks;
  98033. /** @hidden */
  98034. _onPhysicsCollideCallbacks: Array<{
  98035. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  98036. otherImpostors: Array<PhysicsImpostor>;
  98037. }>;
  98038. private _deltaPosition;
  98039. private _deltaRotation;
  98040. private _deltaRotationConjugated;
  98041. /** @hidden */
  98042. _isFromLine: boolean;
  98043. private _parent;
  98044. private _isDisposed;
  98045. private static _tmpVecs;
  98046. private static _tmpQuat;
  98047. /**
  98048. * Specifies if the physics imposter is disposed
  98049. */
  98050. get isDisposed(): boolean;
  98051. /**
  98052. * Gets the mass of the physics imposter
  98053. */
  98054. get mass(): number;
  98055. set mass(value: number);
  98056. /**
  98057. * Gets the coefficient of friction
  98058. */
  98059. get friction(): number;
  98060. /**
  98061. * Sets the coefficient of friction
  98062. */
  98063. set friction(value: number);
  98064. /**
  98065. * Gets the coefficient of restitution
  98066. */
  98067. get restitution(): number;
  98068. /**
  98069. * Sets the coefficient of restitution
  98070. */
  98071. set restitution(value: number);
  98072. /**
  98073. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  98074. */
  98075. get pressure(): number;
  98076. /**
  98077. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  98078. */
  98079. set pressure(value: number);
  98080. /**
  98081. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98082. */
  98083. get stiffness(): number;
  98084. /**
  98085. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98086. */
  98087. set stiffness(value: number);
  98088. /**
  98089. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98090. */
  98091. get velocityIterations(): number;
  98092. /**
  98093. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98094. */
  98095. set velocityIterations(value: number);
  98096. /**
  98097. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98098. */
  98099. get positionIterations(): number;
  98100. /**
  98101. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98102. */
  98103. set positionIterations(value: number);
  98104. /**
  98105. * The unique id of the physics imposter
  98106. * set by the physics engine when adding this impostor to the array
  98107. */
  98108. uniqueId: number;
  98109. /**
  98110. * @hidden
  98111. */
  98112. soft: boolean;
  98113. /**
  98114. * @hidden
  98115. */
  98116. segments: number;
  98117. private _joints;
  98118. /**
  98119. * Initializes the physics imposter
  98120. * @param object The physics-enabled object used as the physics imposter
  98121. * @param type The type of the physics imposter
  98122. * @param _options The options for the physics imposter
  98123. * @param _scene The Babylon scene
  98124. */
  98125. constructor(
  98126. /**
  98127. * The physics-enabled object used as the physics imposter
  98128. */
  98129. object: IPhysicsEnabledObject,
  98130. /**
  98131. * The type of the physics imposter
  98132. */
  98133. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  98134. /**
  98135. * This function will completly initialize this impostor.
  98136. * It will create a new body - but only if this mesh has no parent.
  98137. * If it has, this impostor will not be used other than to define the impostor
  98138. * of the child mesh.
  98139. * @hidden
  98140. */
  98141. _init(): void;
  98142. private _getPhysicsParent;
  98143. /**
  98144. * Should a new body be generated.
  98145. * @returns boolean specifying if body initialization is required
  98146. */
  98147. isBodyInitRequired(): boolean;
  98148. /**
  98149. * Sets the updated scaling
  98150. * @param updated Specifies if the scaling is updated
  98151. */
  98152. setScalingUpdated(): void;
  98153. /**
  98154. * Force a regeneration of this or the parent's impostor's body.
  98155. * Use under cautious - This will remove all joints already implemented.
  98156. */
  98157. forceUpdate(): void;
  98158. /**
  98159. * Gets the body that holds this impostor. Either its own, or its parent.
  98160. */
  98161. get physicsBody(): any;
  98162. /**
  98163. * Get the parent of the physics imposter
  98164. * @returns Physics imposter or null
  98165. */
  98166. get parent(): Nullable<PhysicsImpostor>;
  98167. /**
  98168. * Sets the parent of the physics imposter
  98169. */
  98170. set parent(value: Nullable<PhysicsImpostor>);
  98171. /**
  98172. * Set the physics body. Used mainly by the physics engine/plugin
  98173. */
  98174. set physicsBody(physicsBody: any);
  98175. /**
  98176. * Resets the update flags
  98177. */
  98178. resetUpdateFlags(): void;
  98179. /**
  98180. * Gets the object extend size
  98181. * @returns the object extend size
  98182. */
  98183. getObjectExtendSize(): Vector3;
  98184. /**
  98185. * Gets the object center
  98186. * @returns The object center
  98187. */
  98188. getObjectCenter(): Vector3;
  98189. /**
  98190. * Get a specific parameter from the options parameters
  98191. * @param paramName The object parameter name
  98192. * @returns The object parameter
  98193. */
  98194. getParam(paramName: string): any;
  98195. /**
  98196. * Sets a specific parameter in the options given to the physics plugin
  98197. * @param paramName The parameter name
  98198. * @param value The value of the parameter
  98199. */
  98200. setParam(paramName: string, value: number): void;
  98201. /**
  98202. * Specifically change the body's mass option. Won't recreate the physics body object
  98203. * @param mass The mass of the physics imposter
  98204. */
  98205. setMass(mass: number): void;
  98206. /**
  98207. * Gets the linear velocity
  98208. * @returns linear velocity or null
  98209. */
  98210. getLinearVelocity(): Nullable<Vector3>;
  98211. /**
  98212. * Sets the linear velocity
  98213. * @param velocity linear velocity or null
  98214. */
  98215. setLinearVelocity(velocity: Nullable<Vector3>): void;
  98216. /**
  98217. * Gets the angular velocity
  98218. * @returns angular velocity or null
  98219. */
  98220. getAngularVelocity(): Nullable<Vector3>;
  98221. /**
  98222. * Sets the angular velocity
  98223. * @param velocity The velocity or null
  98224. */
  98225. setAngularVelocity(velocity: Nullable<Vector3>): void;
  98226. /**
  98227. * Execute a function with the physics plugin native code
  98228. * Provide a function the will have two variables - the world object and the physics body object
  98229. * @param func The function to execute with the physics plugin native code
  98230. */
  98231. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  98232. /**
  98233. * Register a function that will be executed before the physics world is stepping forward
  98234. * @param func The function to execute before the physics world is stepped forward
  98235. */
  98236. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98237. /**
  98238. * Unregister a function that will be executed before the physics world is stepping forward
  98239. * @param func The function to execute before the physics world is stepped forward
  98240. */
  98241. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98242. /**
  98243. * Register a function that will be executed after the physics step
  98244. * @param func The function to execute after physics step
  98245. */
  98246. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98247. /**
  98248. * Unregisters a function that will be executed after the physics step
  98249. * @param func The function to execute after physics step
  98250. */
  98251. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98252. /**
  98253. * register a function that will be executed when this impostor collides against a different body
  98254. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  98255. * @param func Callback that is executed on collision
  98256. */
  98257. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  98258. /**
  98259. * Unregisters the physics imposter on contact
  98260. * @param collideAgainst The physics object to collide against
  98261. * @param func Callback to execute on collision
  98262. */
  98263. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  98264. private _tmpQuat;
  98265. private _tmpQuat2;
  98266. /**
  98267. * Get the parent rotation
  98268. * @returns The parent rotation
  98269. */
  98270. getParentsRotation(): Quaternion;
  98271. /**
  98272. * this function is executed by the physics engine.
  98273. */
  98274. beforeStep: () => void;
  98275. /**
  98276. * this function is executed by the physics engine
  98277. */
  98278. afterStep: () => void;
  98279. /**
  98280. * Legacy collision detection event support
  98281. */
  98282. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  98283. /**
  98284. * event and body object due to cannon's event-based architecture.
  98285. */
  98286. onCollide: (e: {
  98287. body: any;
  98288. }) => void;
  98289. /**
  98290. * Apply a force
  98291. * @param force The force to apply
  98292. * @param contactPoint The contact point for the force
  98293. * @returns The physics imposter
  98294. */
  98295. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98296. /**
  98297. * Apply an impulse
  98298. * @param force The impulse force
  98299. * @param contactPoint The contact point for the impulse force
  98300. * @returns The physics imposter
  98301. */
  98302. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98303. /**
  98304. * A help function to create a joint
  98305. * @param otherImpostor A physics imposter used to create a joint
  98306. * @param jointType The type of joint
  98307. * @param jointData The data for the joint
  98308. * @returns The physics imposter
  98309. */
  98310. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  98311. /**
  98312. * Add a joint to this impostor with a different impostor
  98313. * @param otherImpostor A physics imposter used to add a joint
  98314. * @param joint The joint to add
  98315. * @returns The physics imposter
  98316. */
  98317. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  98318. /**
  98319. * Add an anchor to a cloth impostor
  98320. * @param otherImpostor rigid impostor to anchor to
  98321. * @param width ratio across width from 0 to 1
  98322. * @param height ratio up height from 0 to 1
  98323. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  98324. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  98325. * @returns impostor the soft imposter
  98326. */
  98327. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98328. /**
  98329. * Add a hook to a rope impostor
  98330. * @param otherImpostor rigid impostor to anchor to
  98331. * @param length ratio across rope from 0 to 1
  98332. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  98333. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  98334. * @returns impostor the rope imposter
  98335. */
  98336. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98337. /**
  98338. * Will keep this body still, in a sleep mode.
  98339. * @returns the physics imposter
  98340. */
  98341. sleep(): PhysicsImpostor;
  98342. /**
  98343. * Wake the body up.
  98344. * @returns The physics imposter
  98345. */
  98346. wakeUp(): PhysicsImpostor;
  98347. /**
  98348. * Clones the physics imposter
  98349. * @param newObject The physics imposter clones to this physics-enabled object
  98350. * @returns A nullable physics imposter
  98351. */
  98352. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98353. /**
  98354. * Disposes the physics imposter
  98355. */
  98356. dispose(): void;
  98357. /**
  98358. * Sets the delta position
  98359. * @param position The delta position amount
  98360. */
  98361. setDeltaPosition(position: Vector3): void;
  98362. /**
  98363. * Sets the delta rotation
  98364. * @param rotation The delta rotation amount
  98365. */
  98366. setDeltaRotation(rotation: Quaternion): void;
  98367. /**
  98368. * Gets the box size of the physics imposter and stores the result in the input parameter
  98369. * @param result Stores the box size
  98370. * @returns The physics imposter
  98371. */
  98372. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  98373. /**
  98374. * Gets the radius of the physics imposter
  98375. * @returns Radius of the physics imposter
  98376. */
  98377. getRadius(): number;
  98378. /**
  98379. * Sync a bone with this impostor
  98380. * @param bone The bone to sync to the impostor.
  98381. * @param boneMesh The mesh that the bone is influencing.
  98382. * @param jointPivot The pivot of the joint / bone in local space.
  98383. * @param distToJoint Optional distance from the impostor to the joint.
  98384. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98385. */
  98386. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  98387. /**
  98388. * Sync impostor to a bone
  98389. * @param bone The bone that the impostor will be synced to.
  98390. * @param boneMesh The mesh that the bone is influencing.
  98391. * @param jointPivot The pivot of the joint / bone in local space.
  98392. * @param distToJoint Optional distance from the impostor to the joint.
  98393. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98394. * @param boneAxis Optional vector3 axis the bone is aligned with
  98395. */
  98396. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  98397. /**
  98398. * No-Imposter type
  98399. */
  98400. static NoImpostor: number;
  98401. /**
  98402. * Sphere-Imposter type
  98403. */
  98404. static SphereImpostor: number;
  98405. /**
  98406. * Box-Imposter type
  98407. */
  98408. static BoxImpostor: number;
  98409. /**
  98410. * Plane-Imposter type
  98411. */
  98412. static PlaneImpostor: number;
  98413. /**
  98414. * Mesh-imposter type
  98415. */
  98416. static MeshImpostor: number;
  98417. /**
  98418. * Capsule-Impostor type (Ammo.js plugin only)
  98419. */
  98420. static CapsuleImpostor: number;
  98421. /**
  98422. * Cylinder-Imposter type
  98423. */
  98424. static CylinderImpostor: number;
  98425. /**
  98426. * Particle-Imposter type
  98427. */
  98428. static ParticleImpostor: number;
  98429. /**
  98430. * Heightmap-Imposter type
  98431. */
  98432. static HeightmapImpostor: number;
  98433. /**
  98434. * ConvexHull-Impostor type (Ammo.js plugin only)
  98435. */
  98436. static ConvexHullImpostor: number;
  98437. /**
  98438. * Custom-Imposter type (Ammo.js plugin only)
  98439. */
  98440. static CustomImpostor: number;
  98441. /**
  98442. * Rope-Imposter type
  98443. */
  98444. static RopeImpostor: number;
  98445. /**
  98446. * Cloth-Imposter type
  98447. */
  98448. static ClothImpostor: number;
  98449. /**
  98450. * Softbody-Imposter type
  98451. */
  98452. static SoftbodyImpostor: number;
  98453. }
  98454. }
  98455. declare module BABYLON {
  98456. /**
  98457. * @hidden
  98458. **/
  98459. export class _CreationDataStorage {
  98460. closePath?: boolean;
  98461. closeArray?: boolean;
  98462. idx: number[];
  98463. dashSize: number;
  98464. gapSize: number;
  98465. path3D: Path3D;
  98466. pathArray: Vector3[][];
  98467. arc: number;
  98468. radius: number;
  98469. cap: number;
  98470. tessellation: number;
  98471. }
  98472. /**
  98473. * @hidden
  98474. **/
  98475. class _InstanceDataStorage {
  98476. visibleInstances: any;
  98477. batchCache: _InstancesBatch;
  98478. instancesBufferSize: number;
  98479. instancesBuffer: Nullable<Buffer>;
  98480. instancesData: Float32Array;
  98481. overridenInstanceCount: number;
  98482. isFrozen: boolean;
  98483. previousBatch: Nullable<_InstancesBatch>;
  98484. hardwareInstancedRendering: boolean;
  98485. sideOrientation: number;
  98486. manualUpdate: boolean;
  98487. }
  98488. /**
  98489. * @hidden
  98490. **/
  98491. export class _InstancesBatch {
  98492. mustReturn: boolean;
  98493. visibleInstances: Nullable<InstancedMesh[]>[];
  98494. renderSelf: boolean[];
  98495. hardwareInstancedRendering: boolean[];
  98496. }
  98497. /**
  98498. * Class used to represent renderable models
  98499. */
  98500. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  98501. /**
  98502. * Mesh side orientation : usually the external or front surface
  98503. */
  98504. static readonly FRONTSIDE: number;
  98505. /**
  98506. * Mesh side orientation : usually the internal or back surface
  98507. */
  98508. static readonly BACKSIDE: number;
  98509. /**
  98510. * Mesh side orientation : both internal and external or front and back surfaces
  98511. */
  98512. static readonly DOUBLESIDE: number;
  98513. /**
  98514. * Mesh side orientation : by default, `FRONTSIDE`
  98515. */
  98516. static readonly DEFAULTSIDE: number;
  98517. /**
  98518. * Mesh cap setting : no cap
  98519. */
  98520. static readonly NO_CAP: number;
  98521. /**
  98522. * Mesh cap setting : one cap at the beginning of the mesh
  98523. */
  98524. static readonly CAP_START: number;
  98525. /**
  98526. * Mesh cap setting : one cap at the end of the mesh
  98527. */
  98528. static readonly CAP_END: number;
  98529. /**
  98530. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  98531. */
  98532. static readonly CAP_ALL: number;
  98533. /**
  98534. * Mesh pattern setting : no flip or rotate
  98535. */
  98536. static readonly NO_FLIP: number;
  98537. /**
  98538. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  98539. */
  98540. static readonly FLIP_TILE: number;
  98541. /**
  98542. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  98543. */
  98544. static readonly ROTATE_TILE: number;
  98545. /**
  98546. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  98547. */
  98548. static readonly FLIP_ROW: number;
  98549. /**
  98550. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  98551. */
  98552. static readonly ROTATE_ROW: number;
  98553. /**
  98554. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  98555. */
  98556. static readonly FLIP_N_ROTATE_TILE: number;
  98557. /**
  98558. * Mesh pattern setting : rotate pattern and rotate
  98559. */
  98560. static readonly FLIP_N_ROTATE_ROW: number;
  98561. /**
  98562. * Mesh tile positioning : part tiles same on left/right or top/bottom
  98563. */
  98564. static readonly CENTER: number;
  98565. /**
  98566. * Mesh tile positioning : part tiles on left
  98567. */
  98568. static readonly LEFT: number;
  98569. /**
  98570. * Mesh tile positioning : part tiles on right
  98571. */
  98572. static readonly RIGHT: number;
  98573. /**
  98574. * Mesh tile positioning : part tiles on top
  98575. */
  98576. static readonly TOP: number;
  98577. /**
  98578. * Mesh tile positioning : part tiles on bottom
  98579. */
  98580. static readonly BOTTOM: number;
  98581. /**
  98582. * Gets the default side orientation.
  98583. * @param orientation the orientation to value to attempt to get
  98584. * @returns the default orientation
  98585. * @hidden
  98586. */
  98587. static _GetDefaultSideOrientation(orientation?: number): number;
  98588. private _internalMeshDataInfo;
  98589. /**
  98590. * An event triggered before rendering the mesh
  98591. */
  98592. get onBeforeRenderObservable(): Observable<Mesh>;
  98593. /**
  98594. * An event triggered before binding the mesh
  98595. */
  98596. get onBeforeBindObservable(): Observable<Mesh>;
  98597. /**
  98598. * An event triggered after rendering the mesh
  98599. */
  98600. get onAfterRenderObservable(): Observable<Mesh>;
  98601. /**
  98602. * An event triggered before drawing the mesh
  98603. */
  98604. get onBeforeDrawObservable(): Observable<Mesh>;
  98605. private _onBeforeDrawObserver;
  98606. /**
  98607. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98608. */
  98609. set onBeforeDraw(callback: () => void);
  98610. get hasInstances(): boolean;
  98611. /**
  98612. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98613. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98614. */
  98615. delayLoadState: number;
  98616. /**
  98617. * Gets the list of instances created from this mesh
  98618. * it is not supposed to be modified manually.
  98619. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98620. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98621. */
  98622. instances: InstancedMesh[];
  98623. /**
  98624. * Gets the file containing delay loading data for this mesh
  98625. */
  98626. delayLoadingFile: string;
  98627. /** @hidden */
  98628. _binaryInfo: any;
  98629. /**
  98630. * User defined function used to change how LOD level selection is done
  98631. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98632. */
  98633. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  98634. /**
  98635. * Gets or sets the morph target manager
  98636. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98637. */
  98638. get morphTargetManager(): Nullable<MorphTargetManager>;
  98639. set morphTargetManager(value: Nullable<MorphTargetManager>);
  98640. /** @hidden */
  98641. _creationDataStorage: Nullable<_CreationDataStorage>;
  98642. /** @hidden */
  98643. _geometry: Nullable<Geometry>;
  98644. /** @hidden */
  98645. _delayInfo: Array<string>;
  98646. /** @hidden */
  98647. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98648. /** @hidden */
  98649. _instanceDataStorage: _InstanceDataStorage;
  98650. private _effectiveMaterial;
  98651. /** @hidden */
  98652. _shouldGenerateFlatShading: boolean;
  98653. /** @hidden */
  98654. _originalBuilderSideOrientation: number;
  98655. /**
  98656. * Use this property to change the original side orientation defined at construction time
  98657. */
  98658. overrideMaterialSideOrientation: Nullable<number>;
  98659. /**
  98660. * Gets the source mesh (the one used to clone this one from)
  98661. */
  98662. get source(): Nullable<Mesh>;
  98663. /**
  98664. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98665. */
  98666. get isUnIndexed(): boolean;
  98667. set isUnIndexed(value: boolean);
  98668. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98669. get worldMatrixInstancedBuffer(): Float32Array;
  98670. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98671. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98672. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98673. /**
  98674. * @constructor
  98675. * @param name The value used by scene.getMeshByName() to do a lookup.
  98676. * @param scene The scene to add this mesh to.
  98677. * @param parent The parent of this mesh, if it has one
  98678. * @param source An optional Mesh from which geometry is shared, cloned.
  98679. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98680. * When false, achieved by calling a clone(), also passing False.
  98681. * This will make creation of children, recursive.
  98682. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98683. */
  98684. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98685. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98686. doNotInstantiate: boolean;
  98687. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98688. /**
  98689. * Gets the class name
  98690. * @returns the string "Mesh".
  98691. */
  98692. getClassName(): string;
  98693. /** @hidden */
  98694. get _isMesh(): boolean;
  98695. /**
  98696. * Returns a description of this mesh
  98697. * @param fullDetails define if full details about this mesh must be used
  98698. * @returns a descriptive string representing this mesh
  98699. */
  98700. toString(fullDetails?: boolean): string;
  98701. /** @hidden */
  98702. _unBindEffect(): void;
  98703. /**
  98704. * Gets a boolean indicating if this mesh has LOD
  98705. */
  98706. get hasLODLevels(): boolean;
  98707. /**
  98708. * Gets the list of MeshLODLevel associated with the current mesh
  98709. * @returns an array of MeshLODLevel
  98710. */
  98711. getLODLevels(): MeshLODLevel[];
  98712. private _sortLODLevels;
  98713. /**
  98714. * Add a mesh as LOD level triggered at the given distance.
  98715. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98716. * @param distance The distance from the center of the object to show this level
  98717. * @param mesh The mesh to be added as LOD level (can be null)
  98718. * @return This mesh (for chaining)
  98719. */
  98720. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98721. /**
  98722. * Returns the LOD level mesh at the passed distance or null if not found.
  98723. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98724. * @param distance The distance from the center of the object to show this level
  98725. * @returns a Mesh or `null`
  98726. */
  98727. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98728. /**
  98729. * Remove a mesh from the LOD array
  98730. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98731. * @param mesh defines the mesh to be removed
  98732. * @return This mesh (for chaining)
  98733. */
  98734. removeLODLevel(mesh: Mesh): Mesh;
  98735. /**
  98736. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98737. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98738. * @param camera defines the camera to use to compute distance
  98739. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98740. * @return This mesh (for chaining)
  98741. */
  98742. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98743. /**
  98744. * Gets the mesh internal Geometry object
  98745. */
  98746. get geometry(): Nullable<Geometry>;
  98747. /**
  98748. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98749. * @returns the total number of vertices
  98750. */
  98751. getTotalVertices(): number;
  98752. /**
  98753. * Returns the content of an associated vertex buffer
  98754. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98755. * - VertexBuffer.PositionKind
  98756. * - VertexBuffer.UVKind
  98757. * - VertexBuffer.UV2Kind
  98758. * - VertexBuffer.UV3Kind
  98759. * - VertexBuffer.UV4Kind
  98760. * - VertexBuffer.UV5Kind
  98761. * - VertexBuffer.UV6Kind
  98762. * - VertexBuffer.ColorKind
  98763. * - VertexBuffer.MatricesIndicesKind
  98764. * - VertexBuffer.MatricesIndicesExtraKind
  98765. * - VertexBuffer.MatricesWeightsKind
  98766. * - VertexBuffer.MatricesWeightsExtraKind
  98767. * @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
  98768. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  98769. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  98770. */
  98771. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98772. /**
  98773. * Returns the mesh VertexBuffer object from the requested `kind`
  98774. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98775. * - VertexBuffer.PositionKind
  98776. * - VertexBuffer.NormalKind
  98777. * - VertexBuffer.UVKind
  98778. * - VertexBuffer.UV2Kind
  98779. * - VertexBuffer.UV3Kind
  98780. * - VertexBuffer.UV4Kind
  98781. * - VertexBuffer.UV5Kind
  98782. * - VertexBuffer.UV6Kind
  98783. * - VertexBuffer.ColorKind
  98784. * - VertexBuffer.MatricesIndicesKind
  98785. * - VertexBuffer.MatricesIndicesExtraKind
  98786. * - VertexBuffer.MatricesWeightsKind
  98787. * - VertexBuffer.MatricesWeightsExtraKind
  98788. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  98789. */
  98790. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  98791. /**
  98792. * Tests if a specific vertex buffer is associated with this mesh
  98793. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98794. * - VertexBuffer.PositionKind
  98795. * - VertexBuffer.NormalKind
  98796. * - VertexBuffer.UVKind
  98797. * - VertexBuffer.UV2Kind
  98798. * - VertexBuffer.UV3Kind
  98799. * - VertexBuffer.UV4Kind
  98800. * - VertexBuffer.UV5Kind
  98801. * - VertexBuffer.UV6Kind
  98802. * - VertexBuffer.ColorKind
  98803. * - VertexBuffer.MatricesIndicesKind
  98804. * - VertexBuffer.MatricesIndicesExtraKind
  98805. * - VertexBuffer.MatricesWeightsKind
  98806. * - VertexBuffer.MatricesWeightsExtraKind
  98807. * @returns a boolean
  98808. */
  98809. isVerticesDataPresent(kind: string): boolean;
  98810. /**
  98811. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  98812. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  98813. * - VertexBuffer.PositionKind
  98814. * - VertexBuffer.UVKind
  98815. * - VertexBuffer.UV2Kind
  98816. * - VertexBuffer.UV3Kind
  98817. * - VertexBuffer.UV4Kind
  98818. * - VertexBuffer.UV5Kind
  98819. * - VertexBuffer.UV6Kind
  98820. * - VertexBuffer.ColorKind
  98821. * - VertexBuffer.MatricesIndicesKind
  98822. * - VertexBuffer.MatricesIndicesExtraKind
  98823. * - VertexBuffer.MatricesWeightsKind
  98824. * - VertexBuffer.MatricesWeightsExtraKind
  98825. * @returns a boolean
  98826. */
  98827. isVertexBufferUpdatable(kind: string): boolean;
  98828. /**
  98829. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  98830. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98831. * - VertexBuffer.PositionKind
  98832. * - VertexBuffer.NormalKind
  98833. * - VertexBuffer.UVKind
  98834. * - VertexBuffer.UV2Kind
  98835. * - VertexBuffer.UV3Kind
  98836. * - VertexBuffer.UV4Kind
  98837. * - VertexBuffer.UV5Kind
  98838. * - VertexBuffer.UV6Kind
  98839. * - VertexBuffer.ColorKind
  98840. * - VertexBuffer.MatricesIndicesKind
  98841. * - VertexBuffer.MatricesIndicesExtraKind
  98842. * - VertexBuffer.MatricesWeightsKind
  98843. * - VertexBuffer.MatricesWeightsExtraKind
  98844. * @returns an array of strings
  98845. */
  98846. getVerticesDataKinds(): string[];
  98847. /**
  98848. * Returns a positive integer : the total number of indices in this mesh geometry.
  98849. * @returns the numner of indices or zero if the mesh has no geometry.
  98850. */
  98851. getTotalIndices(): number;
  98852. /**
  98853. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  98854. * @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.
  98855. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  98856. * @returns the indices array or an empty array if the mesh has no geometry
  98857. */
  98858. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  98859. get isBlocked(): boolean;
  98860. /**
  98861. * Determine if the current mesh is ready to be rendered
  98862. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  98863. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  98864. * @returns true if all associated assets are ready (material, textures, shaders)
  98865. */
  98866. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  98867. /**
  98868. * 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.
  98869. */
  98870. get areNormalsFrozen(): boolean;
  98871. /**
  98872. * 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.
  98873. * @returns the current mesh
  98874. */
  98875. freezeNormals(): Mesh;
  98876. /**
  98877. * 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
  98878. * @returns the current mesh
  98879. */
  98880. unfreezeNormals(): Mesh;
  98881. /**
  98882. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  98883. */
  98884. set overridenInstanceCount(count: number);
  98885. /** @hidden */
  98886. _preActivate(): Mesh;
  98887. /** @hidden */
  98888. _preActivateForIntermediateRendering(renderId: number): Mesh;
  98889. /** @hidden */
  98890. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  98891. /**
  98892. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98893. * This means the mesh underlying bounding box and sphere are recomputed.
  98894. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98895. * @returns the current mesh
  98896. */
  98897. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  98898. /** @hidden */
  98899. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  98900. /**
  98901. * This function will subdivide the mesh into multiple submeshes
  98902. * @param count defines the expected number of submeshes
  98903. */
  98904. subdivide(count: number): void;
  98905. /**
  98906. * Copy a FloatArray into a specific associated vertex buffer
  98907. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98908. * - VertexBuffer.PositionKind
  98909. * - VertexBuffer.UVKind
  98910. * - VertexBuffer.UV2Kind
  98911. * - VertexBuffer.UV3Kind
  98912. * - VertexBuffer.UV4Kind
  98913. * - VertexBuffer.UV5Kind
  98914. * - VertexBuffer.UV6Kind
  98915. * - VertexBuffer.ColorKind
  98916. * - VertexBuffer.MatricesIndicesKind
  98917. * - VertexBuffer.MatricesIndicesExtraKind
  98918. * - VertexBuffer.MatricesWeightsKind
  98919. * - VertexBuffer.MatricesWeightsExtraKind
  98920. * @param data defines the data source
  98921. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98922. * @param stride defines the data stride size (can be null)
  98923. * @returns the current mesh
  98924. */
  98925. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98926. /**
  98927. * Delete a vertex buffer associated with this mesh
  98928. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  98929. * - VertexBuffer.PositionKind
  98930. * - VertexBuffer.UVKind
  98931. * - VertexBuffer.UV2Kind
  98932. * - VertexBuffer.UV3Kind
  98933. * - VertexBuffer.UV4Kind
  98934. * - VertexBuffer.UV5Kind
  98935. * - VertexBuffer.UV6Kind
  98936. * - VertexBuffer.ColorKind
  98937. * - VertexBuffer.MatricesIndicesKind
  98938. * - VertexBuffer.MatricesIndicesExtraKind
  98939. * - VertexBuffer.MatricesWeightsKind
  98940. * - VertexBuffer.MatricesWeightsExtraKind
  98941. */
  98942. removeVerticesData(kind: string): void;
  98943. /**
  98944. * Flags an associated vertex buffer as updatable
  98945. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  98946. * - VertexBuffer.PositionKind
  98947. * - VertexBuffer.UVKind
  98948. * - VertexBuffer.UV2Kind
  98949. * - VertexBuffer.UV3Kind
  98950. * - VertexBuffer.UV4Kind
  98951. * - VertexBuffer.UV5Kind
  98952. * - VertexBuffer.UV6Kind
  98953. * - VertexBuffer.ColorKind
  98954. * - VertexBuffer.MatricesIndicesKind
  98955. * - VertexBuffer.MatricesIndicesExtraKind
  98956. * - VertexBuffer.MatricesWeightsKind
  98957. * - VertexBuffer.MatricesWeightsExtraKind
  98958. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  98959. */
  98960. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  98961. /**
  98962. * Sets the mesh global Vertex Buffer
  98963. * @param buffer defines the buffer to use
  98964. * @returns the current mesh
  98965. */
  98966. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  98967. /**
  98968. * Update a specific associated vertex buffer
  98969. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  98970. * - VertexBuffer.PositionKind
  98971. * - VertexBuffer.UVKind
  98972. * - VertexBuffer.UV2Kind
  98973. * - VertexBuffer.UV3Kind
  98974. * - VertexBuffer.UV4Kind
  98975. * - VertexBuffer.UV5Kind
  98976. * - VertexBuffer.UV6Kind
  98977. * - VertexBuffer.ColorKind
  98978. * - VertexBuffer.MatricesIndicesKind
  98979. * - VertexBuffer.MatricesIndicesExtraKind
  98980. * - VertexBuffer.MatricesWeightsKind
  98981. * - VertexBuffer.MatricesWeightsExtraKind
  98982. * @param data defines the data source
  98983. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98984. * @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)
  98985. * @returns the current mesh
  98986. */
  98987. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98988. /**
  98989. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98990. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98991. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98992. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98993. * @returns the current mesh
  98994. */
  98995. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98996. /**
  98997. * Creates a un-shared specific occurence of the geometry for the mesh.
  98998. * @returns the current mesh
  98999. */
  99000. makeGeometryUnique(): Mesh;
  99001. /**
  99002. * Set the index buffer of this mesh
  99003. * @param indices defines the source data
  99004. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  99005. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  99006. * @returns the current mesh
  99007. */
  99008. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  99009. /**
  99010. * Update the current index buffer
  99011. * @param indices defines the source data
  99012. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99013. * @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)
  99014. * @returns the current mesh
  99015. */
  99016. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99017. /**
  99018. * Invert the geometry to move from a right handed system to a left handed one.
  99019. * @returns the current mesh
  99020. */
  99021. toLeftHanded(): Mesh;
  99022. /** @hidden */
  99023. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  99024. /** @hidden */
  99025. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  99026. /**
  99027. * Registers for this mesh a javascript function called just before the rendering process
  99028. * @param func defines the function to call before rendering this mesh
  99029. * @returns the current mesh
  99030. */
  99031. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99032. /**
  99033. * Disposes a previously registered javascript function called before the rendering
  99034. * @param func defines the function to remove
  99035. * @returns the current mesh
  99036. */
  99037. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99038. /**
  99039. * Registers for this mesh a javascript function called just after the rendering is complete
  99040. * @param func defines the function to call after rendering this mesh
  99041. * @returns the current mesh
  99042. */
  99043. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99044. /**
  99045. * Disposes a previously registered javascript function called after the rendering.
  99046. * @param func defines the function to remove
  99047. * @returns the current mesh
  99048. */
  99049. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99050. /** @hidden */
  99051. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  99052. /** @hidden */
  99053. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  99054. /** @hidden */
  99055. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  99056. /** @hidden */
  99057. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  99058. /** @hidden */
  99059. _rebuild(): void;
  99060. /** @hidden */
  99061. _freeze(): void;
  99062. /** @hidden */
  99063. _unFreeze(): void;
  99064. /**
  99065. * 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
  99066. * @param subMesh defines the subMesh to render
  99067. * @param enableAlphaMode defines if alpha mode can be changed
  99068. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  99069. * @returns the current mesh
  99070. */
  99071. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  99072. private _onBeforeDraw;
  99073. /**
  99074. * Renormalize the mesh and patch it up if there are no weights
  99075. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  99076. * However in the case of zero weights then we set just a single influence to 1.
  99077. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  99078. */
  99079. cleanMatrixWeights(): void;
  99080. private normalizeSkinFourWeights;
  99081. private normalizeSkinWeightsAndExtra;
  99082. /**
  99083. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  99084. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  99085. * the user know there was an issue with importing the mesh
  99086. * @returns a validation object with skinned, valid and report string
  99087. */
  99088. validateSkinning(): {
  99089. skinned: boolean;
  99090. valid: boolean;
  99091. report: string;
  99092. };
  99093. /** @hidden */
  99094. _checkDelayState(): Mesh;
  99095. private _queueLoad;
  99096. /**
  99097. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99098. * A mesh is in the frustum if its bounding box intersects the frustum
  99099. * @param frustumPlanes defines the frustum to test
  99100. * @returns true if the mesh is in the frustum planes
  99101. */
  99102. isInFrustum(frustumPlanes: Plane[]): boolean;
  99103. /**
  99104. * Sets the mesh material by the material or multiMaterial `id` property
  99105. * @param id is a string identifying the material or the multiMaterial
  99106. * @returns the current mesh
  99107. */
  99108. setMaterialByID(id: string): Mesh;
  99109. /**
  99110. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  99111. * @returns an array of IAnimatable
  99112. */
  99113. getAnimatables(): IAnimatable[];
  99114. /**
  99115. * Modifies the mesh geometry according to the passed transformation matrix.
  99116. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  99117. * The mesh normals are modified using the same transformation.
  99118. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99119. * @param transform defines the transform matrix to use
  99120. * @see http://doc.babylonjs.com/resources/baking_transformations
  99121. * @returns the current mesh
  99122. */
  99123. bakeTransformIntoVertices(transform: Matrix): Mesh;
  99124. /**
  99125. * Modifies the mesh geometry according to its own current World Matrix.
  99126. * The mesh World Matrix is then reset.
  99127. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  99128. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99129. * @see http://doc.babylonjs.com/resources/baking_transformations
  99130. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  99131. * @returns the current mesh
  99132. */
  99133. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  99134. /** @hidden */
  99135. get _positions(): Nullable<Vector3[]>;
  99136. /** @hidden */
  99137. _resetPointsArrayCache(): Mesh;
  99138. /** @hidden */
  99139. _generatePointsArray(): boolean;
  99140. /**
  99141. * Returns a new Mesh object generated from the current mesh properties.
  99142. * This method must not get confused with createInstance()
  99143. * @param name is a string, the name given to the new mesh
  99144. * @param newParent can be any Node object (default `null`)
  99145. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  99146. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  99147. * @returns a new mesh
  99148. */
  99149. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  99150. /**
  99151. * Releases resources associated with this mesh.
  99152. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99153. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99154. */
  99155. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99156. /** @hidden */
  99157. _disposeInstanceSpecificData(): void;
  99158. /**
  99159. * Modifies the mesh geometry according to a displacement map.
  99160. * 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.
  99161. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99162. * @param url is a string, the URL from the image file is to be downloaded.
  99163. * @param minHeight is the lower limit of the displacement.
  99164. * @param maxHeight is the upper limit of the displacement.
  99165. * @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.
  99166. * @param uvOffset is an optional vector2 used to offset UV.
  99167. * @param uvScale is an optional vector2 used to scale UV.
  99168. * @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.
  99169. * @returns the Mesh.
  99170. */
  99171. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99172. /**
  99173. * Modifies the mesh geometry according to a displacementMap buffer.
  99174. * 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.
  99175. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99176. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  99177. * @param heightMapWidth is the width of the buffer image.
  99178. * @param heightMapHeight is the height of the buffer image.
  99179. * @param minHeight is the lower limit of the displacement.
  99180. * @param maxHeight is the upper limit of the displacement.
  99181. * @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.
  99182. * @param uvOffset is an optional vector2 used to offset UV.
  99183. * @param uvScale is an optional vector2 used to scale UV.
  99184. * @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.
  99185. * @returns the Mesh.
  99186. */
  99187. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99188. /**
  99189. * Modify the mesh to get a flat shading rendering.
  99190. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  99191. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  99192. * @returns current mesh
  99193. */
  99194. convertToFlatShadedMesh(): Mesh;
  99195. /**
  99196. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  99197. * In other words, more vertices, no more indices and a single bigger VBO.
  99198. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  99199. * @returns current mesh
  99200. */
  99201. convertToUnIndexedMesh(): Mesh;
  99202. /**
  99203. * Inverses facet orientations.
  99204. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99205. * @param flipNormals will also inverts the normals
  99206. * @returns current mesh
  99207. */
  99208. flipFaces(flipNormals?: boolean): Mesh;
  99209. /**
  99210. * Increase the number of facets and hence vertices in a mesh
  99211. * Vertex normals are interpolated from existing vertex normals
  99212. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99213. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  99214. */
  99215. increaseVertices(numberPerEdge: number): void;
  99216. /**
  99217. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  99218. * This will undo any application of covertToFlatShadedMesh
  99219. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99220. */
  99221. forceSharedVertices(): void;
  99222. /** @hidden */
  99223. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  99224. /** @hidden */
  99225. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  99226. /**
  99227. * Creates a new InstancedMesh object from the mesh model.
  99228. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  99229. * @param name defines the name of the new instance
  99230. * @returns a new InstancedMesh
  99231. */
  99232. createInstance(name: string): InstancedMesh;
  99233. /**
  99234. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  99235. * After this call, all the mesh instances have the same submeshes than the current mesh.
  99236. * @returns the current mesh
  99237. */
  99238. synchronizeInstances(): Mesh;
  99239. /**
  99240. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  99241. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  99242. * This should be used together with the simplification to avoid disappearing triangles.
  99243. * @param successCallback an optional success callback to be called after the optimization finished.
  99244. * @returns the current mesh
  99245. */
  99246. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  99247. /**
  99248. * Serialize current mesh
  99249. * @param serializationObject defines the object which will receive the serialization data
  99250. */
  99251. serialize(serializationObject: any): void;
  99252. /** @hidden */
  99253. _syncGeometryWithMorphTargetManager(): void;
  99254. /** @hidden */
  99255. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  99256. /**
  99257. * Returns a new Mesh object parsed from the source provided.
  99258. * @param parsedMesh is the source
  99259. * @param scene defines the hosting scene
  99260. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  99261. * @returns a new Mesh
  99262. */
  99263. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  99264. /**
  99265. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  99266. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99267. * @param name defines the name of the mesh to create
  99268. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  99269. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  99270. * @param closePath creates a seam between the first and the last points of each path of the path array
  99271. * @param offset is taken in account only if the `pathArray` is containing a single path
  99272. * @param scene defines the hosting scene
  99273. * @param updatable defines if the mesh must be flagged as updatable
  99274. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99275. * @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)
  99276. * @returns a new Mesh
  99277. */
  99278. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99279. /**
  99280. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  99281. * @param name defines the name of the mesh to create
  99282. * @param radius sets the radius size (float) of the polygon (default 0.5)
  99283. * @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
  99284. * @param scene defines the hosting scene
  99285. * @param updatable defines if the mesh must be flagged as updatable
  99286. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99287. * @returns a new Mesh
  99288. */
  99289. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99290. /**
  99291. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  99292. * @param name defines the name of the mesh to create
  99293. * @param size sets the size (float) of each box side (default 1)
  99294. * @param scene defines the hosting scene
  99295. * @param updatable defines if the mesh must be flagged as updatable
  99296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99297. * @returns a new Mesh
  99298. */
  99299. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99300. /**
  99301. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  99302. * @param name defines the name of the mesh to create
  99303. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99304. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99305. * @param scene defines the hosting scene
  99306. * @param updatable defines if the mesh must be flagged as updatable
  99307. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99308. * @returns a new Mesh
  99309. */
  99310. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99311. /**
  99312. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  99313. * @param name defines the name of the mesh to create
  99314. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99315. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99316. * @param scene defines the hosting scene
  99317. * @returns a new Mesh
  99318. */
  99319. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  99320. /**
  99321. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  99322. * @param name defines the name of the mesh to create
  99323. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  99324. * @param diameterTop set the top cap diameter (floats, default 1)
  99325. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  99326. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  99327. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  99328. * @param scene defines the hosting scene
  99329. * @param updatable defines if the mesh must be flagged as updatable
  99330. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99331. * @returns a new Mesh
  99332. */
  99333. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  99334. /**
  99335. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  99336. * @param name defines the name of the mesh to create
  99337. * @param diameter sets the diameter size (float) of the torus (default 1)
  99338. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  99339. * @param tessellation sets the number of torus sides (postive integer, default 16)
  99340. * @param scene defines the hosting scene
  99341. * @param updatable defines if the mesh must be flagged as updatable
  99342. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99343. * @returns a new Mesh
  99344. */
  99345. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99346. /**
  99347. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  99348. * @param name defines the name of the mesh to create
  99349. * @param radius sets the global radius size (float) of the torus knot (default 2)
  99350. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  99351. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  99352. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  99353. * @param p the number of windings on X axis (positive integers, default 2)
  99354. * @param q the number of windings on Y axis (positive integers, default 3)
  99355. * @param scene defines the hosting scene
  99356. * @param updatable defines if the mesh must be flagged as updatable
  99357. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99358. * @returns a new Mesh
  99359. */
  99360. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99361. /**
  99362. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  99363. * @param name defines the name of the mesh to create
  99364. * @param points is an array successive Vector3
  99365. * @param scene defines the hosting scene
  99366. * @param updatable defines if the mesh must be flagged as updatable
  99367. * @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).
  99368. * @returns a new Mesh
  99369. */
  99370. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  99371. /**
  99372. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  99373. * @param name defines the name of the mesh to create
  99374. * @param points is an array successive Vector3
  99375. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  99376. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  99377. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  99378. * @param scene defines the hosting scene
  99379. * @param updatable defines if the mesh must be flagged as updatable
  99380. * @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)
  99381. * @returns a new Mesh
  99382. */
  99383. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  99384. /**
  99385. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  99386. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  99387. * 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.
  99388. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99389. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99390. * Remember you can only change the shape positions, not their number when updating a polygon.
  99391. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  99392. * @param name defines the name of the mesh to create
  99393. * @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
  99394. * @param scene defines the hosting scene
  99395. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99396. * @param updatable defines if the mesh must be flagged as updatable
  99397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99398. * @param earcutInjection can be used to inject your own earcut reference
  99399. * @returns a new Mesh
  99400. */
  99401. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99402. /**
  99403. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  99404. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  99405. * @param name defines the name of the mesh to create
  99406. * @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
  99407. * @param depth defines the height of extrusion
  99408. * @param scene defines the hosting scene
  99409. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99410. * @param updatable defines if the mesh must be flagged as updatable
  99411. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99412. * @param earcutInjection can be used to inject your own earcut reference
  99413. * @returns a new Mesh
  99414. */
  99415. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99416. /**
  99417. * Creates an extruded shape mesh.
  99418. * 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
  99419. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99420. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99421. * @param name defines the name of the mesh to create
  99422. * @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
  99423. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99424. * @param scale is the value to scale the shape
  99425. * @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
  99426. * @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
  99427. * @param scene defines the hosting scene
  99428. * @param updatable defines if the mesh must be flagged as updatable
  99429. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99430. * @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)
  99431. * @returns a new Mesh
  99432. */
  99433. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99434. /**
  99435. * Creates an custom extruded shape mesh.
  99436. * The custom extrusion is a parametric shape.
  99437. * It has no predefined shape. Its final shape will depend on the input parameters.
  99438. * Please consider using the same method from the MeshBuilder class instead
  99439. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99440. * @param name defines the name of the mesh to create
  99441. * @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
  99442. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99443. * @param scaleFunction is a custom Javascript function called on each path point
  99444. * @param rotationFunction is a custom Javascript function called on each path point
  99445. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  99446. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  99447. * @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
  99448. * @param scene defines the hosting scene
  99449. * @param updatable defines if the mesh must be flagged as updatable
  99450. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99451. * @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)
  99452. * @returns a new Mesh
  99453. */
  99454. 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;
  99455. /**
  99456. * Creates lathe mesh.
  99457. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  99458. * Please consider using the same method from the MeshBuilder class instead
  99459. * @param name defines the name of the mesh to create
  99460. * @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
  99461. * @param radius is the radius value of the lathe
  99462. * @param tessellation is the side number of the lathe.
  99463. * @param scene defines the hosting scene
  99464. * @param updatable defines if the mesh must be flagged as updatable
  99465. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99466. * @returns a new Mesh
  99467. */
  99468. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99469. /**
  99470. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  99471. * @param name defines the name of the mesh to create
  99472. * @param size sets the size (float) of both sides of the plane at once (default 1)
  99473. * @param scene defines the hosting scene
  99474. * @param updatable defines if the mesh must be flagged as updatable
  99475. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99476. * @returns a new Mesh
  99477. */
  99478. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99479. /**
  99480. * Creates a ground mesh.
  99481. * Please consider using the same method from the MeshBuilder class instead
  99482. * @param name defines the name of the mesh to create
  99483. * @param width set the width of the ground
  99484. * @param height set the height of the ground
  99485. * @param subdivisions sets the number of subdivisions per side
  99486. * @param scene defines the hosting scene
  99487. * @param updatable defines if the mesh must be flagged as updatable
  99488. * @returns a new Mesh
  99489. */
  99490. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  99491. /**
  99492. * Creates a tiled ground mesh.
  99493. * Please consider using the same method from the MeshBuilder class instead
  99494. * @param name defines the name of the mesh to create
  99495. * @param xmin set the ground minimum X coordinate
  99496. * @param zmin set the ground minimum Y coordinate
  99497. * @param xmax set the ground maximum X coordinate
  99498. * @param zmax set the ground maximum Z coordinate
  99499. * @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
  99500. * @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
  99501. * @param scene defines the hosting scene
  99502. * @param updatable defines if the mesh must be flagged as updatable
  99503. * @returns a new Mesh
  99504. */
  99505. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  99506. w: number;
  99507. h: number;
  99508. }, precision: {
  99509. w: number;
  99510. h: number;
  99511. }, scene: Scene, updatable?: boolean): Mesh;
  99512. /**
  99513. * Creates a ground mesh from a height map.
  99514. * Please consider using the same method from the MeshBuilder class instead
  99515. * @see http://doc.babylonjs.com/babylon101/height_map
  99516. * @param name defines the name of the mesh to create
  99517. * @param url sets the URL of the height map image resource
  99518. * @param width set the ground width size
  99519. * @param height set the ground height size
  99520. * @param subdivisions sets the number of subdivision per side
  99521. * @param minHeight is the minimum altitude on the ground
  99522. * @param maxHeight is the maximum altitude on the ground
  99523. * @param scene defines the hosting scene
  99524. * @param updatable defines if the mesh must be flagged as updatable
  99525. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  99526. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99527. * @returns a new Mesh
  99528. */
  99529. 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;
  99530. /**
  99531. * Creates a tube mesh.
  99532. * The tube is a parametric shape.
  99533. * It has no predefined shape. Its final shape will depend on the input parameters.
  99534. * Please consider using the same method from the MeshBuilder class instead
  99535. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99536. * @param name defines the name of the mesh to create
  99537. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  99538. * @param radius sets the tube radius size
  99539. * @param tessellation is the number of sides on the tubular surface
  99540. * @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
  99541. * @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
  99542. * @param scene defines the hosting scene
  99543. * @param updatable defines if the mesh must be flagged as updatable
  99544. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99545. * @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)
  99546. * @returns a new Mesh
  99547. */
  99548. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  99549. (i: number, distance: number): number;
  99550. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99551. /**
  99552. * Creates a polyhedron mesh.
  99553. * Please consider using the same method from the MeshBuilder class instead.
  99554. * * 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
  99555. * * The parameter `size` (positive float, default 1) sets the polygon size
  99556. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99557. * * 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`
  99558. * * 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
  99559. * * 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)`)
  99560. * * 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
  99561. * * 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
  99562. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99563. * * If you create a double-sided mesh, you can choose what parts of 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
  99564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99565. * @param name defines the name of the mesh to create
  99566. * @param options defines the options used to create the mesh
  99567. * @param scene defines the hosting scene
  99568. * @returns a new Mesh
  99569. */
  99570. static CreatePolyhedron(name: string, options: {
  99571. type?: number;
  99572. size?: number;
  99573. sizeX?: number;
  99574. sizeY?: number;
  99575. sizeZ?: number;
  99576. custom?: any;
  99577. faceUV?: Vector4[];
  99578. faceColors?: Color4[];
  99579. updatable?: boolean;
  99580. sideOrientation?: number;
  99581. }, scene: Scene): Mesh;
  99582. /**
  99583. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  99584. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  99585. * * 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`)
  99586. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  99587. * * 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
  99588. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99589. * * If you create a double-sided mesh, you can choose what parts of 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
  99590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99591. * @param name defines the name of the mesh
  99592. * @param options defines the options used to create the mesh
  99593. * @param scene defines the hosting scene
  99594. * @returns a new Mesh
  99595. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  99596. */
  99597. static CreateIcoSphere(name: string, options: {
  99598. radius?: number;
  99599. flat?: boolean;
  99600. subdivisions?: number;
  99601. sideOrientation?: number;
  99602. updatable?: boolean;
  99603. }, scene: Scene): Mesh;
  99604. /**
  99605. * Creates a decal mesh.
  99606. * Please consider using the same method from the MeshBuilder class instead.
  99607. * A decal is a mesh usually applied as a model onto the surface of another mesh
  99608. * @param name defines the name of the mesh
  99609. * @param sourceMesh defines the mesh receiving the decal
  99610. * @param position sets the position of the decal in world coordinates
  99611. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  99612. * @param size sets the decal scaling
  99613. * @param angle sets the angle to rotate the decal
  99614. * @returns a new Mesh
  99615. */
  99616. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  99617. /**
  99618. * Prepare internal position array for software CPU skinning
  99619. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  99620. */
  99621. setPositionsForCPUSkinning(): Float32Array;
  99622. /**
  99623. * Prepare internal normal array for software CPU skinning
  99624. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  99625. */
  99626. setNormalsForCPUSkinning(): Float32Array;
  99627. /**
  99628. * Updates the vertex buffer by applying transformation from the bones
  99629. * @param skeleton defines the skeleton to apply to current mesh
  99630. * @returns the current mesh
  99631. */
  99632. applySkeleton(skeleton: Skeleton): Mesh;
  99633. /**
  99634. * 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
  99635. * @param meshes defines the list of meshes to scan
  99636. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  99637. */
  99638. static MinMax(meshes: AbstractMesh[]): {
  99639. min: Vector3;
  99640. max: Vector3;
  99641. };
  99642. /**
  99643. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99644. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99645. * @returns a vector3
  99646. */
  99647. static Center(meshesOrMinMaxVector: {
  99648. min: Vector3;
  99649. max: Vector3;
  99650. } | AbstractMesh[]): Vector3;
  99651. /**
  99652. * Merge the array of meshes into a single mesh for performance reasons.
  99653. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99654. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99655. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99656. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99657. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99658. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99659. * @returns a new mesh
  99660. */
  99661. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99662. /** @hidden */
  99663. addInstance(instance: InstancedMesh): void;
  99664. /** @hidden */
  99665. removeInstance(instance: InstancedMesh): void;
  99666. }
  99667. }
  99668. declare module BABYLON {
  99669. /**
  99670. * This is the base class of all the camera used in the application.
  99671. * @see http://doc.babylonjs.com/features/cameras
  99672. */
  99673. export class Camera extends Node {
  99674. /** @hidden */
  99675. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99676. /**
  99677. * This is the default projection mode used by the cameras.
  99678. * It helps recreating a feeling of perspective and better appreciate depth.
  99679. * This is the best way to simulate real life cameras.
  99680. */
  99681. static readonly PERSPECTIVE_CAMERA: number;
  99682. /**
  99683. * This helps creating camera with an orthographic mode.
  99684. * 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.
  99685. */
  99686. static readonly ORTHOGRAPHIC_CAMERA: number;
  99687. /**
  99688. * This is the default FOV mode for perspective cameras.
  99689. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99690. */
  99691. static readonly FOVMODE_VERTICAL_FIXED: number;
  99692. /**
  99693. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99694. */
  99695. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99696. /**
  99697. * This specifies ther is no need for a camera rig.
  99698. * Basically only one eye is rendered corresponding to the camera.
  99699. */
  99700. static readonly RIG_MODE_NONE: number;
  99701. /**
  99702. * Simulates a camera Rig with one blue eye and one red eye.
  99703. * This can be use with 3d blue and red glasses.
  99704. */
  99705. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99706. /**
  99707. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99708. */
  99709. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99710. /**
  99711. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99712. */
  99713. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99714. /**
  99715. * Defines that both eyes of the camera will be rendered over under each other.
  99716. */
  99717. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99718. /**
  99719. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99720. */
  99721. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99722. /**
  99723. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99724. */
  99725. static readonly RIG_MODE_VR: number;
  99726. /**
  99727. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99728. */
  99729. static readonly RIG_MODE_WEBVR: number;
  99730. /**
  99731. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99732. */
  99733. static readonly RIG_MODE_CUSTOM: number;
  99734. /**
  99735. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99736. */
  99737. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99738. /**
  99739. * Define the input manager associated with the camera.
  99740. */
  99741. inputs: CameraInputsManager<Camera>;
  99742. /** @hidden */
  99743. _position: Vector3;
  99744. /**
  99745. * Define the current local position of the camera in the scene
  99746. */
  99747. get position(): Vector3;
  99748. set position(newPosition: Vector3);
  99749. /**
  99750. * The vector the camera should consider as up.
  99751. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99752. */
  99753. upVector: Vector3;
  99754. /**
  99755. * Define the current limit on the left side for an orthographic camera
  99756. * In scene unit
  99757. */
  99758. orthoLeft: Nullable<number>;
  99759. /**
  99760. * Define the current limit on the right side for an orthographic camera
  99761. * In scene unit
  99762. */
  99763. orthoRight: Nullable<number>;
  99764. /**
  99765. * Define the current limit on the bottom side for an orthographic camera
  99766. * In scene unit
  99767. */
  99768. orthoBottom: Nullable<number>;
  99769. /**
  99770. * Define the current limit on the top side for an orthographic camera
  99771. * In scene unit
  99772. */
  99773. orthoTop: Nullable<number>;
  99774. /**
  99775. * Field Of View is set in Radians. (default is 0.8)
  99776. */
  99777. fov: number;
  99778. /**
  99779. * Define the minimum distance the camera can see from.
  99780. * This is important to note that the depth buffer are not infinite and the closer it starts
  99781. * the more your scene might encounter depth fighting issue.
  99782. */
  99783. minZ: number;
  99784. /**
  99785. * Define the maximum distance the camera can see to.
  99786. * This is important to note that the depth buffer are not infinite and the further it end
  99787. * the more your scene might encounter depth fighting issue.
  99788. */
  99789. maxZ: number;
  99790. /**
  99791. * Define the default inertia of the camera.
  99792. * This helps giving a smooth feeling to the camera movement.
  99793. */
  99794. inertia: number;
  99795. /**
  99796. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  99797. */
  99798. mode: number;
  99799. /**
  99800. * Define whether the camera is intermediate.
  99801. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  99802. */
  99803. isIntermediate: boolean;
  99804. /**
  99805. * Define the viewport of the camera.
  99806. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  99807. */
  99808. viewport: Viewport;
  99809. /**
  99810. * Restricts the camera to viewing objects with the same layerMask.
  99811. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  99812. */
  99813. layerMask: number;
  99814. /**
  99815. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  99816. */
  99817. fovMode: number;
  99818. /**
  99819. * Rig mode of the camera.
  99820. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  99821. * This is normally controlled byt the camera themselves as internal use.
  99822. */
  99823. cameraRigMode: number;
  99824. /**
  99825. * Defines the distance between both "eyes" in case of a RIG
  99826. */
  99827. interaxialDistance: number;
  99828. /**
  99829. * Defines if stereoscopic rendering is done side by side or over under.
  99830. */
  99831. isStereoscopicSideBySide: boolean;
  99832. /**
  99833. * 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
  99834. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  99835. * else in the scene. (Eg. security camera)
  99836. *
  99837. * 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)
  99838. */
  99839. customRenderTargets: RenderTargetTexture[];
  99840. /**
  99841. * When set, the camera will render to this render target instead of the default canvas
  99842. *
  99843. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  99844. */
  99845. outputRenderTarget: Nullable<RenderTargetTexture>;
  99846. /**
  99847. * Observable triggered when the camera view matrix has changed.
  99848. */
  99849. onViewMatrixChangedObservable: Observable<Camera>;
  99850. /**
  99851. * Observable triggered when the camera Projection matrix has changed.
  99852. */
  99853. onProjectionMatrixChangedObservable: Observable<Camera>;
  99854. /**
  99855. * Observable triggered when the inputs have been processed.
  99856. */
  99857. onAfterCheckInputsObservable: Observable<Camera>;
  99858. /**
  99859. * Observable triggered when reset has been called and applied to the camera.
  99860. */
  99861. onRestoreStateObservable: Observable<Camera>;
  99862. /**
  99863. * Is this camera a part of a rig system?
  99864. */
  99865. isRigCamera: boolean;
  99866. /**
  99867. * If isRigCamera set to true this will be set with the parent camera.
  99868. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  99869. */
  99870. rigParent?: Camera;
  99871. /** @hidden */
  99872. _cameraRigParams: any;
  99873. /** @hidden */
  99874. _rigCameras: Camera[];
  99875. /** @hidden */
  99876. _rigPostProcess: Nullable<PostProcess>;
  99877. protected _webvrViewMatrix: Matrix;
  99878. /** @hidden */
  99879. _skipRendering: boolean;
  99880. /** @hidden */
  99881. _projectionMatrix: Matrix;
  99882. /** @hidden */
  99883. _postProcesses: Nullable<PostProcess>[];
  99884. /** @hidden */
  99885. _activeMeshes: SmartArray<AbstractMesh>;
  99886. protected _globalPosition: Vector3;
  99887. /** @hidden */
  99888. _computedViewMatrix: Matrix;
  99889. private _doNotComputeProjectionMatrix;
  99890. private _transformMatrix;
  99891. private _frustumPlanes;
  99892. private _refreshFrustumPlanes;
  99893. private _storedFov;
  99894. private _stateStored;
  99895. /**
  99896. * Instantiates a new camera object.
  99897. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  99898. * @see http://doc.babylonjs.com/features/cameras
  99899. * @param name Defines the name of the camera in the scene
  99900. * @param position Defines the position of the camera
  99901. * @param scene Defines the scene the camera belongs too
  99902. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  99903. */
  99904. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99905. /**
  99906. * Store current camera state (fov, position, etc..)
  99907. * @returns the camera
  99908. */
  99909. storeState(): Camera;
  99910. /**
  99911. * Restores the camera state values if it has been stored. You must call storeState() first
  99912. */
  99913. protected _restoreStateValues(): boolean;
  99914. /**
  99915. * Restored camera state. You must call storeState() first.
  99916. * @returns true if restored and false otherwise
  99917. */
  99918. restoreState(): boolean;
  99919. /**
  99920. * Gets the class name of the camera.
  99921. * @returns the class name
  99922. */
  99923. getClassName(): string;
  99924. /** @hidden */
  99925. readonly _isCamera: boolean;
  99926. /**
  99927. * Gets a string representation of the camera useful for debug purpose.
  99928. * @param fullDetails Defines that a more verboe level of logging is required
  99929. * @returns the string representation
  99930. */
  99931. toString(fullDetails?: boolean): string;
  99932. /**
  99933. * Gets the current world space position of the camera.
  99934. */
  99935. get globalPosition(): Vector3;
  99936. /**
  99937. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  99938. * @returns the active meshe list
  99939. */
  99940. getActiveMeshes(): SmartArray<AbstractMesh>;
  99941. /**
  99942. * Check whether a mesh is part of the current active mesh list of the camera
  99943. * @param mesh Defines the mesh to check
  99944. * @returns true if active, false otherwise
  99945. */
  99946. isActiveMesh(mesh: Mesh): boolean;
  99947. /**
  99948. * Is this camera ready to be used/rendered
  99949. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  99950. * @return true if the camera is ready
  99951. */
  99952. isReady(completeCheck?: boolean): boolean;
  99953. /** @hidden */
  99954. _initCache(): void;
  99955. /** @hidden */
  99956. _updateCache(ignoreParentClass?: boolean): void;
  99957. /** @hidden */
  99958. _isSynchronized(): boolean;
  99959. /** @hidden */
  99960. _isSynchronizedViewMatrix(): boolean;
  99961. /** @hidden */
  99962. _isSynchronizedProjectionMatrix(): boolean;
  99963. /**
  99964. * Attach the input controls to a specific dom element to get the input from.
  99965. * @param element Defines the element the controls should be listened from
  99966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99967. */
  99968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99969. /**
  99970. * Detach the current controls from the specified dom element.
  99971. * @param element Defines the element to stop listening the inputs from
  99972. */
  99973. detachControl(element: HTMLElement): void;
  99974. /**
  99975. * Update the camera state according to the different inputs gathered during the frame.
  99976. */
  99977. update(): void;
  99978. /** @hidden */
  99979. _checkInputs(): void;
  99980. /** @hidden */
  99981. get rigCameras(): Camera[];
  99982. /**
  99983. * Gets the post process used by the rig cameras
  99984. */
  99985. get rigPostProcess(): Nullable<PostProcess>;
  99986. /**
  99987. * Internal, gets the first post proces.
  99988. * @returns the first post process to be run on this camera.
  99989. */
  99990. _getFirstPostProcess(): Nullable<PostProcess>;
  99991. private _cascadePostProcessesToRigCams;
  99992. /**
  99993. * Attach a post process to the camera.
  99994. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99995. * @param postProcess The post process to attach to the camera
  99996. * @param insertAt The position of the post process in case several of them are in use in the scene
  99997. * @returns the position the post process has been inserted at
  99998. */
  99999. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  100000. /**
  100001. * Detach a post process to the camera.
  100002. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100003. * @param postProcess The post process to detach from the camera
  100004. */
  100005. detachPostProcess(postProcess: PostProcess): void;
  100006. /**
  100007. * Gets the current world matrix of the camera
  100008. */
  100009. getWorldMatrix(): Matrix;
  100010. /** @hidden */
  100011. _getViewMatrix(): Matrix;
  100012. /**
  100013. * Gets the current view matrix of the camera.
  100014. * @param force forces the camera to recompute the matrix without looking at the cached state
  100015. * @returns the view matrix
  100016. */
  100017. getViewMatrix(force?: boolean): Matrix;
  100018. /**
  100019. * Freeze the projection matrix.
  100020. * It will prevent the cache check of the camera projection compute and can speed up perf
  100021. * if no parameter of the camera are meant to change
  100022. * @param projection Defines manually a projection if necessary
  100023. */
  100024. freezeProjectionMatrix(projection?: Matrix): void;
  100025. /**
  100026. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  100027. */
  100028. unfreezeProjectionMatrix(): void;
  100029. /**
  100030. * Gets the current projection matrix of the camera.
  100031. * @param force forces the camera to recompute the matrix without looking at the cached state
  100032. * @returns the projection matrix
  100033. */
  100034. getProjectionMatrix(force?: boolean): Matrix;
  100035. /**
  100036. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  100037. * @returns a Matrix
  100038. */
  100039. getTransformationMatrix(): Matrix;
  100040. private _updateFrustumPlanes;
  100041. /**
  100042. * Checks if a cullable object (mesh...) is in the camera frustum
  100043. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  100044. * @param target The object to check
  100045. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  100046. * @returns true if the object is in frustum otherwise false
  100047. */
  100048. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  100049. /**
  100050. * Checks if a cullable object (mesh...) is in the camera frustum
  100051. * Unlike isInFrustum this cheks the full bounding box
  100052. * @param target The object to check
  100053. * @returns true if the object is in frustum otherwise false
  100054. */
  100055. isCompletelyInFrustum(target: ICullable): boolean;
  100056. /**
  100057. * Gets a ray in the forward direction from the camera.
  100058. * @param length Defines the length of the ray to create
  100059. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  100060. * @param origin Defines the start point of the ray which defaults to the camera position
  100061. * @returns the forward ray
  100062. */
  100063. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  100064. /**
  100065. * Releases resources associated with this node.
  100066. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100067. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100068. */
  100069. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100070. /** @hidden */
  100071. _isLeftCamera: boolean;
  100072. /**
  100073. * Gets the left camera of a rig setup in case of Rigged Camera
  100074. */
  100075. get isLeftCamera(): boolean;
  100076. /** @hidden */
  100077. _isRightCamera: boolean;
  100078. /**
  100079. * Gets the right camera of a rig setup in case of Rigged Camera
  100080. */
  100081. get isRightCamera(): boolean;
  100082. /**
  100083. * Gets the left camera of a rig setup in case of Rigged Camera
  100084. */
  100085. get leftCamera(): Nullable<FreeCamera>;
  100086. /**
  100087. * Gets the right camera of a rig setup in case of Rigged Camera
  100088. */
  100089. get rightCamera(): Nullable<FreeCamera>;
  100090. /**
  100091. * Gets the left camera target of a rig setup in case of Rigged Camera
  100092. * @returns the target position
  100093. */
  100094. getLeftTarget(): Nullable<Vector3>;
  100095. /**
  100096. * Gets the right camera target of a rig setup in case of Rigged Camera
  100097. * @returns the target position
  100098. */
  100099. getRightTarget(): Nullable<Vector3>;
  100100. /**
  100101. * @hidden
  100102. */
  100103. setCameraRigMode(mode: number, rigParams: any): void;
  100104. /** @hidden */
  100105. static _setStereoscopicRigMode(camera: Camera): void;
  100106. /** @hidden */
  100107. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  100108. /** @hidden */
  100109. static _setVRRigMode(camera: Camera, rigParams: any): void;
  100110. /** @hidden */
  100111. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  100112. /** @hidden */
  100113. _getVRProjectionMatrix(): Matrix;
  100114. protected _updateCameraRotationMatrix(): void;
  100115. protected _updateWebVRCameraRotationMatrix(): void;
  100116. /**
  100117. * This function MUST be overwritten by the different WebVR cameras available.
  100118. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100119. * @hidden
  100120. */
  100121. _getWebVRProjectionMatrix(): Matrix;
  100122. /**
  100123. * This function MUST be overwritten by the different WebVR cameras available.
  100124. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100125. * @hidden
  100126. */
  100127. _getWebVRViewMatrix(): Matrix;
  100128. /** @hidden */
  100129. setCameraRigParameter(name: string, value: any): void;
  100130. /**
  100131. * needs to be overridden by children so sub has required properties to be copied
  100132. * @hidden
  100133. */
  100134. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  100135. /**
  100136. * May need to be overridden by children
  100137. * @hidden
  100138. */
  100139. _updateRigCameras(): void;
  100140. /** @hidden */
  100141. _setupInputs(): void;
  100142. /**
  100143. * Serialiaze the camera setup to a json represention
  100144. * @returns the JSON representation
  100145. */
  100146. serialize(): any;
  100147. /**
  100148. * Clones the current camera.
  100149. * @param name The cloned camera name
  100150. * @returns the cloned camera
  100151. */
  100152. clone(name: string): Camera;
  100153. /**
  100154. * Gets the direction of the camera relative to a given local axis.
  100155. * @param localAxis Defines the reference axis to provide a relative direction.
  100156. * @return the direction
  100157. */
  100158. getDirection(localAxis: Vector3): Vector3;
  100159. /**
  100160. * Returns the current camera absolute rotation
  100161. */
  100162. get absoluteRotation(): Quaternion;
  100163. /**
  100164. * Gets the direction of the camera relative to a given local axis into a passed vector.
  100165. * @param localAxis Defines the reference axis to provide a relative direction.
  100166. * @param result Defines the vector to store the result in
  100167. */
  100168. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  100169. /**
  100170. * Gets a camera constructor for a given camera type
  100171. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  100172. * @param name The name of the camera the result will be able to instantiate
  100173. * @param scene The scene the result will construct the camera in
  100174. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  100175. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  100176. * @returns a factory method to construc the camera
  100177. */
  100178. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  100179. /**
  100180. * Compute the world matrix of the camera.
  100181. * @returns the camera world matrix
  100182. */
  100183. computeWorldMatrix(): Matrix;
  100184. /**
  100185. * Parse a JSON and creates the camera from the parsed information
  100186. * @param parsedCamera The JSON to parse
  100187. * @param scene The scene to instantiate the camera in
  100188. * @returns the newly constructed camera
  100189. */
  100190. static Parse(parsedCamera: any, scene: Scene): Camera;
  100191. }
  100192. }
  100193. declare module BABYLON {
  100194. /**
  100195. * Class containing static functions to help procedurally build meshes
  100196. */
  100197. export class DiscBuilder {
  100198. /**
  100199. * Creates a plane polygonal mesh. By default, this is a disc
  100200. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  100201. * * 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
  100202. * * 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
  100203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100206. * @param name defines the name of the mesh
  100207. * @param options defines the options used to create the mesh
  100208. * @param scene defines the hosting scene
  100209. * @returns the plane polygonal mesh
  100210. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  100211. */
  100212. static CreateDisc(name: string, options: {
  100213. radius?: number;
  100214. tessellation?: number;
  100215. arc?: number;
  100216. updatable?: boolean;
  100217. sideOrientation?: number;
  100218. frontUVs?: Vector4;
  100219. backUVs?: Vector4;
  100220. }, scene?: Nullable<Scene>): Mesh;
  100221. }
  100222. }
  100223. declare module BABYLON {
  100224. /**
  100225. * Options to be used when creating a FresnelParameters.
  100226. */
  100227. export type IFresnelParametersCreationOptions = {
  100228. /**
  100229. * Define the color used on edges (grazing angle)
  100230. */
  100231. leftColor?: Color3;
  100232. /**
  100233. * Define the color used on center
  100234. */
  100235. rightColor?: Color3;
  100236. /**
  100237. * Define bias applied to computed fresnel term
  100238. */
  100239. bias?: number;
  100240. /**
  100241. * Defined the power exponent applied to fresnel term
  100242. */
  100243. power?: number;
  100244. /**
  100245. * Define if the fresnel effect is enable or not.
  100246. */
  100247. isEnabled?: boolean;
  100248. };
  100249. /**
  100250. * Serialized format for FresnelParameters.
  100251. */
  100252. export type IFresnelParametersSerialized = {
  100253. /**
  100254. * Define the color used on edges (grazing angle) [as an array]
  100255. */
  100256. leftColor: number[];
  100257. /**
  100258. * Define the color used on center [as an array]
  100259. */
  100260. rightColor: number[];
  100261. /**
  100262. * Define bias applied to computed fresnel term
  100263. */
  100264. bias: number;
  100265. /**
  100266. * Defined the power exponent applied to fresnel term
  100267. */
  100268. power?: number;
  100269. /**
  100270. * Define if the fresnel effect is enable or not.
  100271. */
  100272. isEnabled: boolean;
  100273. };
  100274. /**
  100275. * This represents all the required information to add a fresnel effect on a material:
  100276. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100277. */
  100278. export class FresnelParameters {
  100279. private _isEnabled;
  100280. /**
  100281. * Define if the fresnel effect is enable or not.
  100282. */
  100283. get isEnabled(): boolean;
  100284. set isEnabled(value: boolean);
  100285. /**
  100286. * Define the color used on edges (grazing angle)
  100287. */
  100288. leftColor: Color3;
  100289. /**
  100290. * Define the color used on center
  100291. */
  100292. rightColor: Color3;
  100293. /**
  100294. * Define bias applied to computed fresnel term
  100295. */
  100296. bias: number;
  100297. /**
  100298. * Defined the power exponent applied to fresnel term
  100299. */
  100300. power: number;
  100301. /**
  100302. * Creates a new FresnelParameters object.
  100303. *
  100304. * @param options provide your own settings to optionally to override defaults
  100305. */
  100306. constructor(options?: IFresnelParametersCreationOptions);
  100307. /**
  100308. * Clones the current fresnel and its valuues
  100309. * @returns a clone fresnel configuration
  100310. */
  100311. clone(): FresnelParameters;
  100312. /**
  100313. * Determines equality between FresnelParameters objects
  100314. * @param otherFresnelParameters defines the second operand
  100315. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  100316. */
  100317. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  100318. /**
  100319. * Serializes the current fresnel parameters to a JSON representation.
  100320. * @return the JSON serialization
  100321. */
  100322. serialize(): IFresnelParametersSerialized;
  100323. /**
  100324. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  100325. * @param parsedFresnelParameters Define the JSON representation
  100326. * @returns the parsed parameters
  100327. */
  100328. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  100329. }
  100330. }
  100331. declare module BABYLON {
  100332. /**
  100333. * Base class of materials working in push mode in babylon JS
  100334. * @hidden
  100335. */
  100336. export class PushMaterial extends Material {
  100337. protected _activeEffect: Effect;
  100338. protected _normalMatrix: Matrix;
  100339. /**
  100340. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100341. * This means that the material can keep using a previous shader while a new one is being compiled.
  100342. * This is mostly used when shader parallel compilation is supported (true by default)
  100343. */
  100344. allowShaderHotSwapping: boolean;
  100345. constructor(name: string, scene: Scene);
  100346. getEffect(): Effect;
  100347. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100348. /**
  100349. * Binds the given world matrix to the active effect
  100350. *
  100351. * @param world the matrix to bind
  100352. */
  100353. bindOnlyWorldMatrix(world: Matrix): void;
  100354. /**
  100355. * Binds the given normal matrix to the active effect
  100356. *
  100357. * @param normalMatrix the matrix to bind
  100358. */
  100359. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100360. bind(world: Matrix, mesh?: Mesh): void;
  100361. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100362. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100363. }
  100364. }
  100365. declare module BABYLON {
  100366. /**
  100367. * This groups all the flags used to control the materials channel.
  100368. */
  100369. export class MaterialFlags {
  100370. private static _DiffuseTextureEnabled;
  100371. /**
  100372. * Are diffuse textures enabled in the application.
  100373. */
  100374. static get DiffuseTextureEnabled(): boolean;
  100375. static set DiffuseTextureEnabled(value: boolean);
  100376. private static _AmbientTextureEnabled;
  100377. /**
  100378. * Are ambient textures enabled in the application.
  100379. */
  100380. static get AmbientTextureEnabled(): boolean;
  100381. static set AmbientTextureEnabled(value: boolean);
  100382. private static _OpacityTextureEnabled;
  100383. /**
  100384. * Are opacity textures enabled in the application.
  100385. */
  100386. static get OpacityTextureEnabled(): boolean;
  100387. static set OpacityTextureEnabled(value: boolean);
  100388. private static _ReflectionTextureEnabled;
  100389. /**
  100390. * Are reflection textures enabled in the application.
  100391. */
  100392. static get ReflectionTextureEnabled(): boolean;
  100393. static set ReflectionTextureEnabled(value: boolean);
  100394. private static _EmissiveTextureEnabled;
  100395. /**
  100396. * Are emissive textures enabled in the application.
  100397. */
  100398. static get EmissiveTextureEnabled(): boolean;
  100399. static set EmissiveTextureEnabled(value: boolean);
  100400. private static _SpecularTextureEnabled;
  100401. /**
  100402. * Are specular textures enabled in the application.
  100403. */
  100404. static get SpecularTextureEnabled(): boolean;
  100405. static set SpecularTextureEnabled(value: boolean);
  100406. private static _BumpTextureEnabled;
  100407. /**
  100408. * Are bump textures enabled in the application.
  100409. */
  100410. static get BumpTextureEnabled(): boolean;
  100411. static set BumpTextureEnabled(value: boolean);
  100412. private static _LightmapTextureEnabled;
  100413. /**
  100414. * Are lightmap textures enabled in the application.
  100415. */
  100416. static get LightmapTextureEnabled(): boolean;
  100417. static set LightmapTextureEnabled(value: boolean);
  100418. private static _RefractionTextureEnabled;
  100419. /**
  100420. * Are refraction textures enabled in the application.
  100421. */
  100422. static get RefractionTextureEnabled(): boolean;
  100423. static set RefractionTextureEnabled(value: boolean);
  100424. private static _ColorGradingTextureEnabled;
  100425. /**
  100426. * Are color grading textures enabled in the application.
  100427. */
  100428. static get ColorGradingTextureEnabled(): boolean;
  100429. static set ColorGradingTextureEnabled(value: boolean);
  100430. private static _FresnelEnabled;
  100431. /**
  100432. * Are fresnels enabled in the application.
  100433. */
  100434. static get FresnelEnabled(): boolean;
  100435. static set FresnelEnabled(value: boolean);
  100436. private static _ClearCoatTextureEnabled;
  100437. /**
  100438. * Are clear coat textures enabled in the application.
  100439. */
  100440. static get ClearCoatTextureEnabled(): boolean;
  100441. static set ClearCoatTextureEnabled(value: boolean);
  100442. private static _ClearCoatBumpTextureEnabled;
  100443. /**
  100444. * Are clear coat bump textures enabled in the application.
  100445. */
  100446. static get ClearCoatBumpTextureEnabled(): boolean;
  100447. static set ClearCoatBumpTextureEnabled(value: boolean);
  100448. private static _ClearCoatTintTextureEnabled;
  100449. /**
  100450. * Are clear coat tint textures enabled in the application.
  100451. */
  100452. static get ClearCoatTintTextureEnabled(): boolean;
  100453. static set ClearCoatTintTextureEnabled(value: boolean);
  100454. private static _SheenTextureEnabled;
  100455. /**
  100456. * Are sheen textures enabled in the application.
  100457. */
  100458. static get SheenTextureEnabled(): boolean;
  100459. static set SheenTextureEnabled(value: boolean);
  100460. private static _AnisotropicTextureEnabled;
  100461. /**
  100462. * Are anisotropic textures enabled in the application.
  100463. */
  100464. static get AnisotropicTextureEnabled(): boolean;
  100465. static set AnisotropicTextureEnabled(value: boolean);
  100466. private static _ThicknessTextureEnabled;
  100467. /**
  100468. * Are thickness textures enabled in the application.
  100469. */
  100470. static get ThicknessTextureEnabled(): boolean;
  100471. static set ThicknessTextureEnabled(value: boolean);
  100472. }
  100473. }
  100474. declare module BABYLON {
  100475. /** @hidden */
  100476. export var defaultFragmentDeclaration: {
  100477. name: string;
  100478. shader: string;
  100479. };
  100480. }
  100481. declare module BABYLON {
  100482. /** @hidden */
  100483. export var defaultUboDeclaration: {
  100484. name: string;
  100485. shader: string;
  100486. };
  100487. }
  100488. declare module BABYLON {
  100489. /** @hidden */
  100490. export var lightFragmentDeclaration: {
  100491. name: string;
  100492. shader: string;
  100493. };
  100494. }
  100495. declare module BABYLON {
  100496. /** @hidden */
  100497. export var lightUboDeclaration: {
  100498. name: string;
  100499. shader: string;
  100500. };
  100501. }
  100502. declare module BABYLON {
  100503. /** @hidden */
  100504. export var lightsFragmentFunctions: {
  100505. name: string;
  100506. shader: string;
  100507. };
  100508. }
  100509. declare module BABYLON {
  100510. /** @hidden */
  100511. export var shadowsFragmentFunctions: {
  100512. name: string;
  100513. shader: string;
  100514. };
  100515. }
  100516. declare module BABYLON {
  100517. /** @hidden */
  100518. export var fresnelFunction: {
  100519. name: string;
  100520. shader: string;
  100521. };
  100522. }
  100523. declare module BABYLON {
  100524. /** @hidden */
  100525. export var reflectionFunction: {
  100526. name: string;
  100527. shader: string;
  100528. };
  100529. }
  100530. declare module BABYLON {
  100531. /** @hidden */
  100532. export var bumpFragmentFunctions: {
  100533. name: string;
  100534. shader: string;
  100535. };
  100536. }
  100537. declare module BABYLON {
  100538. /** @hidden */
  100539. export var logDepthDeclaration: {
  100540. name: string;
  100541. shader: string;
  100542. };
  100543. }
  100544. declare module BABYLON {
  100545. /** @hidden */
  100546. export var bumpFragment: {
  100547. name: string;
  100548. shader: string;
  100549. };
  100550. }
  100551. declare module BABYLON {
  100552. /** @hidden */
  100553. export var depthPrePass: {
  100554. name: string;
  100555. shader: string;
  100556. };
  100557. }
  100558. declare module BABYLON {
  100559. /** @hidden */
  100560. export var lightFragment: {
  100561. name: string;
  100562. shader: string;
  100563. };
  100564. }
  100565. declare module BABYLON {
  100566. /** @hidden */
  100567. export var logDepthFragment: {
  100568. name: string;
  100569. shader: string;
  100570. };
  100571. }
  100572. declare module BABYLON {
  100573. /** @hidden */
  100574. export var defaultPixelShader: {
  100575. name: string;
  100576. shader: string;
  100577. };
  100578. }
  100579. declare module BABYLON {
  100580. /** @hidden */
  100581. export var defaultVertexDeclaration: {
  100582. name: string;
  100583. shader: string;
  100584. };
  100585. }
  100586. declare module BABYLON {
  100587. /** @hidden */
  100588. export var bumpVertexDeclaration: {
  100589. name: string;
  100590. shader: string;
  100591. };
  100592. }
  100593. declare module BABYLON {
  100594. /** @hidden */
  100595. export var bumpVertex: {
  100596. name: string;
  100597. shader: string;
  100598. };
  100599. }
  100600. declare module BABYLON {
  100601. /** @hidden */
  100602. export var fogVertex: {
  100603. name: string;
  100604. shader: string;
  100605. };
  100606. }
  100607. declare module BABYLON {
  100608. /** @hidden */
  100609. export var shadowsVertex: {
  100610. name: string;
  100611. shader: string;
  100612. };
  100613. }
  100614. declare module BABYLON {
  100615. /** @hidden */
  100616. export var pointCloudVertex: {
  100617. name: string;
  100618. shader: string;
  100619. };
  100620. }
  100621. declare module BABYLON {
  100622. /** @hidden */
  100623. export var logDepthVertex: {
  100624. name: string;
  100625. shader: string;
  100626. };
  100627. }
  100628. declare module BABYLON {
  100629. /** @hidden */
  100630. export var defaultVertexShader: {
  100631. name: string;
  100632. shader: string;
  100633. };
  100634. }
  100635. declare module BABYLON {
  100636. /** @hidden */
  100637. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100638. MAINUV1: boolean;
  100639. MAINUV2: boolean;
  100640. DIFFUSE: boolean;
  100641. DIFFUSEDIRECTUV: number;
  100642. AMBIENT: boolean;
  100643. AMBIENTDIRECTUV: number;
  100644. OPACITY: boolean;
  100645. OPACITYDIRECTUV: number;
  100646. OPACITYRGB: boolean;
  100647. REFLECTION: boolean;
  100648. EMISSIVE: boolean;
  100649. EMISSIVEDIRECTUV: number;
  100650. SPECULAR: boolean;
  100651. SPECULARDIRECTUV: number;
  100652. BUMP: boolean;
  100653. BUMPDIRECTUV: number;
  100654. PARALLAX: boolean;
  100655. PARALLAXOCCLUSION: boolean;
  100656. SPECULAROVERALPHA: boolean;
  100657. CLIPPLANE: boolean;
  100658. CLIPPLANE2: boolean;
  100659. CLIPPLANE3: boolean;
  100660. CLIPPLANE4: boolean;
  100661. CLIPPLANE5: boolean;
  100662. CLIPPLANE6: boolean;
  100663. ALPHATEST: boolean;
  100664. DEPTHPREPASS: boolean;
  100665. ALPHAFROMDIFFUSE: boolean;
  100666. POINTSIZE: boolean;
  100667. FOG: boolean;
  100668. SPECULARTERM: boolean;
  100669. DIFFUSEFRESNEL: boolean;
  100670. OPACITYFRESNEL: boolean;
  100671. REFLECTIONFRESNEL: boolean;
  100672. REFRACTIONFRESNEL: boolean;
  100673. EMISSIVEFRESNEL: boolean;
  100674. FRESNEL: boolean;
  100675. NORMAL: boolean;
  100676. UV1: boolean;
  100677. UV2: boolean;
  100678. VERTEXCOLOR: boolean;
  100679. VERTEXALPHA: boolean;
  100680. NUM_BONE_INFLUENCERS: number;
  100681. BonesPerMesh: number;
  100682. BONETEXTURE: boolean;
  100683. INSTANCES: boolean;
  100684. GLOSSINESS: boolean;
  100685. ROUGHNESS: boolean;
  100686. EMISSIVEASILLUMINATION: boolean;
  100687. LINKEMISSIVEWITHDIFFUSE: boolean;
  100688. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100689. LIGHTMAP: boolean;
  100690. LIGHTMAPDIRECTUV: number;
  100691. OBJECTSPACE_NORMALMAP: boolean;
  100692. USELIGHTMAPASSHADOWMAP: boolean;
  100693. REFLECTIONMAP_3D: boolean;
  100694. REFLECTIONMAP_SPHERICAL: boolean;
  100695. REFLECTIONMAP_PLANAR: boolean;
  100696. REFLECTIONMAP_CUBIC: boolean;
  100697. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100698. REFLECTIONMAP_PROJECTION: boolean;
  100699. REFLECTIONMAP_SKYBOX: boolean;
  100700. REFLECTIONMAP_EXPLICIT: boolean;
  100701. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100702. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100703. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100704. INVERTCUBICMAP: boolean;
  100705. LOGARITHMICDEPTH: boolean;
  100706. REFRACTION: boolean;
  100707. REFRACTIONMAP_3D: boolean;
  100708. REFLECTIONOVERALPHA: boolean;
  100709. TWOSIDEDLIGHTING: boolean;
  100710. SHADOWFLOAT: boolean;
  100711. MORPHTARGETS: boolean;
  100712. MORPHTARGETS_NORMAL: boolean;
  100713. MORPHTARGETS_TANGENT: boolean;
  100714. MORPHTARGETS_UV: boolean;
  100715. NUM_MORPH_INFLUENCERS: number;
  100716. NONUNIFORMSCALING: boolean;
  100717. PREMULTIPLYALPHA: boolean;
  100718. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100719. ALPHABLEND: boolean;
  100720. IMAGEPROCESSING: boolean;
  100721. VIGNETTE: boolean;
  100722. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100723. VIGNETTEBLENDMODEOPAQUE: boolean;
  100724. TONEMAPPING: boolean;
  100725. TONEMAPPING_ACES: boolean;
  100726. CONTRAST: boolean;
  100727. COLORCURVES: boolean;
  100728. COLORGRADING: boolean;
  100729. COLORGRADING3D: boolean;
  100730. SAMPLER3DGREENDEPTH: boolean;
  100731. SAMPLER3DBGRMAP: boolean;
  100732. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100733. MULTIVIEW: boolean;
  100734. /**
  100735. * If the reflection texture on this material is in linear color space
  100736. * @hidden
  100737. */
  100738. IS_REFLECTION_LINEAR: boolean;
  100739. /**
  100740. * If the refraction texture on this material is in linear color space
  100741. * @hidden
  100742. */
  100743. IS_REFRACTION_LINEAR: boolean;
  100744. EXPOSURE: boolean;
  100745. constructor();
  100746. setReflectionMode(modeToEnable: string): void;
  100747. }
  100748. /**
  100749. * This is the default material used in Babylon. It is the best trade off between quality
  100750. * and performances.
  100751. * @see http://doc.babylonjs.com/babylon101/materials
  100752. */
  100753. export class StandardMaterial extends PushMaterial {
  100754. private _diffuseTexture;
  100755. /**
  100756. * The basic texture of the material as viewed under a light.
  100757. */
  100758. diffuseTexture: Nullable<BaseTexture>;
  100759. private _ambientTexture;
  100760. /**
  100761. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100762. */
  100763. ambientTexture: Nullable<BaseTexture>;
  100764. private _opacityTexture;
  100765. /**
  100766. * Define the transparency of the material from a texture.
  100767. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100768. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100769. */
  100770. opacityTexture: Nullable<BaseTexture>;
  100771. private _reflectionTexture;
  100772. /**
  100773. * Define the texture used to display the reflection.
  100774. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100775. */
  100776. reflectionTexture: Nullable<BaseTexture>;
  100777. private _emissiveTexture;
  100778. /**
  100779. * Define texture of the material as if self lit.
  100780. * This will be mixed in the final result even in the absence of light.
  100781. */
  100782. emissiveTexture: Nullable<BaseTexture>;
  100783. private _specularTexture;
  100784. /**
  100785. * Define how the color and intensity of the highlight given by the light in the material.
  100786. */
  100787. specularTexture: Nullable<BaseTexture>;
  100788. private _bumpTexture;
  100789. /**
  100790. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100791. * 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.
  100792. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  100793. */
  100794. bumpTexture: Nullable<BaseTexture>;
  100795. private _lightmapTexture;
  100796. /**
  100797. * Complex lighting can be computationally expensive to compute at runtime.
  100798. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100799. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  100800. */
  100801. lightmapTexture: Nullable<BaseTexture>;
  100802. private _refractionTexture;
  100803. /**
  100804. * Define the texture used to display the refraction.
  100805. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100806. */
  100807. refractionTexture: Nullable<BaseTexture>;
  100808. /**
  100809. * The color of the material lit by the environmental background lighting.
  100810. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100811. */
  100812. ambientColor: Color3;
  100813. /**
  100814. * The basic color of the material as viewed under a light.
  100815. */
  100816. diffuseColor: Color3;
  100817. /**
  100818. * Define how the color and intensity of the highlight given by the light in the material.
  100819. */
  100820. specularColor: Color3;
  100821. /**
  100822. * Define the color of the material as if self lit.
  100823. * This will be mixed in the final result even in the absence of light.
  100824. */
  100825. emissiveColor: Color3;
  100826. /**
  100827. * Defines how sharp are the highlights in the material.
  100828. * The bigger the value the sharper giving a more glossy feeling to the result.
  100829. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100830. */
  100831. specularPower: number;
  100832. private _useAlphaFromDiffuseTexture;
  100833. /**
  100834. * Does the transparency come from the diffuse texture alpha channel.
  100835. */
  100836. useAlphaFromDiffuseTexture: boolean;
  100837. private _useEmissiveAsIllumination;
  100838. /**
  100839. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100840. */
  100841. useEmissiveAsIllumination: boolean;
  100842. private _linkEmissiveWithDiffuse;
  100843. /**
  100844. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100845. * the emissive level when the final color is close to one.
  100846. */
  100847. linkEmissiveWithDiffuse: boolean;
  100848. private _useSpecularOverAlpha;
  100849. /**
  100850. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100851. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100852. */
  100853. useSpecularOverAlpha: boolean;
  100854. private _useReflectionOverAlpha;
  100855. /**
  100856. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100857. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100858. */
  100859. useReflectionOverAlpha: boolean;
  100860. private _disableLighting;
  100861. /**
  100862. * Does lights from the scene impacts this material.
  100863. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100864. */
  100865. disableLighting: boolean;
  100866. private _useObjectSpaceNormalMap;
  100867. /**
  100868. * Allows using an object space normal map (instead of tangent space).
  100869. */
  100870. useObjectSpaceNormalMap: boolean;
  100871. private _useParallax;
  100872. /**
  100873. * Is parallax enabled or not.
  100874. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100875. */
  100876. useParallax: boolean;
  100877. private _useParallaxOcclusion;
  100878. /**
  100879. * Is parallax occlusion enabled or not.
  100880. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100881. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  100882. */
  100883. useParallaxOcclusion: boolean;
  100884. /**
  100885. * 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.
  100886. */
  100887. parallaxScaleBias: number;
  100888. private _roughness;
  100889. /**
  100890. * Helps to define how blurry the reflections should appears in the material.
  100891. */
  100892. roughness: number;
  100893. /**
  100894. * In case of refraction, define the value of the index of refraction.
  100895. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100896. */
  100897. indexOfRefraction: number;
  100898. /**
  100899. * Invert the refraction texture alongside the y axis.
  100900. * It can be useful with procedural textures or probe for instance.
  100901. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100902. */
  100903. invertRefractionY: boolean;
  100904. /**
  100905. * Defines the alpha limits in alpha test mode.
  100906. */
  100907. alphaCutOff: number;
  100908. private _useLightmapAsShadowmap;
  100909. /**
  100910. * In case of light mapping, define whether the map contains light or shadow informations.
  100911. */
  100912. useLightmapAsShadowmap: boolean;
  100913. private _diffuseFresnelParameters;
  100914. /**
  100915. * Define the diffuse fresnel parameters of the material.
  100916. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100917. */
  100918. diffuseFresnelParameters: FresnelParameters;
  100919. private _opacityFresnelParameters;
  100920. /**
  100921. * Define the opacity fresnel parameters of the material.
  100922. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100923. */
  100924. opacityFresnelParameters: FresnelParameters;
  100925. private _reflectionFresnelParameters;
  100926. /**
  100927. * Define the reflection fresnel parameters of the material.
  100928. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100929. */
  100930. reflectionFresnelParameters: FresnelParameters;
  100931. private _refractionFresnelParameters;
  100932. /**
  100933. * Define the refraction fresnel parameters of the material.
  100934. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100935. */
  100936. refractionFresnelParameters: FresnelParameters;
  100937. private _emissiveFresnelParameters;
  100938. /**
  100939. * Define the emissive fresnel parameters of the material.
  100940. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100941. */
  100942. emissiveFresnelParameters: FresnelParameters;
  100943. private _useReflectionFresnelFromSpecular;
  100944. /**
  100945. * If true automatically deducts the fresnels values from the material specularity.
  100946. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100947. */
  100948. useReflectionFresnelFromSpecular: boolean;
  100949. private _useGlossinessFromSpecularMapAlpha;
  100950. /**
  100951. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100952. */
  100953. useGlossinessFromSpecularMapAlpha: boolean;
  100954. private _maxSimultaneousLights;
  100955. /**
  100956. * Defines the maximum number of lights that can be used in the material
  100957. */
  100958. maxSimultaneousLights: number;
  100959. private _invertNormalMapX;
  100960. /**
  100961. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100962. */
  100963. invertNormalMapX: boolean;
  100964. private _invertNormalMapY;
  100965. /**
  100966. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100967. */
  100968. invertNormalMapY: boolean;
  100969. private _twoSidedLighting;
  100970. /**
  100971. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100972. */
  100973. twoSidedLighting: boolean;
  100974. /**
  100975. * Default configuration related to image processing available in the standard Material.
  100976. */
  100977. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100978. /**
  100979. * Gets the image processing configuration used either in this material.
  100980. */
  100981. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100982. /**
  100983. * Sets the Default image processing configuration used either in the this material.
  100984. *
  100985. * If sets to null, the scene one is in use.
  100986. */
  100987. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100988. /**
  100989. * Keep track of the image processing observer to allow dispose and replace.
  100990. */
  100991. private _imageProcessingObserver;
  100992. /**
  100993. * Attaches a new image processing configuration to the Standard Material.
  100994. * @param configuration
  100995. */
  100996. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100997. /**
  100998. * Gets wether the color curves effect is enabled.
  100999. */
  101000. get cameraColorCurvesEnabled(): boolean;
  101001. /**
  101002. * Sets wether the color curves effect is enabled.
  101003. */
  101004. set cameraColorCurvesEnabled(value: boolean);
  101005. /**
  101006. * Gets wether the color grading effect is enabled.
  101007. */
  101008. get cameraColorGradingEnabled(): boolean;
  101009. /**
  101010. * Gets wether the color grading effect is enabled.
  101011. */
  101012. set cameraColorGradingEnabled(value: boolean);
  101013. /**
  101014. * Gets wether tonemapping is enabled or not.
  101015. */
  101016. get cameraToneMappingEnabled(): boolean;
  101017. /**
  101018. * Sets wether tonemapping is enabled or not
  101019. */
  101020. set cameraToneMappingEnabled(value: boolean);
  101021. /**
  101022. * The camera exposure used on this material.
  101023. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101024. * This corresponds to a photographic exposure.
  101025. */
  101026. get cameraExposure(): number;
  101027. /**
  101028. * The camera exposure used on this material.
  101029. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101030. * This corresponds to a photographic exposure.
  101031. */
  101032. set cameraExposure(value: number);
  101033. /**
  101034. * Gets The camera contrast used on this material.
  101035. */
  101036. get cameraContrast(): number;
  101037. /**
  101038. * Sets The camera contrast used on this material.
  101039. */
  101040. set cameraContrast(value: number);
  101041. /**
  101042. * Gets the Color Grading 2D Lookup Texture.
  101043. */
  101044. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  101045. /**
  101046. * Sets the Color Grading 2D Lookup Texture.
  101047. */
  101048. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  101049. /**
  101050. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101051. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101052. * 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;
  101053. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101054. */
  101055. get cameraColorCurves(): Nullable<ColorCurves>;
  101056. /**
  101057. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101058. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101059. * 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;
  101060. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101061. */
  101062. set cameraColorCurves(value: Nullable<ColorCurves>);
  101063. /**
  101064. * Custom callback helping to override the default shader used in the material.
  101065. */
  101066. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  101067. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101068. protected _worldViewProjectionMatrix: Matrix;
  101069. protected _globalAmbientColor: Color3;
  101070. protected _useLogarithmicDepth: boolean;
  101071. protected _rebuildInParallel: boolean;
  101072. /**
  101073. * Instantiates a new standard material.
  101074. * This is the default material used in Babylon. It is the best trade off between quality
  101075. * and performances.
  101076. * @see http://doc.babylonjs.com/babylon101/materials
  101077. * @param name Define the name of the material in the scene
  101078. * @param scene Define the scene the material belong to
  101079. */
  101080. constructor(name: string, scene: Scene);
  101081. /**
  101082. * Gets a boolean indicating that current material needs to register RTT
  101083. */
  101084. get hasRenderTargetTextures(): boolean;
  101085. /**
  101086. * Gets the current class name of the material e.g. "StandardMaterial"
  101087. * Mainly use in serialization.
  101088. * @returns the class name
  101089. */
  101090. getClassName(): string;
  101091. /**
  101092. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101093. * You can try switching to logarithmic depth.
  101094. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101095. */
  101096. get useLogarithmicDepth(): boolean;
  101097. set useLogarithmicDepth(value: boolean);
  101098. /**
  101099. * Specifies if the material will require alpha blending
  101100. * @returns a boolean specifying if alpha blending is needed
  101101. */
  101102. needAlphaBlending(): boolean;
  101103. /**
  101104. * Specifies if this material should be rendered in alpha test mode
  101105. * @returns a boolean specifying if an alpha test is needed.
  101106. */
  101107. needAlphaTesting(): boolean;
  101108. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101109. /**
  101110. * Get the texture used for alpha test purpose.
  101111. * @returns the diffuse texture in case of the standard material.
  101112. */
  101113. getAlphaTestTexture(): Nullable<BaseTexture>;
  101114. /**
  101115. * Get if the submesh is ready to be used and all its information available.
  101116. * Child classes can use it to update shaders
  101117. * @param mesh defines the mesh to check
  101118. * @param subMesh defines which submesh to check
  101119. * @param useInstances specifies that instances should be used
  101120. * @returns a boolean indicating that the submesh is ready or not
  101121. */
  101122. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101123. /**
  101124. * Builds the material UBO layouts.
  101125. * Used internally during the effect preparation.
  101126. */
  101127. buildUniformLayout(): void;
  101128. /**
  101129. * Unbinds the material from the mesh
  101130. */
  101131. unbind(): void;
  101132. /**
  101133. * Binds the submesh to this material by preparing the effect and shader to draw
  101134. * @param world defines the world transformation matrix
  101135. * @param mesh defines the mesh containing the submesh
  101136. * @param subMesh defines the submesh to bind the material to
  101137. */
  101138. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101139. /**
  101140. * Get the list of animatables in the material.
  101141. * @returns the list of animatables object used in the material
  101142. */
  101143. getAnimatables(): IAnimatable[];
  101144. /**
  101145. * Gets the active textures from the material
  101146. * @returns an array of textures
  101147. */
  101148. getActiveTextures(): BaseTexture[];
  101149. /**
  101150. * Specifies if the material uses a texture
  101151. * @param texture defines the texture to check against the material
  101152. * @returns a boolean specifying if the material uses the texture
  101153. */
  101154. hasTexture(texture: BaseTexture): boolean;
  101155. /**
  101156. * Disposes the material
  101157. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101158. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101159. */
  101160. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101161. /**
  101162. * Makes a duplicate of the material, and gives it a new name
  101163. * @param name defines the new name for the duplicated material
  101164. * @returns the cloned material
  101165. */
  101166. clone(name: string): StandardMaterial;
  101167. /**
  101168. * Serializes this material in a JSON representation
  101169. * @returns the serialized material object
  101170. */
  101171. serialize(): any;
  101172. /**
  101173. * Creates a standard material from parsed material data
  101174. * @param source defines the JSON representation of the material
  101175. * @param scene defines the hosting scene
  101176. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101177. * @returns a new standard material
  101178. */
  101179. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101180. /**
  101181. * Are diffuse textures enabled in the application.
  101182. */
  101183. static get DiffuseTextureEnabled(): boolean;
  101184. static set DiffuseTextureEnabled(value: boolean);
  101185. /**
  101186. * Are ambient textures enabled in the application.
  101187. */
  101188. static get AmbientTextureEnabled(): boolean;
  101189. static set AmbientTextureEnabled(value: boolean);
  101190. /**
  101191. * Are opacity textures enabled in the application.
  101192. */
  101193. static get OpacityTextureEnabled(): boolean;
  101194. static set OpacityTextureEnabled(value: boolean);
  101195. /**
  101196. * Are reflection textures enabled in the application.
  101197. */
  101198. static get ReflectionTextureEnabled(): boolean;
  101199. static set ReflectionTextureEnabled(value: boolean);
  101200. /**
  101201. * Are emissive textures enabled in the application.
  101202. */
  101203. static get EmissiveTextureEnabled(): boolean;
  101204. static set EmissiveTextureEnabled(value: boolean);
  101205. /**
  101206. * Are specular textures enabled in the application.
  101207. */
  101208. static get SpecularTextureEnabled(): boolean;
  101209. static set SpecularTextureEnabled(value: boolean);
  101210. /**
  101211. * Are bump textures enabled in the application.
  101212. */
  101213. static get BumpTextureEnabled(): boolean;
  101214. static set BumpTextureEnabled(value: boolean);
  101215. /**
  101216. * Are lightmap textures enabled in the application.
  101217. */
  101218. static get LightmapTextureEnabled(): boolean;
  101219. static set LightmapTextureEnabled(value: boolean);
  101220. /**
  101221. * Are refraction textures enabled in the application.
  101222. */
  101223. static get RefractionTextureEnabled(): boolean;
  101224. static set RefractionTextureEnabled(value: boolean);
  101225. /**
  101226. * Are color grading textures enabled in the application.
  101227. */
  101228. static get ColorGradingTextureEnabled(): boolean;
  101229. static set ColorGradingTextureEnabled(value: boolean);
  101230. /**
  101231. * Are fresnels enabled in the application.
  101232. */
  101233. static get FresnelEnabled(): boolean;
  101234. static set FresnelEnabled(value: boolean);
  101235. }
  101236. }
  101237. declare module BABYLON {
  101238. /**
  101239. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  101240. *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.
  101241. * The SPS is also a particle system. It provides some methods to manage the particles.
  101242. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  101243. *
  101244. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  101245. */
  101246. export class SolidParticleSystem implements IDisposable {
  101247. /**
  101248. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  101249. * Example : var p = SPS.particles[i];
  101250. */
  101251. particles: SolidParticle[];
  101252. /**
  101253. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  101254. */
  101255. nbParticles: number;
  101256. /**
  101257. * If the particles must ever face the camera (default false). Useful for planar particles.
  101258. */
  101259. billboard: boolean;
  101260. /**
  101261. * Recompute normals when adding a shape
  101262. */
  101263. recomputeNormals: boolean;
  101264. /**
  101265. * This a counter ofr your own usage. It's not set by any SPS functions.
  101266. */
  101267. counter: number;
  101268. /**
  101269. * The SPS name. This name is also given to the underlying mesh.
  101270. */
  101271. name: string;
  101272. /**
  101273. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  101274. */
  101275. mesh: Mesh;
  101276. /**
  101277. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  101278. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  101279. */
  101280. vars: any;
  101281. /**
  101282. * This array is populated when the SPS is set as 'pickable'.
  101283. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  101284. * Each element of this array is an object `{idx: int, faceId: int}`.
  101285. * `idx` is the picked particle index in the `SPS.particles` array
  101286. * `faceId` is the picked face index counted within this particle.
  101287. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  101288. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  101289. * Use the method SPS.pickedParticle(pickingInfo) instead.
  101290. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101291. */
  101292. pickedParticles: {
  101293. idx: number;
  101294. faceId: number;
  101295. }[];
  101296. /**
  101297. * This array is populated when the SPS is set as 'pickable'
  101298. * Each key of this array is a submesh index.
  101299. * Each element of this array is a second array defined like this :
  101300. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  101301. * Each element of this second array is an object `{idx: int, faceId: int}`.
  101302. * `idx` is the picked particle index in the `SPS.particles` array
  101303. * `faceId` is the picked face index counted within this particle.
  101304. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  101305. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101306. */
  101307. pickedBySubMesh: {
  101308. idx: number;
  101309. faceId: number;
  101310. }[][];
  101311. /**
  101312. * This array is populated when `enableDepthSort` is set to true.
  101313. * Each element of this array is an instance of the class DepthSortedParticle.
  101314. */
  101315. depthSortedParticles: DepthSortedParticle[];
  101316. /**
  101317. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  101318. * @hidden
  101319. */
  101320. _bSphereOnly: boolean;
  101321. /**
  101322. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  101323. * @hidden
  101324. */
  101325. _bSphereRadiusFactor: number;
  101326. private _scene;
  101327. private _positions;
  101328. private _indices;
  101329. private _normals;
  101330. private _colors;
  101331. private _uvs;
  101332. private _indices32;
  101333. private _positions32;
  101334. private _normals32;
  101335. private _fixedNormal32;
  101336. private _colors32;
  101337. private _uvs32;
  101338. private _index;
  101339. private _updatable;
  101340. private _pickable;
  101341. private _isVisibilityBoxLocked;
  101342. private _alwaysVisible;
  101343. private _depthSort;
  101344. private _expandable;
  101345. private _shapeCounter;
  101346. private _copy;
  101347. private _color;
  101348. private _computeParticleColor;
  101349. private _computeParticleTexture;
  101350. private _computeParticleRotation;
  101351. private _computeParticleVertex;
  101352. private _computeBoundingBox;
  101353. private _depthSortParticles;
  101354. private _camera;
  101355. private _mustUnrotateFixedNormals;
  101356. private _particlesIntersect;
  101357. private _needs32Bits;
  101358. private _isNotBuilt;
  101359. private _lastParticleId;
  101360. private _idxOfId;
  101361. private _multimaterialEnabled;
  101362. private _useModelMaterial;
  101363. private _indicesByMaterial;
  101364. private _materialIndexes;
  101365. private _depthSortFunction;
  101366. private _materialSortFunction;
  101367. private _materials;
  101368. private _multimaterial;
  101369. private _materialIndexesById;
  101370. private _defaultMaterial;
  101371. private _autoUpdateSubMeshes;
  101372. /**
  101373. * Creates a SPS (Solid Particle System) object.
  101374. * @param name (String) is the SPS name, this will be the underlying mesh name.
  101375. * @param scene (Scene) is the scene in which the SPS is added.
  101376. * @param options defines the options of the sps e.g.
  101377. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  101378. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  101379. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  101380. * * 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.
  101381. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  101382. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  101383. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  101384. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  101385. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  101386. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  101387. */
  101388. constructor(name: string, scene: Scene, options?: {
  101389. updatable?: boolean;
  101390. isPickable?: boolean;
  101391. enableDepthSort?: boolean;
  101392. particleIntersection?: boolean;
  101393. boundingSphereOnly?: boolean;
  101394. bSphereRadiusFactor?: number;
  101395. expandable?: boolean;
  101396. useModelMaterial?: boolean;
  101397. enableMultiMaterial?: boolean;
  101398. });
  101399. /**
  101400. * Builds the SPS underlying mesh. Returns a standard Mesh.
  101401. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  101402. * @returns the created mesh
  101403. */
  101404. buildMesh(): Mesh;
  101405. /**
  101406. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  101407. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  101408. * Thus the particles generated from `digest()` have their property `position` set yet.
  101409. * @param mesh ( Mesh ) is the mesh to be digested
  101410. * @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
  101411. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  101412. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  101413. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101414. * @returns the current SPS
  101415. */
  101416. digest(mesh: Mesh, options?: {
  101417. facetNb?: number;
  101418. number?: number;
  101419. delta?: number;
  101420. storage?: [];
  101421. }): SolidParticleSystem;
  101422. /**
  101423. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  101424. * @hidden
  101425. */
  101426. private _unrotateFixedNormals;
  101427. /**
  101428. * Resets the temporary working copy particle
  101429. * @hidden
  101430. */
  101431. private _resetCopy;
  101432. /**
  101433. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  101434. * @param p the current index in the positions array to be updated
  101435. * @param ind the current index in the indices array
  101436. * @param shape a Vector3 array, the shape geometry
  101437. * @param positions the positions array to be updated
  101438. * @param meshInd the shape indices array
  101439. * @param indices the indices array to be updated
  101440. * @param meshUV the shape uv array
  101441. * @param uvs the uv array to be updated
  101442. * @param meshCol the shape color array
  101443. * @param colors the color array to be updated
  101444. * @param meshNor the shape normals array
  101445. * @param normals the normals array to be updated
  101446. * @param idx the particle index
  101447. * @param idxInShape the particle index in its shape
  101448. * @param options the addShape() method passed options
  101449. * @model the particle model
  101450. * @hidden
  101451. */
  101452. private _meshBuilder;
  101453. /**
  101454. * Returns a shape Vector3 array from positions float array
  101455. * @param positions float array
  101456. * @returns a vector3 array
  101457. * @hidden
  101458. */
  101459. private _posToShape;
  101460. /**
  101461. * Returns a shapeUV array from a float uvs (array deep copy)
  101462. * @param uvs as a float array
  101463. * @returns a shapeUV array
  101464. * @hidden
  101465. */
  101466. private _uvsToShapeUV;
  101467. /**
  101468. * Adds a new particle object in the particles array
  101469. * @param idx particle index in particles array
  101470. * @param id particle id
  101471. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  101472. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  101473. * @param model particle ModelShape object
  101474. * @param shapeId model shape identifier
  101475. * @param idxInShape index of the particle in the current model
  101476. * @param bInfo model bounding info object
  101477. * @param storage target storage array, if any
  101478. * @hidden
  101479. */
  101480. private _addParticle;
  101481. /**
  101482. * Adds some particles to the SPS from the model shape. Returns the shape id.
  101483. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  101484. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  101485. * @param nb (positive integer) the number of particles to be created from this model
  101486. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  101487. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  101488. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101489. * @returns the number of shapes in the system
  101490. */
  101491. addShape(mesh: Mesh, nb: number, options?: {
  101492. positionFunction?: any;
  101493. vertexFunction?: any;
  101494. storage?: [];
  101495. }): number;
  101496. /**
  101497. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  101498. * @hidden
  101499. */
  101500. private _rebuildParticle;
  101501. /**
  101502. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  101503. * @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.
  101504. * @returns the SPS.
  101505. */
  101506. rebuildMesh(reset?: boolean): SolidParticleSystem;
  101507. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  101508. * Returns an array with the removed particles.
  101509. * 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.
  101510. * The SPS can't be empty so at least one particle needs to remain in place.
  101511. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  101512. * @param start index of the first particle to remove
  101513. * @param end index of the last particle to remove (included)
  101514. * @returns an array populated with the removed particles
  101515. */
  101516. removeParticles(start: number, end: number): SolidParticle[];
  101517. /**
  101518. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  101519. * @param solidParticleArray an array populated with Solid Particles objects
  101520. * @returns the SPS
  101521. */
  101522. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  101523. /**
  101524. * Creates a new particle and modifies the SPS mesh geometry :
  101525. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  101526. * - calls _addParticle() to populate the particle array
  101527. * factorized code from addShape() and insertParticlesFromArray()
  101528. * @param idx particle index in the particles array
  101529. * @param i particle index in its shape
  101530. * @param modelShape particle ModelShape object
  101531. * @param shape shape vertex array
  101532. * @param meshInd shape indices array
  101533. * @param meshUV shape uv array
  101534. * @param meshCol shape color array
  101535. * @param meshNor shape normals array
  101536. * @param bbInfo shape bounding info
  101537. * @param storage target particle storage
  101538. * @options addShape() passed options
  101539. * @hidden
  101540. */
  101541. private _insertNewParticle;
  101542. /**
  101543. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  101544. * This method calls `updateParticle()` for each particle of the SPS.
  101545. * For an animated SPS, it is usually called within the render loop.
  101546. * 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.
  101547. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  101548. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  101549. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  101550. * @returns the SPS.
  101551. */
  101552. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  101553. /**
  101554. * Disposes the SPS.
  101555. */
  101556. dispose(): void;
  101557. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  101558. * idx is the particle index in the SPS
  101559. * faceId is the picked face index counted within this particle.
  101560. * Returns null if the pickInfo can't identify a picked particle.
  101561. * @param pickingInfo (PickingInfo object)
  101562. * @returns {idx: number, faceId: number} or null
  101563. */
  101564. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  101565. idx: number;
  101566. faceId: number;
  101567. }>;
  101568. /**
  101569. * Returns a SolidParticle object from its identifier : particle.id
  101570. * @param id (integer) the particle Id
  101571. * @returns the searched particle or null if not found in the SPS.
  101572. */
  101573. getParticleById(id: number): Nullable<SolidParticle>;
  101574. /**
  101575. * Returns a new array populated with the particles having the passed shapeId.
  101576. * @param shapeId (integer) the shape identifier
  101577. * @returns a new solid particle array
  101578. */
  101579. getParticlesByShapeId(shapeId: number): SolidParticle[];
  101580. /**
  101581. * Populates the passed array "ref" with the particles having the passed shapeId.
  101582. * @param shapeId the shape identifier
  101583. * @returns the SPS
  101584. * @param ref
  101585. */
  101586. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  101587. /**
  101588. * Computes the required SubMeshes according the materials assigned to the particles.
  101589. * @returns the solid particle system.
  101590. * Does nothing if called before the SPS mesh is built.
  101591. */
  101592. computeSubMeshes(): SolidParticleSystem;
  101593. /**
  101594. * Sorts the solid particles by material when MultiMaterial is enabled.
  101595. * Updates the indices32 array.
  101596. * Updates the indicesByMaterial array.
  101597. * Updates the mesh indices array.
  101598. * @returns the SPS
  101599. * @hidden
  101600. */
  101601. private _sortParticlesByMaterial;
  101602. /**
  101603. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  101604. * @hidden
  101605. */
  101606. private _setMaterialIndexesById;
  101607. /**
  101608. * Returns an array with unique values of Materials from the passed array
  101609. * @param array the material array to be checked and filtered
  101610. * @hidden
  101611. */
  101612. private _filterUniqueMaterialId;
  101613. /**
  101614. * Sets a new Standard Material as _defaultMaterial if not already set.
  101615. * @hidden
  101616. */
  101617. private _setDefaultMaterial;
  101618. /**
  101619. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  101620. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101621. * @returns the SPS.
  101622. */
  101623. refreshVisibleSize(): SolidParticleSystem;
  101624. /**
  101625. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  101626. * @param size the size (float) of the visibility box
  101627. * note : this doesn't lock the SPS mesh bounding box.
  101628. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101629. */
  101630. setVisibilityBox(size: number): void;
  101631. /**
  101632. * Gets whether the SPS as always visible or not
  101633. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101634. */
  101635. get isAlwaysVisible(): boolean;
  101636. /**
  101637. * Sets the SPS as always visible or not
  101638. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101639. */
  101640. set isAlwaysVisible(val: boolean);
  101641. /**
  101642. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101643. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101644. */
  101645. set isVisibilityBoxLocked(val: boolean);
  101646. /**
  101647. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101648. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101649. */
  101650. get isVisibilityBoxLocked(): boolean;
  101651. /**
  101652. * Tells to `setParticles()` to compute the particle rotations or not.
  101653. * Default value : true. The SPS is faster when it's set to false.
  101654. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101655. */
  101656. set computeParticleRotation(val: boolean);
  101657. /**
  101658. * Tells to `setParticles()` to compute the particle colors or not.
  101659. * Default value : true. The SPS is faster when it's set to false.
  101660. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101661. */
  101662. set computeParticleColor(val: boolean);
  101663. set computeParticleTexture(val: boolean);
  101664. /**
  101665. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  101666. * Default value : false. The SPS is faster when it's set to false.
  101667. * Note : the particle custom vertex positions aren't stored values.
  101668. */
  101669. set computeParticleVertex(val: boolean);
  101670. /**
  101671. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  101672. */
  101673. set computeBoundingBox(val: boolean);
  101674. /**
  101675. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  101676. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101677. * Default : `true`
  101678. */
  101679. set depthSortParticles(val: boolean);
  101680. /**
  101681. * Gets if `setParticles()` computes the particle rotations or not.
  101682. * Default value : true. The SPS is faster when it's set to false.
  101683. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101684. */
  101685. get computeParticleRotation(): boolean;
  101686. /**
  101687. * Gets if `setParticles()` computes the particle colors or not.
  101688. * Default value : true. The SPS is faster when it's set to false.
  101689. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101690. */
  101691. get computeParticleColor(): boolean;
  101692. /**
  101693. * Gets if `setParticles()` computes the particle textures or not.
  101694. * Default value : true. The SPS is faster when it's set to false.
  101695. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  101696. */
  101697. get computeParticleTexture(): boolean;
  101698. /**
  101699. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  101700. * Default value : false. The SPS is faster when it's set to false.
  101701. * Note : the particle custom vertex positions aren't stored values.
  101702. */
  101703. get computeParticleVertex(): boolean;
  101704. /**
  101705. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101706. */
  101707. get computeBoundingBox(): boolean;
  101708. /**
  101709. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101710. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101711. * Default : `true`
  101712. */
  101713. get depthSortParticles(): boolean;
  101714. /**
  101715. * Gets if the SPS is created as expandable at construction time.
  101716. * Default : `false`
  101717. */
  101718. get expandable(): boolean;
  101719. /**
  101720. * Gets if the SPS supports the Multi Materials
  101721. */
  101722. get multimaterialEnabled(): boolean;
  101723. /**
  101724. * Gets if the SPS uses the model materials for its own multimaterial.
  101725. */
  101726. get useModelMaterial(): boolean;
  101727. /**
  101728. * The SPS used material array.
  101729. */
  101730. get materials(): Material[];
  101731. /**
  101732. * Sets the SPS MultiMaterial from the passed materials.
  101733. * Note : the passed array is internally copied and not used then by reference.
  101734. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101735. */
  101736. setMultiMaterial(materials: Material[]): void;
  101737. /**
  101738. * The SPS computed multimaterial object
  101739. */
  101740. get multimaterial(): MultiMaterial;
  101741. set multimaterial(mm: MultiMaterial);
  101742. /**
  101743. * If the subMeshes must be updated on the next call to setParticles()
  101744. */
  101745. get autoUpdateSubMeshes(): boolean;
  101746. set autoUpdateSubMeshes(val: boolean);
  101747. /**
  101748. * This function does nothing. It may be overwritten to set all the particle first values.
  101749. * The SPS doesn't call this function, you may have to call it by your own.
  101750. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101751. */
  101752. initParticles(): void;
  101753. /**
  101754. * This function does nothing. It may be overwritten to recycle a particle.
  101755. * The SPS doesn't call this function, you may have to call it by your own.
  101756. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101757. * @param particle The particle to recycle
  101758. * @returns the recycled particle
  101759. */
  101760. recycleParticle(particle: SolidParticle): SolidParticle;
  101761. /**
  101762. * Updates a particle : this function should be overwritten by the user.
  101763. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  101764. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101765. * @example : just set a particle position or velocity and recycle conditions
  101766. * @param particle The particle to update
  101767. * @returns the updated particle
  101768. */
  101769. updateParticle(particle: SolidParticle): SolidParticle;
  101770. /**
  101771. * Updates a vertex of a particle : it can be overwritten by the user.
  101772. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  101773. * @param particle the current particle
  101774. * @param vertex the current index of the current particle
  101775. * @param pt the index of the current vertex in the particle shape
  101776. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  101777. * @example : just set a vertex particle position
  101778. * @returns the updated vertex
  101779. */
  101780. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  101781. /**
  101782. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  101783. * This does nothing and may be overwritten by the user.
  101784. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101785. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101786. * @param update the boolean update value actually passed to setParticles()
  101787. */
  101788. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  101789. /**
  101790. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  101791. * This will be passed three parameters.
  101792. * This does nothing and may be overwritten by the user.
  101793. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101794. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  101795. * @param update the boolean update value actually passed to setParticles()
  101796. */
  101797. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  101798. }
  101799. }
  101800. declare module BABYLON {
  101801. /**
  101802. * Represents one particle of a solid particle system.
  101803. */
  101804. export class SolidParticle {
  101805. /**
  101806. * particle global index
  101807. */
  101808. idx: number;
  101809. /**
  101810. * particle identifier
  101811. */
  101812. id: number;
  101813. /**
  101814. * The color of the particle
  101815. */
  101816. color: Nullable<Color4>;
  101817. /**
  101818. * The world space position of the particle.
  101819. */
  101820. position: Vector3;
  101821. /**
  101822. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  101823. */
  101824. rotation: Vector3;
  101825. /**
  101826. * The world space rotation quaternion of the particle.
  101827. */
  101828. rotationQuaternion: Nullable<Quaternion>;
  101829. /**
  101830. * The scaling of the particle.
  101831. */
  101832. scaling: Vector3;
  101833. /**
  101834. * The uvs of the particle.
  101835. */
  101836. uvs: Vector4;
  101837. /**
  101838. * The current speed of the particle.
  101839. */
  101840. velocity: Vector3;
  101841. /**
  101842. * The pivot point in the particle local space.
  101843. */
  101844. pivot: Vector3;
  101845. /**
  101846. * Must the particle be translated from its pivot point in its local space ?
  101847. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  101848. * Default : false
  101849. */
  101850. translateFromPivot: boolean;
  101851. /**
  101852. * Is the particle active or not ?
  101853. */
  101854. alive: boolean;
  101855. /**
  101856. * Is the particle visible or not ?
  101857. */
  101858. isVisible: boolean;
  101859. /**
  101860. * Index of this particle in the global "positions" array (Internal use)
  101861. * @hidden
  101862. */
  101863. _pos: number;
  101864. /**
  101865. * @hidden Index of this particle in the global "indices" array (Internal use)
  101866. */
  101867. _ind: number;
  101868. /**
  101869. * @hidden ModelShape of this particle (Internal use)
  101870. */
  101871. _model: ModelShape;
  101872. /**
  101873. * ModelShape id of this particle
  101874. */
  101875. shapeId: number;
  101876. /**
  101877. * Index of the particle in its shape id
  101878. */
  101879. idxInShape: number;
  101880. /**
  101881. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  101882. */
  101883. _modelBoundingInfo: BoundingInfo;
  101884. /**
  101885. * @hidden Particle BoundingInfo object (Internal use)
  101886. */
  101887. _boundingInfo: BoundingInfo;
  101888. /**
  101889. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  101890. */
  101891. _sps: SolidParticleSystem;
  101892. /**
  101893. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  101894. */
  101895. _stillInvisible: boolean;
  101896. /**
  101897. * @hidden Last computed particle rotation matrix
  101898. */
  101899. _rotationMatrix: number[];
  101900. /**
  101901. * Parent particle Id, if any.
  101902. * Default null.
  101903. */
  101904. parentId: Nullable<number>;
  101905. /**
  101906. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  101907. */
  101908. materialIndex: Nullable<number>;
  101909. /**
  101910. * Custom object or properties.
  101911. */
  101912. props: Nullable<any>;
  101913. /**
  101914. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  101915. * The possible values are :
  101916. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101917. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101918. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101919. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101920. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101921. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  101922. * */
  101923. cullingStrategy: number;
  101924. /**
  101925. * @hidden Internal global position in the SPS.
  101926. */
  101927. _globalPosition: Vector3;
  101928. /**
  101929. * Creates a Solid Particle object.
  101930. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  101931. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  101932. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  101933. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  101934. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  101935. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  101936. * @param shapeId (integer) is the model shape identifier in the SPS.
  101937. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  101938. * @param sps defines the sps it is associated to
  101939. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  101940. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  101941. */
  101942. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  101943. /**
  101944. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  101945. * @param target the particle target
  101946. * @returns the current particle
  101947. */
  101948. copyToRef(target: SolidParticle): SolidParticle;
  101949. /**
  101950. * Legacy support, changed scale to scaling
  101951. */
  101952. get scale(): Vector3;
  101953. /**
  101954. * Legacy support, changed scale to scaling
  101955. */
  101956. set scale(scale: Vector3);
  101957. /**
  101958. * Legacy support, changed quaternion to rotationQuaternion
  101959. */
  101960. get quaternion(): Nullable<Quaternion>;
  101961. /**
  101962. * Legacy support, changed quaternion to rotationQuaternion
  101963. */
  101964. set quaternion(q: Nullable<Quaternion>);
  101965. /**
  101966. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  101967. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  101968. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  101969. * @returns true if it intersects
  101970. */
  101971. intersectsMesh(target: Mesh | SolidParticle): boolean;
  101972. /**
  101973. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  101974. * A particle is in the frustum if its bounding box intersects the frustum
  101975. * @param frustumPlanes defines the frustum to test
  101976. * @returns true if the particle is in the frustum planes
  101977. */
  101978. isInFrustum(frustumPlanes: Plane[]): boolean;
  101979. /**
  101980. * get the rotation matrix of the particle
  101981. * @hidden
  101982. */
  101983. getRotationMatrix(m: Matrix): void;
  101984. }
  101985. /**
  101986. * Represents the shape of the model used by one particle of a solid particle system.
  101987. * SPS internal tool, don't use it manually.
  101988. */
  101989. export class ModelShape {
  101990. /**
  101991. * The shape id
  101992. * @hidden
  101993. */
  101994. shapeID: number;
  101995. /**
  101996. * flat array of model positions (internal use)
  101997. * @hidden
  101998. */
  101999. _shape: Vector3[];
  102000. /**
  102001. * flat array of model UVs (internal use)
  102002. * @hidden
  102003. */
  102004. _shapeUV: number[];
  102005. /**
  102006. * color array of the model
  102007. * @hidden
  102008. */
  102009. _shapeColors: number[];
  102010. /**
  102011. * indices array of the model
  102012. * @hidden
  102013. */
  102014. _indices: number[];
  102015. /**
  102016. * normals array of the model
  102017. * @hidden
  102018. */
  102019. _normals: number[];
  102020. /**
  102021. * length of the shape in the model indices array (internal use)
  102022. * @hidden
  102023. */
  102024. _indicesLength: number;
  102025. /**
  102026. * Custom position function (internal use)
  102027. * @hidden
  102028. */
  102029. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  102030. /**
  102031. * Custom vertex function (internal use)
  102032. * @hidden
  102033. */
  102034. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  102035. /**
  102036. * Model material (internal use)
  102037. * @hidden
  102038. */
  102039. _material: Nullable<Material>;
  102040. /**
  102041. * 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.
  102042. * SPS internal tool, don't use it manually.
  102043. * @hidden
  102044. */
  102045. 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>);
  102046. }
  102047. /**
  102048. * Represents a Depth Sorted Particle in the solid particle system.
  102049. * @hidden
  102050. */
  102051. export class DepthSortedParticle {
  102052. /**
  102053. * Particle index
  102054. */
  102055. idx: number;
  102056. /**
  102057. * Index of the particle in the "indices" array
  102058. */
  102059. ind: number;
  102060. /**
  102061. * Length of the particle shape in the "indices" array
  102062. */
  102063. indicesLength: number;
  102064. /**
  102065. * Squared distance from the particle to the camera
  102066. */
  102067. sqDistance: number;
  102068. /**
  102069. * Material index when used with MultiMaterials
  102070. */
  102071. materialIndex: number;
  102072. /**
  102073. * Creates a new sorted particle
  102074. * @param materialIndex
  102075. */
  102076. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  102077. }
  102078. }
  102079. declare module BABYLON {
  102080. /**
  102081. * @hidden
  102082. */
  102083. export class _MeshCollisionData {
  102084. _checkCollisions: boolean;
  102085. _collisionMask: number;
  102086. _collisionGroup: number;
  102087. _surroundingMeshes: Nullable<AbstractMesh[]>;
  102088. _collider: Nullable<Collider>;
  102089. _oldPositionForCollisions: Vector3;
  102090. _diffPositionForCollisions: Vector3;
  102091. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  102092. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  102093. }
  102094. }
  102095. declare module BABYLON {
  102096. /** @hidden */
  102097. class _FacetDataStorage {
  102098. facetPositions: Vector3[];
  102099. facetNormals: Vector3[];
  102100. facetPartitioning: number[][];
  102101. facetNb: number;
  102102. partitioningSubdivisions: number;
  102103. partitioningBBoxRatio: number;
  102104. facetDataEnabled: boolean;
  102105. facetParameters: any;
  102106. bbSize: Vector3;
  102107. subDiv: {
  102108. max: number;
  102109. X: number;
  102110. Y: number;
  102111. Z: number;
  102112. };
  102113. facetDepthSort: boolean;
  102114. facetDepthSortEnabled: boolean;
  102115. depthSortedIndices: IndicesArray;
  102116. depthSortedFacets: {
  102117. ind: number;
  102118. sqDistance: number;
  102119. }[];
  102120. facetDepthSortFunction: (f1: {
  102121. ind: number;
  102122. sqDistance: number;
  102123. }, f2: {
  102124. ind: number;
  102125. sqDistance: number;
  102126. }) => number;
  102127. facetDepthSortFrom: Vector3;
  102128. facetDepthSortOrigin: Vector3;
  102129. invertedMatrix: Matrix;
  102130. }
  102131. /**
  102132. * @hidden
  102133. **/
  102134. class _InternalAbstractMeshDataInfo {
  102135. _hasVertexAlpha: boolean;
  102136. _useVertexColors: boolean;
  102137. _numBoneInfluencers: number;
  102138. _applyFog: boolean;
  102139. _receiveShadows: boolean;
  102140. _facetData: _FacetDataStorage;
  102141. _visibility: number;
  102142. _skeleton: Nullable<Skeleton>;
  102143. _layerMask: number;
  102144. _computeBonesUsingShaders: boolean;
  102145. _isActive: boolean;
  102146. _onlyForInstances: boolean;
  102147. _isActiveIntermediate: boolean;
  102148. _onlyForInstancesIntermediate: boolean;
  102149. _actAsRegularMesh: boolean;
  102150. }
  102151. /**
  102152. * Class used to store all common mesh properties
  102153. */
  102154. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  102155. /** No occlusion */
  102156. static OCCLUSION_TYPE_NONE: number;
  102157. /** Occlusion set to optimisitic */
  102158. static OCCLUSION_TYPE_OPTIMISTIC: number;
  102159. /** Occlusion set to strict */
  102160. static OCCLUSION_TYPE_STRICT: number;
  102161. /** Use an accurante occlusion algorithm */
  102162. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  102163. /** Use a conservative occlusion algorithm */
  102164. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  102165. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  102166. * Test order :
  102167. * Is the bounding sphere outside the frustum ?
  102168. * If not, are the bounding box vertices outside the frustum ?
  102169. * It not, then the cullable object is in the frustum.
  102170. */
  102171. static readonly CULLINGSTRATEGY_STANDARD: number;
  102172. /** Culling strategy : Bounding Sphere Only.
  102173. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  102174. * It's also less accurate than the standard because some not visible objects can still be selected.
  102175. * Test : is the bounding sphere outside the frustum ?
  102176. * If not, then the cullable object is in the frustum.
  102177. */
  102178. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  102179. /** Culling strategy : Optimistic Inclusion.
  102180. * This in an inclusion test first, then the standard exclusion test.
  102181. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  102182. * 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.
  102183. * Anyway, it's as accurate as the standard strategy.
  102184. * Test :
  102185. * Is the cullable object bounding sphere center in the frustum ?
  102186. * If not, apply the default culling strategy.
  102187. */
  102188. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  102189. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  102190. * This in an inclusion test first, then the bounding sphere only exclusion test.
  102191. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  102192. * 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.
  102193. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  102194. * Test :
  102195. * Is the cullable object bounding sphere center in the frustum ?
  102196. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  102197. */
  102198. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  102199. /**
  102200. * No billboard
  102201. */
  102202. static get BILLBOARDMODE_NONE(): number;
  102203. /** Billboard on X axis */
  102204. static get BILLBOARDMODE_X(): number;
  102205. /** Billboard on Y axis */
  102206. static get BILLBOARDMODE_Y(): number;
  102207. /** Billboard on Z axis */
  102208. static get BILLBOARDMODE_Z(): number;
  102209. /** Billboard on all axes */
  102210. static get BILLBOARDMODE_ALL(): number;
  102211. /** Billboard on using position instead of orientation */
  102212. static get BILLBOARDMODE_USE_POSITION(): number;
  102213. /** @hidden */
  102214. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  102215. /**
  102216. * The culling strategy to use to check whether the mesh must be rendered or not.
  102217. * This value can be changed at any time and will be used on the next render mesh selection.
  102218. * The possible values are :
  102219. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102220. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102221. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102222. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102223. * Please read each static variable documentation to get details about the culling process.
  102224. * */
  102225. cullingStrategy: number;
  102226. /**
  102227. * Gets the number of facets in the mesh
  102228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102229. */
  102230. get facetNb(): number;
  102231. /**
  102232. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  102233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102234. */
  102235. get partitioningSubdivisions(): number;
  102236. set partitioningSubdivisions(nb: number);
  102237. /**
  102238. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  102239. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  102240. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102241. */
  102242. get partitioningBBoxRatio(): number;
  102243. set partitioningBBoxRatio(ratio: number);
  102244. /**
  102245. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  102246. * Works only for updatable meshes.
  102247. * Doesn't work with multi-materials
  102248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102249. */
  102250. get mustDepthSortFacets(): boolean;
  102251. set mustDepthSortFacets(sort: boolean);
  102252. /**
  102253. * The location (Vector3) where the facet depth sort must be computed from.
  102254. * By default, the active camera position.
  102255. * Used only when facet depth sort is enabled
  102256. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102257. */
  102258. get facetDepthSortFrom(): Vector3;
  102259. set facetDepthSortFrom(location: Vector3);
  102260. /**
  102261. * gets a boolean indicating if facetData is enabled
  102262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102263. */
  102264. get isFacetDataEnabled(): boolean;
  102265. /** @hidden */
  102266. _updateNonUniformScalingState(value: boolean): boolean;
  102267. /**
  102268. * An event triggered when this mesh collides with another one
  102269. */
  102270. onCollideObservable: Observable<AbstractMesh>;
  102271. /** Set a function to call when this mesh collides with another one */
  102272. set onCollide(callback: () => void);
  102273. /**
  102274. * An event triggered when the collision's position changes
  102275. */
  102276. onCollisionPositionChangeObservable: Observable<Vector3>;
  102277. /** Set a function to call when the collision's position changes */
  102278. set onCollisionPositionChange(callback: () => void);
  102279. /**
  102280. * An event triggered when material is changed
  102281. */
  102282. onMaterialChangedObservable: Observable<AbstractMesh>;
  102283. /**
  102284. * Gets or sets the orientation for POV movement & rotation
  102285. */
  102286. definedFacingForward: boolean;
  102287. /** @hidden */
  102288. _occlusionQuery: Nullable<WebGLQuery>;
  102289. /** @hidden */
  102290. _renderingGroup: Nullable<RenderingGroup>;
  102291. /**
  102292. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102293. */
  102294. get visibility(): number;
  102295. /**
  102296. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102297. */
  102298. set visibility(value: number);
  102299. /** Gets or sets the alpha index used to sort transparent meshes
  102300. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  102301. */
  102302. alphaIndex: number;
  102303. /**
  102304. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  102305. */
  102306. isVisible: boolean;
  102307. /**
  102308. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  102309. */
  102310. isPickable: boolean;
  102311. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  102312. showSubMeshesBoundingBox: boolean;
  102313. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  102314. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102315. */
  102316. isBlocker: boolean;
  102317. /**
  102318. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  102319. */
  102320. enablePointerMoveEvents: boolean;
  102321. /**
  102322. * Specifies the rendering group id for this mesh (0 by default)
  102323. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  102324. */
  102325. renderingGroupId: number;
  102326. private _material;
  102327. /** Gets or sets current material */
  102328. get material(): Nullable<Material>;
  102329. set material(value: Nullable<Material>);
  102330. /**
  102331. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  102332. * @see http://doc.babylonjs.com/babylon101/shadows
  102333. */
  102334. get receiveShadows(): boolean;
  102335. set receiveShadows(value: boolean);
  102336. /** Defines color to use when rendering outline */
  102337. outlineColor: Color3;
  102338. /** Define width to use when rendering outline */
  102339. outlineWidth: number;
  102340. /** Defines color to use when rendering overlay */
  102341. overlayColor: Color3;
  102342. /** Defines alpha to use when rendering overlay */
  102343. overlayAlpha: number;
  102344. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  102345. get hasVertexAlpha(): boolean;
  102346. set hasVertexAlpha(value: boolean);
  102347. /** 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) */
  102348. get useVertexColors(): boolean;
  102349. set useVertexColors(value: boolean);
  102350. /**
  102351. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  102352. */
  102353. get computeBonesUsingShaders(): boolean;
  102354. set computeBonesUsingShaders(value: boolean);
  102355. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  102356. get numBoneInfluencers(): number;
  102357. set numBoneInfluencers(value: number);
  102358. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  102359. get applyFog(): boolean;
  102360. set applyFog(value: boolean);
  102361. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  102362. useOctreeForRenderingSelection: boolean;
  102363. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  102364. useOctreeForPicking: boolean;
  102365. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  102366. useOctreeForCollisions: boolean;
  102367. /**
  102368. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  102369. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  102370. */
  102371. get layerMask(): number;
  102372. set layerMask(value: number);
  102373. /**
  102374. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  102375. */
  102376. alwaysSelectAsActiveMesh: boolean;
  102377. /**
  102378. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  102379. */
  102380. doNotSyncBoundingInfo: boolean;
  102381. /**
  102382. * Gets or sets the current action manager
  102383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102384. */
  102385. actionManager: Nullable<AbstractActionManager>;
  102386. private _meshCollisionData;
  102387. /**
  102388. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  102389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102390. */
  102391. ellipsoid: Vector3;
  102392. /**
  102393. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  102394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102395. */
  102396. ellipsoidOffset: Vector3;
  102397. /**
  102398. * Gets or sets a collision mask used to mask collisions (default is -1).
  102399. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102400. */
  102401. get collisionMask(): number;
  102402. set collisionMask(mask: number);
  102403. /**
  102404. * Gets or sets the current collision group mask (-1 by default).
  102405. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102406. */
  102407. get collisionGroup(): number;
  102408. set collisionGroup(mask: number);
  102409. /**
  102410. * Gets or sets current surrounding meshes (null by default).
  102411. *
  102412. * By default collision detection is tested against every mesh in the scene.
  102413. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  102414. * meshes will be tested for the collision.
  102415. *
  102416. * Note: if set to an empty array no collision will happen when this mesh is moved.
  102417. */
  102418. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  102419. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  102420. /**
  102421. * Defines edge width used when edgesRenderer is enabled
  102422. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102423. */
  102424. edgesWidth: number;
  102425. /**
  102426. * Defines edge color used when edgesRenderer is enabled
  102427. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102428. */
  102429. edgesColor: Color4;
  102430. /** @hidden */
  102431. _edgesRenderer: Nullable<IEdgesRenderer>;
  102432. /** @hidden */
  102433. _masterMesh: Nullable<AbstractMesh>;
  102434. /** @hidden */
  102435. _boundingInfo: Nullable<BoundingInfo>;
  102436. /** @hidden */
  102437. _renderId: number;
  102438. /**
  102439. * Gets or sets the list of subMeshes
  102440. * @see http://doc.babylonjs.com/how_to/multi_materials
  102441. */
  102442. subMeshes: SubMesh[];
  102443. /** @hidden */
  102444. _intersectionsInProgress: AbstractMesh[];
  102445. /** @hidden */
  102446. _unIndexed: boolean;
  102447. /** @hidden */
  102448. _lightSources: Light[];
  102449. /** Gets the list of lights affecting that mesh */
  102450. get lightSources(): Light[];
  102451. /** @hidden */
  102452. get _positions(): Nullable<Vector3[]>;
  102453. /** @hidden */
  102454. _waitingData: {
  102455. lods: Nullable<any>;
  102456. actions: Nullable<any>;
  102457. freezeWorldMatrix: Nullable<boolean>;
  102458. };
  102459. /** @hidden */
  102460. _bonesTransformMatrices: Nullable<Float32Array>;
  102461. /** @hidden */
  102462. _transformMatrixTexture: Nullable<RawTexture>;
  102463. /**
  102464. * Gets or sets a skeleton to apply skining transformations
  102465. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102466. */
  102467. set skeleton(value: Nullable<Skeleton>);
  102468. get skeleton(): Nullable<Skeleton>;
  102469. /**
  102470. * An event triggered when the mesh is rebuilt.
  102471. */
  102472. onRebuildObservable: Observable<AbstractMesh>;
  102473. /**
  102474. * Creates a new AbstractMesh
  102475. * @param name defines the name of the mesh
  102476. * @param scene defines the hosting scene
  102477. */
  102478. constructor(name: string, scene?: Nullable<Scene>);
  102479. /**
  102480. * Returns the string "AbstractMesh"
  102481. * @returns "AbstractMesh"
  102482. */
  102483. getClassName(): string;
  102484. /**
  102485. * Gets a string representation of the current mesh
  102486. * @param fullDetails defines a boolean indicating if full details must be included
  102487. * @returns a string representation of the current mesh
  102488. */
  102489. toString(fullDetails?: boolean): string;
  102490. /**
  102491. * @hidden
  102492. */
  102493. protected _getEffectiveParent(): Nullable<Node>;
  102494. /** @hidden */
  102495. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102496. /** @hidden */
  102497. _rebuild(): void;
  102498. /** @hidden */
  102499. _resyncLightSources(): void;
  102500. /** @hidden */
  102501. _resyncLightSource(light: Light): void;
  102502. /** @hidden */
  102503. _unBindEffect(): void;
  102504. /** @hidden */
  102505. _removeLightSource(light: Light, dispose: boolean): void;
  102506. private _markSubMeshesAsDirty;
  102507. /** @hidden */
  102508. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  102509. /** @hidden */
  102510. _markSubMeshesAsAttributesDirty(): void;
  102511. /** @hidden */
  102512. _markSubMeshesAsMiscDirty(): void;
  102513. /**
  102514. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  102515. */
  102516. get scaling(): Vector3;
  102517. set scaling(newScaling: Vector3);
  102518. /**
  102519. * Returns true if the mesh is blocked. Implemented by child classes
  102520. */
  102521. get isBlocked(): boolean;
  102522. /**
  102523. * Returns the mesh itself by default. Implemented by child classes
  102524. * @param camera defines the camera to use to pick the right LOD level
  102525. * @returns the currentAbstractMesh
  102526. */
  102527. getLOD(camera: Camera): Nullable<AbstractMesh>;
  102528. /**
  102529. * Returns 0 by default. Implemented by child classes
  102530. * @returns an integer
  102531. */
  102532. getTotalVertices(): number;
  102533. /**
  102534. * Returns a positive integer : the total number of indices in this mesh geometry.
  102535. * @returns the numner of indices or zero if the mesh has no geometry.
  102536. */
  102537. getTotalIndices(): number;
  102538. /**
  102539. * Returns null by default. Implemented by child classes
  102540. * @returns null
  102541. */
  102542. getIndices(): Nullable<IndicesArray>;
  102543. /**
  102544. * Returns the array of the requested vertex data kind. Implemented by child classes
  102545. * @param kind defines the vertex data kind to use
  102546. * @returns null
  102547. */
  102548. getVerticesData(kind: string): Nullable<FloatArray>;
  102549. /**
  102550. * Sets the vertex data of the mesh geometry for the requested `kind`.
  102551. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  102552. * Note that a new underlying VertexBuffer object is created each call.
  102553. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  102554. * @param kind defines vertex data kind:
  102555. * * VertexBuffer.PositionKind
  102556. * * VertexBuffer.UVKind
  102557. * * VertexBuffer.UV2Kind
  102558. * * VertexBuffer.UV3Kind
  102559. * * VertexBuffer.UV4Kind
  102560. * * VertexBuffer.UV5Kind
  102561. * * VertexBuffer.UV6Kind
  102562. * * VertexBuffer.ColorKind
  102563. * * VertexBuffer.MatricesIndicesKind
  102564. * * VertexBuffer.MatricesIndicesExtraKind
  102565. * * VertexBuffer.MatricesWeightsKind
  102566. * * VertexBuffer.MatricesWeightsExtraKind
  102567. * @param data defines the data source
  102568. * @param updatable defines if the data must be flagged as updatable (or static)
  102569. * @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
  102570. * @returns the current mesh
  102571. */
  102572. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  102573. /**
  102574. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  102575. * If the mesh has no geometry, it is simply returned as it is.
  102576. * @param kind defines vertex data kind:
  102577. * * VertexBuffer.PositionKind
  102578. * * VertexBuffer.UVKind
  102579. * * VertexBuffer.UV2Kind
  102580. * * VertexBuffer.UV3Kind
  102581. * * VertexBuffer.UV4Kind
  102582. * * VertexBuffer.UV5Kind
  102583. * * VertexBuffer.UV6Kind
  102584. * * VertexBuffer.ColorKind
  102585. * * VertexBuffer.MatricesIndicesKind
  102586. * * VertexBuffer.MatricesIndicesExtraKind
  102587. * * VertexBuffer.MatricesWeightsKind
  102588. * * VertexBuffer.MatricesWeightsExtraKind
  102589. * @param data defines the data source
  102590. * @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
  102591. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  102592. * @returns the current mesh
  102593. */
  102594. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  102595. /**
  102596. * Sets the mesh indices,
  102597. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  102598. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  102599. * @param totalVertices Defines the total number of vertices
  102600. * @returns the current mesh
  102601. */
  102602. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  102603. /**
  102604. * Gets a boolean indicating if specific vertex data is present
  102605. * @param kind defines the vertex data kind to use
  102606. * @returns true is data kind is present
  102607. */
  102608. isVerticesDataPresent(kind: string): boolean;
  102609. /**
  102610. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  102611. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  102612. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  102613. * @returns a BoundingInfo
  102614. */
  102615. getBoundingInfo(): BoundingInfo;
  102616. /**
  102617. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  102618. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  102619. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  102620. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  102621. * @returns the current mesh
  102622. */
  102623. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  102624. /**
  102625. * Overwrite the current bounding info
  102626. * @param boundingInfo defines the new bounding info
  102627. * @returns the current mesh
  102628. */
  102629. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  102630. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  102631. get useBones(): boolean;
  102632. /** @hidden */
  102633. _preActivate(): void;
  102634. /** @hidden */
  102635. _preActivateForIntermediateRendering(renderId: number): void;
  102636. /** @hidden */
  102637. _activate(renderId: number, intermediateRendering: boolean): boolean;
  102638. /** @hidden */
  102639. _postActivate(): void;
  102640. /** @hidden */
  102641. _freeze(): void;
  102642. /** @hidden */
  102643. _unFreeze(): void;
  102644. /**
  102645. * Gets the current world matrix
  102646. * @returns a Matrix
  102647. */
  102648. getWorldMatrix(): Matrix;
  102649. /** @hidden */
  102650. _getWorldMatrixDeterminant(): number;
  102651. /**
  102652. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  102653. */
  102654. get isAnInstance(): boolean;
  102655. /**
  102656. * Gets a boolean indicating if this mesh has instances
  102657. */
  102658. get hasInstances(): boolean;
  102659. /**
  102660. * Perform relative position change from the point of view of behind the front of the mesh.
  102661. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102662. * Supports definition of mesh facing forward or backward
  102663. * @param amountRight defines the distance on the right axis
  102664. * @param amountUp defines the distance on the up axis
  102665. * @param amountForward defines the distance on the forward axis
  102666. * @returns the current mesh
  102667. */
  102668. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  102669. /**
  102670. * Calculate relative position change from the point of view of behind the front of the mesh.
  102671. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102672. * Supports definition of mesh facing forward or backward
  102673. * @param amountRight defines the distance on the right axis
  102674. * @param amountUp defines the distance on the up axis
  102675. * @param amountForward defines the distance on the forward axis
  102676. * @returns the new displacement vector
  102677. */
  102678. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  102679. /**
  102680. * Perform relative rotation change from the point of view of behind the front of the mesh.
  102681. * Supports definition of mesh facing forward or backward
  102682. * @param flipBack defines the flip
  102683. * @param twirlClockwise defines the twirl
  102684. * @param tiltRight defines the tilt
  102685. * @returns the current mesh
  102686. */
  102687. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  102688. /**
  102689. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  102690. * Supports definition of mesh facing forward or backward.
  102691. * @param flipBack defines the flip
  102692. * @param twirlClockwise defines the twirl
  102693. * @param tiltRight defines the tilt
  102694. * @returns the new rotation vector
  102695. */
  102696. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  102697. /**
  102698. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  102699. * This means the mesh underlying bounding box and sphere are recomputed.
  102700. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  102701. * @returns the current mesh
  102702. */
  102703. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  102704. /** @hidden */
  102705. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  102706. /** @hidden */
  102707. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  102708. /** @hidden */
  102709. _updateBoundingInfo(): AbstractMesh;
  102710. /** @hidden */
  102711. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  102712. /** @hidden */
  102713. protected _afterComputeWorldMatrix(): void;
  102714. /** @hidden */
  102715. get _effectiveMesh(): AbstractMesh;
  102716. /**
  102717. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102718. * A mesh is in the frustum if its bounding box intersects the frustum
  102719. * @param frustumPlanes defines the frustum to test
  102720. * @returns true if the mesh is in the frustum planes
  102721. */
  102722. isInFrustum(frustumPlanes: Plane[]): boolean;
  102723. /**
  102724. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102725. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102726. * @param frustumPlanes defines the frustum to test
  102727. * @returns true if the mesh is completely in the frustum planes
  102728. */
  102729. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102730. /**
  102731. * True if the mesh intersects another mesh or a SolidParticle object
  102732. * @param mesh defines a target mesh or SolidParticle to test
  102733. * @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)
  102734. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102735. * @returns true if there is an intersection
  102736. */
  102737. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102738. /**
  102739. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102740. * @param point defines the point to test
  102741. * @returns true if there is an intersection
  102742. */
  102743. intersectsPoint(point: Vector3): boolean;
  102744. /**
  102745. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102746. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102747. */
  102748. get checkCollisions(): boolean;
  102749. set checkCollisions(collisionEnabled: boolean);
  102750. /**
  102751. * Gets Collider object used to compute collisions (not physics)
  102752. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102753. */
  102754. get collider(): Nullable<Collider>;
  102755. /**
  102756. * Move the mesh using collision engine
  102757. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102758. * @param displacement defines the requested displacement vector
  102759. * @returns the current mesh
  102760. */
  102761. moveWithCollisions(displacement: Vector3): AbstractMesh;
  102762. private _onCollisionPositionChange;
  102763. /** @hidden */
  102764. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  102765. /** @hidden */
  102766. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  102767. /** @hidden */
  102768. _checkCollision(collider: Collider): AbstractMesh;
  102769. /** @hidden */
  102770. _generatePointsArray(): boolean;
  102771. /**
  102772. * Checks if the passed Ray intersects with the mesh
  102773. * @param ray defines the ray to use
  102774. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  102775. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102776. * @returns the picking info
  102777. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  102778. */
  102779. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  102780. /**
  102781. * Clones the current mesh
  102782. * @param name defines the mesh name
  102783. * @param newParent defines the new mesh parent
  102784. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  102785. * @returns the new mesh
  102786. */
  102787. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  102788. /**
  102789. * Disposes all the submeshes of the current meshnp
  102790. * @returns the current mesh
  102791. */
  102792. releaseSubMeshes(): AbstractMesh;
  102793. /**
  102794. * Releases resources associated with this abstract mesh.
  102795. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102796. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102797. */
  102798. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102799. /**
  102800. * Adds the passed mesh as a child to the current mesh
  102801. * @param mesh defines the child mesh
  102802. * @returns the current mesh
  102803. */
  102804. addChild(mesh: AbstractMesh): AbstractMesh;
  102805. /**
  102806. * Removes the passed mesh from the current mesh children list
  102807. * @param mesh defines the child mesh
  102808. * @returns the current mesh
  102809. */
  102810. removeChild(mesh: AbstractMesh): AbstractMesh;
  102811. /** @hidden */
  102812. private _initFacetData;
  102813. /**
  102814. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  102815. * This method can be called within the render loop.
  102816. * 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
  102817. * @returns the current mesh
  102818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102819. */
  102820. updateFacetData(): AbstractMesh;
  102821. /**
  102822. * Returns the facetLocalNormals array.
  102823. * The normals are expressed in the mesh local spac
  102824. * @returns an array of Vector3
  102825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102826. */
  102827. getFacetLocalNormals(): Vector3[];
  102828. /**
  102829. * Returns the facetLocalPositions array.
  102830. * The facet positions are expressed in the mesh local space
  102831. * @returns an array of Vector3
  102832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102833. */
  102834. getFacetLocalPositions(): Vector3[];
  102835. /**
  102836. * Returns the facetLocalPartioning array
  102837. * @returns an array of array of numbers
  102838. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102839. */
  102840. getFacetLocalPartitioning(): number[][];
  102841. /**
  102842. * Returns the i-th facet position in the world system.
  102843. * This method allocates a new Vector3 per call
  102844. * @param i defines the facet index
  102845. * @returns a new Vector3
  102846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102847. */
  102848. getFacetPosition(i: number): Vector3;
  102849. /**
  102850. * Sets the reference Vector3 with the i-th facet position in the world system
  102851. * @param i defines the facet index
  102852. * @param ref defines the target vector
  102853. * @returns the current mesh
  102854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102855. */
  102856. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  102857. /**
  102858. * Returns the i-th facet normal in the world system.
  102859. * This method allocates a new Vector3 per call
  102860. * @param i defines the facet index
  102861. * @returns a new Vector3
  102862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102863. */
  102864. getFacetNormal(i: number): Vector3;
  102865. /**
  102866. * Sets the reference Vector3 with the i-th facet normal in the world system
  102867. * @param i defines the facet index
  102868. * @param ref defines the target vector
  102869. * @returns the current mesh
  102870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102871. */
  102872. getFacetNormalToRef(i: number, ref: Vector3): this;
  102873. /**
  102874. * 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)
  102875. * @param x defines x coordinate
  102876. * @param y defines y coordinate
  102877. * @param z defines z coordinate
  102878. * @returns the array of facet indexes
  102879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102880. */
  102881. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  102882. /**
  102883. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  102884. * @param projected sets as the (x,y,z) world projection on the facet
  102885. * @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
  102886. * @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
  102887. * @param x defines x coordinate
  102888. * @param y defines y coordinate
  102889. * @param z defines z coordinate
  102890. * @returns the face index if found (or null instead)
  102891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102892. */
  102893. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102894. /**
  102895. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  102896. * @param projected sets as the (x,y,z) local projection on the facet
  102897. * @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
  102898. * @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
  102899. * @param x defines x coordinate
  102900. * @param y defines y coordinate
  102901. * @param z defines z coordinate
  102902. * @returns the face index if found (or null instead)
  102903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102904. */
  102905. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  102906. /**
  102907. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  102908. * @returns the parameters
  102909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102910. */
  102911. getFacetDataParameters(): any;
  102912. /**
  102913. * Disables the feature FacetData and frees the related memory
  102914. * @returns the current mesh
  102915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  102916. */
  102917. disableFacetData(): AbstractMesh;
  102918. /**
  102919. * Updates the AbstractMesh indices array
  102920. * @param indices defines the data source
  102921. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  102922. * @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)
  102923. * @returns the current mesh
  102924. */
  102925. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  102926. /**
  102927. * Creates new normals data for the mesh
  102928. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  102929. * @returns the current mesh
  102930. */
  102931. createNormals(updatable: boolean): AbstractMesh;
  102932. /**
  102933. * Align the mesh with a normal
  102934. * @param normal defines the normal to use
  102935. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  102936. * @returns the current mesh
  102937. */
  102938. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  102939. /** @hidden */
  102940. _checkOcclusionQuery(): boolean;
  102941. /**
  102942. * Disables the mesh edge rendering mode
  102943. * @returns the currentAbstractMesh
  102944. */
  102945. disableEdgesRendering(): AbstractMesh;
  102946. /**
  102947. * Enables the edge rendering mode on the mesh.
  102948. * This mode makes the mesh edges visible
  102949. * @param epsilon defines the maximal distance between two angles to detect a face
  102950. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  102951. * @returns the currentAbstractMesh
  102952. * @see https://www.babylonjs-playground.com/#19O9TU#0
  102953. */
  102954. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  102955. }
  102956. }
  102957. declare module BABYLON {
  102958. /**
  102959. * Interface used to define ActionEvent
  102960. */
  102961. export interface IActionEvent {
  102962. /** The mesh or sprite that triggered the action */
  102963. source: any;
  102964. /** The X mouse cursor position at the time of the event */
  102965. pointerX: number;
  102966. /** The Y mouse cursor position at the time of the event */
  102967. pointerY: number;
  102968. /** The mesh that is currently pointed at (can be null) */
  102969. meshUnderPointer: Nullable<AbstractMesh>;
  102970. /** the original (browser) event that triggered the ActionEvent */
  102971. sourceEvent?: any;
  102972. /** additional data for the event */
  102973. additionalData?: any;
  102974. }
  102975. /**
  102976. * ActionEvent is the event being sent when an action is triggered.
  102977. */
  102978. export class ActionEvent implements IActionEvent {
  102979. /** The mesh or sprite that triggered the action */
  102980. source: any;
  102981. /** The X mouse cursor position at the time of the event */
  102982. pointerX: number;
  102983. /** The Y mouse cursor position at the time of the event */
  102984. pointerY: number;
  102985. /** The mesh that is currently pointed at (can be null) */
  102986. meshUnderPointer: Nullable<AbstractMesh>;
  102987. /** the original (browser) event that triggered the ActionEvent */
  102988. sourceEvent?: any;
  102989. /** additional data for the event */
  102990. additionalData?: any;
  102991. /**
  102992. * Creates a new ActionEvent
  102993. * @param source The mesh or sprite that triggered the action
  102994. * @param pointerX The X mouse cursor position at the time of the event
  102995. * @param pointerY The Y mouse cursor position at the time of the event
  102996. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  102997. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  102998. * @param additionalData additional data for the event
  102999. */
  103000. constructor(
  103001. /** The mesh or sprite that triggered the action */
  103002. source: any,
  103003. /** The X mouse cursor position at the time of the event */
  103004. pointerX: number,
  103005. /** The Y mouse cursor position at the time of the event */
  103006. pointerY: number,
  103007. /** The mesh that is currently pointed at (can be null) */
  103008. meshUnderPointer: Nullable<AbstractMesh>,
  103009. /** the original (browser) event that triggered the ActionEvent */
  103010. sourceEvent?: any,
  103011. /** additional data for the event */
  103012. additionalData?: any);
  103013. /**
  103014. * Helper function to auto-create an ActionEvent from a source mesh.
  103015. * @param source The source mesh that triggered the event
  103016. * @param evt The original (browser) event
  103017. * @param additionalData additional data for the event
  103018. * @returns the new ActionEvent
  103019. */
  103020. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  103021. /**
  103022. * Helper function to auto-create an ActionEvent from a source sprite
  103023. * @param source The source sprite that triggered the event
  103024. * @param scene Scene associated with the sprite
  103025. * @param evt The original (browser) event
  103026. * @param additionalData additional data for the event
  103027. * @returns the new ActionEvent
  103028. */
  103029. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  103030. /**
  103031. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  103032. * @param scene the scene where the event occurred
  103033. * @param evt The original (browser) event
  103034. * @returns the new ActionEvent
  103035. */
  103036. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  103037. /**
  103038. * Helper function to auto-create an ActionEvent from a primitive
  103039. * @param prim defines the target primitive
  103040. * @param pointerPos defines the pointer position
  103041. * @param evt The original (browser) event
  103042. * @param additionalData additional data for the event
  103043. * @returns the new ActionEvent
  103044. */
  103045. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  103046. }
  103047. }
  103048. declare module BABYLON {
  103049. /**
  103050. * Abstract class used to decouple action Manager from scene and meshes.
  103051. * Do not instantiate.
  103052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103053. */
  103054. export abstract class AbstractActionManager implements IDisposable {
  103055. /** Gets the list of active triggers */
  103056. static Triggers: {
  103057. [key: string]: number;
  103058. };
  103059. /** Gets the cursor to use when hovering items */
  103060. hoverCursor: string;
  103061. /** Gets the list of actions */
  103062. actions: IAction[];
  103063. /**
  103064. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  103065. */
  103066. isRecursive: boolean;
  103067. /**
  103068. * Releases all associated resources
  103069. */
  103070. abstract dispose(): void;
  103071. /**
  103072. * Does this action manager has pointer triggers
  103073. */
  103074. abstract get hasPointerTriggers(): boolean;
  103075. /**
  103076. * Does this action manager has pick triggers
  103077. */
  103078. abstract get hasPickTriggers(): boolean;
  103079. /**
  103080. * Process a specific trigger
  103081. * @param trigger defines the trigger to process
  103082. * @param evt defines the event details to be processed
  103083. */
  103084. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  103085. /**
  103086. * Does this action manager handles actions of any of the given triggers
  103087. * @param triggers defines the triggers to be tested
  103088. * @return a boolean indicating whether one (or more) of the triggers is handled
  103089. */
  103090. abstract hasSpecificTriggers(triggers: number[]): boolean;
  103091. /**
  103092. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  103093. * speed.
  103094. * @param triggerA defines the trigger to be tested
  103095. * @param triggerB defines the trigger to be tested
  103096. * @return a boolean indicating whether one (or more) of the triggers is handled
  103097. */
  103098. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  103099. /**
  103100. * Does this action manager handles actions of a given trigger
  103101. * @param trigger defines the trigger to be tested
  103102. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  103103. * @return whether the trigger is handled
  103104. */
  103105. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  103106. /**
  103107. * Serialize this manager to a JSON object
  103108. * @param name defines the property name to store this manager
  103109. * @returns a JSON representation of this manager
  103110. */
  103111. abstract serialize(name: string): any;
  103112. /**
  103113. * Registers an action to this action manager
  103114. * @param action defines the action to be registered
  103115. * @return the action amended (prepared) after registration
  103116. */
  103117. abstract registerAction(action: IAction): Nullable<IAction>;
  103118. /**
  103119. * Unregisters an action to this action manager
  103120. * @param action defines the action to be unregistered
  103121. * @return a boolean indicating whether the action has been unregistered
  103122. */
  103123. abstract unregisterAction(action: IAction): Boolean;
  103124. /**
  103125. * Does exist one action manager with at least one trigger
  103126. **/
  103127. static get HasTriggers(): boolean;
  103128. /**
  103129. * Does exist one action manager with at least one pick trigger
  103130. **/
  103131. static get HasPickTriggers(): boolean;
  103132. /**
  103133. * Does exist one action manager that handles actions of a given trigger
  103134. * @param trigger defines the trigger to be tested
  103135. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  103136. **/
  103137. static HasSpecificTrigger(trigger: number): boolean;
  103138. }
  103139. }
  103140. declare module BABYLON {
  103141. /**
  103142. * Defines how a node can be built from a string name.
  103143. */
  103144. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  103145. /**
  103146. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  103147. */
  103148. export class Node implements IBehaviorAware<Node> {
  103149. /** @hidden */
  103150. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  103151. private static _NodeConstructors;
  103152. /**
  103153. * Add a new node constructor
  103154. * @param type defines the type name of the node to construct
  103155. * @param constructorFunc defines the constructor function
  103156. */
  103157. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  103158. /**
  103159. * Returns a node constructor based on type name
  103160. * @param type defines the type name
  103161. * @param name defines the new node name
  103162. * @param scene defines the hosting scene
  103163. * @param options defines optional options to transmit to constructors
  103164. * @returns the new constructor or null
  103165. */
  103166. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  103167. /**
  103168. * Gets or sets the name of the node
  103169. */
  103170. name: string;
  103171. /**
  103172. * Gets or sets the id of the node
  103173. */
  103174. id: string;
  103175. /**
  103176. * Gets or sets the unique id of the node
  103177. */
  103178. uniqueId: number;
  103179. /**
  103180. * Gets or sets a string used to store user defined state for the node
  103181. */
  103182. state: string;
  103183. /**
  103184. * Gets or sets an object used to store user defined information for the node
  103185. */
  103186. metadata: any;
  103187. /**
  103188. * For internal use only. Please do not use.
  103189. */
  103190. reservedDataStore: any;
  103191. /**
  103192. * List of inspectable custom properties (used by the Inspector)
  103193. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103194. */
  103195. inspectableCustomProperties: IInspectable[];
  103196. private _doNotSerialize;
  103197. /**
  103198. * Gets or sets a boolean used to define if the node must be serialized
  103199. */
  103200. get doNotSerialize(): boolean;
  103201. set doNotSerialize(value: boolean);
  103202. /** @hidden */
  103203. _isDisposed: boolean;
  103204. /**
  103205. * Gets a list of Animations associated with the node
  103206. */
  103207. animations: Animation[];
  103208. protected _ranges: {
  103209. [name: string]: Nullable<AnimationRange>;
  103210. };
  103211. /**
  103212. * Callback raised when the node is ready to be used
  103213. */
  103214. onReady: Nullable<(node: Node) => void>;
  103215. private _isEnabled;
  103216. private _isParentEnabled;
  103217. private _isReady;
  103218. /** @hidden */
  103219. _currentRenderId: number;
  103220. private _parentUpdateId;
  103221. /** @hidden */
  103222. _childUpdateId: number;
  103223. /** @hidden */
  103224. _waitingParentId: Nullable<string>;
  103225. /** @hidden */
  103226. _scene: Scene;
  103227. /** @hidden */
  103228. _cache: any;
  103229. private _parentNode;
  103230. private _children;
  103231. /** @hidden */
  103232. _worldMatrix: Matrix;
  103233. /** @hidden */
  103234. _worldMatrixDeterminant: number;
  103235. /** @hidden */
  103236. _worldMatrixDeterminantIsDirty: boolean;
  103237. /** @hidden */
  103238. private _sceneRootNodesIndex;
  103239. /**
  103240. * Gets a boolean indicating if the node has been disposed
  103241. * @returns true if the node was disposed
  103242. */
  103243. isDisposed(): boolean;
  103244. /**
  103245. * Gets or sets the parent of the node (without keeping the current position in the scene)
  103246. * @see https://doc.babylonjs.com/how_to/parenting
  103247. */
  103248. set parent(parent: Nullable<Node>);
  103249. get parent(): Nullable<Node>;
  103250. /** @hidden */
  103251. _addToSceneRootNodes(): void;
  103252. /** @hidden */
  103253. _removeFromSceneRootNodes(): void;
  103254. private _animationPropertiesOverride;
  103255. /**
  103256. * Gets or sets the animation properties override
  103257. */
  103258. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103259. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103260. /**
  103261. * Gets a string idenfifying the name of the class
  103262. * @returns "Node" string
  103263. */
  103264. getClassName(): string;
  103265. /** @hidden */
  103266. readonly _isNode: boolean;
  103267. /**
  103268. * An event triggered when the mesh is disposed
  103269. */
  103270. onDisposeObservable: Observable<Node>;
  103271. private _onDisposeObserver;
  103272. /**
  103273. * Sets a callback that will be raised when the node will be disposed
  103274. */
  103275. set onDispose(callback: () => void);
  103276. /**
  103277. * Creates a new Node
  103278. * @param name the name and id to be given to this node
  103279. * @param scene the scene this node will be added to
  103280. */
  103281. constructor(name: string, scene?: Nullable<Scene>);
  103282. /**
  103283. * Gets the scene of the node
  103284. * @returns a scene
  103285. */
  103286. getScene(): Scene;
  103287. /**
  103288. * Gets the engine of the node
  103289. * @returns a Engine
  103290. */
  103291. getEngine(): Engine;
  103292. private _behaviors;
  103293. /**
  103294. * Attach a behavior to the node
  103295. * @see http://doc.babylonjs.com/features/behaviour
  103296. * @param behavior defines the behavior to attach
  103297. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  103298. * @returns the current Node
  103299. */
  103300. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  103301. /**
  103302. * Remove an attached behavior
  103303. * @see http://doc.babylonjs.com/features/behaviour
  103304. * @param behavior defines the behavior to attach
  103305. * @returns the current Node
  103306. */
  103307. removeBehavior(behavior: Behavior<Node>): Node;
  103308. /**
  103309. * Gets the list of attached behaviors
  103310. * @see http://doc.babylonjs.com/features/behaviour
  103311. */
  103312. get behaviors(): Behavior<Node>[];
  103313. /**
  103314. * Gets an attached behavior by name
  103315. * @param name defines the name of the behavior to look for
  103316. * @see http://doc.babylonjs.com/features/behaviour
  103317. * @returns null if behavior was not found else the requested behavior
  103318. */
  103319. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  103320. /**
  103321. * Returns the latest update of the World matrix
  103322. * @returns a Matrix
  103323. */
  103324. getWorldMatrix(): Matrix;
  103325. /** @hidden */
  103326. _getWorldMatrixDeterminant(): number;
  103327. /**
  103328. * Returns directly the latest state of the mesh World matrix.
  103329. * A Matrix is returned.
  103330. */
  103331. get worldMatrixFromCache(): Matrix;
  103332. /** @hidden */
  103333. _initCache(): void;
  103334. /** @hidden */
  103335. updateCache(force?: boolean): void;
  103336. /** @hidden */
  103337. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  103338. /** @hidden */
  103339. _updateCache(ignoreParentClass?: boolean): void;
  103340. /** @hidden */
  103341. _isSynchronized(): boolean;
  103342. /** @hidden */
  103343. _markSyncedWithParent(): void;
  103344. /** @hidden */
  103345. isSynchronizedWithParent(): boolean;
  103346. /** @hidden */
  103347. isSynchronized(): boolean;
  103348. /**
  103349. * Is this node ready to be used/rendered
  103350. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  103351. * @return true if the node is ready
  103352. */
  103353. isReady(completeCheck?: boolean): boolean;
  103354. /**
  103355. * Is this node enabled?
  103356. * 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
  103357. * @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
  103358. * @return whether this node (and its parent) is enabled
  103359. */
  103360. isEnabled(checkAncestors?: boolean): boolean;
  103361. /** @hidden */
  103362. protected _syncParentEnabledState(): void;
  103363. /**
  103364. * Set the enabled state of this node
  103365. * @param value defines the new enabled state
  103366. */
  103367. setEnabled(value: boolean): void;
  103368. /**
  103369. * Is this node a descendant of the given node?
  103370. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  103371. * @param ancestor defines the parent node to inspect
  103372. * @returns a boolean indicating if this node is a descendant of the given node
  103373. */
  103374. isDescendantOf(ancestor: Node): boolean;
  103375. /** @hidden */
  103376. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  103377. /**
  103378. * Will return all nodes that have this node as ascendant
  103379. * @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
  103380. * @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
  103381. * @return all children nodes of all types
  103382. */
  103383. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  103384. /**
  103385. * Get all child-meshes of this node
  103386. * @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)
  103387. * @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
  103388. * @returns an array of AbstractMesh
  103389. */
  103390. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  103391. /**
  103392. * Get all direct children of this node
  103393. * @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
  103394. * @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)
  103395. * @returns an array of Node
  103396. */
  103397. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  103398. /** @hidden */
  103399. _setReady(state: boolean): void;
  103400. /**
  103401. * Get an animation by name
  103402. * @param name defines the name of the animation to look for
  103403. * @returns null if not found else the requested animation
  103404. */
  103405. getAnimationByName(name: string): Nullable<Animation>;
  103406. /**
  103407. * Creates an animation range for this node
  103408. * @param name defines the name of the range
  103409. * @param from defines the starting key
  103410. * @param to defines the end key
  103411. */
  103412. createAnimationRange(name: string, from: number, to: number): void;
  103413. /**
  103414. * Delete a specific animation range
  103415. * @param name defines the name of the range to delete
  103416. * @param deleteFrames defines if animation frames from the range must be deleted as well
  103417. */
  103418. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  103419. /**
  103420. * Get an animation range by name
  103421. * @param name defines the name of the animation range to look for
  103422. * @returns null if not found else the requested animation range
  103423. */
  103424. getAnimationRange(name: string): Nullable<AnimationRange>;
  103425. /**
  103426. * Gets the list of all animation ranges defined on this node
  103427. * @returns an array
  103428. */
  103429. getAnimationRanges(): Nullable<AnimationRange>[];
  103430. /**
  103431. * Will start the animation sequence
  103432. * @param name defines the range frames for animation sequence
  103433. * @param loop defines if the animation should loop (false by default)
  103434. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  103435. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  103436. * @returns the object created for this animation. If range does not exist, it will return null
  103437. */
  103438. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  103439. /**
  103440. * Serialize animation ranges into a JSON compatible object
  103441. * @returns serialization object
  103442. */
  103443. serializeAnimationRanges(): any;
  103444. /**
  103445. * Computes the world matrix of the node
  103446. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  103447. * @returns the world matrix
  103448. */
  103449. computeWorldMatrix(force?: boolean): Matrix;
  103450. /**
  103451. * Releases resources associated with this node.
  103452. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103453. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103454. */
  103455. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103456. /**
  103457. * Parse animation range data from a serialization object and store them into a given node
  103458. * @param node defines where to store the animation ranges
  103459. * @param parsedNode defines the serialization object to read data from
  103460. * @param scene defines the hosting scene
  103461. */
  103462. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  103463. /**
  103464. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  103465. * @param includeDescendants Include bounding info from descendants as well (true by default)
  103466. * @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
  103467. * @returns the new bounding vectors
  103468. */
  103469. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  103470. min: Vector3;
  103471. max: Vector3;
  103472. };
  103473. }
  103474. }
  103475. declare module BABYLON {
  103476. /**
  103477. * @hidden
  103478. */
  103479. export class _IAnimationState {
  103480. key: number;
  103481. repeatCount: number;
  103482. workValue?: any;
  103483. loopMode?: number;
  103484. offsetValue?: any;
  103485. highLimitValue?: any;
  103486. }
  103487. /**
  103488. * Class used to store any kind of animation
  103489. */
  103490. export class Animation {
  103491. /**Name of the animation */
  103492. name: string;
  103493. /**Property to animate */
  103494. targetProperty: string;
  103495. /**The frames per second of the animation */
  103496. framePerSecond: number;
  103497. /**The data type of the animation */
  103498. dataType: number;
  103499. /**The loop mode of the animation */
  103500. loopMode?: number | undefined;
  103501. /**Specifies if blending should be enabled */
  103502. enableBlending?: boolean | undefined;
  103503. /**
  103504. * Use matrix interpolation instead of using direct key value when animating matrices
  103505. */
  103506. static AllowMatricesInterpolation: boolean;
  103507. /**
  103508. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  103509. */
  103510. static AllowMatrixDecomposeForInterpolation: boolean;
  103511. /**
  103512. * Stores the key frames of the animation
  103513. */
  103514. private _keys;
  103515. /**
  103516. * Stores the easing function of the animation
  103517. */
  103518. private _easingFunction;
  103519. /**
  103520. * @hidden Internal use only
  103521. */
  103522. _runtimeAnimations: RuntimeAnimation[];
  103523. /**
  103524. * The set of event that will be linked to this animation
  103525. */
  103526. private _events;
  103527. /**
  103528. * Stores an array of target property paths
  103529. */
  103530. targetPropertyPath: string[];
  103531. /**
  103532. * Stores the blending speed of the animation
  103533. */
  103534. blendingSpeed: number;
  103535. /**
  103536. * Stores the animation ranges for the animation
  103537. */
  103538. private _ranges;
  103539. /**
  103540. * @hidden Internal use
  103541. */
  103542. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  103543. /**
  103544. * Sets up an animation
  103545. * @param property The property to animate
  103546. * @param animationType The animation type to apply
  103547. * @param framePerSecond The frames per second of the animation
  103548. * @param easingFunction The easing function used in the animation
  103549. * @returns The created animation
  103550. */
  103551. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  103552. /**
  103553. * Create and start an animation on a node
  103554. * @param name defines the name of the global animation that will be run on all nodes
  103555. * @param node defines the root node where the animation will take place
  103556. * @param targetProperty defines property to animate
  103557. * @param framePerSecond defines the number of frame per second yo use
  103558. * @param totalFrame defines the number of frames in total
  103559. * @param from defines the initial value
  103560. * @param to defines the final value
  103561. * @param loopMode defines which loop mode you want to use (off by default)
  103562. * @param easingFunction defines the easing function to use (linear by default)
  103563. * @param onAnimationEnd defines the callback to call when animation end
  103564. * @returns the animatable created for this animation
  103565. */
  103566. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103567. /**
  103568. * Create and start an animation on a node and its descendants
  103569. * @param name defines the name of the global animation that will be run on all nodes
  103570. * @param node defines the root node where the animation will take place
  103571. * @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
  103572. * @param targetProperty defines property to animate
  103573. * @param framePerSecond defines the number of frame per second to use
  103574. * @param totalFrame defines the number of frames in total
  103575. * @param from defines the initial value
  103576. * @param to defines the final value
  103577. * @param loopMode defines which loop mode you want to use (off by default)
  103578. * @param easingFunction defines the easing function to use (linear by default)
  103579. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  103580. * @returns the list of animatables created for all nodes
  103581. * @example https://www.babylonjs-playground.com/#MH0VLI
  103582. */
  103583. 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[]>;
  103584. /**
  103585. * Creates a new animation, merges it with the existing animations and starts it
  103586. * @param name Name of the animation
  103587. * @param node Node which contains the scene that begins the animations
  103588. * @param targetProperty Specifies which property to animate
  103589. * @param framePerSecond The frames per second of the animation
  103590. * @param totalFrame The total number of frames
  103591. * @param from The frame at the beginning of the animation
  103592. * @param to The frame at the end of the animation
  103593. * @param loopMode Specifies the loop mode of the animation
  103594. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  103595. * @param onAnimationEnd Callback to run once the animation is complete
  103596. * @returns Nullable animation
  103597. */
  103598. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103599. /**
  103600. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  103601. * @param sourceAnimation defines the Animation containing keyframes to convert
  103602. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  103603. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  103604. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  103605. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  103606. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  103607. */
  103608. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  103609. /**
  103610. * Transition property of an host to the target Value
  103611. * @param property The property to transition
  103612. * @param targetValue The target Value of the property
  103613. * @param host The object where the property to animate belongs
  103614. * @param scene Scene used to run the animation
  103615. * @param frameRate Framerate (in frame/s) to use
  103616. * @param transition The transition type we want to use
  103617. * @param duration The duration of the animation, in milliseconds
  103618. * @param onAnimationEnd Callback trigger at the end of the animation
  103619. * @returns Nullable animation
  103620. */
  103621. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  103622. /**
  103623. * Return the array of runtime animations currently using this animation
  103624. */
  103625. get runtimeAnimations(): RuntimeAnimation[];
  103626. /**
  103627. * Specifies if any of the runtime animations are currently running
  103628. */
  103629. get hasRunningRuntimeAnimations(): boolean;
  103630. /**
  103631. * Initializes the animation
  103632. * @param name Name of the animation
  103633. * @param targetProperty Property to animate
  103634. * @param framePerSecond The frames per second of the animation
  103635. * @param dataType The data type of the animation
  103636. * @param loopMode The loop mode of the animation
  103637. * @param enableBlending Specifies if blending should be enabled
  103638. */
  103639. constructor(
  103640. /**Name of the animation */
  103641. name: string,
  103642. /**Property to animate */
  103643. targetProperty: string,
  103644. /**The frames per second of the animation */
  103645. framePerSecond: number,
  103646. /**The data type of the animation */
  103647. dataType: number,
  103648. /**The loop mode of the animation */
  103649. loopMode?: number | undefined,
  103650. /**Specifies if blending should be enabled */
  103651. enableBlending?: boolean | undefined);
  103652. /**
  103653. * Converts the animation to a string
  103654. * @param fullDetails support for multiple levels of logging within scene loading
  103655. * @returns String form of the animation
  103656. */
  103657. toString(fullDetails?: boolean): string;
  103658. /**
  103659. * Add an event to this animation
  103660. * @param event Event to add
  103661. */
  103662. addEvent(event: AnimationEvent): void;
  103663. /**
  103664. * Remove all events found at the given frame
  103665. * @param frame The frame to remove events from
  103666. */
  103667. removeEvents(frame: number): void;
  103668. /**
  103669. * Retrieves all the events from the animation
  103670. * @returns Events from the animation
  103671. */
  103672. getEvents(): AnimationEvent[];
  103673. /**
  103674. * Creates an animation range
  103675. * @param name Name of the animation range
  103676. * @param from Starting frame of the animation range
  103677. * @param to Ending frame of the animation
  103678. */
  103679. createRange(name: string, from: number, to: number): void;
  103680. /**
  103681. * Deletes an animation range by name
  103682. * @param name Name of the animation range to delete
  103683. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  103684. */
  103685. deleteRange(name: string, deleteFrames?: boolean): void;
  103686. /**
  103687. * Gets the animation range by name, or null if not defined
  103688. * @param name Name of the animation range
  103689. * @returns Nullable animation range
  103690. */
  103691. getRange(name: string): Nullable<AnimationRange>;
  103692. /**
  103693. * Gets the key frames from the animation
  103694. * @returns The key frames of the animation
  103695. */
  103696. getKeys(): Array<IAnimationKey>;
  103697. /**
  103698. * Gets the highest frame rate of the animation
  103699. * @returns Highest frame rate of the animation
  103700. */
  103701. getHighestFrame(): number;
  103702. /**
  103703. * Gets the easing function of the animation
  103704. * @returns Easing function of the animation
  103705. */
  103706. getEasingFunction(): IEasingFunction;
  103707. /**
  103708. * Sets the easing function of the animation
  103709. * @param easingFunction A custom mathematical formula for animation
  103710. */
  103711. setEasingFunction(easingFunction: EasingFunction): void;
  103712. /**
  103713. * Interpolates a scalar linearly
  103714. * @param startValue Start value of the animation curve
  103715. * @param endValue End value of the animation curve
  103716. * @param gradient Scalar amount to interpolate
  103717. * @returns Interpolated scalar value
  103718. */
  103719. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  103720. /**
  103721. * Interpolates a scalar cubically
  103722. * @param startValue Start value of the animation curve
  103723. * @param outTangent End tangent of the animation
  103724. * @param endValue End value of the animation curve
  103725. * @param inTangent Start tangent of the animation curve
  103726. * @param gradient Scalar amount to interpolate
  103727. * @returns Interpolated scalar value
  103728. */
  103729. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103730. /**
  103731. * Interpolates a quaternion using a spherical linear interpolation
  103732. * @param startValue Start value of the animation curve
  103733. * @param endValue End value of the animation curve
  103734. * @param gradient Scalar amount to interpolate
  103735. * @returns Interpolated quaternion value
  103736. */
  103737. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103738. /**
  103739. * Interpolates a quaternion cubically
  103740. * @param startValue Start value of the animation curve
  103741. * @param outTangent End tangent of the animation curve
  103742. * @param endValue End value of the animation curve
  103743. * @param inTangent Start tangent of the animation curve
  103744. * @param gradient Scalar amount to interpolate
  103745. * @returns Interpolated quaternion value
  103746. */
  103747. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103748. /**
  103749. * Interpolates a Vector3 linearl
  103750. * @param startValue Start value of the animation curve
  103751. * @param endValue End value of the animation curve
  103752. * @param gradient Scalar amount to interpolate
  103753. * @returns Interpolated scalar value
  103754. */
  103755. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  103756. /**
  103757. * Interpolates a Vector3 cubically
  103758. * @param startValue Start value of the animation curve
  103759. * @param outTangent End tangent of the animation
  103760. * @param endValue End value of the animation curve
  103761. * @param inTangent Start tangent of the animation curve
  103762. * @param gradient Scalar amount to interpolate
  103763. * @returns InterpolatedVector3 value
  103764. */
  103765. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  103766. /**
  103767. * Interpolates a Vector2 linearly
  103768. * @param startValue Start value of the animation curve
  103769. * @param endValue End value of the animation curve
  103770. * @param gradient Scalar amount to interpolate
  103771. * @returns Interpolated Vector2 value
  103772. */
  103773. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  103774. /**
  103775. * Interpolates a Vector2 cubically
  103776. * @param startValue Start value of the animation curve
  103777. * @param outTangent End tangent of the animation
  103778. * @param endValue End value of the animation curve
  103779. * @param inTangent Start tangent of the animation curve
  103780. * @param gradient Scalar amount to interpolate
  103781. * @returns Interpolated Vector2 value
  103782. */
  103783. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  103784. /**
  103785. * Interpolates a size linearly
  103786. * @param startValue Start value of the animation curve
  103787. * @param endValue End value of the animation curve
  103788. * @param gradient Scalar amount to interpolate
  103789. * @returns Interpolated Size value
  103790. */
  103791. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  103792. /**
  103793. * Interpolates a Color3 linearly
  103794. * @param startValue Start value of the animation curve
  103795. * @param endValue End value of the animation curve
  103796. * @param gradient Scalar amount to interpolate
  103797. * @returns Interpolated Color3 value
  103798. */
  103799. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  103800. /**
  103801. * Interpolates a Color4 linearly
  103802. * @param startValue Start value of the animation curve
  103803. * @param endValue End value of the animation curve
  103804. * @param gradient Scalar amount to interpolate
  103805. * @returns Interpolated Color3 value
  103806. */
  103807. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  103808. /**
  103809. * @hidden Internal use only
  103810. */
  103811. _getKeyValue(value: any): any;
  103812. /**
  103813. * @hidden Internal use only
  103814. */
  103815. _interpolate(currentFrame: number, state: _IAnimationState): any;
  103816. /**
  103817. * Defines the function to use to interpolate matrices
  103818. * @param startValue defines the start matrix
  103819. * @param endValue defines the end matrix
  103820. * @param gradient defines the gradient between both matrices
  103821. * @param result defines an optional target matrix where to store the interpolation
  103822. * @returns the interpolated matrix
  103823. */
  103824. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  103825. /**
  103826. * Makes a copy of the animation
  103827. * @returns Cloned animation
  103828. */
  103829. clone(): Animation;
  103830. /**
  103831. * Sets the key frames of the animation
  103832. * @param values The animation key frames to set
  103833. */
  103834. setKeys(values: Array<IAnimationKey>): void;
  103835. /**
  103836. * Serializes the animation to an object
  103837. * @returns Serialized object
  103838. */
  103839. serialize(): any;
  103840. /**
  103841. * Float animation type
  103842. */
  103843. static readonly ANIMATIONTYPE_FLOAT: number;
  103844. /**
  103845. * Vector3 animation type
  103846. */
  103847. static readonly ANIMATIONTYPE_VECTOR3: number;
  103848. /**
  103849. * Quaternion animation type
  103850. */
  103851. static readonly ANIMATIONTYPE_QUATERNION: number;
  103852. /**
  103853. * Matrix animation type
  103854. */
  103855. static readonly ANIMATIONTYPE_MATRIX: number;
  103856. /**
  103857. * Color3 animation type
  103858. */
  103859. static readonly ANIMATIONTYPE_COLOR3: number;
  103860. /**
  103861. * Color3 animation type
  103862. */
  103863. static readonly ANIMATIONTYPE_COLOR4: number;
  103864. /**
  103865. * Vector2 animation type
  103866. */
  103867. static readonly ANIMATIONTYPE_VECTOR2: number;
  103868. /**
  103869. * Size animation type
  103870. */
  103871. static readonly ANIMATIONTYPE_SIZE: number;
  103872. /**
  103873. * Relative Loop Mode
  103874. */
  103875. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  103876. /**
  103877. * Cycle Loop Mode
  103878. */
  103879. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  103880. /**
  103881. * Constant Loop Mode
  103882. */
  103883. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  103884. /** @hidden */
  103885. static _UniversalLerp(left: any, right: any, amount: number): any;
  103886. /**
  103887. * Parses an animation object and creates an animation
  103888. * @param parsedAnimation Parsed animation object
  103889. * @returns Animation object
  103890. */
  103891. static Parse(parsedAnimation: any): Animation;
  103892. /**
  103893. * Appends the serialized animations from the source animations
  103894. * @param source Source containing the animations
  103895. * @param destination Target to store the animations
  103896. */
  103897. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103898. }
  103899. }
  103900. declare module BABYLON {
  103901. /**
  103902. * Interface containing an array of animations
  103903. */
  103904. export interface IAnimatable {
  103905. /**
  103906. * Array of animations
  103907. */
  103908. animations: Nullable<Array<Animation>>;
  103909. }
  103910. }
  103911. declare module BABYLON {
  103912. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  103913. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103914. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103915. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103916. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103917. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103918. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103919. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103920. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103921. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103922. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103923. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103924. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103925. /**
  103926. * Decorator used to define property that can be serialized as reference to a camera
  103927. * @param sourceName defines the name of the property to decorate
  103928. */
  103929. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  103930. /**
  103931. * Class used to help serialization objects
  103932. */
  103933. export class SerializationHelper {
  103934. /** @hidden */
  103935. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  103936. /** @hidden */
  103937. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  103938. /** @hidden */
  103939. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  103940. /** @hidden */
  103941. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  103942. /**
  103943. * Appends the serialized animations from the source animations
  103944. * @param source Source containing the animations
  103945. * @param destination Target to store the animations
  103946. */
  103947. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  103948. /**
  103949. * Static function used to serialized a specific entity
  103950. * @param entity defines the entity to serialize
  103951. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  103952. * @returns a JSON compatible object representing the serialization of the entity
  103953. */
  103954. static Serialize<T>(entity: T, serializationObject?: any): any;
  103955. /**
  103956. * Creates a new entity from a serialization data object
  103957. * @param creationFunction defines a function used to instanciated the new entity
  103958. * @param source defines the source serialization data
  103959. * @param scene defines the hosting scene
  103960. * @param rootUrl defines the root url for resources
  103961. * @returns a new entity
  103962. */
  103963. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  103964. /**
  103965. * Clones an object
  103966. * @param creationFunction defines the function used to instanciate the new object
  103967. * @param source defines the source object
  103968. * @returns the cloned object
  103969. */
  103970. static Clone<T>(creationFunction: () => T, source: T): T;
  103971. /**
  103972. * Instanciates a new object based on a source one (some data will be shared between both object)
  103973. * @param creationFunction defines the function used to instanciate the new object
  103974. * @param source defines the source object
  103975. * @returns the new object
  103976. */
  103977. static Instanciate<T>(creationFunction: () => T, source: T): T;
  103978. }
  103979. }
  103980. declare module BABYLON {
  103981. /**
  103982. * Class used to manipulate GUIDs
  103983. */
  103984. export class GUID {
  103985. /**
  103986. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103987. * Be aware Math.random() could cause collisions, but:
  103988. * "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"
  103989. * @returns a pseudo random id
  103990. */
  103991. static RandomId(): string;
  103992. }
  103993. }
  103994. declare module BABYLON {
  103995. /**
  103996. * Base class of all the textures in babylon.
  103997. * It groups all the common properties the materials, post process, lights... might need
  103998. * in order to make a correct use of the texture.
  103999. */
  104000. export class BaseTexture implements IAnimatable {
  104001. /**
  104002. * Default anisotropic filtering level for the application.
  104003. * It is set to 4 as a good tradeoff between perf and quality.
  104004. */
  104005. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  104006. /**
  104007. * Gets or sets the unique id of the texture
  104008. */
  104009. uniqueId: number;
  104010. /**
  104011. * Define the name of the texture.
  104012. */
  104013. name: string;
  104014. /**
  104015. * Gets or sets an object used to store user defined information.
  104016. */
  104017. metadata: any;
  104018. /**
  104019. * For internal use only. Please do not use.
  104020. */
  104021. reservedDataStore: any;
  104022. private _hasAlpha;
  104023. /**
  104024. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  104025. */
  104026. set hasAlpha(value: boolean);
  104027. get hasAlpha(): boolean;
  104028. /**
  104029. * Defines if the alpha value should be determined via the rgb values.
  104030. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  104031. */
  104032. getAlphaFromRGB: boolean;
  104033. /**
  104034. * Intensity or strength of the texture.
  104035. * It is commonly used by materials to fine tune the intensity of the texture
  104036. */
  104037. level: number;
  104038. /**
  104039. * Define the UV chanel to use starting from 0 and defaulting to 0.
  104040. * This is part of the texture as textures usually maps to one uv set.
  104041. */
  104042. coordinatesIndex: number;
  104043. private _coordinatesMode;
  104044. /**
  104045. * How a texture is mapped.
  104046. *
  104047. * | Value | Type | Description |
  104048. * | ----- | ----------------------------------- | ----------- |
  104049. * | 0 | EXPLICIT_MODE | |
  104050. * | 1 | SPHERICAL_MODE | |
  104051. * | 2 | PLANAR_MODE | |
  104052. * | 3 | CUBIC_MODE | |
  104053. * | 4 | PROJECTION_MODE | |
  104054. * | 5 | SKYBOX_MODE | |
  104055. * | 6 | INVCUBIC_MODE | |
  104056. * | 7 | EQUIRECTANGULAR_MODE | |
  104057. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  104058. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  104059. */
  104060. set coordinatesMode(value: number);
  104061. get coordinatesMode(): number;
  104062. /**
  104063. * | Value | Type | Description |
  104064. * | ----- | ------------------ | ----------- |
  104065. * | 0 | CLAMP_ADDRESSMODE | |
  104066. * | 1 | WRAP_ADDRESSMODE | |
  104067. * | 2 | MIRROR_ADDRESSMODE | |
  104068. */
  104069. wrapU: number;
  104070. /**
  104071. * | Value | Type | Description |
  104072. * | ----- | ------------------ | ----------- |
  104073. * | 0 | CLAMP_ADDRESSMODE | |
  104074. * | 1 | WRAP_ADDRESSMODE | |
  104075. * | 2 | MIRROR_ADDRESSMODE | |
  104076. */
  104077. wrapV: number;
  104078. /**
  104079. * | Value | Type | Description |
  104080. * | ----- | ------------------ | ----------- |
  104081. * | 0 | CLAMP_ADDRESSMODE | |
  104082. * | 1 | WRAP_ADDRESSMODE | |
  104083. * | 2 | MIRROR_ADDRESSMODE | |
  104084. */
  104085. wrapR: number;
  104086. /**
  104087. * With compliant hardware and browser (supporting anisotropic filtering)
  104088. * this defines the level of anisotropic filtering in the texture.
  104089. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  104090. */
  104091. anisotropicFilteringLevel: number;
  104092. /**
  104093. * Define if the texture is a cube texture or if false a 2d texture.
  104094. */
  104095. get isCube(): boolean;
  104096. set isCube(value: boolean);
  104097. /**
  104098. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  104099. */
  104100. get is3D(): boolean;
  104101. set is3D(value: boolean);
  104102. /**
  104103. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  104104. */
  104105. get is2DArray(): boolean;
  104106. set is2DArray(value: boolean);
  104107. /**
  104108. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  104109. * HDR texture are usually stored in linear space.
  104110. * This only impacts the PBR and Background materials
  104111. */
  104112. gammaSpace: boolean;
  104113. /**
  104114. * Gets or sets whether or not the texture contains RGBD data.
  104115. */
  104116. get isRGBD(): boolean;
  104117. set isRGBD(value: boolean);
  104118. /**
  104119. * Is Z inverted in the texture (useful in a cube texture).
  104120. */
  104121. invertZ: boolean;
  104122. /**
  104123. * Are mip maps generated for this texture or not.
  104124. */
  104125. get noMipmap(): boolean;
  104126. /**
  104127. * @hidden
  104128. */
  104129. lodLevelInAlpha: boolean;
  104130. /**
  104131. * With prefiltered texture, defined the offset used during the prefiltering steps.
  104132. */
  104133. get lodGenerationOffset(): number;
  104134. set lodGenerationOffset(value: number);
  104135. /**
  104136. * With prefiltered texture, defined the scale used during the prefiltering steps.
  104137. */
  104138. get lodGenerationScale(): number;
  104139. set lodGenerationScale(value: number);
  104140. /**
  104141. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  104142. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  104143. * average roughness values.
  104144. */
  104145. get linearSpecularLOD(): boolean;
  104146. set linearSpecularLOD(value: boolean);
  104147. /**
  104148. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  104149. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  104150. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  104151. */
  104152. get irradianceTexture(): Nullable<BaseTexture>;
  104153. set irradianceTexture(value: Nullable<BaseTexture>);
  104154. /**
  104155. * Define if the texture is a render target.
  104156. */
  104157. isRenderTarget: boolean;
  104158. /**
  104159. * Define the unique id of the texture in the scene.
  104160. */
  104161. get uid(): string;
  104162. /**
  104163. * Return a string representation of the texture.
  104164. * @returns the texture as a string
  104165. */
  104166. toString(): string;
  104167. /**
  104168. * Get the class name of the texture.
  104169. * @returns "BaseTexture"
  104170. */
  104171. getClassName(): string;
  104172. /**
  104173. * Define the list of animation attached to the texture.
  104174. */
  104175. animations: Animation[];
  104176. /**
  104177. * An event triggered when the texture is disposed.
  104178. */
  104179. onDisposeObservable: Observable<BaseTexture>;
  104180. private _onDisposeObserver;
  104181. /**
  104182. * Callback triggered when the texture has been disposed.
  104183. * Kept for back compatibility, you can use the onDisposeObservable instead.
  104184. */
  104185. set onDispose(callback: () => void);
  104186. /**
  104187. * Define the current state of the loading sequence when in delayed load mode.
  104188. */
  104189. delayLoadState: number;
  104190. private _scene;
  104191. /** @hidden */
  104192. _texture: Nullable<InternalTexture>;
  104193. private _uid;
  104194. /**
  104195. * Define if the texture is preventinga material to render or not.
  104196. * If not and the texture is not ready, the engine will use a default black texture instead.
  104197. */
  104198. get isBlocking(): boolean;
  104199. /**
  104200. * Instantiates a new BaseTexture.
  104201. * Base class of all the textures in babylon.
  104202. * It groups all the common properties the materials, post process, lights... might need
  104203. * in order to make a correct use of the texture.
  104204. * @param scene Define the scene the texture blongs to
  104205. */
  104206. constructor(scene: Nullable<Scene>);
  104207. /**
  104208. * Get the scene the texture belongs to.
  104209. * @returns the scene or null if undefined
  104210. */
  104211. getScene(): Nullable<Scene>;
  104212. /**
  104213. * Get the texture transform matrix used to offset tile the texture for istance.
  104214. * @returns the transformation matrix
  104215. */
  104216. getTextureMatrix(): Matrix;
  104217. /**
  104218. * Get the texture reflection matrix used to rotate/transform the reflection.
  104219. * @returns the reflection matrix
  104220. */
  104221. getReflectionTextureMatrix(): Matrix;
  104222. /**
  104223. * Get the underlying lower level texture from Babylon.
  104224. * @returns the insternal texture
  104225. */
  104226. getInternalTexture(): Nullable<InternalTexture>;
  104227. /**
  104228. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  104229. * @returns true if ready or not blocking
  104230. */
  104231. isReadyOrNotBlocking(): boolean;
  104232. /**
  104233. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  104234. * @returns true if fully ready
  104235. */
  104236. isReady(): boolean;
  104237. private _cachedSize;
  104238. /**
  104239. * Get the size of the texture.
  104240. * @returns the texture size.
  104241. */
  104242. getSize(): ISize;
  104243. /**
  104244. * Get the base size of the texture.
  104245. * It can be different from the size if the texture has been resized for POT for instance
  104246. * @returns the base size
  104247. */
  104248. getBaseSize(): ISize;
  104249. /**
  104250. * Update the sampling mode of the texture.
  104251. * Default is Trilinear mode.
  104252. *
  104253. * | Value | Type | Description |
  104254. * | ----- | ------------------ | ----------- |
  104255. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  104256. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  104257. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  104258. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  104259. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  104260. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  104261. * | 7 | NEAREST_LINEAR | |
  104262. * | 8 | NEAREST_NEAREST | |
  104263. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  104264. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  104265. * | 11 | LINEAR_LINEAR | |
  104266. * | 12 | LINEAR_NEAREST | |
  104267. *
  104268. * > _mag_: magnification filter (close to the viewer)
  104269. * > _min_: minification filter (far from the viewer)
  104270. * > _mip_: filter used between mip map levels
  104271. *@param samplingMode Define the new sampling mode of the texture
  104272. */
  104273. updateSamplingMode(samplingMode: number): void;
  104274. /**
  104275. * Scales the texture if is `canRescale()`
  104276. * @param ratio the resize factor we want to use to rescale
  104277. */
  104278. scale(ratio: number): void;
  104279. /**
  104280. * Get if the texture can rescale.
  104281. */
  104282. get canRescale(): boolean;
  104283. /** @hidden */
  104284. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  104285. /** @hidden */
  104286. _rebuild(): void;
  104287. /**
  104288. * Triggers the load sequence in delayed load mode.
  104289. */
  104290. delayLoad(): void;
  104291. /**
  104292. * Clones the texture.
  104293. * @returns the cloned texture
  104294. */
  104295. clone(): Nullable<BaseTexture>;
  104296. /**
  104297. * Get the texture underlying type (INT, FLOAT...)
  104298. */
  104299. get textureType(): number;
  104300. /**
  104301. * Get the texture underlying format (RGB, RGBA...)
  104302. */
  104303. get textureFormat(): number;
  104304. /**
  104305. * Indicates that textures need to be re-calculated for all materials
  104306. */
  104307. protected _markAllSubMeshesAsTexturesDirty(): void;
  104308. /**
  104309. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  104310. * This will returns an RGBA array buffer containing either in values (0-255) or
  104311. * float values (0-1) depending of the underlying buffer type.
  104312. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  104313. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  104314. * @param buffer defines a user defined buffer to fill with data (can be null)
  104315. * @returns The Array buffer containing the pixels data.
  104316. */
  104317. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  104318. /**
  104319. * Release and destroy the underlying lower level texture aka internalTexture.
  104320. */
  104321. releaseInternalTexture(): void;
  104322. /** @hidden */
  104323. get _lodTextureHigh(): Nullable<BaseTexture>;
  104324. /** @hidden */
  104325. get _lodTextureMid(): Nullable<BaseTexture>;
  104326. /** @hidden */
  104327. get _lodTextureLow(): Nullable<BaseTexture>;
  104328. /**
  104329. * Dispose the texture and release its associated resources.
  104330. */
  104331. dispose(): void;
  104332. /**
  104333. * Serialize the texture into a JSON representation that can be parsed later on.
  104334. * @returns the JSON representation of the texture
  104335. */
  104336. serialize(): any;
  104337. /**
  104338. * Helper function to be called back once a list of texture contains only ready textures.
  104339. * @param textures Define the list of textures to wait for
  104340. * @param callback Define the callback triggered once the entire list will be ready
  104341. */
  104342. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  104343. }
  104344. }
  104345. declare module BABYLON {
  104346. /**
  104347. * Options to be used when creating an effect.
  104348. */
  104349. export interface IEffectCreationOptions {
  104350. /**
  104351. * Atrributes that will be used in the shader.
  104352. */
  104353. attributes: string[];
  104354. /**
  104355. * Uniform varible names that will be set in the shader.
  104356. */
  104357. uniformsNames: string[];
  104358. /**
  104359. * Uniform buffer variable names that will be set in the shader.
  104360. */
  104361. uniformBuffersNames: string[];
  104362. /**
  104363. * Sampler texture variable names that will be set in the shader.
  104364. */
  104365. samplers: string[];
  104366. /**
  104367. * Define statements that will be set in the shader.
  104368. */
  104369. defines: any;
  104370. /**
  104371. * Possible fallbacks for this effect to improve performance when needed.
  104372. */
  104373. fallbacks: Nullable<IEffectFallbacks>;
  104374. /**
  104375. * Callback that will be called when the shader is compiled.
  104376. */
  104377. onCompiled: Nullable<(effect: Effect) => void>;
  104378. /**
  104379. * Callback that will be called if an error occurs during shader compilation.
  104380. */
  104381. onError: Nullable<(effect: Effect, errors: string) => void>;
  104382. /**
  104383. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104384. */
  104385. indexParameters?: any;
  104386. /**
  104387. * Max number of lights that can be used in the shader.
  104388. */
  104389. maxSimultaneousLights?: number;
  104390. /**
  104391. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  104392. */
  104393. transformFeedbackVaryings?: Nullable<string[]>;
  104394. }
  104395. /**
  104396. * Effect containing vertex and fragment shader that can be executed on an object.
  104397. */
  104398. export class Effect implements IDisposable {
  104399. /**
  104400. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104401. */
  104402. static ShadersRepository: string;
  104403. /**
  104404. * Enable logging of the shader code when a compilation error occurs
  104405. */
  104406. static LogShaderCodeOnCompilationError: boolean;
  104407. /**
  104408. * Name of the effect.
  104409. */
  104410. name: any;
  104411. /**
  104412. * String container all the define statements that should be set on the shader.
  104413. */
  104414. defines: string;
  104415. /**
  104416. * Callback that will be called when the shader is compiled.
  104417. */
  104418. onCompiled: Nullable<(effect: Effect) => void>;
  104419. /**
  104420. * Callback that will be called if an error occurs during shader compilation.
  104421. */
  104422. onError: Nullable<(effect: Effect, errors: string) => void>;
  104423. /**
  104424. * Callback that will be called when effect is bound.
  104425. */
  104426. onBind: Nullable<(effect: Effect) => void>;
  104427. /**
  104428. * Unique ID of the effect.
  104429. */
  104430. uniqueId: number;
  104431. /**
  104432. * Observable that will be called when the shader is compiled.
  104433. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  104434. */
  104435. onCompileObservable: Observable<Effect>;
  104436. /**
  104437. * Observable that will be called if an error occurs during shader compilation.
  104438. */
  104439. onErrorObservable: Observable<Effect>;
  104440. /** @hidden */
  104441. _onBindObservable: Nullable<Observable<Effect>>;
  104442. /**
  104443. * @hidden
  104444. * Specifies if the effect was previously ready
  104445. */
  104446. _wasPreviouslyReady: boolean;
  104447. /**
  104448. * Observable that will be called when effect is bound.
  104449. */
  104450. get onBindObservable(): Observable<Effect>;
  104451. /** @hidden */
  104452. _bonesComputationForcedToCPU: boolean;
  104453. private static _uniqueIdSeed;
  104454. private _engine;
  104455. private _uniformBuffersNames;
  104456. private _uniformsNames;
  104457. private _samplerList;
  104458. private _samplers;
  104459. private _isReady;
  104460. private _compilationError;
  104461. private _allFallbacksProcessed;
  104462. private _attributesNames;
  104463. private _attributes;
  104464. private _attributeLocationByName;
  104465. private _uniforms;
  104466. /**
  104467. * Key for the effect.
  104468. * @hidden
  104469. */
  104470. _key: string;
  104471. private _indexParameters;
  104472. private _fallbacks;
  104473. private _vertexSourceCode;
  104474. private _fragmentSourceCode;
  104475. private _vertexSourceCodeOverride;
  104476. private _fragmentSourceCodeOverride;
  104477. private _transformFeedbackVaryings;
  104478. /**
  104479. * Compiled shader to webGL program.
  104480. * @hidden
  104481. */
  104482. _pipelineContext: Nullable<IPipelineContext>;
  104483. private _valueCache;
  104484. private static _baseCache;
  104485. /**
  104486. * Instantiates an effect.
  104487. * An effect can be used to create/manage/execute vertex and fragment shaders.
  104488. * @param baseName Name of the effect.
  104489. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  104490. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  104491. * @param samplers List of sampler variables that will be passed to the shader.
  104492. * @param engine Engine to be used to render the effect
  104493. * @param defines Define statements to be added to the shader.
  104494. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  104495. * @param onCompiled Callback that will be called when the shader is compiled.
  104496. * @param onError Callback that will be called if an error occurs during shader compilation.
  104497. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104498. */
  104499. 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);
  104500. private _useFinalCode;
  104501. /**
  104502. * Unique key for this effect
  104503. */
  104504. get key(): string;
  104505. /**
  104506. * If the effect has been compiled and prepared.
  104507. * @returns if the effect is compiled and prepared.
  104508. */
  104509. isReady(): boolean;
  104510. private _isReadyInternal;
  104511. /**
  104512. * The engine the effect was initialized with.
  104513. * @returns the engine.
  104514. */
  104515. getEngine(): Engine;
  104516. /**
  104517. * The pipeline context for this effect
  104518. * @returns the associated pipeline context
  104519. */
  104520. getPipelineContext(): Nullable<IPipelineContext>;
  104521. /**
  104522. * The set of names of attribute variables for the shader.
  104523. * @returns An array of attribute names.
  104524. */
  104525. getAttributesNames(): string[];
  104526. /**
  104527. * Returns the attribute at the given index.
  104528. * @param index The index of the attribute.
  104529. * @returns The location of the attribute.
  104530. */
  104531. getAttributeLocation(index: number): number;
  104532. /**
  104533. * Returns the attribute based on the name of the variable.
  104534. * @param name of the attribute to look up.
  104535. * @returns the attribute location.
  104536. */
  104537. getAttributeLocationByName(name: string): number;
  104538. /**
  104539. * The number of attributes.
  104540. * @returns the numnber of attributes.
  104541. */
  104542. getAttributesCount(): number;
  104543. /**
  104544. * Gets the index of a uniform variable.
  104545. * @param uniformName of the uniform to look up.
  104546. * @returns the index.
  104547. */
  104548. getUniformIndex(uniformName: string): number;
  104549. /**
  104550. * Returns the attribute based on the name of the variable.
  104551. * @param uniformName of the uniform to look up.
  104552. * @returns the location of the uniform.
  104553. */
  104554. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  104555. /**
  104556. * Returns an array of sampler variable names
  104557. * @returns The array of sampler variable neames.
  104558. */
  104559. getSamplers(): string[];
  104560. /**
  104561. * The error from the last compilation.
  104562. * @returns the error string.
  104563. */
  104564. getCompilationError(): string;
  104565. /**
  104566. * Gets a boolean indicating that all fallbacks were used during compilation
  104567. * @returns true if all fallbacks were used
  104568. */
  104569. allFallbacksProcessed(): boolean;
  104570. /**
  104571. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  104572. * @param func The callback to be used.
  104573. */
  104574. executeWhenCompiled(func: (effect: Effect) => void): void;
  104575. private _checkIsReady;
  104576. private _loadShader;
  104577. /**
  104578. * Recompiles the webGL program
  104579. * @param vertexSourceCode The source code for the vertex shader.
  104580. * @param fragmentSourceCode The source code for the fragment shader.
  104581. * @param onCompiled Callback called when completed.
  104582. * @param onError Callback called on error.
  104583. * @hidden
  104584. */
  104585. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  104586. /**
  104587. * Prepares the effect
  104588. * @hidden
  104589. */
  104590. _prepareEffect(): void;
  104591. private _getShaderCodeAndErrorLine;
  104592. private _processCompilationErrors;
  104593. /**
  104594. * Checks if the effect is supported. (Must be called after compilation)
  104595. */
  104596. get isSupported(): boolean;
  104597. /**
  104598. * Binds a texture to the engine to be used as output of the shader.
  104599. * @param channel Name of the output variable.
  104600. * @param texture Texture to bind.
  104601. * @hidden
  104602. */
  104603. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  104604. /**
  104605. * Sets a texture on the engine to be used in the shader.
  104606. * @param channel Name of the sampler variable.
  104607. * @param texture Texture to set.
  104608. */
  104609. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  104610. /**
  104611. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  104612. * @param channel Name of the sampler variable.
  104613. * @param texture Texture to set.
  104614. */
  104615. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  104616. /**
  104617. * Sets an array of textures on the engine to be used in the shader.
  104618. * @param channel Name of the variable.
  104619. * @param textures Textures to set.
  104620. */
  104621. setTextureArray(channel: string, textures: BaseTexture[]): void;
  104622. /**
  104623. * 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)
  104624. * @param channel Name of the sampler variable.
  104625. * @param postProcess Post process to get the input texture from.
  104626. */
  104627. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  104628. /**
  104629. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  104630. * 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)
  104631. * @param channel Name of the sampler variable.
  104632. * @param postProcess Post process to get the output texture from.
  104633. */
  104634. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  104635. /** @hidden */
  104636. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  104637. /** @hidden */
  104638. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  104639. /** @hidden */
  104640. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  104641. /** @hidden */
  104642. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  104643. /**
  104644. * Binds a buffer to a uniform.
  104645. * @param buffer Buffer to bind.
  104646. * @param name Name of the uniform variable to bind to.
  104647. */
  104648. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  104649. /**
  104650. * Binds block to a uniform.
  104651. * @param blockName Name of the block to bind.
  104652. * @param index Index to bind.
  104653. */
  104654. bindUniformBlock(blockName: string, index: number): void;
  104655. /**
  104656. * Sets an interger value on a uniform variable.
  104657. * @param uniformName Name of the variable.
  104658. * @param value Value to be set.
  104659. * @returns this effect.
  104660. */
  104661. setInt(uniformName: string, value: number): Effect;
  104662. /**
  104663. * Sets an int array on a uniform variable.
  104664. * @param uniformName Name of the variable.
  104665. * @param array array to be set.
  104666. * @returns this effect.
  104667. */
  104668. setIntArray(uniformName: string, array: Int32Array): Effect;
  104669. /**
  104670. * 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)
  104671. * @param uniformName Name of the variable.
  104672. * @param array array to be set.
  104673. * @returns this effect.
  104674. */
  104675. setIntArray2(uniformName: string, array: Int32Array): Effect;
  104676. /**
  104677. * 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)
  104678. * @param uniformName Name of the variable.
  104679. * @param array array to be set.
  104680. * @returns this effect.
  104681. */
  104682. setIntArray3(uniformName: string, array: Int32Array): Effect;
  104683. /**
  104684. * 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)
  104685. * @param uniformName Name of the variable.
  104686. * @param array array to be set.
  104687. * @returns this effect.
  104688. */
  104689. setIntArray4(uniformName: string, array: Int32Array): Effect;
  104690. /**
  104691. * Sets an float array on a uniform variable.
  104692. * @param uniformName Name of the variable.
  104693. * @param array array to be set.
  104694. * @returns this effect.
  104695. */
  104696. setFloatArray(uniformName: string, array: Float32Array): Effect;
  104697. /**
  104698. * 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)
  104699. * @param uniformName Name of the variable.
  104700. * @param array array to be set.
  104701. * @returns this effect.
  104702. */
  104703. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  104704. /**
  104705. * 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)
  104706. * @param uniformName Name of the variable.
  104707. * @param array array to be set.
  104708. * @returns this effect.
  104709. */
  104710. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  104711. /**
  104712. * 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)
  104713. * @param uniformName Name of the variable.
  104714. * @param array array to be set.
  104715. * @returns this effect.
  104716. */
  104717. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  104718. /**
  104719. * Sets an array on a uniform variable.
  104720. * @param uniformName Name of the variable.
  104721. * @param array array to be set.
  104722. * @returns this effect.
  104723. */
  104724. setArray(uniformName: string, array: number[]): Effect;
  104725. /**
  104726. * 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)
  104727. * @param uniformName Name of the variable.
  104728. * @param array array to be set.
  104729. * @returns this effect.
  104730. */
  104731. setArray2(uniformName: string, array: number[]): Effect;
  104732. /**
  104733. * 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)
  104734. * @param uniformName Name of the variable.
  104735. * @param array array to be set.
  104736. * @returns this effect.
  104737. */
  104738. setArray3(uniformName: string, array: number[]): Effect;
  104739. /**
  104740. * 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)
  104741. * @param uniformName Name of the variable.
  104742. * @param array array to be set.
  104743. * @returns this effect.
  104744. */
  104745. setArray4(uniformName: string, array: number[]): Effect;
  104746. /**
  104747. * Sets matrices on a uniform variable.
  104748. * @param uniformName Name of the variable.
  104749. * @param matrices matrices to be set.
  104750. * @returns this effect.
  104751. */
  104752. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104753. /**
  104754. * Sets matrix on a uniform variable.
  104755. * @param uniformName Name of the variable.
  104756. * @param matrix matrix to be set.
  104757. * @returns this effect.
  104758. */
  104759. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  104760. /**
  104761. * 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)
  104762. * @param uniformName Name of the variable.
  104763. * @param matrix matrix to be set.
  104764. * @returns this effect.
  104765. */
  104766. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  104767. /**
  104768. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  104769. * @param uniformName Name of the variable.
  104770. * @param matrix matrix to be set.
  104771. * @returns this effect.
  104772. */
  104773. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  104774. /**
  104775. * Sets a float on a uniform variable.
  104776. * @param uniformName Name of the variable.
  104777. * @param value value to be set.
  104778. * @returns this effect.
  104779. */
  104780. setFloat(uniformName: string, value: number): Effect;
  104781. /**
  104782. * Sets a boolean on a uniform variable.
  104783. * @param uniformName Name of the variable.
  104784. * @param bool value to be set.
  104785. * @returns this effect.
  104786. */
  104787. setBool(uniformName: string, bool: boolean): Effect;
  104788. /**
  104789. * Sets a Vector2 on a uniform variable.
  104790. * @param uniformName Name of the variable.
  104791. * @param vector2 vector2 to be set.
  104792. * @returns this effect.
  104793. */
  104794. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  104795. /**
  104796. * Sets a float2 on a uniform variable.
  104797. * @param uniformName Name of the variable.
  104798. * @param x First float in float2.
  104799. * @param y Second float in float2.
  104800. * @returns this effect.
  104801. */
  104802. setFloat2(uniformName: string, x: number, y: number): Effect;
  104803. /**
  104804. * Sets a Vector3 on a uniform variable.
  104805. * @param uniformName Name of the variable.
  104806. * @param vector3 Value to be set.
  104807. * @returns this effect.
  104808. */
  104809. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  104810. /**
  104811. * Sets a float3 on a uniform variable.
  104812. * @param uniformName Name of the variable.
  104813. * @param x First float in float3.
  104814. * @param y Second float in float3.
  104815. * @param z Third float in float3.
  104816. * @returns this effect.
  104817. */
  104818. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  104819. /**
  104820. * Sets a Vector4 on a uniform variable.
  104821. * @param uniformName Name of the variable.
  104822. * @param vector4 Value to be set.
  104823. * @returns this effect.
  104824. */
  104825. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  104826. /**
  104827. * Sets a float4 on a uniform variable.
  104828. * @param uniformName Name of the variable.
  104829. * @param x First float in float4.
  104830. * @param y Second float in float4.
  104831. * @param z Third float in float4.
  104832. * @param w Fourth float in float4.
  104833. * @returns this effect.
  104834. */
  104835. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  104836. /**
  104837. * Sets a Color3 on a uniform variable.
  104838. * @param uniformName Name of the variable.
  104839. * @param color3 Value to be set.
  104840. * @returns this effect.
  104841. */
  104842. setColor3(uniformName: string, color3: IColor3Like): Effect;
  104843. /**
  104844. * Sets a Color4 on a uniform variable.
  104845. * @param uniformName Name of the variable.
  104846. * @param color3 Value to be set.
  104847. * @param alpha Alpha value to be set.
  104848. * @returns this effect.
  104849. */
  104850. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  104851. /**
  104852. * Sets a Color4 on a uniform variable
  104853. * @param uniformName defines the name of the variable
  104854. * @param color4 defines the value to be set
  104855. * @returns this effect.
  104856. */
  104857. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  104858. /** Release all associated resources */
  104859. dispose(): void;
  104860. /**
  104861. * This function will add a new shader to the shader store
  104862. * @param name the name of the shader
  104863. * @param pixelShader optional pixel shader content
  104864. * @param vertexShader optional vertex shader content
  104865. */
  104866. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  104867. /**
  104868. * Store of each shader (The can be looked up using effect.key)
  104869. */
  104870. static ShadersStore: {
  104871. [key: string]: string;
  104872. };
  104873. /**
  104874. * Store of each included file for a shader (The can be looked up using effect.key)
  104875. */
  104876. static IncludesShadersStore: {
  104877. [key: string]: string;
  104878. };
  104879. /**
  104880. * Resets the cache of effects.
  104881. */
  104882. static ResetCache(): void;
  104883. }
  104884. }
  104885. declare module BABYLON {
  104886. /**
  104887. * Interface used to describe the capabilities of the engine relatively to the current browser
  104888. */
  104889. export interface EngineCapabilities {
  104890. /** Maximum textures units per fragment shader */
  104891. maxTexturesImageUnits: number;
  104892. /** Maximum texture units per vertex shader */
  104893. maxVertexTextureImageUnits: number;
  104894. /** Maximum textures units in the entire pipeline */
  104895. maxCombinedTexturesImageUnits: number;
  104896. /** Maximum texture size */
  104897. maxTextureSize: number;
  104898. /** Maximum texture samples */
  104899. maxSamples?: number;
  104900. /** Maximum cube texture size */
  104901. maxCubemapTextureSize: number;
  104902. /** Maximum render texture size */
  104903. maxRenderTextureSize: number;
  104904. /** Maximum number of vertex attributes */
  104905. maxVertexAttribs: number;
  104906. /** Maximum number of varyings */
  104907. maxVaryingVectors: number;
  104908. /** Maximum number of uniforms per vertex shader */
  104909. maxVertexUniformVectors: number;
  104910. /** Maximum number of uniforms per fragment shader */
  104911. maxFragmentUniformVectors: number;
  104912. /** Defines if standard derivates (dx/dy) are supported */
  104913. standardDerivatives: boolean;
  104914. /** Defines if s3tc texture compression is supported */
  104915. s3tc?: WEBGL_compressed_texture_s3tc;
  104916. /** Defines if pvrtc texture compression is supported */
  104917. pvrtc: any;
  104918. /** Defines if etc1 texture compression is supported */
  104919. etc1: any;
  104920. /** Defines if etc2 texture compression is supported */
  104921. etc2: any;
  104922. /** Defines if astc texture compression is supported */
  104923. astc: any;
  104924. /** Defines if float textures are supported */
  104925. textureFloat: boolean;
  104926. /** Defines if vertex array objects are supported */
  104927. vertexArrayObject: boolean;
  104928. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  104929. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  104930. /** Gets the maximum level of anisotropy supported */
  104931. maxAnisotropy: number;
  104932. /** Defines if instancing is supported */
  104933. instancedArrays: boolean;
  104934. /** Defines if 32 bits indices are supported */
  104935. uintIndices: boolean;
  104936. /** Defines if high precision shaders are supported */
  104937. highPrecisionShaderSupported: boolean;
  104938. /** Defines if depth reading in the fragment shader is supported */
  104939. fragmentDepthSupported: boolean;
  104940. /** Defines if float texture linear filtering is supported*/
  104941. textureFloatLinearFiltering: boolean;
  104942. /** Defines if rendering to float textures is supported */
  104943. textureFloatRender: boolean;
  104944. /** Defines if half float textures are supported*/
  104945. textureHalfFloat: boolean;
  104946. /** Defines if half float texture linear filtering is supported*/
  104947. textureHalfFloatLinearFiltering: boolean;
  104948. /** Defines if rendering to half float textures is supported */
  104949. textureHalfFloatRender: boolean;
  104950. /** Defines if textureLOD shader command is supported */
  104951. textureLOD: boolean;
  104952. /** Defines if draw buffers extension is supported */
  104953. drawBuffersExtension: boolean;
  104954. /** Defines if depth textures are supported */
  104955. depthTextureExtension: boolean;
  104956. /** Defines if float color buffer are supported */
  104957. colorBufferFloat: boolean;
  104958. /** Gets disjoint timer query extension (null if not supported) */
  104959. timerQuery?: EXT_disjoint_timer_query;
  104960. /** Defines if timestamp can be used with timer query */
  104961. canUseTimestampForTimerQuery: boolean;
  104962. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  104963. multiview?: any;
  104964. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  104965. oculusMultiview?: any;
  104966. /** Function used to let the system compiles shaders in background */
  104967. parallelShaderCompile?: {
  104968. COMPLETION_STATUS_KHR: number;
  104969. };
  104970. /** Max number of texture samples for MSAA */
  104971. maxMSAASamples: number;
  104972. /** Defines if the blend min max extension is supported */
  104973. blendMinMax: boolean;
  104974. }
  104975. }
  104976. declare module BABYLON {
  104977. /**
  104978. * @hidden
  104979. **/
  104980. export class DepthCullingState {
  104981. private _isDepthTestDirty;
  104982. private _isDepthMaskDirty;
  104983. private _isDepthFuncDirty;
  104984. private _isCullFaceDirty;
  104985. private _isCullDirty;
  104986. private _isZOffsetDirty;
  104987. private _isFrontFaceDirty;
  104988. private _depthTest;
  104989. private _depthMask;
  104990. private _depthFunc;
  104991. private _cull;
  104992. private _cullFace;
  104993. private _zOffset;
  104994. private _frontFace;
  104995. /**
  104996. * Initializes the state.
  104997. */
  104998. constructor();
  104999. get isDirty(): boolean;
  105000. get zOffset(): number;
  105001. set zOffset(value: number);
  105002. get cullFace(): Nullable<number>;
  105003. set cullFace(value: Nullable<number>);
  105004. get cull(): Nullable<boolean>;
  105005. set cull(value: Nullable<boolean>);
  105006. get depthFunc(): Nullable<number>;
  105007. set depthFunc(value: Nullable<number>);
  105008. get depthMask(): boolean;
  105009. set depthMask(value: boolean);
  105010. get depthTest(): boolean;
  105011. set depthTest(value: boolean);
  105012. get frontFace(): Nullable<number>;
  105013. set frontFace(value: Nullable<number>);
  105014. reset(): void;
  105015. apply(gl: WebGLRenderingContext): void;
  105016. }
  105017. }
  105018. declare module BABYLON {
  105019. /**
  105020. * @hidden
  105021. **/
  105022. export class StencilState {
  105023. /** 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 */
  105024. static readonly ALWAYS: number;
  105025. /** Passed to stencilOperation to specify that stencil value must be kept */
  105026. static readonly KEEP: number;
  105027. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105028. static readonly REPLACE: number;
  105029. private _isStencilTestDirty;
  105030. private _isStencilMaskDirty;
  105031. private _isStencilFuncDirty;
  105032. private _isStencilOpDirty;
  105033. private _stencilTest;
  105034. private _stencilMask;
  105035. private _stencilFunc;
  105036. private _stencilFuncRef;
  105037. private _stencilFuncMask;
  105038. private _stencilOpStencilFail;
  105039. private _stencilOpDepthFail;
  105040. private _stencilOpStencilDepthPass;
  105041. get isDirty(): boolean;
  105042. get stencilFunc(): number;
  105043. set stencilFunc(value: number);
  105044. get stencilFuncRef(): number;
  105045. set stencilFuncRef(value: number);
  105046. get stencilFuncMask(): number;
  105047. set stencilFuncMask(value: number);
  105048. get stencilOpStencilFail(): number;
  105049. set stencilOpStencilFail(value: number);
  105050. get stencilOpDepthFail(): number;
  105051. set stencilOpDepthFail(value: number);
  105052. get stencilOpStencilDepthPass(): number;
  105053. set stencilOpStencilDepthPass(value: number);
  105054. get stencilMask(): number;
  105055. set stencilMask(value: number);
  105056. get stencilTest(): boolean;
  105057. set stencilTest(value: boolean);
  105058. constructor();
  105059. reset(): void;
  105060. apply(gl: WebGLRenderingContext): void;
  105061. }
  105062. }
  105063. declare module BABYLON {
  105064. /**
  105065. * @hidden
  105066. **/
  105067. export class AlphaState {
  105068. private _isAlphaBlendDirty;
  105069. private _isBlendFunctionParametersDirty;
  105070. private _isBlendEquationParametersDirty;
  105071. private _isBlendConstantsDirty;
  105072. private _alphaBlend;
  105073. private _blendFunctionParameters;
  105074. private _blendEquationParameters;
  105075. private _blendConstants;
  105076. /**
  105077. * Initializes the state.
  105078. */
  105079. constructor();
  105080. get isDirty(): boolean;
  105081. get alphaBlend(): boolean;
  105082. set alphaBlend(value: boolean);
  105083. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  105084. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  105085. setAlphaEquationParameters(rgb: number, alpha: number): void;
  105086. reset(): void;
  105087. apply(gl: WebGLRenderingContext): void;
  105088. }
  105089. }
  105090. declare module BABYLON {
  105091. /** @hidden */
  105092. export class WebGL2ShaderProcessor implements IShaderProcessor {
  105093. attributeProcessor(attribute: string): string;
  105094. varyingProcessor(varying: string, isFragment: boolean): string;
  105095. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  105096. }
  105097. }
  105098. declare module BABYLON {
  105099. /**
  105100. * Interface for attribute information associated with buffer instanciation
  105101. */
  105102. export interface InstancingAttributeInfo {
  105103. /**
  105104. * Name of the GLSL attribute
  105105. * if attribute index is not specified, this is used to retrieve the index from the effect
  105106. */
  105107. attributeName: string;
  105108. /**
  105109. * Index/offset of the attribute in the vertex shader
  105110. * if not specified, this will be computes from the name.
  105111. */
  105112. index?: number;
  105113. /**
  105114. * size of the attribute, 1, 2, 3 or 4
  105115. */
  105116. attributeSize: number;
  105117. /**
  105118. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  105119. */
  105120. offset: number;
  105121. /**
  105122. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  105123. * default to 1
  105124. */
  105125. divisor?: number;
  105126. /**
  105127. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  105128. * default is FLOAT
  105129. */
  105130. attributeType?: number;
  105131. /**
  105132. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  105133. */
  105134. normalized?: boolean;
  105135. }
  105136. }
  105137. declare module BABYLON {
  105138. interface ThinEngine {
  105139. /**
  105140. * Update a video texture
  105141. * @param texture defines the texture to update
  105142. * @param video defines the video element to use
  105143. * @param invertY defines if data must be stored with Y axis inverted
  105144. */
  105145. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  105146. }
  105147. }
  105148. declare module BABYLON {
  105149. /**
  105150. * Settings for finer control over video usage
  105151. */
  105152. export interface VideoTextureSettings {
  105153. /**
  105154. * Applies `autoplay` to video, if specified
  105155. */
  105156. autoPlay?: boolean;
  105157. /**
  105158. * Applies `loop` to video, if specified
  105159. */
  105160. loop?: boolean;
  105161. /**
  105162. * Automatically updates internal texture from video at every frame in the render loop
  105163. */
  105164. autoUpdateTexture: boolean;
  105165. /**
  105166. * Image src displayed during the video loading or until the user interacts with the video.
  105167. */
  105168. poster?: string;
  105169. }
  105170. /**
  105171. * If you want to display a video in your scene, this is the special texture for that.
  105172. * This special texture works similar to other textures, with the exception of a few parameters.
  105173. * @see https://doc.babylonjs.com/how_to/video_texture
  105174. */
  105175. export class VideoTexture extends Texture {
  105176. /**
  105177. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  105178. */
  105179. readonly autoUpdateTexture: boolean;
  105180. /**
  105181. * The video instance used by the texture internally
  105182. */
  105183. readonly video: HTMLVideoElement;
  105184. private _onUserActionRequestedObservable;
  105185. /**
  105186. * Event triggerd when a dom action is required by the user to play the video.
  105187. * This happens due to recent changes in browser policies preventing video to auto start.
  105188. */
  105189. get onUserActionRequestedObservable(): Observable<Texture>;
  105190. private _generateMipMaps;
  105191. private _engine;
  105192. private _stillImageCaptured;
  105193. private _displayingPosterTexture;
  105194. private _settings;
  105195. private _createInternalTextureOnEvent;
  105196. private _frameId;
  105197. private _currentSrc;
  105198. /**
  105199. * Creates a video texture.
  105200. * If you want to display a video in your scene, this is the special texture for that.
  105201. * This special texture works similar to other textures, with the exception of a few parameters.
  105202. * @see https://doc.babylonjs.com/how_to/video_texture
  105203. * @param name optional name, will detect from video source, if not defined
  105204. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  105205. * @param scene is obviously the current scene.
  105206. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  105207. * @param invertY is false by default but can be used to invert video on Y axis
  105208. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  105209. * @param settings allows finer control over video usage
  105210. */
  105211. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  105212. private _getName;
  105213. private _getVideo;
  105214. private _createInternalTexture;
  105215. private reset;
  105216. /**
  105217. * @hidden Internal method to initiate `update`.
  105218. */
  105219. _rebuild(): void;
  105220. /**
  105221. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  105222. */
  105223. update(): void;
  105224. /**
  105225. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  105226. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  105227. */
  105228. updateTexture(isVisible: boolean): void;
  105229. protected _updateInternalTexture: () => void;
  105230. /**
  105231. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  105232. * @param url New url.
  105233. */
  105234. updateURL(url: string): void;
  105235. /**
  105236. * Clones the texture.
  105237. * @returns the cloned texture
  105238. */
  105239. clone(): VideoTexture;
  105240. /**
  105241. * Dispose the texture and release its associated resources.
  105242. */
  105243. dispose(): void;
  105244. /**
  105245. * Creates a video texture straight from a stream.
  105246. * @param scene Define the scene the texture should be created in
  105247. * @param stream Define the stream the texture should be created from
  105248. * @returns The created video texture as a promise
  105249. */
  105250. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  105251. /**
  105252. * Creates a video texture straight from your WebCam video feed.
  105253. * @param scene Define the scene the texture should be created in
  105254. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105255. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105256. * @returns The created video texture as a promise
  105257. */
  105258. static CreateFromWebCamAsync(scene: Scene, constraints: {
  105259. minWidth: number;
  105260. maxWidth: number;
  105261. minHeight: number;
  105262. maxHeight: number;
  105263. deviceId: string;
  105264. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  105265. /**
  105266. * Creates a video texture straight from your WebCam video feed.
  105267. * @param scene Define the scene the texture should be created in
  105268. * @param onReady Define a callback to triggered once the texture will be ready
  105269. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105270. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105271. */
  105272. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  105273. minWidth: number;
  105274. maxWidth: number;
  105275. minHeight: number;
  105276. maxHeight: number;
  105277. deviceId: string;
  105278. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  105279. }
  105280. }
  105281. declare module BABYLON {
  105282. /**
  105283. * Defines the interface used by objects working like Scene
  105284. * @hidden
  105285. */
  105286. export interface ISceneLike {
  105287. _addPendingData(data: any): void;
  105288. _removePendingData(data: any): void;
  105289. offlineProvider: IOfflineProvider;
  105290. }
  105291. /** Interface defining initialization parameters for Engine class */
  105292. export interface EngineOptions extends WebGLContextAttributes {
  105293. /**
  105294. * Defines if the engine should no exceed a specified device ratio
  105295. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  105296. */
  105297. limitDeviceRatio?: number;
  105298. /**
  105299. * Defines if webvr should be enabled automatically
  105300. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105301. */
  105302. autoEnableWebVR?: boolean;
  105303. /**
  105304. * Defines if webgl2 should be turned off even if supported
  105305. * @see http://doc.babylonjs.com/features/webgl2
  105306. */
  105307. disableWebGL2Support?: boolean;
  105308. /**
  105309. * Defines if webaudio should be initialized as well
  105310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105311. */
  105312. audioEngine?: boolean;
  105313. /**
  105314. * Defines if animations should run using a deterministic lock step
  105315. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105316. */
  105317. deterministicLockstep?: boolean;
  105318. /** Defines the maximum steps to use with deterministic lock step mode */
  105319. lockstepMaxSteps?: number;
  105320. /** Defines the seconds between each deterministic lock step */
  105321. timeStep?: number;
  105322. /**
  105323. * Defines that engine should ignore context lost events
  105324. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  105325. */
  105326. doNotHandleContextLost?: boolean;
  105327. /**
  105328. * Defines that engine should ignore modifying touch action attribute and style
  105329. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  105330. */
  105331. doNotHandleTouchAction?: boolean;
  105332. /**
  105333. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  105334. */
  105335. useHighPrecisionFloats?: boolean;
  105336. }
  105337. /**
  105338. * The base engine class (root of all engines)
  105339. */
  105340. export class ThinEngine {
  105341. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  105342. static ExceptionList: ({
  105343. key: string;
  105344. capture: string;
  105345. captureConstraint: number;
  105346. targets: string[];
  105347. } | {
  105348. key: string;
  105349. capture: null;
  105350. captureConstraint: null;
  105351. targets: string[];
  105352. })[];
  105353. /** @hidden */
  105354. static _TextureLoaders: IInternalTextureLoader[];
  105355. /**
  105356. * Returns the current npm package of the sdk
  105357. */
  105358. static get NpmPackage(): string;
  105359. /**
  105360. * Returns the current version of the framework
  105361. */
  105362. static get Version(): string;
  105363. /**
  105364. * Returns a string describing the current engine
  105365. */
  105366. get description(): string;
  105367. /**
  105368. * Gets or sets the epsilon value used by collision engine
  105369. */
  105370. static CollisionsEpsilon: number;
  105371. /**
  105372. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  105373. */
  105374. static get ShadersRepository(): string;
  105375. static set ShadersRepository(value: string);
  105376. /** @hidden */
  105377. _shaderProcessor: IShaderProcessor;
  105378. /**
  105379. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  105380. */
  105381. forcePOTTextures: boolean;
  105382. /**
  105383. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  105384. */
  105385. isFullscreen: boolean;
  105386. /**
  105387. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  105388. */
  105389. cullBackFaces: boolean;
  105390. /**
  105391. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  105392. */
  105393. renderEvenInBackground: boolean;
  105394. /**
  105395. * Gets or sets a boolean indicating that cache can be kept between frames
  105396. */
  105397. preventCacheWipeBetweenFrames: boolean;
  105398. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  105399. validateShaderPrograms: boolean;
  105400. /**
  105401. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  105402. * This can provide greater z depth for distant objects.
  105403. */
  105404. useReverseDepthBuffer: boolean;
  105405. /**
  105406. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  105407. */
  105408. disableUniformBuffers: boolean;
  105409. /** @hidden */
  105410. _uniformBuffers: UniformBuffer[];
  105411. /**
  105412. * Gets a boolean indicating that the engine supports uniform buffers
  105413. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  105414. */
  105415. get supportsUniformBuffers(): boolean;
  105416. /** @hidden */
  105417. _gl: WebGLRenderingContext;
  105418. /** @hidden */
  105419. _webGLVersion: number;
  105420. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  105421. protected _windowIsBackground: boolean;
  105422. protected _creationOptions: EngineOptions;
  105423. protected _highPrecisionShadersAllowed: boolean;
  105424. /** @hidden */
  105425. get _shouldUseHighPrecisionShader(): boolean;
  105426. /**
  105427. * Gets a boolean indicating that only power of 2 textures are supported
  105428. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  105429. */
  105430. get needPOTTextures(): boolean;
  105431. /** @hidden */
  105432. _badOS: boolean;
  105433. /** @hidden */
  105434. _badDesktopOS: boolean;
  105435. private _hardwareScalingLevel;
  105436. /** @hidden */
  105437. _caps: EngineCapabilities;
  105438. private _isStencilEnable;
  105439. private _glVersion;
  105440. private _glRenderer;
  105441. private _glVendor;
  105442. /** @hidden */
  105443. _videoTextureSupported: boolean;
  105444. protected _renderingQueueLaunched: boolean;
  105445. protected _activeRenderLoops: (() => void)[];
  105446. /**
  105447. * Observable signaled when a context lost event is raised
  105448. */
  105449. onContextLostObservable: Observable<ThinEngine>;
  105450. /**
  105451. * Observable signaled when a context restored event is raised
  105452. */
  105453. onContextRestoredObservable: Observable<ThinEngine>;
  105454. private _onContextLost;
  105455. private _onContextRestored;
  105456. protected _contextWasLost: boolean;
  105457. /** @hidden */
  105458. _doNotHandleContextLost: boolean;
  105459. /**
  105460. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  105461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  105462. */
  105463. get doNotHandleContextLost(): boolean;
  105464. set doNotHandleContextLost(value: boolean);
  105465. /**
  105466. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  105467. */
  105468. disableVertexArrayObjects: boolean;
  105469. /** @hidden */
  105470. protected _colorWrite: boolean;
  105471. /** @hidden */
  105472. protected _colorWriteChanged: boolean;
  105473. /** @hidden */
  105474. protected _depthCullingState: DepthCullingState;
  105475. /** @hidden */
  105476. protected _stencilState: StencilState;
  105477. /** @hidden */
  105478. _alphaState: AlphaState;
  105479. /** @hidden */
  105480. _alphaMode: number;
  105481. /** @hidden */
  105482. _alphaEquation: number;
  105483. /** @hidden */
  105484. _internalTexturesCache: InternalTexture[];
  105485. /** @hidden */
  105486. protected _activeChannel: number;
  105487. private _currentTextureChannel;
  105488. /** @hidden */
  105489. protected _boundTexturesCache: {
  105490. [key: string]: Nullable<InternalTexture>;
  105491. };
  105492. /** @hidden */
  105493. protected _currentEffect: Nullable<Effect>;
  105494. /** @hidden */
  105495. protected _currentProgram: Nullable<WebGLProgram>;
  105496. private _compiledEffects;
  105497. private _vertexAttribArraysEnabled;
  105498. /** @hidden */
  105499. protected _cachedViewport: Nullable<IViewportLike>;
  105500. private _cachedVertexArrayObject;
  105501. /** @hidden */
  105502. protected _cachedVertexBuffers: any;
  105503. /** @hidden */
  105504. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  105505. /** @hidden */
  105506. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  105507. /** @hidden */
  105508. _currentRenderTarget: Nullable<InternalTexture>;
  105509. private _uintIndicesCurrentlySet;
  105510. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  105511. /** @hidden */
  105512. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  105513. private _currentBufferPointers;
  105514. private _currentInstanceLocations;
  105515. private _currentInstanceBuffers;
  105516. private _textureUnits;
  105517. /** @hidden */
  105518. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105519. /** @hidden */
  105520. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105521. /** @hidden */
  105522. _boundRenderFunction: any;
  105523. private _vaoRecordInProgress;
  105524. private _mustWipeVertexAttributes;
  105525. private _emptyTexture;
  105526. private _emptyCubeTexture;
  105527. private _emptyTexture3D;
  105528. private _emptyTexture2DArray;
  105529. /** @hidden */
  105530. _frameHandler: number;
  105531. private _nextFreeTextureSlots;
  105532. private _maxSimultaneousTextures;
  105533. private _activeRequests;
  105534. /** @hidden */
  105535. _transformTextureUrl: Nullable<(url: string) => string>;
  105536. protected get _supportsHardwareTextureRescaling(): boolean;
  105537. private _framebufferDimensionsObject;
  105538. /**
  105539. * sets the object from which width and height will be taken from when getting render width and height
  105540. * Will fallback to the gl object
  105541. * @param dimensions the framebuffer width and height that will be used.
  105542. */
  105543. set framebufferDimensionsObject(dimensions: Nullable<{
  105544. framebufferWidth: number;
  105545. framebufferHeight: number;
  105546. }>);
  105547. /**
  105548. * Gets the current viewport
  105549. */
  105550. get currentViewport(): Nullable<IViewportLike>;
  105551. /**
  105552. * Gets the default empty texture
  105553. */
  105554. get emptyTexture(): InternalTexture;
  105555. /**
  105556. * Gets the default empty 3D texture
  105557. */
  105558. get emptyTexture3D(): InternalTexture;
  105559. /**
  105560. * Gets the default empty 2D array texture
  105561. */
  105562. get emptyTexture2DArray(): InternalTexture;
  105563. /**
  105564. * Gets the default empty cube texture
  105565. */
  105566. get emptyCubeTexture(): InternalTexture;
  105567. /**
  105568. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  105569. */
  105570. readonly premultipliedAlpha: boolean;
  105571. /**
  105572. * Observable event triggered before each texture is initialized
  105573. */
  105574. onBeforeTextureInitObservable: Observable<Texture>;
  105575. /**
  105576. * Creates a new engine
  105577. * @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
  105578. * @param antialias defines enable antialiasing (default: false)
  105579. * @param options defines further options to be sent to the getContext() function
  105580. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105581. */
  105582. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105583. private _rebuildInternalTextures;
  105584. private _rebuildEffects;
  105585. /**
  105586. * Gets a boolean indicating if all created effects are ready
  105587. * @returns true if all effects are ready
  105588. */
  105589. areAllEffectsReady(): boolean;
  105590. protected _rebuildBuffers(): void;
  105591. protected _initGLContext(): void;
  105592. /**
  105593. * Gets version of the current webGL context
  105594. */
  105595. get webGLVersion(): number;
  105596. /**
  105597. * Gets a string idenfifying the name of the class
  105598. * @returns "Engine" string
  105599. */
  105600. getClassName(): string;
  105601. /**
  105602. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  105603. */
  105604. get isStencilEnable(): boolean;
  105605. /** @hidden */
  105606. _prepareWorkingCanvas(): void;
  105607. /**
  105608. * Reset the texture cache to empty state
  105609. */
  105610. resetTextureCache(): void;
  105611. /**
  105612. * Gets an object containing information about the current webGL context
  105613. * @returns an object containing the vender, the renderer and the version of the current webGL context
  105614. */
  105615. getGlInfo(): {
  105616. vendor: string;
  105617. renderer: string;
  105618. version: string;
  105619. };
  105620. /**
  105621. * Defines the hardware scaling level.
  105622. * By default the hardware scaling level is computed from the window device ratio.
  105623. * 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.
  105624. * @param level defines the level to use
  105625. */
  105626. setHardwareScalingLevel(level: number): void;
  105627. /**
  105628. * Gets the current hardware scaling level.
  105629. * By default the hardware scaling level is computed from the window device ratio.
  105630. * 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.
  105631. * @returns a number indicating the current hardware scaling level
  105632. */
  105633. getHardwareScalingLevel(): number;
  105634. /**
  105635. * Gets the list of loaded textures
  105636. * @returns an array containing all loaded textures
  105637. */
  105638. getLoadedTexturesCache(): InternalTexture[];
  105639. /**
  105640. * Gets the object containing all engine capabilities
  105641. * @returns the EngineCapabilities object
  105642. */
  105643. getCaps(): EngineCapabilities;
  105644. /**
  105645. * stop executing a render loop function and remove it from the execution array
  105646. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  105647. */
  105648. stopRenderLoop(renderFunction?: () => void): void;
  105649. /** @hidden */
  105650. _renderLoop(): void;
  105651. /**
  105652. * Gets the HTML canvas attached with the current webGL context
  105653. * @returns a HTML canvas
  105654. */
  105655. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  105656. /**
  105657. * Gets host window
  105658. * @returns the host window object
  105659. */
  105660. getHostWindow(): Nullable<Window>;
  105661. /**
  105662. * Gets the current render width
  105663. * @param useScreen defines if screen size must be used (or the current render target if any)
  105664. * @returns a number defining the current render width
  105665. */
  105666. getRenderWidth(useScreen?: boolean): number;
  105667. /**
  105668. * Gets the current render height
  105669. * @param useScreen defines if screen size must be used (or the current render target if any)
  105670. * @returns a number defining the current render height
  105671. */
  105672. getRenderHeight(useScreen?: boolean): number;
  105673. /**
  105674. * Can be used to override the current requestAnimationFrame requester.
  105675. * @hidden
  105676. */
  105677. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  105678. /**
  105679. * Register and execute a render loop. The engine can have more than one render function
  105680. * @param renderFunction defines the function to continuously execute
  105681. */
  105682. runRenderLoop(renderFunction: () => void): void;
  105683. /**
  105684. * Clear the current render buffer or the current render target (if any is set up)
  105685. * @param color defines the color to use
  105686. * @param backBuffer defines if the back buffer must be cleared
  105687. * @param depth defines if the depth buffer must be cleared
  105688. * @param stencil defines if the stencil buffer must be cleared
  105689. */
  105690. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105691. private _viewportCached;
  105692. /** @hidden */
  105693. _viewport(x: number, y: number, width: number, height: number): void;
  105694. /**
  105695. * Set the WebGL's viewport
  105696. * @param viewport defines the viewport element to be used
  105697. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  105698. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  105699. */
  105700. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  105701. /**
  105702. * Begin a new frame
  105703. */
  105704. beginFrame(): void;
  105705. /**
  105706. * Enf the current frame
  105707. */
  105708. endFrame(): void;
  105709. /**
  105710. * Resize the view according to the canvas' size
  105711. */
  105712. resize(): void;
  105713. /**
  105714. * Force a specific size of the canvas
  105715. * @param width defines the new canvas' width
  105716. * @param height defines the new canvas' height
  105717. */
  105718. setSize(width: number, height: number): void;
  105719. /**
  105720. * Binds the frame buffer to the specified texture.
  105721. * @param texture The texture to render to or null for the default canvas
  105722. * @param faceIndex The face of the texture to render to in case of cube texture
  105723. * @param requiredWidth The width of the target to render to
  105724. * @param requiredHeight The height of the target to render to
  105725. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105726. * @param lodLevel defines the lod level to bind to the frame buffer
  105727. * @param layer defines the 2d array index to bind to frame buffer to
  105728. */
  105729. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105730. /** @hidden */
  105731. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105732. /**
  105733. * Unbind the current render target texture from the webGL context
  105734. * @param texture defines the render target texture to unbind
  105735. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105736. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105737. */
  105738. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105739. /**
  105740. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105741. */
  105742. flushFramebuffer(): void;
  105743. /**
  105744. * Unbind the current render target and bind the default framebuffer
  105745. */
  105746. restoreDefaultFramebuffer(): void;
  105747. /** @hidden */
  105748. protected _resetVertexBufferBinding(): void;
  105749. /**
  105750. * Creates a vertex buffer
  105751. * @param data the data for the vertex buffer
  105752. * @returns the new WebGL static buffer
  105753. */
  105754. createVertexBuffer(data: DataArray): DataBuffer;
  105755. private _createVertexBuffer;
  105756. /**
  105757. * Creates a dynamic vertex buffer
  105758. * @param data the data for the dynamic vertex buffer
  105759. * @returns the new WebGL dynamic buffer
  105760. */
  105761. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  105762. protected _resetIndexBufferBinding(): void;
  105763. /**
  105764. * Creates a new index buffer
  105765. * @param indices defines the content of the index buffer
  105766. * @param updatable defines if the index buffer must be updatable
  105767. * @returns a new webGL buffer
  105768. */
  105769. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  105770. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  105771. /**
  105772. * Bind a webGL buffer to the webGL context
  105773. * @param buffer defines the buffer to bind
  105774. */
  105775. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  105776. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  105777. private bindBuffer;
  105778. /**
  105779. * update the bound buffer with the given data
  105780. * @param data defines the data to update
  105781. */
  105782. updateArrayBuffer(data: Float32Array): void;
  105783. private _vertexAttribPointer;
  105784. /** @hidden */
  105785. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  105786. private _bindVertexBuffersAttributes;
  105787. /**
  105788. * Records a vertex array object
  105789. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  105790. * @param vertexBuffers defines the list of vertex buffers to store
  105791. * @param indexBuffer defines the index buffer to store
  105792. * @param effect defines the effect to store
  105793. * @returns the new vertex array object
  105794. */
  105795. recordVertexArrayObject(vertexBuffers: {
  105796. [key: string]: VertexBuffer;
  105797. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  105798. /**
  105799. * Bind a specific vertex array object
  105800. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  105801. * @param vertexArrayObject defines the vertex array object to bind
  105802. * @param indexBuffer defines the index buffer to bind
  105803. */
  105804. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  105805. /**
  105806. * Bind webGl buffers directly to the webGL context
  105807. * @param vertexBuffer defines the vertex buffer to bind
  105808. * @param indexBuffer defines the index buffer to bind
  105809. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  105810. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  105811. * @param effect defines the effect associated with the vertex buffer
  105812. */
  105813. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  105814. private _unbindVertexArrayObject;
  105815. /**
  105816. * Bind a list of vertex buffers to the webGL context
  105817. * @param vertexBuffers defines the list of vertex buffers to bind
  105818. * @param indexBuffer defines the index buffer to bind
  105819. * @param effect defines the effect associated with the vertex buffers
  105820. */
  105821. bindBuffers(vertexBuffers: {
  105822. [key: string]: Nullable<VertexBuffer>;
  105823. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  105824. /**
  105825. * Unbind all instance attributes
  105826. */
  105827. unbindInstanceAttributes(): void;
  105828. /**
  105829. * Release and free the memory of a vertex array object
  105830. * @param vao defines the vertex array object to delete
  105831. */
  105832. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  105833. /** @hidden */
  105834. _releaseBuffer(buffer: DataBuffer): boolean;
  105835. protected _deleteBuffer(buffer: DataBuffer): void;
  105836. /**
  105837. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  105838. * @param instancesBuffer defines the webGL buffer to update and bind
  105839. * @param data defines the data to store in the buffer
  105840. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  105841. */
  105842. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  105843. /**
  105844. * Bind the content of a webGL buffer used with instantiation
  105845. * @param instancesBuffer defines the webGL buffer to bind
  105846. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  105847. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  105848. */
  105849. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  105850. /**
  105851. * Disable the instance attribute corresponding to the name in parameter
  105852. * @param name defines the name of the attribute to disable
  105853. */
  105854. disableInstanceAttributeByName(name: string): void;
  105855. /**
  105856. * Disable the instance attribute corresponding to the location in parameter
  105857. * @param attributeLocation defines the attribute location of the attribute to disable
  105858. */
  105859. disableInstanceAttribute(attributeLocation: number): void;
  105860. /**
  105861. * Disable the attribute corresponding to the location in parameter
  105862. * @param attributeLocation defines the attribute location of the attribute to disable
  105863. */
  105864. disableAttributeByIndex(attributeLocation: number): void;
  105865. /**
  105866. * Send a draw order
  105867. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  105868. * @param indexStart defines the starting index
  105869. * @param indexCount defines the number of index to draw
  105870. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105871. */
  105872. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  105873. /**
  105874. * Draw a list of points
  105875. * @param verticesStart defines the index of first vertex to draw
  105876. * @param verticesCount defines the count of vertices to draw
  105877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105878. */
  105879. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105880. /**
  105881. * Draw a list of unindexed primitives
  105882. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  105883. * @param verticesStart defines the index of first vertex to draw
  105884. * @param verticesCount defines the count of vertices to draw
  105885. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105886. */
  105887. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105888. /**
  105889. * Draw a list of indexed primitives
  105890. * @param fillMode defines the primitive to use
  105891. * @param indexStart defines the starting index
  105892. * @param indexCount defines the number of index to draw
  105893. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105894. */
  105895. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  105896. /**
  105897. * Draw a list of unindexed primitives
  105898. * @param fillMode defines the primitive to use
  105899. * @param verticesStart defines the index of first vertex to draw
  105900. * @param verticesCount defines the count of vertices to draw
  105901. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  105902. */
  105903. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  105904. private _drawMode;
  105905. /** @hidden */
  105906. protected _reportDrawCall(): void;
  105907. /** @hidden */
  105908. _releaseEffect(effect: Effect): void;
  105909. /** @hidden */
  105910. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  105911. /**
  105912. * Create a new effect (used to store vertex/fragment shaders)
  105913. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  105914. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  105915. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  105916. * @param samplers defines an array of string used to represent textures
  105917. * @param defines defines the string containing the defines to use to compile the shaders
  105918. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  105919. * @param onCompiled defines a function to call when the effect creation is successful
  105920. * @param onError defines a function to call when the effect creation has failed
  105921. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  105922. * @returns the new Effect
  105923. */
  105924. 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;
  105925. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  105926. private _compileShader;
  105927. private _compileRawShader;
  105928. /** @hidden */
  105929. _getShaderSource(shader: WebGLShader): Nullable<string>;
  105930. /**
  105931. * Directly creates a webGL program
  105932. * @param pipelineContext defines the pipeline context to attach to
  105933. * @param vertexCode defines the vertex shader code to use
  105934. * @param fragmentCode defines the fragment shader code to use
  105935. * @param context defines the webGL context to use (if not set, the current one will be used)
  105936. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105937. * @returns the new webGL program
  105938. */
  105939. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105940. /**
  105941. * Creates a webGL program
  105942. * @param pipelineContext defines the pipeline context to attach to
  105943. * @param vertexCode defines the vertex shader code to use
  105944. * @param fragmentCode defines the fragment shader code to use
  105945. * @param defines defines the string containing the defines to use to compile the shaders
  105946. * @param context defines the webGL context to use (if not set, the current one will be used)
  105947. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  105948. * @returns the new webGL program
  105949. */
  105950. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105951. /**
  105952. * Creates a new pipeline context
  105953. * @returns the new pipeline
  105954. */
  105955. createPipelineContext(): IPipelineContext;
  105956. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  105957. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  105958. /** @hidden */
  105959. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  105960. /** @hidden */
  105961. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  105962. /** @hidden */
  105963. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  105964. /**
  105965. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  105966. * @param pipelineContext defines the pipeline context to use
  105967. * @param uniformsNames defines the list of uniform names
  105968. * @returns an array of webGL uniform locations
  105969. */
  105970. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  105971. /**
  105972. * Gets the lsit of active attributes for a given webGL program
  105973. * @param pipelineContext defines the pipeline context to use
  105974. * @param attributesNames defines the list of attribute names to get
  105975. * @returns an array of indices indicating the offset of each attribute
  105976. */
  105977. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  105978. /**
  105979. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  105980. * @param effect defines the effect to activate
  105981. */
  105982. enableEffect(effect: Nullable<Effect>): void;
  105983. /**
  105984. * Set the value of an uniform to a number (int)
  105985. * @param uniform defines the webGL uniform location where to store the value
  105986. * @param value defines the int number to store
  105987. */
  105988. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  105989. /**
  105990. * Set the value of an uniform to an array of int32
  105991. * @param uniform defines the webGL uniform location where to store the value
  105992. * @param array defines the array of int32 to store
  105993. */
  105994. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  105995. /**
  105996. * Set the value of an uniform to an array of int32 (stored as vec2)
  105997. * @param uniform defines the webGL uniform location where to store the value
  105998. * @param array defines the array of int32 to store
  105999. */
  106000. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106001. /**
  106002. * Set the value of an uniform to an array of int32 (stored as vec3)
  106003. * @param uniform defines the webGL uniform location where to store the value
  106004. * @param array defines the array of int32 to store
  106005. */
  106006. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106007. /**
  106008. * Set the value of an uniform to an array of int32 (stored as vec4)
  106009. * @param uniform defines the webGL uniform location where to store the value
  106010. * @param array defines the array of int32 to store
  106011. */
  106012. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106013. /**
  106014. * Set the value of an uniform to an array of number
  106015. * @param uniform defines the webGL uniform location where to store the value
  106016. * @param array defines the array of number to store
  106017. */
  106018. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106019. /**
  106020. * Set the value of an uniform to an array of number (stored as vec2)
  106021. * @param uniform defines the webGL uniform location where to store the value
  106022. * @param array defines the array of number to store
  106023. */
  106024. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106025. /**
  106026. * Set the value of an uniform to an array of number (stored as vec3)
  106027. * @param uniform defines the webGL uniform location where to store the value
  106028. * @param array defines the array of number to store
  106029. */
  106030. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106031. /**
  106032. * Set the value of an uniform to an array of number (stored as vec4)
  106033. * @param uniform defines the webGL uniform location where to store the value
  106034. * @param array defines the array of number to store
  106035. */
  106036. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106037. /**
  106038. * Set the value of an uniform to an array of float32 (stored as matrices)
  106039. * @param uniform defines the webGL uniform location where to store the value
  106040. * @param matrices defines the array of float32 to store
  106041. */
  106042. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  106043. /**
  106044. * Set the value of an uniform to a matrix (3x3)
  106045. * @param uniform defines the webGL uniform location where to store the value
  106046. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  106047. */
  106048. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106049. /**
  106050. * Set the value of an uniform to a matrix (2x2)
  106051. * @param uniform defines the webGL uniform location where to store the value
  106052. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  106053. */
  106054. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106055. /**
  106056. * Set the value of an uniform to a number (float)
  106057. * @param uniform defines the webGL uniform location where to store the value
  106058. * @param value defines the float number to store
  106059. */
  106060. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106061. /**
  106062. * Set the value of an uniform to a vec2
  106063. * @param uniform defines the webGL uniform location where to store the value
  106064. * @param x defines the 1st component of the value
  106065. * @param y defines the 2nd component of the value
  106066. */
  106067. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  106068. /**
  106069. * Set the value of an uniform to a vec3
  106070. * @param uniform defines the webGL uniform location where to store the value
  106071. * @param x defines the 1st component of the value
  106072. * @param y defines the 2nd component of the value
  106073. * @param z defines the 3rd component of the value
  106074. */
  106075. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  106076. /**
  106077. * Set the value of an uniform to a vec4
  106078. * @param uniform defines the webGL uniform location where to store the value
  106079. * @param x defines the 1st component of the value
  106080. * @param y defines the 2nd component of the value
  106081. * @param z defines the 3rd component of the value
  106082. * @param w defines the 4th component of the value
  106083. */
  106084. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  106085. /**
  106086. * Apply all cached states (depth, culling, stencil and alpha)
  106087. */
  106088. applyStates(): void;
  106089. /**
  106090. * Enable or disable color writing
  106091. * @param enable defines the state to set
  106092. */
  106093. setColorWrite(enable: boolean): void;
  106094. /**
  106095. * Gets a boolean indicating if color writing is enabled
  106096. * @returns the current color writing state
  106097. */
  106098. getColorWrite(): boolean;
  106099. /**
  106100. * Gets the depth culling state manager
  106101. */
  106102. get depthCullingState(): DepthCullingState;
  106103. /**
  106104. * Gets the alpha state manager
  106105. */
  106106. get alphaState(): AlphaState;
  106107. /**
  106108. * Gets the stencil state manager
  106109. */
  106110. get stencilState(): StencilState;
  106111. /**
  106112. * Clears the list of texture accessible through engine.
  106113. * This can help preventing texture load conflict due to name collision.
  106114. */
  106115. clearInternalTexturesCache(): void;
  106116. /**
  106117. * Force the entire cache to be cleared
  106118. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  106119. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  106120. */
  106121. wipeCaches(bruteForce?: boolean): void;
  106122. /** @hidden */
  106123. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  106124. min: number;
  106125. mag: number;
  106126. };
  106127. /** @hidden */
  106128. _createTexture(): WebGLTexture;
  106129. /**
  106130. * Usually called from Texture.ts.
  106131. * Passed information to create a WebGLTexture
  106132. * @param url defines a value which contains one of the following:
  106133. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  106134. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  106135. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  106136. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  106137. * @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)
  106138. * @param scene needed for loading to the correct scene
  106139. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  106140. * @param onLoad optional callback to be called upon successful completion
  106141. * @param onError optional callback to be called upon failure
  106142. * @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
  106143. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  106144. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  106145. * @param forcedExtension defines the extension to use to pick the right loader
  106146. * @param mimeType defines an optional mime type
  106147. * @returns a InternalTexture for assignment back into BABYLON.Texture
  106148. */
  106149. createTexture(url: 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;
  106150. /**
  106151. * Loads an image as an HTMLImageElement.
  106152. * @param input url string, ArrayBuffer, or Blob to load
  106153. * @param onLoad callback called when the image successfully loads
  106154. * @param onError callback called when the image fails to load
  106155. * @param offlineProvider offline provider for caching
  106156. * @param mimeType optional mime type
  106157. * @returns the HTMLImageElement of the loaded image
  106158. * @hidden
  106159. */
  106160. 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>;
  106161. /**
  106162. * @hidden
  106163. */
  106164. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106165. /**
  106166. * Creates a raw texture
  106167. * @param data defines the data to store in the texture
  106168. * @param width defines the width of the texture
  106169. * @param height defines the height of the texture
  106170. * @param format defines the format of the data
  106171. * @param generateMipMaps defines if the engine should generate the mip levels
  106172. * @param invertY defines if data must be stored with Y axis inverted
  106173. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  106174. * @param compression defines the compression used (null by default)
  106175. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106176. * @returns the raw texture inside an InternalTexture
  106177. */
  106178. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  106179. /**
  106180. * Creates a new raw cube texture
  106181. * @param data defines the array of data to use to create each face
  106182. * @param size defines the size of the textures
  106183. * @param format defines the format of the data
  106184. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106185. * @param generateMipMaps defines if the engine should generate the mip levels
  106186. * @param invertY defines if data must be stored with Y axis inverted
  106187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106188. * @param compression defines the compression used (null by default)
  106189. * @returns the cube texture as an InternalTexture
  106190. */
  106191. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  106192. /**
  106193. * Creates a new raw 3D texture
  106194. * @param data defines the data used to create the texture
  106195. * @param width defines the width of the texture
  106196. * @param height defines the height of the texture
  106197. * @param depth defines the depth of the texture
  106198. * @param format defines the format of the texture
  106199. * @param generateMipMaps defines if the engine must generate mip levels
  106200. * @param invertY defines if data must be stored with Y axis inverted
  106201. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106202. * @param compression defines the compressed used (can be null)
  106203. * @param textureType defines the compressed used (can be null)
  106204. * @returns a new raw 3D texture (stored in an InternalTexture)
  106205. */
  106206. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106207. /**
  106208. * Creates a new raw 2D array texture
  106209. * @param data defines the data used to create the texture
  106210. * @param width defines the width of the texture
  106211. * @param height defines the height of the texture
  106212. * @param depth defines the number of layers of the texture
  106213. * @param format defines the format of the texture
  106214. * @param generateMipMaps defines if the engine must generate mip levels
  106215. * @param invertY defines if data must be stored with Y axis inverted
  106216. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106217. * @param compression defines the compressed used (can be null)
  106218. * @param textureType defines the compressed used (can be null)
  106219. * @returns a new raw 2D array texture (stored in an InternalTexture)
  106220. */
  106221. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106222. private _unpackFlipYCached;
  106223. /**
  106224. * In case you are sharing the context with other applications, it might
  106225. * be interested to not cache the unpack flip y state to ensure a consistent
  106226. * value would be set.
  106227. */
  106228. enableUnpackFlipYCached: boolean;
  106229. /** @hidden */
  106230. _unpackFlipY(value: boolean): void;
  106231. /** @hidden */
  106232. _getUnpackAlignement(): number;
  106233. private _getTextureTarget;
  106234. /**
  106235. * Update the sampling mode of a given texture
  106236. * @param samplingMode defines the required sampling mode
  106237. * @param texture defines the texture to update
  106238. * @param generateMipMaps defines whether to generate mipmaps for the texture
  106239. */
  106240. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  106241. /**
  106242. * Update the sampling mode of a given texture
  106243. * @param texture defines the texture to update
  106244. * @param wrapU defines the texture wrap mode of the u coordinates
  106245. * @param wrapV defines the texture wrap mode of the v coordinates
  106246. * @param wrapR defines the texture wrap mode of the r coordinates
  106247. */
  106248. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  106249. /** @hidden */
  106250. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  106251. width: number;
  106252. height: number;
  106253. layers?: number;
  106254. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  106255. /** @hidden */
  106256. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106257. /** @hidden */
  106258. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  106259. /**
  106260. * Update a portion of an internal texture
  106261. * @param texture defines the texture to update
  106262. * @param imageData defines the data to store into the texture
  106263. * @param xOffset defines the x coordinates of the update rectangle
  106264. * @param yOffset defines the y coordinates of the update rectangle
  106265. * @param width defines the width of the update rectangle
  106266. * @param height defines the height of the update rectangle
  106267. * @param faceIndex defines the face index if texture is a cube (0 by default)
  106268. * @param lod defines the lod level to update (0 by default)
  106269. */
  106270. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  106271. /** @hidden */
  106272. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106273. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  106274. private _prepareWebGLTexture;
  106275. /** @hidden */
  106276. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  106277. private _getDepthStencilBuffer;
  106278. /** @hidden */
  106279. _releaseFramebufferObjects(texture: InternalTexture): void;
  106280. /** @hidden */
  106281. _releaseTexture(texture: InternalTexture): void;
  106282. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  106283. protected _setProgram(program: WebGLProgram): void;
  106284. protected _boundUniforms: {
  106285. [key: number]: WebGLUniformLocation;
  106286. };
  106287. /**
  106288. * Binds an effect to the webGL context
  106289. * @param effect defines the effect to bind
  106290. */
  106291. bindSamplers(effect: Effect): void;
  106292. private _activateCurrentTexture;
  106293. /** @hidden */
  106294. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  106295. /** @hidden */
  106296. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  106297. /**
  106298. * Unbind all textures from the webGL context
  106299. */
  106300. unbindAllTextures(): void;
  106301. /**
  106302. * Sets a texture to the according uniform.
  106303. * @param channel The texture channel
  106304. * @param uniform The uniform to set
  106305. * @param texture The texture to apply
  106306. */
  106307. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  106308. private _bindSamplerUniformToChannel;
  106309. private _getTextureWrapMode;
  106310. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  106311. /**
  106312. * Sets an array of texture to the webGL context
  106313. * @param channel defines the channel where the texture array must be set
  106314. * @param uniform defines the associated uniform location
  106315. * @param textures defines the array of textures to bind
  106316. */
  106317. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  106318. /** @hidden */
  106319. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  106320. private _setTextureParameterFloat;
  106321. private _setTextureParameterInteger;
  106322. /**
  106323. * Unbind all vertex attributes from the webGL context
  106324. */
  106325. unbindAllAttributes(): void;
  106326. /**
  106327. * 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
  106328. */
  106329. releaseEffects(): void;
  106330. /**
  106331. * Dispose and release all associated resources
  106332. */
  106333. dispose(): void;
  106334. /**
  106335. * Attach a new callback raised when context lost event is fired
  106336. * @param callback defines the callback to call
  106337. */
  106338. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106339. /**
  106340. * Attach a new callback raised when context restored event is fired
  106341. * @param callback defines the callback to call
  106342. */
  106343. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106344. /**
  106345. * Get the current error code of the webGL context
  106346. * @returns the error code
  106347. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106348. */
  106349. getError(): number;
  106350. private _canRenderToFloatFramebuffer;
  106351. private _canRenderToHalfFloatFramebuffer;
  106352. private _canRenderToFramebuffer;
  106353. /** @hidden */
  106354. _getWebGLTextureType(type: number): number;
  106355. /** @hidden */
  106356. _getInternalFormat(format: number): number;
  106357. /** @hidden */
  106358. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  106359. /** @hidden */
  106360. _getRGBAMultiSampleBufferFormat(type: number): number;
  106361. /** @hidden */
  106362. _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;
  106363. /**
  106364. * Loads a file from a url
  106365. * @param url url to load
  106366. * @param onSuccess callback called when the file successfully loads
  106367. * @param onProgress callback called while file is loading (if the server supports this mode)
  106368. * @param offlineProvider defines the offline provider for caching
  106369. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106370. * @param onError callback called when the file fails to load
  106371. * @returns a file request object
  106372. * @hidden
  106373. */
  106374. 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;
  106375. /**
  106376. * Reads pixels from the current frame buffer. Please note that this function can be slow
  106377. * @param x defines the x coordinate of the rectangle where pixels must be read
  106378. * @param y defines the y coordinate of the rectangle where pixels must be read
  106379. * @param width defines the width of the rectangle where pixels must be read
  106380. * @param height defines the height of the rectangle where pixels must be read
  106381. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  106382. * @returns a Uint8Array containing RGBA colors
  106383. */
  106384. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  106385. private static _isSupported;
  106386. /**
  106387. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  106388. * @returns true if the engine can be created
  106389. * @ignorenaming
  106390. */
  106391. static isSupported(): boolean;
  106392. /**
  106393. * Find the next highest power of two.
  106394. * @param x Number to start search from.
  106395. * @return Next highest power of two.
  106396. */
  106397. static CeilingPOT(x: number): number;
  106398. /**
  106399. * Find the next lowest power of two.
  106400. * @param x Number to start search from.
  106401. * @return Next lowest power of two.
  106402. */
  106403. static FloorPOT(x: number): number;
  106404. /**
  106405. * Find the nearest power of two.
  106406. * @param x Number to start search from.
  106407. * @return Next nearest power of two.
  106408. */
  106409. static NearestPOT(x: number): number;
  106410. /**
  106411. * Get the closest exponent of two
  106412. * @param value defines the value to approximate
  106413. * @param max defines the maximum value to return
  106414. * @param mode defines how to define the closest value
  106415. * @returns closest exponent of two of the given value
  106416. */
  106417. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  106418. /**
  106419. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  106420. * @param func - the function to be called
  106421. * @param requester - the object that will request the next frame. Falls back to window.
  106422. * @returns frame number
  106423. */
  106424. static QueueNewFrame(func: () => void, requester?: any): number;
  106425. /**
  106426. * Gets host document
  106427. * @returns the host document object
  106428. */
  106429. getHostDocument(): Nullable<Document>;
  106430. }
  106431. }
  106432. declare module BABYLON {
  106433. /**
  106434. * Class representing spherical harmonics coefficients to the 3rd degree
  106435. */
  106436. export class SphericalHarmonics {
  106437. /**
  106438. * Defines whether or not the harmonics have been prescaled for rendering.
  106439. */
  106440. preScaled: boolean;
  106441. /**
  106442. * The l0,0 coefficients of the spherical harmonics
  106443. */
  106444. l00: Vector3;
  106445. /**
  106446. * The l1,-1 coefficients of the spherical harmonics
  106447. */
  106448. l1_1: Vector3;
  106449. /**
  106450. * The l1,0 coefficients of the spherical harmonics
  106451. */
  106452. l10: Vector3;
  106453. /**
  106454. * The l1,1 coefficients of the spherical harmonics
  106455. */
  106456. l11: Vector3;
  106457. /**
  106458. * The l2,-2 coefficients of the spherical harmonics
  106459. */
  106460. l2_2: Vector3;
  106461. /**
  106462. * The l2,-1 coefficients of the spherical harmonics
  106463. */
  106464. l2_1: Vector3;
  106465. /**
  106466. * The l2,0 coefficients of the spherical harmonics
  106467. */
  106468. l20: Vector3;
  106469. /**
  106470. * The l2,1 coefficients of the spherical harmonics
  106471. */
  106472. l21: Vector3;
  106473. /**
  106474. * The l2,2 coefficients of the spherical harmonics
  106475. */
  106476. l22: Vector3;
  106477. /**
  106478. * Adds a light to the spherical harmonics
  106479. * @param direction the direction of the light
  106480. * @param color the color of the light
  106481. * @param deltaSolidAngle the delta solid angle of the light
  106482. */
  106483. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106484. /**
  106485. * Scales the spherical harmonics by the given amount
  106486. * @param scale the amount to scale
  106487. */
  106488. scaleInPlace(scale: number): void;
  106489. /**
  106490. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106491. *
  106492. * ```
  106493. * E_lm = A_l * L_lm
  106494. * ```
  106495. *
  106496. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106497. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106498. * the scaling factors are given in equation 9.
  106499. */
  106500. convertIncidentRadianceToIrradiance(): void;
  106501. /**
  106502. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106503. *
  106504. * ```
  106505. * L = (1/pi) * E * rho
  106506. * ```
  106507. *
  106508. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106509. */
  106510. convertIrradianceToLambertianRadiance(): void;
  106511. /**
  106512. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106513. * required operations at run time.
  106514. *
  106515. * This is simply done by scaling back the SH with Ylm constants parameter.
  106516. * The trigonometric part being applied by the shader at run time.
  106517. */
  106518. preScaleForRendering(): void;
  106519. /**
  106520. * Constructs a spherical harmonics from an array.
  106521. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106522. * @returns the spherical harmonics
  106523. */
  106524. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106525. /**
  106526. * Gets the spherical harmonics from polynomial
  106527. * @param polynomial the spherical polynomial
  106528. * @returns the spherical harmonics
  106529. */
  106530. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106531. }
  106532. /**
  106533. * Class representing spherical polynomial coefficients to the 3rd degree
  106534. */
  106535. export class SphericalPolynomial {
  106536. private _harmonics;
  106537. /**
  106538. * The spherical harmonics used to create the polynomials.
  106539. */
  106540. get preScaledHarmonics(): SphericalHarmonics;
  106541. /**
  106542. * The x coefficients of the spherical polynomial
  106543. */
  106544. x: Vector3;
  106545. /**
  106546. * The y coefficients of the spherical polynomial
  106547. */
  106548. y: Vector3;
  106549. /**
  106550. * The z coefficients of the spherical polynomial
  106551. */
  106552. z: Vector3;
  106553. /**
  106554. * The xx coefficients of the spherical polynomial
  106555. */
  106556. xx: Vector3;
  106557. /**
  106558. * The yy coefficients of the spherical polynomial
  106559. */
  106560. yy: Vector3;
  106561. /**
  106562. * The zz coefficients of the spherical polynomial
  106563. */
  106564. zz: Vector3;
  106565. /**
  106566. * The xy coefficients of the spherical polynomial
  106567. */
  106568. xy: Vector3;
  106569. /**
  106570. * The yz coefficients of the spherical polynomial
  106571. */
  106572. yz: Vector3;
  106573. /**
  106574. * The zx coefficients of the spherical polynomial
  106575. */
  106576. zx: Vector3;
  106577. /**
  106578. * Adds an ambient color to the spherical polynomial
  106579. * @param color the color to add
  106580. */
  106581. addAmbient(color: Color3): void;
  106582. /**
  106583. * Scales the spherical polynomial by the given amount
  106584. * @param scale the amount to scale
  106585. */
  106586. scaleInPlace(scale: number): void;
  106587. /**
  106588. * Gets the spherical polynomial from harmonics
  106589. * @param harmonics the spherical harmonics
  106590. * @returns the spherical polynomial
  106591. */
  106592. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106593. /**
  106594. * Constructs a spherical polynomial from an array.
  106595. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106596. * @returns the spherical polynomial
  106597. */
  106598. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106599. }
  106600. }
  106601. declare module BABYLON {
  106602. /**
  106603. * Defines the source of the internal texture
  106604. */
  106605. export enum InternalTextureSource {
  106606. /**
  106607. * The source of the texture data is unknown
  106608. */
  106609. Unknown = 0,
  106610. /**
  106611. * Texture data comes from an URL
  106612. */
  106613. Url = 1,
  106614. /**
  106615. * Texture data is only used for temporary storage
  106616. */
  106617. Temp = 2,
  106618. /**
  106619. * Texture data comes from raw data (ArrayBuffer)
  106620. */
  106621. Raw = 3,
  106622. /**
  106623. * Texture content is dynamic (video or dynamic texture)
  106624. */
  106625. Dynamic = 4,
  106626. /**
  106627. * Texture content is generated by rendering to it
  106628. */
  106629. RenderTarget = 5,
  106630. /**
  106631. * Texture content is part of a multi render target process
  106632. */
  106633. MultiRenderTarget = 6,
  106634. /**
  106635. * Texture data comes from a cube data file
  106636. */
  106637. Cube = 7,
  106638. /**
  106639. * Texture data comes from a raw cube data
  106640. */
  106641. CubeRaw = 8,
  106642. /**
  106643. * Texture data come from a prefiltered cube data file
  106644. */
  106645. CubePrefiltered = 9,
  106646. /**
  106647. * Texture content is raw 3D data
  106648. */
  106649. Raw3D = 10,
  106650. /**
  106651. * Texture content is raw 2D array data
  106652. */
  106653. Raw2DArray = 11,
  106654. /**
  106655. * Texture content is a depth texture
  106656. */
  106657. Depth = 12,
  106658. /**
  106659. * Texture data comes from a raw cube data encoded with RGBD
  106660. */
  106661. CubeRawRGBD = 13
  106662. }
  106663. /**
  106664. * Class used to store data associated with WebGL texture data for the engine
  106665. * This class should not be used directly
  106666. */
  106667. export class InternalTexture {
  106668. /** @hidden */
  106669. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  106670. /**
  106671. * Defines if the texture is ready
  106672. */
  106673. isReady: boolean;
  106674. /**
  106675. * Defines if the texture is a cube texture
  106676. */
  106677. isCube: boolean;
  106678. /**
  106679. * Defines if the texture contains 3D data
  106680. */
  106681. is3D: boolean;
  106682. /**
  106683. * Defines if the texture contains 2D array data
  106684. */
  106685. is2DArray: boolean;
  106686. /**
  106687. * Defines if the texture contains multiview data
  106688. */
  106689. isMultiview: boolean;
  106690. /**
  106691. * Gets the URL used to load this texture
  106692. */
  106693. url: string;
  106694. /**
  106695. * Gets the sampling mode of the texture
  106696. */
  106697. samplingMode: number;
  106698. /**
  106699. * Gets a boolean indicating if the texture needs mipmaps generation
  106700. */
  106701. generateMipMaps: boolean;
  106702. /**
  106703. * Gets the number of samples used by the texture (WebGL2+ only)
  106704. */
  106705. samples: number;
  106706. /**
  106707. * Gets the type of the texture (int, float...)
  106708. */
  106709. type: number;
  106710. /**
  106711. * Gets the format of the texture (RGB, RGBA...)
  106712. */
  106713. format: number;
  106714. /**
  106715. * Observable called when the texture is loaded
  106716. */
  106717. onLoadedObservable: Observable<InternalTexture>;
  106718. /**
  106719. * Gets the width of the texture
  106720. */
  106721. width: number;
  106722. /**
  106723. * Gets the height of the texture
  106724. */
  106725. height: number;
  106726. /**
  106727. * Gets the depth of the texture
  106728. */
  106729. depth: number;
  106730. /**
  106731. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106732. */
  106733. baseWidth: number;
  106734. /**
  106735. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106736. */
  106737. baseHeight: number;
  106738. /**
  106739. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106740. */
  106741. baseDepth: number;
  106742. /**
  106743. * Gets a boolean indicating if the texture is inverted on Y axis
  106744. */
  106745. invertY: boolean;
  106746. /** @hidden */
  106747. _invertVScale: boolean;
  106748. /** @hidden */
  106749. _associatedChannel: number;
  106750. /** @hidden */
  106751. _source: InternalTextureSource;
  106752. /** @hidden */
  106753. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106754. /** @hidden */
  106755. _bufferView: Nullable<ArrayBufferView>;
  106756. /** @hidden */
  106757. _bufferViewArray: Nullable<ArrayBufferView[]>;
  106758. /** @hidden */
  106759. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  106760. /** @hidden */
  106761. _size: number;
  106762. /** @hidden */
  106763. _extension: string;
  106764. /** @hidden */
  106765. _files: Nullable<string[]>;
  106766. /** @hidden */
  106767. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  106768. /** @hidden */
  106769. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  106770. /** @hidden */
  106771. _framebuffer: Nullable<WebGLFramebuffer>;
  106772. /** @hidden */
  106773. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  106774. /** @hidden */
  106775. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  106776. /** @hidden */
  106777. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  106778. /** @hidden */
  106779. _attachments: Nullable<number[]>;
  106780. /** @hidden */
  106781. _cachedCoordinatesMode: Nullable<number>;
  106782. /** @hidden */
  106783. _cachedWrapU: Nullable<number>;
  106784. /** @hidden */
  106785. _cachedWrapV: Nullable<number>;
  106786. /** @hidden */
  106787. _cachedWrapR: Nullable<number>;
  106788. /** @hidden */
  106789. _cachedAnisotropicFilteringLevel: Nullable<number>;
  106790. /** @hidden */
  106791. _isDisabled: boolean;
  106792. /** @hidden */
  106793. _compression: Nullable<string>;
  106794. /** @hidden */
  106795. _generateStencilBuffer: boolean;
  106796. /** @hidden */
  106797. _generateDepthBuffer: boolean;
  106798. /** @hidden */
  106799. _comparisonFunction: number;
  106800. /** @hidden */
  106801. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  106802. /** @hidden */
  106803. _lodGenerationScale: number;
  106804. /** @hidden */
  106805. _lodGenerationOffset: number;
  106806. /** @hidden */
  106807. _depthStencilTexture: Nullable<InternalTexture>;
  106808. /** @hidden */
  106809. _colorTextureArray: Nullable<WebGLTexture>;
  106810. /** @hidden */
  106811. _depthStencilTextureArray: Nullable<WebGLTexture>;
  106812. /** @hidden */
  106813. _lodTextureHigh: Nullable<BaseTexture>;
  106814. /** @hidden */
  106815. _lodTextureMid: Nullable<BaseTexture>;
  106816. /** @hidden */
  106817. _lodTextureLow: Nullable<BaseTexture>;
  106818. /** @hidden */
  106819. _isRGBD: boolean;
  106820. /** @hidden */
  106821. _linearSpecularLOD: boolean;
  106822. /** @hidden */
  106823. _irradianceTexture: Nullable<BaseTexture>;
  106824. /** @hidden */
  106825. _webGLTexture: Nullable<WebGLTexture>;
  106826. /** @hidden */
  106827. _references: number;
  106828. private _engine;
  106829. /**
  106830. * Gets the Engine the texture belongs to.
  106831. * @returns The babylon engine
  106832. */
  106833. getEngine(): ThinEngine;
  106834. /**
  106835. * Gets the data source type of the texture
  106836. */
  106837. get source(): InternalTextureSource;
  106838. /**
  106839. * Creates a new InternalTexture
  106840. * @param engine defines the engine to use
  106841. * @param source defines the type of data that will be used
  106842. * @param delayAllocation if the texture allocation should be delayed (default: false)
  106843. */
  106844. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  106845. /**
  106846. * Increments the number of references (ie. the number of Texture that point to it)
  106847. */
  106848. incrementReferences(): void;
  106849. /**
  106850. * Change the size of the texture (not the size of the content)
  106851. * @param width defines the new width
  106852. * @param height defines the new height
  106853. * @param depth defines the new depth (1 by default)
  106854. */
  106855. updateSize(width: int, height: int, depth?: int): void;
  106856. /** @hidden */
  106857. _rebuild(): void;
  106858. /** @hidden */
  106859. _swapAndDie(target: InternalTexture): void;
  106860. /**
  106861. * Dispose the current allocated resources
  106862. */
  106863. dispose(): void;
  106864. }
  106865. }
  106866. declare module BABYLON {
  106867. /**
  106868. * Class used to work with sound analyzer using fast fourier transform (FFT)
  106869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106870. */
  106871. export class Analyser {
  106872. /**
  106873. * Gets or sets the smoothing
  106874. * @ignorenaming
  106875. */
  106876. SMOOTHING: number;
  106877. /**
  106878. * Gets or sets the FFT table size
  106879. * @ignorenaming
  106880. */
  106881. FFT_SIZE: number;
  106882. /**
  106883. * Gets or sets the bar graph amplitude
  106884. * @ignorenaming
  106885. */
  106886. BARGRAPHAMPLITUDE: number;
  106887. /**
  106888. * Gets or sets the position of the debug canvas
  106889. * @ignorenaming
  106890. */
  106891. DEBUGCANVASPOS: {
  106892. x: number;
  106893. y: number;
  106894. };
  106895. /**
  106896. * Gets or sets the debug canvas size
  106897. * @ignorenaming
  106898. */
  106899. DEBUGCANVASSIZE: {
  106900. width: number;
  106901. height: number;
  106902. };
  106903. private _byteFreqs;
  106904. private _byteTime;
  106905. private _floatFreqs;
  106906. private _webAudioAnalyser;
  106907. private _debugCanvas;
  106908. private _debugCanvasContext;
  106909. private _scene;
  106910. private _registerFunc;
  106911. private _audioEngine;
  106912. /**
  106913. * Creates a new analyser
  106914. * @param scene defines hosting scene
  106915. */
  106916. constructor(scene: Scene);
  106917. /**
  106918. * Get the number of data values you will have to play with for the visualization
  106919. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  106920. * @returns a number
  106921. */
  106922. getFrequencyBinCount(): number;
  106923. /**
  106924. * Gets the current frequency data as a byte array
  106925. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106926. * @returns a Uint8Array
  106927. */
  106928. getByteFrequencyData(): Uint8Array;
  106929. /**
  106930. * Gets the current waveform as a byte array
  106931. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  106932. * @returns a Uint8Array
  106933. */
  106934. getByteTimeDomainData(): Uint8Array;
  106935. /**
  106936. * Gets the current frequency data as a float array
  106937. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  106938. * @returns a Float32Array
  106939. */
  106940. getFloatFrequencyData(): Float32Array;
  106941. /**
  106942. * Renders the debug canvas
  106943. */
  106944. drawDebugCanvas(): void;
  106945. /**
  106946. * Stops rendering the debug canvas and removes it
  106947. */
  106948. stopDebugCanvas(): void;
  106949. /**
  106950. * Connects two audio nodes
  106951. * @param inputAudioNode defines first node to connect
  106952. * @param outputAudioNode defines second node to connect
  106953. */
  106954. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  106955. /**
  106956. * Releases all associated resources
  106957. */
  106958. dispose(): void;
  106959. }
  106960. }
  106961. declare module BABYLON {
  106962. /**
  106963. * This represents an audio engine and it is responsible
  106964. * to play, synchronize and analyse sounds throughout the application.
  106965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106966. */
  106967. export interface IAudioEngine extends IDisposable {
  106968. /**
  106969. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  106970. */
  106971. readonly canUseWebAudio: boolean;
  106972. /**
  106973. * Gets the current AudioContext if available.
  106974. */
  106975. readonly audioContext: Nullable<AudioContext>;
  106976. /**
  106977. * The master gain node defines the global audio volume of your audio engine.
  106978. */
  106979. readonly masterGain: GainNode;
  106980. /**
  106981. * Gets whether or not mp3 are supported by your browser.
  106982. */
  106983. readonly isMP3supported: boolean;
  106984. /**
  106985. * Gets whether or not ogg are supported by your browser.
  106986. */
  106987. readonly isOGGsupported: boolean;
  106988. /**
  106989. * Defines if Babylon should emit a warning if WebAudio is not supported.
  106990. * @ignoreNaming
  106991. */
  106992. WarnedWebAudioUnsupported: boolean;
  106993. /**
  106994. * Defines if the audio engine relies on a custom unlocked button.
  106995. * In this case, the embedded button will not be displayed.
  106996. */
  106997. useCustomUnlockedButton: boolean;
  106998. /**
  106999. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  107000. */
  107001. readonly unlocked: boolean;
  107002. /**
  107003. * Event raised when audio has been unlocked on the browser.
  107004. */
  107005. onAudioUnlockedObservable: Observable<AudioEngine>;
  107006. /**
  107007. * Event raised when audio has been locked on the browser.
  107008. */
  107009. onAudioLockedObservable: Observable<AudioEngine>;
  107010. /**
  107011. * Flags the audio engine in Locked state.
  107012. * This happens due to new browser policies preventing audio to autoplay.
  107013. */
  107014. lock(): void;
  107015. /**
  107016. * Unlocks the audio engine once a user action has been done on the dom.
  107017. * This is helpful to resume play once browser policies have been satisfied.
  107018. */
  107019. unlock(): void;
  107020. /**
  107021. * Gets the global volume sets on the master gain.
  107022. * @returns the global volume if set or -1 otherwise
  107023. */
  107024. getGlobalVolume(): number;
  107025. /**
  107026. * Sets the global volume of your experience (sets on the master gain).
  107027. * @param newVolume Defines the new global volume of the application
  107028. */
  107029. setGlobalVolume(newVolume: number): void;
  107030. /**
  107031. * Connect the audio engine to an audio analyser allowing some amazing
  107032. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107034. * @param analyser The analyser to connect to the engine
  107035. */
  107036. connectToAnalyser(analyser: Analyser): void;
  107037. }
  107038. /**
  107039. * This represents the default audio engine used in babylon.
  107040. * It is responsible to play, synchronize and analyse sounds throughout the application.
  107041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107042. */
  107043. export class AudioEngine implements IAudioEngine {
  107044. private _audioContext;
  107045. private _audioContextInitialized;
  107046. private _muteButton;
  107047. private _hostElement;
  107048. /**
  107049. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107050. */
  107051. canUseWebAudio: boolean;
  107052. /**
  107053. * The master gain node defines the global audio volume of your audio engine.
  107054. */
  107055. masterGain: GainNode;
  107056. /**
  107057. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107058. * @ignoreNaming
  107059. */
  107060. WarnedWebAudioUnsupported: boolean;
  107061. /**
  107062. * Gets whether or not mp3 are supported by your browser.
  107063. */
  107064. isMP3supported: boolean;
  107065. /**
  107066. * Gets whether or not ogg are supported by your browser.
  107067. */
  107068. isOGGsupported: boolean;
  107069. /**
  107070. * Gets whether audio has been unlocked on the device.
  107071. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  107072. * a user interaction has happened.
  107073. */
  107074. unlocked: boolean;
  107075. /**
  107076. * Defines if the audio engine relies on a custom unlocked button.
  107077. * In this case, the embedded button will not be displayed.
  107078. */
  107079. useCustomUnlockedButton: boolean;
  107080. /**
  107081. * Event raised when audio has been unlocked on the browser.
  107082. */
  107083. onAudioUnlockedObservable: Observable<AudioEngine>;
  107084. /**
  107085. * Event raised when audio has been locked on the browser.
  107086. */
  107087. onAudioLockedObservable: Observable<AudioEngine>;
  107088. /**
  107089. * Gets the current AudioContext if available.
  107090. */
  107091. get audioContext(): Nullable<AudioContext>;
  107092. private _connectedAnalyser;
  107093. /**
  107094. * Instantiates a new audio engine.
  107095. *
  107096. * There should be only one per page as some browsers restrict the number
  107097. * of audio contexts you can create.
  107098. * @param hostElement defines the host element where to display the mute icon if necessary
  107099. */
  107100. constructor(hostElement?: Nullable<HTMLElement>);
  107101. /**
  107102. * Flags the audio engine in Locked state.
  107103. * This happens due to new browser policies preventing audio to autoplay.
  107104. */
  107105. lock(): void;
  107106. /**
  107107. * Unlocks the audio engine once a user action has been done on the dom.
  107108. * This is helpful to resume play once browser policies have been satisfied.
  107109. */
  107110. unlock(): void;
  107111. private _resumeAudioContext;
  107112. private _initializeAudioContext;
  107113. private _tryToRun;
  107114. private _triggerRunningState;
  107115. private _triggerSuspendedState;
  107116. private _displayMuteButton;
  107117. private _moveButtonToTopLeft;
  107118. private _onResize;
  107119. private _hideMuteButton;
  107120. /**
  107121. * Destroy and release the resources associated with the audio ccontext.
  107122. */
  107123. dispose(): void;
  107124. /**
  107125. * Gets the global volume sets on the master gain.
  107126. * @returns the global volume if set or -1 otherwise
  107127. */
  107128. getGlobalVolume(): number;
  107129. /**
  107130. * Sets the global volume of your experience (sets on the master gain).
  107131. * @param newVolume Defines the new global volume of the application
  107132. */
  107133. setGlobalVolume(newVolume: number): void;
  107134. /**
  107135. * Connect the audio engine to an audio analyser allowing some amazing
  107136. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107138. * @param analyser The analyser to connect to the engine
  107139. */
  107140. connectToAnalyser(analyser: Analyser): void;
  107141. }
  107142. }
  107143. declare module BABYLON {
  107144. /**
  107145. * Interface used to present a loading screen while loading a scene
  107146. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107147. */
  107148. export interface ILoadingScreen {
  107149. /**
  107150. * Function called to display the loading screen
  107151. */
  107152. displayLoadingUI: () => void;
  107153. /**
  107154. * Function called to hide the loading screen
  107155. */
  107156. hideLoadingUI: () => void;
  107157. /**
  107158. * Gets or sets the color to use for the background
  107159. */
  107160. loadingUIBackgroundColor: string;
  107161. /**
  107162. * Gets or sets the text to display while loading
  107163. */
  107164. loadingUIText: string;
  107165. }
  107166. /**
  107167. * Class used for the default loading screen
  107168. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107169. */
  107170. export class DefaultLoadingScreen implements ILoadingScreen {
  107171. private _renderingCanvas;
  107172. private _loadingText;
  107173. private _loadingDivBackgroundColor;
  107174. private _loadingDiv;
  107175. private _loadingTextDiv;
  107176. /** Gets or sets the logo url to use for the default loading screen */
  107177. static DefaultLogoUrl: string;
  107178. /** Gets or sets the spinner url to use for the default loading screen */
  107179. static DefaultSpinnerUrl: string;
  107180. /**
  107181. * Creates a new default loading screen
  107182. * @param _renderingCanvas defines the canvas used to render the scene
  107183. * @param _loadingText defines the default text to display
  107184. * @param _loadingDivBackgroundColor defines the default background color
  107185. */
  107186. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  107187. /**
  107188. * Function called to display the loading screen
  107189. */
  107190. displayLoadingUI(): void;
  107191. /**
  107192. * Function called to hide the loading screen
  107193. */
  107194. hideLoadingUI(): void;
  107195. /**
  107196. * Gets or sets the text to display while loading
  107197. */
  107198. set loadingUIText(text: string);
  107199. get loadingUIText(): string;
  107200. /**
  107201. * Gets or sets the color to use for the background
  107202. */
  107203. get loadingUIBackgroundColor(): string;
  107204. set loadingUIBackgroundColor(color: string);
  107205. private _resizeLoadingUI;
  107206. }
  107207. }
  107208. declare module BABYLON {
  107209. /**
  107210. * Interface for any object that can request an animation frame
  107211. */
  107212. export interface ICustomAnimationFrameRequester {
  107213. /**
  107214. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  107215. */
  107216. renderFunction?: Function;
  107217. /**
  107218. * Called to request the next frame to render to
  107219. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  107220. */
  107221. requestAnimationFrame: Function;
  107222. /**
  107223. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  107224. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  107225. */
  107226. requestID?: number;
  107227. }
  107228. }
  107229. declare module BABYLON {
  107230. /**
  107231. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  107232. */
  107233. export class PerformanceMonitor {
  107234. private _enabled;
  107235. private _rollingFrameTime;
  107236. private _lastFrameTimeMs;
  107237. /**
  107238. * constructor
  107239. * @param frameSampleSize The number of samples required to saturate the sliding window
  107240. */
  107241. constructor(frameSampleSize?: number);
  107242. /**
  107243. * Samples current frame
  107244. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  107245. */
  107246. sampleFrame(timeMs?: number): void;
  107247. /**
  107248. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107249. */
  107250. get averageFrameTime(): number;
  107251. /**
  107252. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107253. */
  107254. get averageFrameTimeVariance(): number;
  107255. /**
  107256. * Returns the frame time of the most recent frame
  107257. */
  107258. get instantaneousFrameTime(): number;
  107259. /**
  107260. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  107261. */
  107262. get averageFPS(): number;
  107263. /**
  107264. * Returns the average framerate in frames per second using the most recent frame time
  107265. */
  107266. get instantaneousFPS(): number;
  107267. /**
  107268. * Returns true if enough samples have been taken to completely fill the sliding window
  107269. */
  107270. get isSaturated(): boolean;
  107271. /**
  107272. * Enables contributions to the sliding window sample set
  107273. */
  107274. enable(): void;
  107275. /**
  107276. * Disables contributions to the sliding window sample set
  107277. * Samples will not be interpolated over the disabled period
  107278. */
  107279. disable(): void;
  107280. /**
  107281. * Returns true if sampling is enabled
  107282. */
  107283. get isEnabled(): boolean;
  107284. /**
  107285. * Resets performance monitor
  107286. */
  107287. reset(): void;
  107288. }
  107289. /**
  107290. * RollingAverage
  107291. *
  107292. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  107293. */
  107294. export class RollingAverage {
  107295. /**
  107296. * Current average
  107297. */
  107298. average: number;
  107299. /**
  107300. * Current variance
  107301. */
  107302. variance: number;
  107303. protected _samples: Array<number>;
  107304. protected _sampleCount: number;
  107305. protected _pos: number;
  107306. protected _m2: number;
  107307. /**
  107308. * constructor
  107309. * @param length The number of samples required to saturate the sliding window
  107310. */
  107311. constructor(length: number);
  107312. /**
  107313. * Adds a sample to the sample set
  107314. * @param v The sample value
  107315. */
  107316. add(v: number): void;
  107317. /**
  107318. * Returns previously added values or null if outside of history or outside the sliding window domain
  107319. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  107320. * @return Value previously recorded with add() or null if outside of range
  107321. */
  107322. history(i: number): number;
  107323. /**
  107324. * Returns true if enough samples have been taken to completely fill the sliding window
  107325. * @return true if sample-set saturated
  107326. */
  107327. isSaturated(): boolean;
  107328. /**
  107329. * Resets the rolling average (equivalent to 0 samples taken so far)
  107330. */
  107331. reset(): void;
  107332. /**
  107333. * Wraps a value around the sample range boundaries
  107334. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  107335. * @return Wrapped position in sample range
  107336. */
  107337. protected _wrapPosition(i: number): number;
  107338. }
  107339. }
  107340. declare module BABYLON {
  107341. /**
  107342. * This class is used to track a performance counter which is number based.
  107343. * The user has access to many properties which give statistics of different nature.
  107344. *
  107345. * The implementer can track two kinds of Performance Counter: time and count.
  107346. * 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.
  107347. * 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.
  107348. */
  107349. export class PerfCounter {
  107350. /**
  107351. * Gets or sets a global boolean to turn on and off all the counters
  107352. */
  107353. static Enabled: boolean;
  107354. /**
  107355. * Returns the smallest value ever
  107356. */
  107357. get min(): number;
  107358. /**
  107359. * Returns the biggest value ever
  107360. */
  107361. get max(): number;
  107362. /**
  107363. * Returns the average value since the performance counter is running
  107364. */
  107365. get average(): number;
  107366. /**
  107367. * Returns the average value of the last second the counter was monitored
  107368. */
  107369. get lastSecAverage(): number;
  107370. /**
  107371. * Returns the current value
  107372. */
  107373. get current(): number;
  107374. /**
  107375. * Gets the accumulated total
  107376. */
  107377. get total(): number;
  107378. /**
  107379. * Gets the total value count
  107380. */
  107381. get count(): number;
  107382. /**
  107383. * Creates a new counter
  107384. */
  107385. constructor();
  107386. /**
  107387. * Call this method to start monitoring a new frame.
  107388. * 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.
  107389. */
  107390. fetchNewFrame(): void;
  107391. /**
  107392. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  107393. * @param newCount the count value to add to the monitored count
  107394. * @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.
  107395. */
  107396. addCount(newCount: number, fetchResult: boolean): void;
  107397. /**
  107398. * Start monitoring this performance counter
  107399. */
  107400. beginMonitoring(): void;
  107401. /**
  107402. * Compute the time lapsed since the previous beginMonitoring() call.
  107403. * @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
  107404. */
  107405. endMonitoring(newFrame?: boolean): void;
  107406. private _fetchResult;
  107407. private _startMonitoringTime;
  107408. private _min;
  107409. private _max;
  107410. private _average;
  107411. private _current;
  107412. private _totalValueCount;
  107413. private _totalAccumulated;
  107414. private _lastSecAverage;
  107415. private _lastSecAccumulated;
  107416. private _lastSecTime;
  107417. private _lastSecValueCount;
  107418. }
  107419. }
  107420. declare module BABYLON {
  107421. interface ThinEngine {
  107422. /**
  107423. * Sets alpha constants used by some alpha blending modes
  107424. * @param r defines the red component
  107425. * @param g defines the green component
  107426. * @param b defines the blue component
  107427. * @param a defines the alpha component
  107428. */
  107429. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  107430. /**
  107431. * Sets the current alpha mode
  107432. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  107433. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  107434. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107435. */
  107436. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107437. /**
  107438. * Gets the current alpha mode
  107439. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107440. * @returns the current alpha mode
  107441. */
  107442. getAlphaMode(): number;
  107443. /**
  107444. * Sets the current alpha equation
  107445. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  107446. */
  107447. setAlphaEquation(equation: number): void;
  107448. /**
  107449. * Gets the current alpha equation.
  107450. * @returns the current alpha equation
  107451. */
  107452. getAlphaEquation(): number;
  107453. }
  107454. }
  107455. declare module BABYLON {
  107456. /**
  107457. * Defines the interface used by display changed events
  107458. */
  107459. export interface IDisplayChangedEventArgs {
  107460. /** Gets the vrDisplay object (if any) */
  107461. vrDisplay: Nullable<any>;
  107462. /** Gets a boolean indicating if webVR is supported */
  107463. vrSupported: boolean;
  107464. }
  107465. /**
  107466. * Defines the interface used by objects containing a viewport (like a camera)
  107467. */
  107468. interface IViewportOwnerLike {
  107469. /**
  107470. * Gets or sets the viewport
  107471. */
  107472. viewport: IViewportLike;
  107473. }
  107474. /**
  107475. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  107476. */
  107477. export class Engine extends ThinEngine {
  107478. /** Defines that alpha blending is disabled */
  107479. static readonly ALPHA_DISABLE: number;
  107480. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  107481. static readonly ALPHA_ADD: number;
  107482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  107483. static readonly ALPHA_COMBINE: number;
  107484. /** Defines that alpha blending to DEST - SRC * DEST */
  107485. static readonly ALPHA_SUBTRACT: number;
  107486. /** Defines that alpha blending to SRC * DEST */
  107487. static readonly ALPHA_MULTIPLY: number;
  107488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  107489. static readonly ALPHA_MAXIMIZED: number;
  107490. /** Defines that alpha blending to SRC + DEST */
  107491. static readonly ALPHA_ONEONE: number;
  107492. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  107493. static readonly ALPHA_PREMULTIPLIED: number;
  107494. /**
  107495. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  107496. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  107497. */
  107498. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  107499. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  107500. static readonly ALPHA_INTERPOLATE: number;
  107501. /**
  107502. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  107503. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  107504. */
  107505. static readonly ALPHA_SCREENMODE: number;
  107506. /** Defines that the ressource is not delayed*/
  107507. static readonly DELAYLOADSTATE_NONE: number;
  107508. /** Defines that the ressource was successfully delay loaded */
  107509. static readonly DELAYLOADSTATE_LOADED: number;
  107510. /** Defines that the ressource is currently delay loading */
  107511. static readonly DELAYLOADSTATE_LOADING: number;
  107512. /** Defines that the ressource is delayed and has not started loading */
  107513. static readonly DELAYLOADSTATE_NOTLOADED: number;
  107514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  107515. static readonly NEVER: number;
  107516. /** 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 */
  107517. static readonly ALWAYS: number;
  107518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  107519. static readonly LESS: number;
  107520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  107521. static readonly EQUAL: number;
  107522. /** 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 */
  107523. static readonly LEQUAL: number;
  107524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  107525. static readonly GREATER: number;
  107526. /** 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 */
  107527. static readonly GEQUAL: number;
  107528. /** 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 */
  107529. static readonly NOTEQUAL: number;
  107530. /** Passed to stencilOperation to specify that stencil value must be kept */
  107531. static readonly KEEP: number;
  107532. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107533. static readonly REPLACE: number;
  107534. /** Passed to stencilOperation to specify that stencil value must be incremented */
  107535. static readonly INCR: number;
  107536. /** Passed to stencilOperation to specify that stencil value must be decremented */
  107537. static readonly DECR: number;
  107538. /** Passed to stencilOperation to specify that stencil value must be inverted */
  107539. static readonly INVERT: number;
  107540. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  107541. static readonly INCR_WRAP: number;
  107542. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  107543. static readonly DECR_WRAP: number;
  107544. /** Texture is not repeating outside of 0..1 UVs */
  107545. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  107546. /** Texture is repeating outside of 0..1 UVs */
  107547. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  107548. /** Texture is repeating and mirrored */
  107549. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  107550. /** ALPHA */
  107551. static readonly TEXTUREFORMAT_ALPHA: number;
  107552. /** LUMINANCE */
  107553. static readonly TEXTUREFORMAT_LUMINANCE: number;
  107554. /** LUMINANCE_ALPHA */
  107555. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  107556. /** RGB */
  107557. static readonly TEXTUREFORMAT_RGB: number;
  107558. /** RGBA */
  107559. static readonly TEXTUREFORMAT_RGBA: number;
  107560. /** RED */
  107561. static readonly TEXTUREFORMAT_RED: number;
  107562. /** RED (2nd reference) */
  107563. static readonly TEXTUREFORMAT_R: number;
  107564. /** RG */
  107565. static readonly TEXTUREFORMAT_RG: number;
  107566. /** RED_INTEGER */
  107567. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  107568. /** RED_INTEGER (2nd reference) */
  107569. static readonly TEXTUREFORMAT_R_INTEGER: number;
  107570. /** RG_INTEGER */
  107571. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  107572. /** RGB_INTEGER */
  107573. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  107574. /** RGBA_INTEGER */
  107575. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  107576. /** UNSIGNED_BYTE */
  107577. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  107578. /** UNSIGNED_BYTE (2nd reference) */
  107579. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  107580. /** FLOAT */
  107581. static readonly TEXTURETYPE_FLOAT: number;
  107582. /** HALF_FLOAT */
  107583. static readonly TEXTURETYPE_HALF_FLOAT: number;
  107584. /** BYTE */
  107585. static readonly TEXTURETYPE_BYTE: number;
  107586. /** SHORT */
  107587. static readonly TEXTURETYPE_SHORT: number;
  107588. /** UNSIGNED_SHORT */
  107589. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  107590. /** INT */
  107591. static readonly TEXTURETYPE_INT: number;
  107592. /** UNSIGNED_INT */
  107593. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  107594. /** UNSIGNED_SHORT_4_4_4_4 */
  107595. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  107596. /** UNSIGNED_SHORT_5_5_5_1 */
  107597. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  107598. /** UNSIGNED_SHORT_5_6_5 */
  107599. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  107600. /** UNSIGNED_INT_2_10_10_10_REV */
  107601. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  107602. /** UNSIGNED_INT_24_8 */
  107603. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  107604. /** UNSIGNED_INT_10F_11F_11F_REV */
  107605. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  107606. /** UNSIGNED_INT_5_9_9_9_REV */
  107607. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  107608. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  107609. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  107610. /** nearest is mag = nearest and min = nearest and mip = linear */
  107611. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  107612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107613. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  107614. /** Trilinear is mag = linear and min = linear and mip = linear */
  107615. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  107616. /** nearest is mag = nearest and min = nearest and mip = linear */
  107617. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  107618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107619. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  107620. /** Trilinear is mag = linear and min = linear and mip = linear */
  107621. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  107622. /** mag = nearest and min = nearest and mip = nearest */
  107623. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  107624. /** mag = nearest and min = linear and mip = nearest */
  107625. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  107626. /** mag = nearest and min = linear and mip = linear */
  107627. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  107628. /** mag = nearest and min = linear and mip = none */
  107629. static readonly TEXTURE_NEAREST_LINEAR: number;
  107630. /** mag = nearest and min = nearest and mip = none */
  107631. static readonly TEXTURE_NEAREST_NEAREST: number;
  107632. /** mag = linear and min = nearest and mip = nearest */
  107633. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  107634. /** mag = linear and min = nearest and mip = linear */
  107635. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  107636. /** mag = linear and min = linear and mip = none */
  107637. static readonly TEXTURE_LINEAR_LINEAR: number;
  107638. /** mag = linear and min = nearest and mip = none */
  107639. static readonly TEXTURE_LINEAR_NEAREST: number;
  107640. /** Explicit coordinates mode */
  107641. static readonly TEXTURE_EXPLICIT_MODE: number;
  107642. /** Spherical coordinates mode */
  107643. static readonly TEXTURE_SPHERICAL_MODE: number;
  107644. /** Planar coordinates mode */
  107645. static readonly TEXTURE_PLANAR_MODE: number;
  107646. /** Cubic coordinates mode */
  107647. static readonly TEXTURE_CUBIC_MODE: number;
  107648. /** Projection coordinates mode */
  107649. static readonly TEXTURE_PROJECTION_MODE: number;
  107650. /** Skybox coordinates mode */
  107651. static readonly TEXTURE_SKYBOX_MODE: number;
  107652. /** Inverse Cubic coordinates mode */
  107653. static readonly TEXTURE_INVCUBIC_MODE: number;
  107654. /** Equirectangular coordinates mode */
  107655. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  107656. /** Equirectangular Fixed coordinates mode */
  107657. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  107658. /** Equirectangular Fixed Mirrored coordinates mode */
  107659. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  107660. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  107661. static readonly SCALEMODE_FLOOR: number;
  107662. /** Defines that texture rescaling will look for the nearest power of 2 size */
  107663. static readonly SCALEMODE_NEAREST: number;
  107664. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  107665. static readonly SCALEMODE_CEILING: number;
  107666. /**
  107667. * Returns the current npm package of the sdk
  107668. */
  107669. static get NpmPackage(): string;
  107670. /**
  107671. * Returns the current version of the framework
  107672. */
  107673. static get Version(): string;
  107674. /** Gets the list of created engines */
  107675. static get Instances(): Engine[];
  107676. /**
  107677. * Gets the latest created engine
  107678. */
  107679. static get LastCreatedEngine(): Nullable<Engine>;
  107680. /**
  107681. * Gets the latest created scene
  107682. */
  107683. static get LastCreatedScene(): Nullable<Scene>;
  107684. /**
  107685. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  107686. * @param flag defines which part of the materials must be marked as dirty
  107687. * @param predicate defines a predicate used to filter which materials should be affected
  107688. */
  107689. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107690. /**
  107691. * Method called to create the default loading screen.
  107692. * This can be overriden in your own app.
  107693. * @param canvas The rendering canvas element
  107694. * @returns The loading screen
  107695. */
  107696. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  107697. /**
  107698. * Method called to create the default rescale post process on each engine.
  107699. */
  107700. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  107701. /**
  107702. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  107703. **/
  107704. enableOfflineSupport: boolean;
  107705. /**
  107706. * 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)
  107707. **/
  107708. disableManifestCheck: boolean;
  107709. /**
  107710. * Gets the list of created scenes
  107711. */
  107712. scenes: Scene[];
  107713. /**
  107714. * Event raised when a new scene is created
  107715. */
  107716. onNewSceneAddedObservable: Observable<Scene>;
  107717. /**
  107718. * Gets the list of created postprocesses
  107719. */
  107720. postProcesses: PostProcess[];
  107721. /**
  107722. * Gets a boolean indicating if the pointer is currently locked
  107723. */
  107724. isPointerLock: boolean;
  107725. /**
  107726. * Observable event triggered each time the rendering canvas is resized
  107727. */
  107728. onResizeObservable: Observable<Engine>;
  107729. /**
  107730. * Observable event triggered each time the canvas loses focus
  107731. */
  107732. onCanvasBlurObservable: Observable<Engine>;
  107733. /**
  107734. * Observable event triggered each time the canvas gains focus
  107735. */
  107736. onCanvasFocusObservable: Observable<Engine>;
  107737. /**
  107738. * Observable event triggered each time the canvas receives pointerout event
  107739. */
  107740. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107741. /**
  107742. * Observable raised when the engine begins a new frame
  107743. */
  107744. onBeginFrameObservable: Observable<Engine>;
  107745. /**
  107746. * If set, will be used to request the next animation frame for the render loop
  107747. */
  107748. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107749. /**
  107750. * Observable raised when the engine ends the current frame
  107751. */
  107752. onEndFrameObservable: Observable<Engine>;
  107753. /**
  107754. * Observable raised when the engine is about to compile a shader
  107755. */
  107756. onBeforeShaderCompilationObservable: Observable<Engine>;
  107757. /**
  107758. * Observable raised when the engine has jsut compiled a shader
  107759. */
  107760. onAfterShaderCompilationObservable: Observable<Engine>;
  107761. /**
  107762. * Gets the audio engine
  107763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107764. * @ignorenaming
  107765. */
  107766. static audioEngine: IAudioEngine;
  107767. /**
  107768. * Default AudioEngine factory responsible of creating the Audio Engine.
  107769. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  107770. */
  107771. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  107772. /**
  107773. * Default offline support factory responsible of creating a tool used to store data locally.
  107774. * By default, this will create a Database object if the workload has been embedded.
  107775. */
  107776. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  107777. private _loadingScreen;
  107778. private _pointerLockRequested;
  107779. private _dummyFramebuffer;
  107780. private _rescalePostProcess;
  107781. private _deterministicLockstep;
  107782. private _lockstepMaxSteps;
  107783. private _timeStep;
  107784. protected get _supportsHardwareTextureRescaling(): boolean;
  107785. private _fps;
  107786. private _deltaTime;
  107787. /** @hidden */
  107788. _drawCalls: PerfCounter;
  107789. /** 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 */
  107790. canvasTabIndex: number;
  107791. /**
  107792. * Turn this value on if you want to pause FPS computation when in background
  107793. */
  107794. disablePerformanceMonitorInBackground: boolean;
  107795. private _performanceMonitor;
  107796. /**
  107797. * Gets the performance monitor attached to this engine
  107798. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  107799. */
  107800. get performanceMonitor(): PerformanceMonitor;
  107801. private _onFocus;
  107802. private _onBlur;
  107803. private _onCanvasPointerOut;
  107804. private _onCanvasBlur;
  107805. private _onCanvasFocus;
  107806. private _onFullscreenChange;
  107807. private _onPointerLockChange;
  107808. /**
  107809. * Gets the HTML element used to attach event listeners
  107810. * @returns a HTML element
  107811. */
  107812. getInputElement(): Nullable<HTMLElement>;
  107813. /**
  107814. * Creates a new engine
  107815. * @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
  107816. * @param antialias defines enable antialiasing (default: false)
  107817. * @param options defines further options to be sent to the getContext() function
  107818. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  107819. */
  107820. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  107821. /**
  107822. * Gets current aspect ratio
  107823. * @param viewportOwner defines the camera to use to get the aspect ratio
  107824. * @param useScreen defines if screen size must be used (or the current render target if any)
  107825. * @returns a number defining the aspect ratio
  107826. */
  107827. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  107828. /**
  107829. * Gets current screen aspect ratio
  107830. * @returns a number defining the aspect ratio
  107831. */
  107832. getScreenAspectRatio(): number;
  107833. /**
  107834. * Gets the client rect of the HTML canvas attached with the current webGL context
  107835. * @returns a client rectanglee
  107836. */
  107837. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  107838. /**
  107839. * Gets the client rect of the HTML element used for events
  107840. * @returns a client rectanglee
  107841. */
  107842. getInputElementClientRect(): Nullable<ClientRect>;
  107843. /**
  107844. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  107845. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107846. * @returns true if engine is in deterministic lock step mode
  107847. */
  107848. isDeterministicLockStep(): boolean;
  107849. /**
  107850. * Gets the max steps when engine is running in deterministic lock step
  107851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107852. * @returns the max steps
  107853. */
  107854. getLockstepMaxSteps(): number;
  107855. /**
  107856. * Returns the time in ms between steps when using deterministic lock step.
  107857. * @returns time step in (ms)
  107858. */
  107859. getTimeStep(): number;
  107860. /**
  107861. * Force the mipmap generation for the given render target texture
  107862. * @param texture defines the render target texture to use
  107863. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  107864. */
  107865. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  107866. /** States */
  107867. /**
  107868. * Set various states to the webGL context
  107869. * @param culling defines backface culling state
  107870. * @param zOffset defines the value to apply to zOffset (0 by default)
  107871. * @param force defines if states must be applied even if cache is up to date
  107872. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  107873. */
  107874. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107875. /**
  107876. * Set the z offset to apply to current rendering
  107877. * @param value defines the offset to apply
  107878. */
  107879. setZOffset(value: number): void;
  107880. /**
  107881. * Gets the current value of the zOffset
  107882. * @returns the current zOffset state
  107883. */
  107884. getZOffset(): number;
  107885. /**
  107886. * Enable or disable depth buffering
  107887. * @param enable defines the state to set
  107888. */
  107889. setDepthBuffer(enable: boolean): void;
  107890. /**
  107891. * Gets a boolean indicating if depth writing is enabled
  107892. * @returns the current depth writing state
  107893. */
  107894. getDepthWrite(): boolean;
  107895. /**
  107896. * Enable or disable depth writing
  107897. * @param enable defines the state to set
  107898. */
  107899. setDepthWrite(enable: boolean): void;
  107900. /**
  107901. * Gets a boolean indicating if stencil buffer is enabled
  107902. * @returns the current stencil buffer state
  107903. */
  107904. getStencilBuffer(): boolean;
  107905. /**
  107906. * Enable or disable the stencil buffer
  107907. * @param enable defines if the stencil buffer must be enabled or disabled
  107908. */
  107909. setStencilBuffer(enable: boolean): void;
  107910. /**
  107911. * Gets the current stencil mask
  107912. * @returns a number defining the new stencil mask to use
  107913. */
  107914. getStencilMask(): number;
  107915. /**
  107916. * Sets the current stencil mask
  107917. * @param mask defines the new stencil mask to use
  107918. */
  107919. setStencilMask(mask: number): void;
  107920. /**
  107921. * Gets the current stencil function
  107922. * @returns a number defining the stencil function to use
  107923. */
  107924. getStencilFunction(): number;
  107925. /**
  107926. * Gets the current stencil reference value
  107927. * @returns a number defining the stencil reference value to use
  107928. */
  107929. getStencilFunctionReference(): number;
  107930. /**
  107931. * Gets the current stencil mask
  107932. * @returns a number defining the stencil mask to use
  107933. */
  107934. getStencilFunctionMask(): number;
  107935. /**
  107936. * Sets the current stencil function
  107937. * @param stencilFunc defines the new stencil function to use
  107938. */
  107939. setStencilFunction(stencilFunc: number): void;
  107940. /**
  107941. * Sets the current stencil reference
  107942. * @param reference defines the new stencil reference to use
  107943. */
  107944. setStencilFunctionReference(reference: number): void;
  107945. /**
  107946. * Sets the current stencil mask
  107947. * @param mask defines the new stencil mask to use
  107948. */
  107949. setStencilFunctionMask(mask: number): void;
  107950. /**
  107951. * Gets the current stencil operation when stencil fails
  107952. * @returns a number defining stencil operation to use when stencil fails
  107953. */
  107954. getStencilOperationFail(): number;
  107955. /**
  107956. * Gets the current stencil operation when depth fails
  107957. * @returns a number defining stencil operation to use when depth fails
  107958. */
  107959. getStencilOperationDepthFail(): number;
  107960. /**
  107961. * Gets the current stencil operation when stencil passes
  107962. * @returns a number defining stencil operation to use when stencil passes
  107963. */
  107964. getStencilOperationPass(): number;
  107965. /**
  107966. * Sets the stencil operation to use when stencil fails
  107967. * @param operation defines the stencil operation to use when stencil fails
  107968. */
  107969. setStencilOperationFail(operation: number): void;
  107970. /**
  107971. * Sets the stencil operation to use when depth fails
  107972. * @param operation defines the stencil operation to use when depth fails
  107973. */
  107974. setStencilOperationDepthFail(operation: number): void;
  107975. /**
  107976. * Sets the stencil operation to use when stencil passes
  107977. * @param operation defines the stencil operation to use when stencil passes
  107978. */
  107979. setStencilOperationPass(operation: number): void;
  107980. /**
  107981. * Sets a boolean indicating if the dithering state is enabled or disabled
  107982. * @param value defines the dithering state
  107983. */
  107984. setDitheringState(value: boolean): void;
  107985. /**
  107986. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  107987. * @param value defines the rasterizer state
  107988. */
  107989. setRasterizerState(value: boolean): void;
  107990. /**
  107991. * Gets the current depth function
  107992. * @returns a number defining the depth function
  107993. */
  107994. getDepthFunction(): Nullable<number>;
  107995. /**
  107996. * Sets the current depth function
  107997. * @param depthFunc defines the function to use
  107998. */
  107999. setDepthFunction(depthFunc: number): void;
  108000. /**
  108001. * Sets the current depth function to GREATER
  108002. */
  108003. setDepthFunctionToGreater(): void;
  108004. /**
  108005. * Sets the current depth function to GEQUAL
  108006. */
  108007. setDepthFunctionToGreaterOrEqual(): void;
  108008. /**
  108009. * Sets the current depth function to LESS
  108010. */
  108011. setDepthFunctionToLess(): void;
  108012. /**
  108013. * Sets the current depth function to LEQUAL
  108014. */
  108015. setDepthFunctionToLessOrEqual(): void;
  108016. private _cachedStencilBuffer;
  108017. private _cachedStencilFunction;
  108018. private _cachedStencilMask;
  108019. private _cachedStencilOperationPass;
  108020. private _cachedStencilOperationFail;
  108021. private _cachedStencilOperationDepthFail;
  108022. private _cachedStencilReference;
  108023. /**
  108024. * Caches the the state of the stencil buffer
  108025. */
  108026. cacheStencilState(): void;
  108027. /**
  108028. * Restores the state of the stencil buffer
  108029. */
  108030. restoreStencilState(): void;
  108031. /**
  108032. * Directly set the WebGL Viewport
  108033. * @param x defines the x coordinate of the viewport (in screen space)
  108034. * @param y defines the y coordinate of the viewport (in screen space)
  108035. * @param width defines the width of the viewport (in screen space)
  108036. * @param height defines the height of the viewport (in screen space)
  108037. * @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
  108038. */
  108039. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  108040. /**
  108041. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  108042. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108043. * @param y defines the y-coordinate of the corner of the clear rectangle
  108044. * @param width defines the width of the clear rectangle
  108045. * @param height defines the height of the clear rectangle
  108046. * @param clearColor defines the clear color
  108047. */
  108048. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  108049. /**
  108050. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  108051. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108052. * @param y defines the y-coordinate of the corner of the clear rectangle
  108053. * @param width defines the width of the clear rectangle
  108054. * @param height defines the height of the clear rectangle
  108055. */
  108056. enableScissor(x: number, y: number, width: number, height: number): void;
  108057. /**
  108058. * Disable previously set scissor test rectangle
  108059. */
  108060. disableScissor(): void;
  108061. protected _reportDrawCall(): void;
  108062. /**
  108063. * Initializes a webVR display and starts listening to display change events
  108064. * The onVRDisplayChangedObservable will be notified upon these changes
  108065. * @returns The onVRDisplayChangedObservable
  108066. */
  108067. initWebVR(): Observable<IDisplayChangedEventArgs>;
  108068. /** @hidden */
  108069. _prepareVRComponent(): void;
  108070. /** @hidden */
  108071. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  108072. /** @hidden */
  108073. _submitVRFrame(): void;
  108074. /**
  108075. * Call this function to leave webVR mode
  108076. * Will do nothing if webVR is not supported or if there is no webVR device
  108077. * @see http://doc.babylonjs.com/how_to/webvr_camera
  108078. */
  108079. disableVR(): void;
  108080. /**
  108081. * Gets a boolean indicating that the system is in VR mode and is presenting
  108082. * @returns true if VR mode is engaged
  108083. */
  108084. isVRPresenting(): boolean;
  108085. /** @hidden */
  108086. _requestVRFrame(): void;
  108087. /** @hidden */
  108088. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108089. /**
  108090. * Gets the source code of the vertex shader associated with a specific webGL program
  108091. * @param program defines the program to use
  108092. * @returns a string containing the source code of the vertex shader associated with the program
  108093. */
  108094. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  108095. /**
  108096. * Gets the source code of the fragment shader associated with a specific webGL program
  108097. * @param program defines the program to use
  108098. * @returns a string containing the source code of the fragment shader associated with the program
  108099. */
  108100. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  108101. /**
  108102. * Sets a depth stencil texture from a render target to the according uniform.
  108103. * @param channel The texture channel
  108104. * @param uniform The uniform to set
  108105. * @param texture The render target texture containing the depth stencil texture to apply
  108106. */
  108107. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  108108. /**
  108109. * Sets a texture to the webGL context from a postprocess
  108110. * @param channel defines the channel to use
  108111. * @param postProcess defines the source postprocess
  108112. */
  108113. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  108114. /**
  108115. * Binds the output of the passed in post process to the texture channel specified
  108116. * @param channel The channel the texture should be bound to
  108117. * @param postProcess The post process which's output should be bound
  108118. */
  108119. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  108120. /** @hidden */
  108121. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  108122. protected _rebuildBuffers(): void;
  108123. /** @hidden */
  108124. _renderFrame(): void;
  108125. _renderLoop(): void;
  108126. /** @hidden */
  108127. _renderViews(): boolean;
  108128. /**
  108129. * Toggle full screen mode
  108130. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108131. */
  108132. switchFullscreen(requestPointerLock: boolean): void;
  108133. /**
  108134. * Enters full screen mode
  108135. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108136. */
  108137. enterFullscreen(requestPointerLock: boolean): void;
  108138. /**
  108139. * Exits full screen mode
  108140. */
  108141. exitFullscreen(): void;
  108142. /**
  108143. * Enters Pointerlock mode
  108144. */
  108145. enterPointerlock(): void;
  108146. /**
  108147. * Exits Pointerlock mode
  108148. */
  108149. exitPointerlock(): void;
  108150. /**
  108151. * Begin a new frame
  108152. */
  108153. beginFrame(): void;
  108154. /**
  108155. * Enf the current frame
  108156. */
  108157. endFrame(): void;
  108158. resize(): void;
  108159. /**
  108160. * Force a specific size of the canvas
  108161. * @param width defines the new canvas' width
  108162. * @param height defines the new canvas' height
  108163. */
  108164. setSize(width: number, height: number): void;
  108165. /**
  108166. * Updates a dynamic vertex buffer.
  108167. * @param vertexBuffer the vertex buffer to update
  108168. * @param data the data used to update the vertex buffer
  108169. * @param byteOffset the byte offset of the data
  108170. * @param byteLength the byte length of the data
  108171. */
  108172. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  108173. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108174. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108175. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108176. _releaseTexture(texture: InternalTexture): void;
  108177. /**
  108178. * @hidden
  108179. * Rescales a texture
  108180. * @param source input texutre
  108181. * @param destination destination texture
  108182. * @param scene scene to use to render the resize
  108183. * @param internalFormat format to use when resizing
  108184. * @param onComplete callback to be called when resize has completed
  108185. */
  108186. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108187. /**
  108188. * Gets the current framerate
  108189. * @returns a number representing the framerate
  108190. */
  108191. getFps(): number;
  108192. /**
  108193. * Gets the time spent between current and previous frame
  108194. * @returns a number representing the delta time in ms
  108195. */
  108196. getDeltaTime(): number;
  108197. private _measureFps;
  108198. /** @hidden */
  108199. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  108200. /**
  108201. * Update a dynamic index buffer
  108202. * @param indexBuffer defines the target index buffer
  108203. * @param indices defines the data to update
  108204. * @param offset defines the offset in the target index buffer where update should start
  108205. */
  108206. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  108207. /**
  108208. * Updates the sample count of a render target texture
  108209. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108210. * @param texture defines the texture to update
  108211. * @param samples defines the sample count to set
  108212. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108213. */
  108214. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  108215. /**
  108216. * Updates a depth texture Comparison Mode and Function.
  108217. * If the comparison Function is equal to 0, the mode will be set to none.
  108218. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  108219. * @param texture The texture to set the comparison function for
  108220. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  108221. */
  108222. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  108223. /**
  108224. * Creates a webGL buffer to use with instanciation
  108225. * @param capacity defines the size of the buffer
  108226. * @returns the webGL buffer
  108227. */
  108228. createInstancesBuffer(capacity: number): DataBuffer;
  108229. /**
  108230. * Delete a webGL buffer used with instanciation
  108231. * @param buffer defines the webGL buffer to delete
  108232. */
  108233. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  108234. private _clientWaitAsync;
  108235. /** @hidden */
  108236. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  108237. /** @hidden */
  108238. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  108239. dispose(): void;
  108240. private _disableTouchAction;
  108241. /**
  108242. * Display the loading screen
  108243. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108244. */
  108245. displayLoadingUI(): void;
  108246. /**
  108247. * Hide the loading screen
  108248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108249. */
  108250. hideLoadingUI(): void;
  108251. /**
  108252. * Gets the current loading screen object
  108253. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108254. */
  108255. get loadingScreen(): ILoadingScreen;
  108256. /**
  108257. * Sets the current loading screen object
  108258. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108259. */
  108260. set loadingScreen(loadingScreen: ILoadingScreen);
  108261. /**
  108262. * Sets the current loading screen text
  108263. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108264. */
  108265. set loadingUIText(text: string);
  108266. /**
  108267. * Sets the current loading screen background color
  108268. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108269. */
  108270. set loadingUIBackgroundColor(color: string);
  108271. /** Pointerlock and fullscreen */
  108272. /**
  108273. * Ask the browser to promote the current element to pointerlock mode
  108274. * @param element defines the DOM element to promote
  108275. */
  108276. static _RequestPointerlock(element: HTMLElement): void;
  108277. /**
  108278. * Asks the browser to exit pointerlock mode
  108279. */
  108280. static _ExitPointerlock(): void;
  108281. /**
  108282. * Ask the browser to promote the current element to fullscreen rendering mode
  108283. * @param element defines the DOM element to promote
  108284. */
  108285. static _RequestFullscreen(element: HTMLElement): void;
  108286. /**
  108287. * Asks the browser to exit fullscreen mode
  108288. */
  108289. static _ExitFullscreen(): void;
  108290. }
  108291. }
  108292. declare module BABYLON {
  108293. /**
  108294. * The engine store class is responsible to hold all the instances of Engine and Scene created
  108295. * during the life time of the application.
  108296. */
  108297. export class EngineStore {
  108298. /** Gets the list of created engines */
  108299. static Instances: Engine[];
  108300. /** @hidden */
  108301. static _LastCreatedScene: Nullable<Scene>;
  108302. /**
  108303. * Gets the latest created engine
  108304. */
  108305. static get LastCreatedEngine(): Nullable<Engine>;
  108306. /**
  108307. * Gets the latest created scene
  108308. */
  108309. static get LastCreatedScene(): Nullable<Scene>;
  108310. /**
  108311. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108312. * @ignorenaming
  108313. */
  108314. static UseFallbackTexture: boolean;
  108315. /**
  108316. * Texture content used if a texture cannot loaded
  108317. * @ignorenaming
  108318. */
  108319. static FallbackTexture: string;
  108320. }
  108321. }
  108322. declare module BABYLON {
  108323. /**
  108324. * Helper class that provides a small promise polyfill
  108325. */
  108326. export class PromisePolyfill {
  108327. /**
  108328. * Static function used to check if the polyfill is required
  108329. * If this is the case then the function will inject the polyfill to window.Promise
  108330. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  108331. */
  108332. static Apply(force?: boolean): void;
  108333. }
  108334. }
  108335. declare module BABYLON {
  108336. /**
  108337. * Interface for screenshot methods with describe argument called `size` as object with options
  108338. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  108339. */
  108340. export interface IScreenshotSize {
  108341. /**
  108342. * number in pixels for canvas height
  108343. */
  108344. height?: number;
  108345. /**
  108346. * multiplier allowing render at a higher or lower resolution
  108347. * If value is defined then height and width will be ignored and taken from camera
  108348. */
  108349. precision?: number;
  108350. /**
  108351. * number in pixels for canvas width
  108352. */
  108353. width?: number;
  108354. }
  108355. }
  108356. declare module BABYLON {
  108357. interface IColor4Like {
  108358. r: float;
  108359. g: float;
  108360. b: float;
  108361. a: float;
  108362. }
  108363. /**
  108364. * Class containing a set of static utilities functions
  108365. */
  108366. export class Tools {
  108367. /**
  108368. * Gets or sets the base URL to use to load assets
  108369. */
  108370. static get BaseUrl(): string;
  108371. static set BaseUrl(value: string);
  108372. /**
  108373. * Enable/Disable Custom HTTP Request Headers globally.
  108374. * default = false
  108375. * @see CustomRequestHeaders
  108376. */
  108377. static UseCustomRequestHeaders: boolean;
  108378. /**
  108379. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  108380. * i.e. when loading files, where the server/service expects an Authorization header
  108381. */
  108382. static CustomRequestHeaders: {
  108383. [key: string]: string;
  108384. };
  108385. /**
  108386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  108387. */
  108388. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  108389. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  108390. /**
  108391. * Default behaviour for cors in the application.
  108392. * It can be a string if the expected behavior is identical in the entire app.
  108393. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  108394. */
  108395. static get CorsBehavior(): string | ((url: string | string[]) => string);
  108396. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  108397. /**
  108398. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108399. * @ignorenaming
  108400. */
  108401. static get UseFallbackTexture(): boolean;
  108402. static set UseFallbackTexture(value: boolean);
  108403. /**
  108404. * Use this object to register external classes like custom textures or material
  108405. * to allow the laoders to instantiate them
  108406. */
  108407. static get RegisteredExternalClasses(): {
  108408. [key: string]: Object;
  108409. };
  108410. static set RegisteredExternalClasses(classes: {
  108411. [key: string]: Object;
  108412. });
  108413. /**
  108414. * Texture content used if a texture cannot loaded
  108415. * @ignorenaming
  108416. */
  108417. static get fallbackTexture(): string;
  108418. static set fallbackTexture(value: string);
  108419. /**
  108420. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  108421. * @param u defines the coordinate on X axis
  108422. * @param v defines the coordinate on Y axis
  108423. * @param width defines the width of the source data
  108424. * @param height defines the height of the source data
  108425. * @param pixels defines the source byte array
  108426. * @param color defines the output color
  108427. */
  108428. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  108429. /**
  108430. * Interpolates between a and b via alpha
  108431. * @param a The lower value (returned when alpha = 0)
  108432. * @param b The upper value (returned when alpha = 1)
  108433. * @param alpha The interpolation-factor
  108434. * @return The mixed value
  108435. */
  108436. static Mix(a: number, b: number, alpha: number): number;
  108437. /**
  108438. * Tries to instantiate a new object from a given class name
  108439. * @param className defines the class name to instantiate
  108440. * @returns the new object or null if the system was not able to do the instantiation
  108441. */
  108442. static Instantiate(className: string): any;
  108443. /**
  108444. * Provides a slice function that will work even on IE
  108445. * @param data defines the array to slice
  108446. * @param start defines the start of the data (optional)
  108447. * @param end defines the end of the data (optional)
  108448. * @returns the new sliced array
  108449. */
  108450. static Slice<T>(data: T, start?: number, end?: number): T;
  108451. /**
  108452. * Polyfill for setImmediate
  108453. * @param action defines the action to execute after the current execution block
  108454. */
  108455. static SetImmediate(action: () => void): void;
  108456. /**
  108457. * Function indicating if a number is an exponent of 2
  108458. * @param value defines the value to test
  108459. * @returns true if the value is an exponent of 2
  108460. */
  108461. static IsExponentOfTwo(value: number): boolean;
  108462. private static _tmpFloatArray;
  108463. /**
  108464. * Returns the nearest 32-bit single precision float representation of a Number
  108465. * @param value A Number. If the parameter is of a different type, it will get converted
  108466. * to a number or to NaN if it cannot be converted
  108467. * @returns number
  108468. */
  108469. static FloatRound(value: number): number;
  108470. /**
  108471. * Extracts the filename from a path
  108472. * @param path defines the path to use
  108473. * @returns the filename
  108474. */
  108475. static GetFilename(path: string): string;
  108476. /**
  108477. * Extracts the "folder" part of a path (everything before the filename).
  108478. * @param uri The URI to extract the info from
  108479. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  108480. * @returns The "folder" part of the path
  108481. */
  108482. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  108483. /**
  108484. * Extracts text content from a DOM element hierarchy
  108485. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  108486. */
  108487. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  108488. /**
  108489. * Convert an angle in radians to degrees
  108490. * @param angle defines the angle to convert
  108491. * @returns the angle in degrees
  108492. */
  108493. static ToDegrees(angle: number): number;
  108494. /**
  108495. * Convert an angle in degrees to radians
  108496. * @param angle defines the angle to convert
  108497. * @returns the angle in radians
  108498. */
  108499. static ToRadians(angle: number): number;
  108500. /**
  108501. * Returns an array if obj is not an array
  108502. * @param obj defines the object to evaluate as an array
  108503. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  108504. * @returns either obj directly if obj is an array or a new array containing obj
  108505. */
  108506. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  108507. /**
  108508. * Gets the pointer prefix to use
  108509. * @returns "pointer" if touch is enabled. Else returns "mouse"
  108510. */
  108511. static GetPointerPrefix(): string;
  108512. /**
  108513. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  108514. * @param url define the url we are trying
  108515. * @param element define the dom element where to configure the cors policy
  108516. */
  108517. static SetCorsBehavior(url: string | string[], element: {
  108518. crossOrigin: string | null;
  108519. }): void;
  108520. /**
  108521. * Removes unwanted characters from an url
  108522. * @param url defines the url to clean
  108523. * @returns the cleaned url
  108524. */
  108525. static CleanUrl(url: string): string;
  108526. /**
  108527. * Gets or sets a function used to pre-process url before using them to load assets
  108528. */
  108529. static get PreprocessUrl(): (url: string) => string;
  108530. static set PreprocessUrl(processor: (url: string) => string);
  108531. /**
  108532. * Loads an image as an HTMLImageElement.
  108533. * @param input url string, ArrayBuffer, or Blob to load
  108534. * @param onLoad callback called when the image successfully loads
  108535. * @param onError callback called when the image fails to load
  108536. * @param offlineProvider offline provider for caching
  108537. * @param mimeType optional mime type
  108538. * @returns the HTMLImageElement of the loaded image
  108539. */
  108540. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  108541. /**
  108542. * Loads a file from a url
  108543. * @param url url string, ArrayBuffer, or Blob to load
  108544. * @param onSuccess callback called when the file successfully loads
  108545. * @param onProgress callback called while file is loading (if the server supports this mode)
  108546. * @param offlineProvider defines the offline provider for caching
  108547. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108548. * @param onError callback called when the file fails to load
  108549. * @returns a file request object
  108550. */
  108551. 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;
  108552. /**
  108553. * Loads a file from a url
  108554. * @param url the file url to load
  108555. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108556. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  108557. */
  108558. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  108559. /**
  108560. * Load a script (identified by an url). When the url returns, the
  108561. * content of this file is added into a new script element, attached to the DOM (body element)
  108562. * @param scriptUrl defines the url of the script to laod
  108563. * @param onSuccess defines the callback called when the script is loaded
  108564. * @param onError defines the callback to call if an error occurs
  108565. * @param scriptId defines the id of the script element
  108566. */
  108567. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  108568. /**
  108569. * Load an asynchronous script (identified by an url). When the url returns, the
  108570. * content of this file is added into a new script element, attached to the DOM (body element)
  108571. * @param scriptUrl defines the url of the script to laod
  108572. * @param scriptId defines the id of the script element
  108573. * @returns a promise request object
  108574. */
  108575. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  108576. /**
  108577. * Loads a file from a blob
  108578. * @param fileToLoad defines the blob to use
  108579. * @param callback defines the callback to call when data is loaded
  108580. * @param progressCallback defines the callback to call during loading process
  108581. * @returns a file request object
  108582. */
  108583. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  108584. /**
  108585. * Reads a file from a File object
  108586. * @param file defines the file to load
  108587. * @param onSuccess defines the callback to call when data is loaded
  108588. * @param onProgress defines the callback to call during loading process
  108589. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  108590. * @param onError defines the callback to call when an error occurs
  108591. * @returns a file request object
  108592. */
  108593. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108594. /**
  108595. * Creates a data url from a given string content
  108596. * @param content defines the content to convert
  108597. * @returns the new data url link
  108598. */
  108599. static FileAsURL(content: string): string;
  108600. /**
  108601. * Format the given number to a specific decimal format
  108602. * @param value defines the number to format
  108603. * @param decimals defines the number of decimals to use
  108604. * @returns the formatted string
  108605. */
  108606. static Format(value: number, decimals?: number): string;
  108607. /**
  108608. * Tries to copy an object by duplicating every property
  108609. * @param source defines the source object
  108610. * @param destination defines the target object
  108611. * @param doNotCopyList defines a list of properties to avoid
  108612. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  108613. */
  108614. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  108615. /**
  108616. * Gets a boolean indicating if the given object has no own property
  108617. * @param obj defines the object to test
  108618. * @returns true if object has no own property
  108619. */
  108620. static IsEmpty(obj: any): boolean;
  108621. /**
  108622. * Function used to register events at window level
  108623. * @param windowElement defines the Window object to use
  108624. * @param events defines the events to register
  108625. */
  108626. static RegisterTopRootEvents(windowElement: Window, events: {
  108627. name: string;
  108628. handler: Nullable<(e: FocusEvent) => any>;
  108629. }[]): void;
  108630. /**
  108631. * Function used to unregister events from window level
  108632. * @param windowElement defines the Window object to use
  108633. * @param events defines the events to unregister
  108634. */
  108635. static UnregisterTopRootEvents(windowElement: Window, events: {
  108636. name: string;
  108637. handler: Nullable<(e: FocusEvent) => any>;
  108638. }[]): void;
  108639. /**
  108640. * @ignore
  108641. */
  108642. static _ScreenshotCanvas: HTMLCanvasElement;
  108643. /**
  108644. * Dumps the current bound framebuffer
  108645. * @param width defines the rendering width
  108646. * @param height defines the rendering height
  108647. * @param engine defines the hosting engine
  108648. * @param successCallback defines the callback triggered once the data are available
  108649. * @param mimeType defines the mime type of the result
  108650. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  108651. */
  108652. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108653. /**
  108654. * Converts the canvas data to blob.
  108655. * This acts as a polyfill for browsers not supporting the to blob function.
  108656. * @param canvas Defines the canvas to extract the data from
  108657. * @param successCallback Defines the callback triggered once the data are available
  108658. * @param mimeType Defines the mime type of the result
  108659. */
  108660. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  108661. /**
  108662. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  108663. * @param successCallback defines the callback triggered once the data are available
  108664. * @param mimeType defines the mime type of the result
  108665. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  108666. */
  108667. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108668. /**
  108669. * Downloads a blob in the browser
  108670. * @param blob defines the blob to download
  108671. * @param fileName defines the name of the downloaded file
  108672. */
  108673. static Download(blob: Blob, fileName: string): void;
  108674. /**
  108675. * Captures a screenshot of the current rendering
  108676. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108677. * @param engine defines the rendering engine
  108678. * @param camera defines the source camera
  108679. * @param size This parameter can be set to a single number or to an object with the
  108680. * following (optional) properties: precision, width, height. If a single number is passed,
  108681. * it will be used for both width and height. If an object is passed, the screenshot size
  108682. * will be derived from the parameters. The precision property is a multiplier allowing
  108683. * rendering at a higher or lower resolution
  108684. * @param successCallback defines the callback receives a single parameter which contains the
  108685. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108686. * src parameter of an <img> to display it
  108687. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108688. * Check your browser for supported MIME types
  108689. */
  108690. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  108691. /**
  108692. * Captures a screenshot of the current rendering
  108693. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108694. * @param engine defines the rendering engine
  108695. * @param camera defines the source camera
  108696. * @param size This parameter can be set to a single number or to an object with the
  108697. * following (optional) properties: precision, width, height. If a single number is passed,
  108698. * it will be used for both width and height. If an object is passed, the screenshot size
  108699. * will be derived from the parameters. The precision property is a multiplier allowing
  108700. * rendering at a higher or lower resolution
  108701. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108702. * Check your browser for supported MIME types
  108703. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108704. * to the src parameter of an <img> to display it
  108705. */
  108706. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  108707. /**
  108708. * Generates an image screenshot from the specified camera.
  108709. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108710. * @param engine The engine to use for rendering
  108711. * @param camera The camera to use for rendering
  108712. * @param size This parameter can be set to a single number or to an object with the
  108713. * following (optional) properties: precision, width, height. If a single number is passed,
  108714. * it will be used for both width and height. If an object is passed, the screenshot size
  108715. * will be derived from the parameters. The precision property is a multiplier allowing
  108716. * rendering at a higher or lower resolution
  108717. * @param successCallback The callback receives a single parameter which contains the
  108718. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108719. * src parameter of an <img> to display it
  108720. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108721. * Check your browser for supported MIME types
  108722. * @param samples Texture samples (default: 1)
  108723. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108724. * @param fileName A name for for the downloaded file.
  108725. */
  108726. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108727. /**
  108728. * Generates an image screenshot from the specified camera.
  108729. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108730. * @param engine The engine to use for rendering
  108731. * @param camera The camera to use for rendering
  108732. * @param size This parameter can be set to a single number or to an object with the
  108733. * following (optional) properties: precision, width, height. If a single number is passed,
  108734. * it will be used for both width and height. If an object is passed, the screenshot size
  108735. * will be derived from the parameters. The precision property is a multiplier allowing
  108736. * rendering at a higher or lower resolution
  108737. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108738. * Check your browser for supported MIME types
  108739. * @param samples Texture samples (default: 1)
  108740. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108741. * @param fileName A name for for the downloaded file.
  108742. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108743. * to the src parameter of an <img> to display it
  108744. */
  108745. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108746. /**
  108747. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108748. * Be aware Math.random() could cause collisions, but:
  108749. * "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"
  108750. * @returns a pseudo random id
  108751. */
  108752. static RandomId(): string;
  108753. /**
  108754. * Test if the given uri is a base64 string
  108755. * @param uri The uri to test
  108756. * @return True if the uri is a base64 string or false otherwise
  108757. */
  108758. static IsBase64(uri: string): boolean;
  108759. /**
  108760. * Decode the given base64 uri.
  108761. * @param uri The uri to decode
  108762. * @return The decoded base64 data.
  108763. */
  108764. static DecodeBase64(uri: string): ArrayBuffer;
  108765. /**
  108766. * Gets the absolute url.
  108767. * @param url the input url
  108768. * @return the absolute url
  108769. */
  108770. static GetAbsoluteUrl(url: string): string;
  108771. /**
  108772. * No log
  108773. */
  108774. static readonly NoneLogLevel: number;
  108775. /**
  108776. * Only message logs
  108777. */
  108778. static readonly MessageLogLevel: number;
  108779. /**
  108780. * Only warning logs
  108781. */
  108782. static readonly WarningLogLevel: number;
  108783. /**
  108784. * Only error logs
  108785. */
  108786. static readonly ErrorLogLevel: number;
  108787. /**
  108788. * All logs
  108789. */
  108790. static readonly AllLogLevel: number;
  108791. /**
  108792. * Gets a value indicating the number of loading errors
  108793. * @ignorenaming
  108794. */
  108795. static get errorsCount(): number;
  108796. /**
  108797. * Callback called when a new log is added
  108798. */
  108799. static OnNewCacheEntry: (entry: string) => void;
  108800. /**
  108801. * Log a message to the console
  108802. * @param message defines the message to log
  108803. */
  108804. static Log(message: string): void;
  108805. /**
  108806. * Write a warning message to the console
  108807. * @param message defines the message to log
  108808. */
  108809. static Warn(message: string): void;
  108810. /**
  108811. * Write an error message to the console
  108812. * @param message defines the message to log
  108813. */
  108814. static Error(message: string): void;
  108815. /**
  108816. * Gets current log cache (list of logs)
  108817. */
  108818. static get LogCache(): string;
  108819. /**
  108820. * Clears the log cache
  108821. */
  108822. static ClearLogCache(): void;
  108823. /**
  108824. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  108825. */
  108826. static set LogLevels(level: number);
  108827. /**
  108828. * Checks if the window object exists
  108829. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  108830. */
  108831. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  108832. /**
  108833. * No performance log
  108834. */
  108835. static readonly PerformanceNoneLogLevel: number;
  108836. /**
  108837. * Use user marks to log performance
  108838. */
  108839. static readonly PerformanceUserMarkLogLevel: number;
  108840. /**
  108841. * Log performance to the console
  108842. */
  108843. static readonly PerformanceConsoleLogLevel: number;
  108844. private static _performance;
  108845. /**
  108846. * Sets the current performance log level
  108847. */
  108848. static set PerformanceLogLevel(level: number);
  108849. private static _StartPerformanceCounterDisabled;
  108850. private static _EndPerformanceCounterDisabled;
  108851. private static _StartUserMark;
  108852. private static _EndUserMark;
  108853. private static _StartPerformanceConsole;
  108854. private static _EndPerformanceConsole;
  108855. /**
  108856. * Starts a performance counter
  108857. */
  108858. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  108859. /**
  108860. * Ends a specific performance coutner
  108861. */
  108862. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  108863. /**
  108864. * Gets either window.performance.now() if supported or Date.now() else
  108865. */
  108866. static get Now(): number;
  108867. /**
  108868. * This method will return the name of the class used to create the instance of the given object.
  108869. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  108870. * @param object the object to get the class name from
  108871. * @param isType defines if the object is actually a type
  108872. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  108873. */
  108874. static GetClassName(object: any, isType?: boolean): string;
  108875. /**
  108876. * Gets the first element of an array satisfying a given predicate
  108877. * @param array defines the array to browse
  108878. * @param predicate defines the predicate to use
  108879. * @returns null if not found or the element
  108880. */
  108881. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  108882. /**
  108883. * This method will return the name of the full name of the class, including its owning module (if any).
  108884. * 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).
  108885. * @param object the object to get the class name from
  108886. * @param isType defines if the object is actually a type
  108887. * @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.
  108888. * @ignorenaming
  108889. */
  108890. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  108891. /**
  108892. * Returns a promise that resolves after the given amount of time.
  108893. * @param delay Number of milliseconds to delay
  108894. * @returns Promise that resolves after the given amount of time
  108895. */
  108896. static DelayAsync(delay: number): Promise<void>;
  108897. /**
  108898. * Utility function to detect if the current user agent is Safari
  108899. * @returns whether or not the current user agent is safari
  108900. */
  108901. static IsSafari(): boolean;
  108902. }
  108903. /**
  108904. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  108905. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  108906. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  108907. * @param name The name of the class, case should be preserved
  108908. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  108909. */
  108910. export function className(name: string, module?: string): (target: Object) => void;
  108911. /**
  108912. * An implementation of a loop for asynchronous functions.
  108913. */
  108914. export class AsyncLoop {
  108915. /**
  108916. * Defines the number of iterations for the loop
  108917. */
  108918. iterations: number;
  108919. /**
  108920. * Defines the current index of the loop.
  108921. */
  108922. index: number;
  108923. private _done;
  108924. private _fn;
  108925. private _successCallback;
  108926. /**
  108927. * Constructor.
  108928. * @param iterations the number of iterations.
  108929. * @param func the function to run each iteration
  108930. * @param successCallback the callback that will be called upon succesful execution
  108931. * @param offset starting offset.
  108932. */
  108933. constructor(
  108934. /**
  108935. * Defines the number of iterations for the loop
  108936. */
  108937. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  108938. /**
  108939. * Execute the next iteration. Must be called after the last iteration was finished.
  108940. */
  108941. executeNext(): void;
  108942. /**
  108943. * Break the loop and run the success callback.
  108944. */
  108945. breakLoop(): void;
  108946. /**
  108947. * Create and run an async loop.
  108948. * @param iterations the number of iterations.
  108949. * @param fn the function to run each iteration
  108950. * @param successCallback the callback that will be called upon succesful execution
  108951. * @param offset starting offset.
  108952. * @returns the created async loop object
  108953. */
  108954. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  108955. /**
  108956. * A for-loop that will run a given number of iterations synchronous and the rest async.
  108957. * @param iterations total number of iterations
  108958. * @param syncedIterations number of synchronous iterations in each async iteration.
  108959. * @param fn the function to call each iteration.
  108960. * @param callback a success call back that will be called when iterating stops.
  108961. * @param breakFunction a break condition (optional)
  108962. * @param timeout timeout settings for the setTimeout function. default - 0.
  108963. * @returns the created async loop object
  108964. */
  108965. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  108966. }
  108967. }
  108968. declare module BABYLON {
  108969. /**
  108970. * This class implement a typical dictionary using a string as key and the generic type T as value.
  108971. * The underlying implementation relies on an associative array to ensure the best performances.
  108972. * The value can be anything including 'null' but except 'undefined'
  108973. */
  108974. export class StringDictionary<T> {
  108975. /**
  108976. * This will clear this dictionary and copy the content from the 'source' one.
  108977. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  108978. * @param source the dictionary to take the content from and copy to this dictionary
  108979. */
  108980. copyFrom(source: StringDictionary<T>): void;
  108981. /**
  108982. * Get a value based from its key
  108983. * @param key the given key to get the matching value from
  108984. * @return the value if found, otherwise undefined is returned
  108985. */
  108986. get(key: string): T | undefined;
  108987. /**
  108988. * Get a value from its key or add it if it doesn't exist.
  108989. * This method will ensure you that a given key/data will be present in the dictionary.
  108990. * @param key the given key to get the matching value from
  108991. * @param factory the factory that will create the value if the key is not present in the dictionary.
  108992. * The factory will only be invoked if there's no data for the given key.
  108993. * @return the value corresponding to the key.
  108994. */
  108995. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  108996. /**
  108997. * Get a value from its key if present in the dictionary otherwise add it
  108998. * @param key the key to get the value from
  108999. * @param val if there's no such key/value pair in the dictionary add it with this value
  109000. * @return the value corresponding to the key
  109001. */
  109002. getOrAdd(key: string, val: T): T;
  109003. /**
  109004. * Check if there's a given key in the dictionary
  109005. * @param key the key to check for
  109006. * @return true if the key is present, false otherwise
  109007. */
  109008. contains(key: string): boolean;
  109009. /**
  109010. * Add a new key and its corresponding value
  109011. * @param key the key to add
  109012. * @param value the value corresponding to the key
  109013. * @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
  109014. */
  109015. add(key: string, value: T): boolean;
  109016. /**
  109017. * Update a specific value associated to a key
  109018. * @param key defines the key to use
  109019. * @param value defines the value to store
  109020. * @returns true if the value was updated (or false if the key was not found)
  109021. */
  109022. set(key: string, value: T): boolean;
  109023. /**
  109024. * Get the element of the given key and remove it from the dictionary
  109025. * @param key defines the key to search
  109026. * @returns the value associated with the key or null if not found
  109027. */
  109028. getAndRemove(key: string): Nullable<T>;
  109029. /**
  109030. * Remove a key/value from the dictionary.
  109031. * @param key the key to remove
  109032. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  109033. */
  109034. remove(key: string): boolean;
  109035. /**
  109036. * Clear the whole content of the dictionary
  109037. */
  109038. clear(): void;
  109039. /**
  109040. * Gets the current count
  109041. */
  109042. get count(): number;
  109043. /**
  109044. * Execute a callback on each key/val of the dictionary.
  109045. * Note that you can remove any element in this dictionary in the callback implementation
  109046. * @param callback the callback to execute on a given key/value pair
  109047. */
  109048. forEach(callback: (key: string, val: T) => void): void;
  109049. /**
  109050. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  109051. * If the callback returns null or undefined the method will iterate to the next key/value pair
  109052. * Note that you can remove any element in this dictionary in the callback implementation
  109053. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  109054. * @returns the first item
  109055. */
  109056. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  109057. private _count;
  109058. private _data;
  109059. }
  109060. }
  109061. declare module BABYLON {
  109062. /** @hidden */
  109063. export interface ICollisionCoordinator {
  109064. createCollider(): Collider;
  109065. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109066. init(scene: Scene): void;
  109067. }
  109068. /** @hidden */
  109069. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  109070. private _scene;
  109071. private _scaledPosition;
  109072. private _scaledVelocity;
  109073. private _finalPosition;
  109074. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109075. createCollider(): Collider;
  109076. init(scene: Scene): void;
  109077. private _collideWithWorld;
  109078. }
  109079. }
  109080. declare module BABYLON {
  109081. /**
  109082. * Class used to manage all inputs for the scene.
  109083. */
  109084. export class InputManager {
  109085. /** The distance in pixel that you have to move to prevent some events */
  109086. static DragMovementThreshold: number;
  109087. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  109088. static LongPressDelay: number;
  109089. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  109090. static DoubleClickDelay: number;
  109091. /** If you need to check double click without raising a single click at first click, enable this flag */
  109092. static ExclusiveDoubleClickMode: boolean;
  109093. private _wheelEventName;
  109094. private _onPointerMove;
  109095. private _onPointerDown;
  109096. private _onPointerUp;
  109097. private _initClickEvent;
  109098. private _initActionManager;
  109099. private _delayedSimpleClick;
  109100. private _delayedSimpleClickTimeout;
  109101. private _previousDelayedSimpleClickTimeout;
  109102. private _meshPickProceed;
  109103. private _previousButtonPressed;
  109104. private _currentPickResult;
  109105. private _previousPickResult;
  109106. private _totalPointersPressed;
  109107. private _doubleClickOccured;
  109108. private _pointerOverMesh;
  109109. private _pickedDownMesh;
  109110. private _pickedUpMesh;
  109111. private _pointerX;
  109112. private _pointerY;
  109113. private _unTranslatedPointerX;
  109114. private _unTranslatedPointerY;
  109115. private _startingPointerPosition;
  109116. private _previousStartingPointerPosition;
  109117. private _startingPointerTime;
  109118. private _previousStartingPointerTime;
  109119. private _pointerCaptures;
  109120. private _onKeyDown;
  109121. private _onKeyUp;
  109122. private _onCanvasFocusObserver;
  109123. private _onCanvasBlurObserver;
  109124. private _scene;
  109125. /**
  109126. * Creates a new InputManager
  109127. * @param scene defines the hosting scene
  109128. */
  109129. constructor(scene: Scene);
  109130. /**
  109131. * Gets the mesh that is currently under the pointer
  109132. */
  109133. get meshUnderPointer(): Nullable<AbstractMesh>;
  109134. /**
  109135. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  109136. */
  109137. get unTranslatedPointer(): Vector2;
  109138. /**
  109139. * Gets or sets the current on-screen X position of the pointer
  109140. */
  109141. get pointerX(): number;
  109142. set pointerX(value: number);
  109143. /**
  109144. * Gets or sets the current on-screen Y position of the pointer
  109145. */
  109146. get pointerY(): number;
  109147. set pointerY(value: number);
  109148. private _updatePointerPosition;
  109149. private _processPointerMove;
  109150. private _setRayOnPointerInfo;
  109151. private _checkPrePointerObservable;
  109152. /**
  109153. * Use this method to simulate a pointer move on a mesh
  109154. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109155. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109156. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109157. */
  109158. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109159. /**
  109160. * Use this method to simulate a pointer down on a mesh
  109161. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109162. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109163. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109164. */
  109165. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109166. private _processPointerDown;
  109167. /** @hidden */
  109168. _isPointerSwiping(): boolean;
  109169. /**
  109170. * Use this method to simulate a pointer up on a mesh
  109171. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109172. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109173. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109174. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109175. */
  109176. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  109177. private _processPointerUp;
  109178. /**
  109179. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109180. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109181. * @returns true if the pointer was captured
  109182. */
  109183. isPointerCaptured(pointerId?: number): boolean;
  109184. /**
  109185. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109186. * @param attachUp defines if you want to attach events to pointerup
  109187. * @param attachDown defines if you want to attach events to pointerdown
  109188. * @param attachMove defines if you want to attach events to pointermove
  109189. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  109190. */
  109191. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  109192. /**
  109193. * Detaches all event handlers
  109194. */
  109195. detachControl(): void;
  109196. /**
  109197. * Force the value of meshUnderPointer
  109198. * @param mesh defines the mesh to use
  109199. */
  109200. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109201. /**
  109202. * Gets the mesh under the pointer
  109203. * @returns a Mesh or null if no mesh is under the pointer
  109204. */
  109205. getPointerOverMesh(): Nullable<AbstractMesh>;
  109206. }
  109207. }
  109208. declare module BABYLON {
  109209. /**
  109210. * Helper class used to generate session unique ID
  109211. */
  109212. export class UniqueIdGenerator {
  109213. private static _UniqueIdCounter;
  109214. /**
  109215. * Gets an unique (relatively to the current scene) Id
  109216. */
  109217. static get UniqueId(): number;
  109218. }
  109219. }
  109220. declare module BABYLON {
  109221. /**
  109222. * This class defines the direct association between an animation and a target
  109223. */
  109224. export class TargetedAnimation {
  109225. /**
  109226. * Animation to perform
  109227. */
  109228. animation: Animation;
  109229. /**
  109230. * Target to animate
  109231. */
  109232. target: any;
  109233. /**
  109234. * Serialize the object
  109235. * @returns the JSON object representing the current entity
  109236. */
  109237. serialize(): any;
  109238. }
  109239. /**
  109240. * Use this class to create coordinated animations on multiple targets
  109241. */
  109242. export class AnimationGroup implements IDisposable {
  109243. /** The name of the animation group */
  109244. name: string;
  109245. private _scene;
  109246. private _targetedAnimations;
  109247. private _animatables;
  109248. private _from;
  109249. private _to;
  109250. private _isStarted;
  109251. private _isPaused;
  109252. private _speedRatio;
  109253. private _loopAnimation;
  109254. private _isAdditive;
  109255. /**
  109256. * Gets or sets the unique id of the node
  109257. */
  109258. uniqueId: number;
  109259. /**
  109260. * This observable will notify when one animation have ended
  109261. */
  109262. onAnimationEndObservable: Observable<TargetedAnimation>;
  109263. /**
  109264. * Observer raised when one animation loops
  109265. */
  109266. onAnimationLoopObservable: Observable<TargetedAnimation>;
  109267. /**
  109268. * Observer raised when all animations have looped
  109269. */
  109270. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  109271. /**
  109272. * This observable will notify when all animations have ended.
  109273. */
  109274. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  109275. /**
  109276. * This observable will notify when all animations have paused.
  109277. */
  109278. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  109279. /**
  109280. * This observable will notify when all animations are playing.
  109281. */
  109282. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  109283. /**
  109284. * Gets the first frame
  109285. */
  109286. get from(): number;
  109287. /**
  109288. * Gets the last frame
  109289. */
  109290. get to(): number;
  109291. /**
  109292. * Define if the animations are started
  109293. */
  109294. get isStarted(): boolean;
  109295. /**
  109296. * Gets a value indicating that the current group is playing
  109297. */
  109298. get isPlaying(): boolean;
  109299. /**
  109300. * Gets or sets the speed ratio to use for all animations
  109301. */
  109302. get speedRatio(): number;
  109303. /**
  109304. * Gets or sets the speed ratio to use for all animations
  109305. */
  109306. set speedRatio(value: number);
  109307. /**
  109308. * Gets or sets if all animations should loop or not
  109309. */
  109310. get loopAnimation(): boolean;
  109311. set loopAnimation(value: boolean);
  109312. /**
  109313. * Gets or sets if all animations should be evaluated additively
  109314. */
  109315. get isAdditive(): boolean;
  109316. set isAdditive(value: boolean);
  109317. /**
  109318. * Gets the targeted animations for this animation group
  109319. */
  109320. get targetedAnimations(): Array<TargetedAnimation>;
  109321. /**
  109322. * returning the list of animatables controlled by this animation group.
  109323. */
  109324. get animatables(): Array<Animatable>;
  109325. /**
  109326. * Instantiates a new Animation Group.
  109327. * This helps managing several animations at once.
  109328. * @see http://doc.babylonjs.com/how_to/group
  109329. * @param name Defines the name of the group
  109330. * @param scene Defines the scene the group belongs to
  109331. */
  109332. constructor(
  109333. /** The name of the animation group */
  109334. name: string, scene?: Nullable<Scene>);
  109335. /**
  109336. * Add an animation (with its target) in the group
  109337. * @param animation defines the animation we want to add
  109338. * @param target defines the target of the animation
  109339. * @returns the TargetedAnimation object
  109340. */
  109341. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  109342. /**
  109343. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  109344. * It can add constant keys at begin or end
  109345. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  109346. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  109347. * @returns the animation group
  109348. */
  109349. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  109350. private _animationLoopCount;
  109351. private _animationLoopFlags;
  109352. private _processLoop;
  109353. /**
  109354. * Start all animations on given targets
  109355. * @param loop defines if animations must loop
  109356. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  109357. * @param from defines the from key (optional)
  109358. * @param to defines the to key (optional)
  109359. * @param isAdditive defines the additive state for the resulting animatables (optional)
  109360. * @returns the current animation group
  109361. */
  109362. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  109363. /**
  109364. * Pause all animations
  109365. * @returns the animation group
  109366. */
  109367. pause(): AnimationGroup;
  109368. /**
  109369. * Play all animations to initial state
  109370. * This function will start() the animations if they were not started or will restart() them if they were paused
  109371. * @param loop defines if animations must loop
  109372. * @returns the animation group
  109373. */
  109374. play(loop?: boolean): AnimationGroup;
  109375. /**
  109376. * Reset all animations to initial state
  109377. * @returns the animation group
  109378. */
  109379. reset(): AnimationGroup;
  109380. /**
  109381. * Restart animations from key 0
  109382. * @returns the animation group
  109383. */
  109384. restart(): AnimationGroup;
  109385. /**
  109386. * Stop all animations
  109387. * @returns the animation group
  109388. */
  109389. stop(): AnimationGroup;
  109390. /**
  109391. * Set animation weight for all animatables
  109392. * @param weight defines the weight to use
  109393. * @return the animationGroup
  109394. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109395. */
  109396. setWeightForAllAnimatables(weight: number): AnimationGroup;
  109397. /**
  109398. * Synchronize and normalize all animatables with a source animatable
  109399. * @param root defines the root animatable to synchronize with
  109400. * @return the animationGroup
  109401. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109402. */
  109403. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  109404. /**
  109405. * Goes to a specific frame in this animation group
  109406. * @param frame the frame number to go to
  109407. * @return the animationGroup
  109408. */
  109409. goToFrame(frame: number): AnimationGroup;
  109410. /**
  109411. * Dispose all associated resources
  109412. */
  109413. dispose(): void;
  109414. private _checkAnimationGroupEnded;
  109415. /**
  109416. * Clone the current animation group and returns a copy
  109417. * @param newName defines the name of the new group
  109418. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  109419. * @returns the new aniamtion group
  109420. */
  109421. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  109422. /**
  109423. * Serializes the animationGroup to an object
  109424. * @returns Serialized object
  109425. */
  109426. serialize(): any;
  109427. /**
  109428. * Returns a new AnimationGroup object parsed from the source provided.
  109429. * @param parsedAnimationGroup defines the source
  109430. * @param scene defines the scene that will receive the animationGroup
  109431. * @returns a new AnimationGroup
  109432. */
  109433. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  109434. /**
  109435. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109436. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  109437. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109438. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  109439. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  109440. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  109441. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  109442. */
  109443. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  109444. /**
  109445. * Returns the string "AnimationGroup"
  109446. * @returns "AnimationGroup"
  109447. */
  109448. getClassName(): string;
  109449. /**
  109450. * Creates a detailled string about the object
  109451. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  109452. * @returns a string representing the object
  109453. */
  109454. toString(fullDetails?: boolean): string;
  109455. }
  109456. }
  109457. declare module BABYLON {
  109458. /**
  109459. * Define an interface for all classes that will hold resources
  109460. */
  109461. export interface IDisposable {
  109462. /**
  109463. * Releases all held resources
  109464. */
  109465. dispose(): void;
  109466. }
  109467. /** Interface defining initialization parameters for Scene class */
  109468. export interface SceneOptions {
  109469. /**
  109470. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  109471. * It will improve performance when the number of geometries becomes important.
  109472. */
  109473. useGeometryUniqueIdsMap?: boolean;
  109474. /**
  109475. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  109476. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109477. */
  109478. useMaterialMeshMap?: boolean;
  109479. /**
  109480. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  109481. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109482. */
  109483. useClonedMeshMap?: boolean;
  109484. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  109485. virtual?: boolean;
  109486. }
  109487. /**
  109488. * Represents a scene to be rendered by the engine.
  109489. * @see http://doc.babylonjs.com/features/scene
  109490. */
  109491. export class Scene extends AbstractScene implements IAnimatable {
  109492. /** The fog is deactivated */
  109493. static readonly FOGMODE_NONE: number;
  109494. /** The fog density is following an exponential function */
  109495. static readonly FOGMODE_EXP: number;
  109496. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  109497. static readonly FOGMODE_EXP2: number;
  109498. /** The fog density is following a linear function. */
  109499. static readonly FOGMODE_LINEAR: number;
  109500. /**
  109501. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  109502. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109503. */
  109504. static MinDeltaTime: number;
  109505. /**
  109506. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  109507. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109508. */
  109509. static MaxDeltaTime: number;
  109510. /**
  109511. * Factory used to create the default material.
  109512. * @param name The name of the material to create
  109513. * @param scene The scene to create the material for
  109514. * @returns The default material
  109515. */
  109516. static DefaultMaterialFactory(scene: Scene): Material;
  109517. /**
  109518. * Factory used to create the a collision coordinator.
  109519. * @returns The collision coordinator
  109520. */
  109521. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  109522. /** @hidden */
  109523. _inputManager: InputManager;
  109524. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  109525. cameraToUseForPointers: Nullable<Camera>;
  109526. /** @hidden */
  109527. readonly _isScene: boolean;
  109528. /** @hidden */
  109529. _blockEntityCollection: boolean;
  109530. /**
  109531. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  109532. */
  109533. autoClear: boolean;
  109534. /**
  109535. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  109536. */
  109537. autoClearDepthAndStencil: boolean;
  109538. /**
  109539. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  109540. */
  109541. clearColor: Color4;
  109542. /**
  109543. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  109544. */
  109545. ambientColor: Color3;
  109546. /**
  109547. * This is use to store the default BRDF lookup for PBR materials in your scene.
  109548. * It should only be one of the following (if not the default embedded one):
  109549. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109550. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  109551. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109552. * The material properties need to be setup according to the type of texture in use.
  109553. */
  109554. environmentBRDFTexture: BaseTexture;
  109555. /** @hidden */
  109556. protected _environmentTexture: Nullable<BaseTexture>;
  109557. /**
  109558. * Texture used in all pbr material as the reflection texture.
  109559. * As in the majority of the scene they are the same (exception for multi room and so on),
  109560. * this is easier to reference from here than from all the materials.
  109561. */
  109562. get environmentTexture(): Nullable<BaseTexture>;
  109563. /**
  109564. * Texture used in all pbr material as the reflection texture.
  109565. * As in the majority of the scene they are the same (exception for multi room and so on),
  109566. * this is easier to set here than in all the materials.
  109567. */
  109568. set environmentTexture(value: Nullable<BaseTexture>);
  109569. /** @hidden */
  109570. protected _environmentIntensity: number;
  109571. /**
  109572. * Intensity of the environment in all pbr material.
  109573. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109574. * As in the majority of the scene they are the same (exception for multi room and so on),
  109575. * this is easier to reference from here than from all the materials.
  109576. */
  109577. get environmentIntensity(): number;
  109578. /**
  109579. * Intensity of the environment in all pbr material.
  109580. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109581. * As in the majority of the scene they are the same (exception for multi room and so on),
  109582. * this is easier to set here than in all the materials.
  109583. */
  109584. set environmentIntensity(value: number);
  109585. /** @hidden */
  109586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109587. /**
  109588. * Default image processing configuration used either in the rendering
  109589. * Forward main pass or through the imageProcessingPostProcess if present.
  109590. * As in the majority of the scene they are the same (exception for multi camera),
  109591. * this is easier to reference from here than from all the materials and post process.
  109592. *
  109593. * No setter as we it is a shared configuration, you can set the values instead.
  109594. */
  109595. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109596. private _forceWireframe;
  109597. /**
  109598. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  109599. */
  109600. set forceWireframe(value: boolean);
  109601. get forceWireframe(): boolean;
  109602. private _skipFrustumClipping;
  109603. /**
  109604. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  109605. */
  109606. set skipFrustumClipping(value: boolean);
  109607. get skipFrustumClipping(): boolean;
  109608. private _forcePointsCloud;
  109609. /**
  109610. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  109611. */
  109612. set forcePointsCloud(value: boolean);
  109613. get forcePointsCloud(): boolean;
  109614. /**
  109615. * Gets or sets the active clipplane 1
  109616. */
  109617. clipPlane: Nullable<Plane>;
  109618. /**
  109619. * Gets or sets the active clipplane 2
  109620. */
  109621. clipPlane2: Nullable<Plane>;
  109622. /**
  109623. * Gets or sets the active clipplane 3
  109624. */
  109625. clipPlane3: Nullable<Plane>;
  109626. /**
  109627. * Gets or sets the active clipplane 4
  109628. */
  109629. clipPlane4: Nullable<Plane>;
  109630. /**
  109631. * Gets or sets the active clipplane 5
  109632. */
  109633. clipPlane5: Nullable<Plane>;
  109634. /**
  109635. * Gets or sets the active clipplane 6
  109636. */
  109637. clipPlane6: Nullable<Plane>;
  109638. /**
  109639. * Gets or sets a boolean indicating if animations are enabled
  109640. */
  109641. animationsEnabled: boolean;
  109642. private _animationPropertiesOverride;
  109643. /**
  109644. * Gets or sets the animation properties override
  109645. */
  109646. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109647. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109648. /**
  109649. * Gets or sets a boolean indicating if a constant deltatime has to be used
  109650. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  109651. */
  109652. useConstantAnimationDeltaTime: boolean;
  109653. /**
  109654. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  109655. * Please note that it requires to run a ray cast through the scene on every frame
  109656. */
  109657. constantlyUpdateMeshUnderPointer: boolean;
  109658. /**
  109659. * Defines the HTML cursor to use when hovering over interactive elements
  109660. */
  109661. hoverCursor: string;
  109662. /**
  109663. * Defines the HTML default cursor to use (empty by default)
  109664. */
  109665. defaultCursor: string;
  109666. /**
  109667. * Defines whether cursors are handled by the scene.
  109668. */
  109669. doNotHandleCursors: boolean;
  109670. /**
  109671. * This is used to call preventDefault() on pointer down
  109672. * in order to block unwanted artifacts like system double clicks
  109673. */
  109674. preventDefaultOnPointerDown: boolean;
  109675. /**
  109676. * This is used to call preventDefault() on pointer up
  109677. * in order to block unwanted artifacts like system double clicks
  109678. */
  109679. preventDefaultOnPointerUp: boolean;
  109680. /**
  109681. * Gets or sets user defined metadata
  109682. */
  109683. metadata: any;
  109684. /**
  109685. * For internal use only. Please do not use.
  109686. */
  109687. reservedDataStore: any;
  109688. /**
  109689. * Gets the name of the plugin used to load this scene (null by default)
  109690. */
  109691. loadingPluginName: string;
  109692. /**
  109693. * Use this array to add regular expressions used to disable offline support for specific urls
  109694. */
  109695. disableOfflineSupportExceptionRules: RegExp[];
  109696. /**
  109697. * An event triggered when the scene is disposed.
  109698. */
  109699. onDisposeObservable: Observable<Scene>;
  109700. private _onDisposeObserver;
  109701. /** Sets a function to be executed when this scene is disposed. */
  109702. set onDispose(callback: () => void);
  109703. /**
  109704. * An event triggered before rendering the scene (right after animations and physics)
  109705. */
  109706. onBeforeRenderObservable: Observable<Scene>;
  109707. private _onBeforeRenderObserver;
  109708. /** Sets a function to be executed before rendering this scene */
  109709. set beforeRender(callback: Nullable<() => void>);
  109710. /**
  109711. * An event triggered after rendering the scene
  109712. */
  109713. onAfterRenderObservable: Observable<Scene>;
  109714. /**
  109715. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  109716. */
  109717. onAfterRenderCameraObservable: Observable<Camera>;
  109718. private _onAfterRenderObserver;
  109719. /** Sets a function to be executed after rendering this scene */
  109720. set afterRender(callback: Nullable<() => void>);
  109721. /**
  109722. * An event triggered before animating the scene
  109723. */
  109724. onBeforeAnimationsObservable: Observable<Scene>;
  109725. /**
  109726. * An event triggered after animations processing
  109727. */
  109728. onAfterAnimationsObservable: Observable<Scene>;
  109729. /**
  109730. * An event triggered before draw calls are ready to be sent
  109731. */
  109732. onBeforeDrawPhaseObservable: Observable<Scene>;
  109733. /**
  109734. * An event triggered after draw calls have been sent
  109735. */
  109736. onAfterDrawPhaseObservable: Observable<Scene>;
  109737. /**
  109738. * An event triggered when the scene is ready
  109739. */
  109740. onReadyObservable: Observable<Scene>;
  109741. /**
  109742. * An event triggered before rendering a camera
  109743. */
  109744. onBeforeCameraRenderObservable: Observable<Camera>;
  109745. private _onBeforeCameraRenderObserver;
  109746. /** Sets a function to be executed before rendering a camera*/
  109747. set beforeCameraRender(callback: () => void);
  109748. /**
  109749. * An event triggered after rendering a camera
  109750. */
  109751. onAfterCameraRenderObservable: Observable<Camera>;
  109752. private _onAfterCameraRenderObserver;
  109753. /** Sets a function to be executed after rendering a camera*/
  109754. set afterCameraRender(callback: () => void);
  109755. /**
  109756. * An event triggered when active meshes evaluation is about to start
  109757. */
  109758. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  109759. /**
  109760. * An event triggered when active meshes evaluation is done
  109761. */
  109762. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  109763. /**
  109764. * An event triggered when particles rendering is about to start
  109765. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109766. */
  109767. onBeforeParticlesRenderingObservable: Observable<Scene>;
  109768. /**
  109769. * An event triggered when particles rendering is done
  109770. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109771. */
  109772. onAfterParticlesRenderingObservable: Observable<Scene>;
  109773. /**
  109774. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  109775. */
  109776. onDataLoadedObservable: Observable<Scene>;
  109777. /**
  109778. * An event triggered when a camera is created
  109779. */
  109780. onNewCameraAddedObservable: Observable<Camera>;
  109781. /**
  109782. * An event triggered when a camera is removed
  109783. */
  109784. onCameraRemovedObservable: Observable<Camera>;
  109785. /**
  109786. * An event triggered when a light is created
  109787. */
  109788. onNewLightAddedObservable: Observable<Light>;
  109789. /**
  109790. * An event triggered when a light is removed
  109791. */
  109792. onLightRemovedObservable: Observable<Light>;
  109793. /**
  109794. * An event triggered when a geometry is created
  109795. */
  109796. onNewGeometryAddedObservable: Observable<Geometry>;
  109797. /**
  109798. * An event triggered when a geometry is removed
  109799. */
  109800. onGeometryRemovedObservable: Observable<Geometry>;
  109801. /**
  109802. * An event triggered when a transform node is created
  109803. */
  109804. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  109805. /**
  109806. * An event triggered when a transform node is removed
  109807. */
  109808. onTransformNodeRemovedObservable: Observable<TransformNode>;
  109809. /**
  109810. * An event triggered when a mesh is created
  109811. */
  109812. onNewMeshAddedObservable: Observable<AbstractMesh>;
  109813. /**
  109814. * An event triggered when a mesh is removed
  109815. */
  109816. onMeshRemovedObservable: Observable<AbstractMesh>;
  109817. /**
  109818. * An event triggered when a skeleton is created
  109819. */
  109820. onNewSkeletonAddedObservable: Observable<Skeleton>;
  109821. /**
  109822. * An event triggered when a skeleton is removed
  109823. */
  109824. onSkeletonRemovedObservable: Observable<Skeleton>;
  109825. /**
  109826. * An event triggered when a material is created
  109827. */
  109828. onNewMaterialAddedObservable: Observable<Material>;
  109829. /**
  109830. * An event triggered when a material is removed
  109831. */
  109832. onMaterialRemovedObservable: Observable<Material>;
  109833. /**
  109834. * An event triggered when a texture is created
  109835. */
  109836. onNewTextureAddedObservable: Observable<BaseTexture>;
  109837. /**
  109838. * An event triggered when a texture is removed
  109839. */
  109840. onTextureRemovedObservable: Observable<BaseTexture>;
  109841. /**
  109842. * An event triggered when render targets are about to be rendered
  109843. * Can happen multiple times per frame.
  109844. */
  109845. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  109846. /**
  109847. * An event triggered when render targets were rendered.
  109848. * Can happen multiple times per frame.
  109849. */
  109850. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  109851. /**
  109852. * An event triggered before calculating deterministic simulation step
  109853. */
  109854. onBeforeStepObservable: Observable<Scene>;
  109855. /**
  109856. * An event triggered after calculating deterministic simulation step
  109857. */
  109858. onAfterStepObservable: Observable<Scene>;
  109859. /**
  109860. * An event triggered when the activeCamera property is updated
  109861. */
  109862. onActiveCameraChanged: Observable<Scene>;
  109863. /**
  109864. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  109865. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  109866. * 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)
  109867. */
  109868. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  109869. /**
  109870. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  109871. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  109872. * 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)
  109873. */
  109874. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  109875. /**
  109876. * This Observable will when a mesh has been imported into the scene.
  109877. */
  109878. onMeshImportedObservable: Observable<AbstractMesh>;
  109879. /**
  109880. * This Observable will when an animation file has been imported into the scene.
  109881. */
  109882. onAnimationFileImportedObservable: Observable<Scene>;
  109883. /**
  109884. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  109885. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  109886. */
  109887. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  109888. /** @hidden */
  109889. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  109890. /**
  109891. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  109892. */
  109893. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  109894. /**
  109895. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  109896. */
  109897. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  109898. /**
  109899. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  109900. */
  109901. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  109902. /** Callback called when a pointer move is detected */
  109903. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  109904. /** Callback called when a pointer down is detected */
  109905. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  109906. /** Callback called when a pointer up is detected */
  109907. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  109908. /** Callback called when a pointer pick is detected */
  109909. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  109910. /**
  109911. * 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).
  109912. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  109913. */
  109914. onPrePointerObservable: Observable<PointerInfoPre>;
  109915. /**
  109916. * Observable event triggered each time an input event is received from the rendering canvas
  109917. */
  109918. onPointerObservable: Observable<PointerInfo>;
  109919. /**
  109920. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  109921. */
  109922. get unTranslatedPointer(): Vector2;
  109923. /**
  109924. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  109925. */
  109926. static get DragMovementThreshold(): number;
  109927. static set DragMovementThreshold(value: number);
  109928. /**
  109929. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  109930. */
  109931. static get LongPressDelay(): number;
  109932. static set LongPressDelay(value: number);
  109933. /**
  109934. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  109935. */
  109936. static get DoubleClickDelay(): number;
  109937. static set DoubleClickDelay(value: number);
  109938. /** If you need to check double click without raising a single click at first click, enable this flag */
  109939. static get ExclusiveDoubleClickMode(): boolean;
  109940. static set ExclusiveDoubleClickMode(value: boolean);
  109941. /** @hidden */
  109942. _mirroredCameraPosition: Nullable<Vector3>;
  109943. /**
  109944. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  109945. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  109946. */
  109947. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  109948. /**
  109949. * Observable event triggered each time an keyboard event is received from the hosting window
  109950. */
  109951. onKeyboardObservable: Observable<KeyboardInfo>;
  109952. private _useRightHandedSystem;
  109953. /**
  109954. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  109955. */
  109956. set useRightHandedSystem(value: boolean);
  109957. get useRightHandedSystem(): boolean;
  109958. private _timeAccumulator;
  109959. private _currentStepId;
  109960. private _currentInternalStep;
  109961. /**
  109962. * Sets the step Id used by deterministic lock step
  109963. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109964. * @param newStepId defines the step Id
  109965. */
  109966. setStepId(newStepId: number): void;
  109967. /**
  109968. * Gets the step Id used by deterministic lock step
  109969. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109970. * @returns the step Id
  109971. */
  109972. getStepId(): number;
  109973. /**
  109974. * Gets the internal step used by deterministic lock step
  109975. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109976. * @returns the internal step
  109977. */
  109978. getInternalStep(): number;
  109979. private _fogEnabled;
  109980. /**
  109981. * Gets or sets a boolean indicating if fog is enabled on this scene
  109982. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109983. * (Default is true)
  109984. */
  109985. set fogEnabled(value: boolean);
  109986. get fogEnabled(): boolean;
  109987. private _fogMode;
  109988. /**
  109989. * Gets or sets the fog mode to use
  109990. * @see http://doc.babylonjs.com/babylon101/environment#fog
  109991. * | mode | value |
  109992. * | --- | --- |
  109993. * | FOGMODE_NONE | 0 |
  109994. * | FOGMODE_EXP | 1 |
  109995. * | FOGMODE_EXP2 | 2 |
  109996. * | FOGMODE_LINEAR | 3 |
  109997. */
  109998. set fogMode(value: number);
  109999. get fogMode(): number;
  110000. /**
  110001. * Gets or sets the fog color to use
  110002. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110003. * (Default is Color3(0.2, 0.2, 0.3))
  110004. */
  110005. fogColor: Color3;
  110006. /**
  110007. * Gets or sets the fog density to use
  110008. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110009. * (Default is 0.1)
  110010. */
  110011. fogDensity: number;
  110012. /**
  110013. * Gets or sets the fog start distance to use
  110014. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110015. * (Default is 0)
  110016. */
  110017. fogStart: number;
  110018. /**
  110019. * Gets or sets the fog end distance to use
  110020. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110021. * (Default is 1000)
  110022. */
  110023. fogEnd: number;
  110024. private _shadowsEnabled;
  110025. /**
  110026. * Gets or sets a boolean indicating if shadows are enabled on this scene
  110027. */
  110028. set shadowsEnabled(value: boolean);
  110029. get shadowsEnabled(): boolean;
  110030. private _lightsEnabled;
  110031. /**
  110032. * Gets or sets a boolean indicating if lights are enabled on this scene
  110033. */
  110034. set lightsEnabled(value: boolean);
  110035. get lightsEnabled(): boolean;
  110036. /** All of the active cameras added to this scene. */
  110037. activeCameras: Camera[];
  110038. /** @hidden */
  110039. _activeCamera: Nullable<Camera>;
  110040. /** Gets or sets the current active camera */
  110041. get activeCamera(): Nullable<Camera>;
  110042. set activeCamera(value: Nullable<Camera>);
  110043. private _defaultMaterial;
  110044. /** The default material used on meshes when no material is affected */
  110045. get defaultMaterial(): Material;
  110046. /** The default material used on meshes when no material is affected */
  110047. set defaultMaterial(value: Material);
  110048. private _texturesEnabled;
  110049. /**
  110050. * Gets or sets a boolean indicating if textures are enabled on this scene
  110051. */
  110052. set texturesEnabled(value: boolean);
  110053. get texturesEnabled(): boolean;
  110054. /**
  110055. * Gets or sets a boolean indicating if particles are enabled on this scene
  110056. */
  110057. particlesEnabled: boolean;
  110058. /**
  110059. * Gets or sets a boolean indicating if sprites are enabled on this scene
  110060. */
  110061. spritesEnabled: boolean;
  110062. private _skeletonsEnabled;
  110063. /**
  110064. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  110065. */
  110066. set skeletonsEnabled(value: boolean);
  110067. get skeletonsEnabled(): boolean;
  110068. /**
  110069. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  110070. */
  110071. lensFlaresEnabled: boolean;
  110072. /**
  110073. * Gets or sets a boolean indicating if collisions are enabled on this scene
  110074. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110075. */
  110076. collisionsEnabled: boolean;
  110077. private _collisionCoordinator;
  110078. /** @hidden */
  110079. get collisionCoordinator(): ICollisionCoordinator;
  110080. /**
  110081. * Defines the gravity applied to this scene (used only for collisions)
  110082. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110083. */
  110084. gravity: Vector3;
  110085. /**
  110086. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  110087. */
  110088. postProcessesEnabled: boolean;
  110089. /**
  110090. * The list of postprocesses added to the scene
  110091. */
  110092. postProcesses: PostProcess[];
  110093. /**
  110094. * Gets the current postprocess manager
  110095. */
  110096. postProcessManager: PostProcessManager;
  110097. /**
  110098. * Gets or sets a boolean indicating if render targets are enabled on this scene
  110099. */
  110100. renderTargetsEnabled: boolean;
  110101. /**
  110102. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  110103. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  110104. */
  110105. dumpNextRenderTargets: boolean;
  110106. /**
  110107. * The list of user defined render targets added to the scene
  110108. */
  110109. customRenderTargets: RenderTargetTexture[];
  110110. /**
  110111. * Defines if texture loading must be delayed
  110112. * If true, textures will only be loaded when they need to be rendered
  110113. */
  110114. useDelayedTextureLoading: boolean;
  110115. /**
  110116. * Gets the list of meshes imported to the scene through SceneLoader
  110117. */
  110118. importedMeshesFiles: String[];
  110119. /**
  110120. * Gets or sets a boolean indicating if probes are enabled on this scene
  110121. */
  110122. probesEnabled: boolean;
  110123. /**
  110124. * Gets or sets the current offline provider to use to store scene data
  110125. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110126. */
  110127. offlineProvider: IOfflineProvider;
  110128. /**
  110129. * Gets or sets the action manager associated with the scene
  110130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110131. */
  110132. actionManager: AbstractActionManager;
  110133. private _meshesForIntersections;
  110134. /**
  110135. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  110136. */
  110137. proceduralTexturesEnabled: boolean;
  110138. private _engine;
  110139. private _totalVertices;
  110140. /** @hidden */
  110141. _activeIndices: PerfCounter;
  110142. /** @hidden */
  110143. _activeParticles: PerfCounter;
  110144. /** @hidden */
  110145. _activeBones: PerfCounter;
  110146. private _animationRatio;
  110147. /** @hidden */
  110148. _animationTimeLast: number;
  110149. /** @hidden */
  110150. _animationTime: number;
  110151. /**
  110152. * Gets or sets a general scale for animation speed
  110153. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  110154. */
  110155. animationTimeScale: number;
  110156. /** @hidden */
  110157. _cachedMaterial: Nullable<Material>;
  110158. /** @hidden */
  110159. _cachedEffect: Nullable<Effect>;
  110160. /** @hidden */
  110161. _cachedVisibility: Nullable<number>;
  110162. private _renderId;
  110163. private _frameId;
  110164. private _executeWhenReadyTimeoutId;
  110165. private _intermediateRendering;
  110166. private _viewUpdateFlag;
  110167. private _projectionUpdateFlag;
  110168. /** @hidden */
  110169. _toBeDisposed: Nullable<IDisposable>[];
  110170. private _activeRequests;
  110171. /** @hidden */
  110172. _pendingData: any[];
  110173. private _isDisposed;
  110174. /**
  110175. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  110176. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  110177. */
  110178. dispatchAllSubMeshesOfActiveMeshes: boolean;
  110179. private _activeMeshes;
  110180. private _processedMaterials;
  110181. private _renderTargets;
  110182. /** @hidden */
  110183. _activeParticleSystems: SmartArray<IParticleSystem>;
  110184. private _activeSkeletons;
  110185. private _softwareSkinnedMeshes;
  110186. private _renderingManager;
  110187. /** @hidden */
  110188. _activeAnimatables: Animatable[];
  110189. private _transformMatrix;
  110190. private _sceneUbo;
  110191. /** @hidden */
  110192. _viewMatrix: Matrix;
  110193. private _projectionMatrix;
  110194. /** @hidden */
  110195. _forcedViewPosition: Nullable<Vector3>;
  110196. /** @hidden */
  110197. _frustumPlanes: Plane[];
  110198. /**
  110199. * Gets the list of frustum planes (built from the active camera)
  110200. */
  110201. get frustumPlanes(): Plane[];
  110202. /**
  110203. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  110204. * This is useful if there are more lights that the maximum simulteanous authorized
  110205. */
  110206. requireLightSorting: boolean;
  110207. /** @hidden */
  110208. readonly useMaterialMeshMap: boolean;
  110209. /** @hidden */
  110210. readonly useClonedMeshMap: boolean;
  110211. private _externalData;
  110212. private _uid;
  110213. /**
  110214. * @hidden
  110215. * Backing store of defined scene components.
  110216. */
  110217. _components: ISceneComponent[];
  110218. /**
  110219. * @hidden
  110220. * Backing store of defined scene components.
  110221. */
  110222. _serializableComponents: ISceneSerializableComponent[];
  110223. /**
  110224. * List of components to register on the next registration step.
  110225. */
  110226. private _transientComponents;
  110227. /**
  110228. * Registers the transient components if needed.
  110229. */
  110230. private _registerTransientComponents;
  110231. /**
  110232. * @hidden
  110233. * Add a component to the scene.
  110234. * Note that the ccomponent could be registered on th next frame if this is called after
  110235. * the register component stage.
  110236. * @param component Defines the component to add to the scene
  110237. */
  110238. _addComponent(component: ISceneComponent): void;
  110239. /**
  110240. * @hidden
  110241. * Gets a component from the scene.
  110242. * @param name defines the name of the component to retrieve
  110243. * @returns the component or null if not present
  110244. */
  110245. _getComponent(name: string): Nullable<ISceneComponent>;
  110246. /**
  110247. * @hidden
  110248. * Defines the actions happening before camera updates.
  110249. */
  110250. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  110251. /**
  110252. * @hidden
  110253. * Defines the actions happening before clear the canvas.
  110254. */
  110255. _beforeClearStage: Stage<SimpleStageAction>;
  110256. /**
  110257. * @hidden
  110258. * Defines the actions when collecting render targets for the frame.
  110259. */
  110260. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110261. /**
  110262. * @hidden
  110263. * Defines the actions happening for one camera in the frame.
  110264. */
  110265. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110266. /**
  110267. * @hidden
  110268. * Defines the actions happening during the per mesh ready checks.
  110269. */
  110270. _isReadyForMeshStage: Stage<MeshStageAction>;
  110271. /**
  110272. * @hidden
  110273. * Defines the actions happening before evaluate active mesh checks.
  110274. */
  110275. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  110276. /**
  110277. * @hidden
  110278. * Defines the actions happening during the evaluate sub mesh checks.
  110279. */
  110280. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  110281. /**
  110282. * @hidden
  110283. * Defines the actions happening during the active mesh stage.
  110284. */
  110285. _activeMeshStage: Stage<ActiveMeshStageAction>;
  110286. /**
  110287. * @hidden
  110288. * Defines the actions happening during the per camera render target step.
  110289. */
  110290. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  110291. /**
  110292. * @hidden
  110293. * Defines the actions happening just before the active camera is drawing.
  110294. */
  110295. _beforeCameraDrawStage: Stage<CameraStageAction>;
  110296. /**
  110297. * @hidden
  110298. * Defines the actions happening just before a render target is drawing.
  110299. */
  110300. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110301. /**
  110302. * @hidden
  110303. * Defines the actions happening just before a rendering group is drawing.
  110304. */
  110305. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110306. /**
  110307. * @hidden
  110308. * Defines the actions happening just before a mesh is drawing.
  110309. */
  110310. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110311. /**
  110312. * @hidden
  110313. * Defines the actions happening just after a mesh has been drawn.
  110314. */
  110315. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110316. /**
  110317. * @hidden
  110318. * Defines the actions happening just after a rendering group has been drawn.
  110319. */
  110320. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110321. /**
  110322. * @hidden
  110323. * Defines the actions happening just after the active camera has been drawn.
  110324. */
  110325. _afterCameraDrawStage: Stage<CameraStageAction>;
  110326. /**
  110327. * @hidden
  110328. * Defines the actions happening just after a render target has been drawn.
  110329. */
  110330. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110331. /**
  110332. * @hidden
  110333. * Defines the actions happening just after rendering all cameras and computing intersections.
  110334. */
  110335. _afterRenderStage: Stage<SimpleStageAction>;
  110336. /**
  110337. * @hidden
  110338. * Defines the actions happening when a pointer move event happens.
  110339. */
  110340. _pointerMoveStage: Stage<PointerMoveStageAction>;
  110341. /**
  110342. * @hidden
  110343. * Defines the actions happening when a pointer down event happens.
  110344. */
  110345. _pointerDownStage: Stage<PointerUpDownStageAction>;
  110346. /**
  110347. * @hidden
  110348. * Defines the actions happening when a pointer up event happens.
  110349. */
  110350. _pointerUpStage: Stage<PointerUpDownStageAction>;
  110351. /**
  110352. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  110353. */
  110354. private geometriesByUniqueId;
  110355. /**
  110356. * Creates a new Scene
  110357. * @param engine defines the engine to use to render this scene
  110358. * @param options defines the scene options
  110359. */
  110360. constructor(engine: Engine, options?: SceneOptions);
  110361. /**
  110362. * Gets a string idenfifying the name of the class
  110363. * @returns "Scene" string
  110364. */
  110365. getClassName(): string;
  110366. private _defaultMeshCandidates;
  110367. /**
  110368. * @hidden
  110369. */
  110370. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110371. private _defaultSubMeshCandidates;
  110372. /**
  110373. * @hidden
  110374. */
  110375. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110376. /**
  110377. * Sets the default candidate providers for the scene.
  110378. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  110379. * and getCollidingSubMeshCandidates to their default function
  110380. */
  110381. setDefaultCandidateProviders(): void;
  110382. /**
  110383. * Gets the mesh that is currently under the pointer
  110384. */
  110385. get meshUnderPointer(): Nullable<AbstractMesh>;
  110386. /**
  110387. * Gets or sets the current on-screen X position of the pointer
  110388. */
  110389. get pointerX(): number;
  110390. set pointerX(value: number);
  110391. /**
  110392. * Gets or sets the current on-screen Y position of the pointer
  110393. */
  110394. get pointerY(): number;
  110395. set pointerY(value: number);
  110396. /**
  110397. * Gets the cached material (ie. the latest rendered one)
  110398. * @returns the cached material
  110399. */
  110400. getCachedMaterial(): Nullable<Material>;
  110401. /**
  110402. * Gets the cached effect (ie. the latest rendered one)
  110403. * @returns the cached effect
  110404. */
  110405. getCachedEffect(): Nullable<Effect>;
  110406. /**
  110407. * Gets the cached visibility state (ie. the latest rendered one)
  110408. * @returns the cached visibility state
  110409. */
  110410. getCachedVisibility(): Nullable<number>;
  110411. /**
  110412. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  110413. * @param material defines the current material
  110414. * @param effect defines the current effect
  110415. * @param visibility defines the current visibility state
  110416. * @returns true if one parameter is not cached
  110417. */
  110418. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  110419. /**
  110420. * Gets the engine associated with the scene
  110421. * @returns an Engine
  110422. */
  110423. getEngine(): Engine;
  110424. /**
  110425. * Gets the total number of vertices rendered per frame
  110426. * @returns the total number of vertices rendered per frame
  110427. */
  110428. getTotalVertices(): number;
  110429. /**
  110430. * Gets the performance counter for total vertices
  110431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110432. */
  110433. get totalVerticesPerfCounter(): PerfCounter;
  110434. /**
  110435. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  110436. * @returns the total number of active indices rendered per frame
  110437. */
  110438. getActiveIndices(): number;
  110439. /**
  110440. * Gets the performance counter for active indices
  110441. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110442. */
  110443. get totalActiveIndicesPerfCounter(): PerfCounter;
  110444. /**
  110445. * Gets the total number of active particles rendered per frame
  110446. * @returns the total number of active particles rendered per frame
  110447. */
  110448. getActiveParticles(): number;
  110449. /**
  110450. * Gets the performance counter for active particles
  110451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110452. */
  110453. get activeParticlesPerfCounter(): PerfCounter;
  110454. /**
  110455. * Gets the total number of active bones rendered per frame
  110456. * @returns the total number of active bones rendered per frame
  110457. */
  110458. getActiveBones(): number;
  110459. /**
  110460. * Gets the performance counter for active bones
  110461. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110462. */
  110463. get activeBonesPerfCounter(): PerfCounter;
  110464. /**
  110465. * Gets the array of active meshes
  110466. * @returns an array of AbstractMesh
  110467. */
  110468. getActiveMeshes(): SmartArray<AbstractMesh>;
  110469. /**
  110470. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  110471. * @returns a number
  110472. */
  110473. getAnimationRatio(): number;
  110474. /**
  110475. * Gets an unique Id for the current render phase
  110476. * @returns a number
  110477. */
  110478. getRenderId(): number;
  110479. /**
  110480. * Gets an unique Id for the current frame
  110481. * @returns a number
  110482. */
  110483. getFrameId(): number;
  110484. /** Call this function if you want to manually increment the render Id*/
  110485. incrementRenderId(): void;
  110486. private _createUbo;
  110487. /**
  110488. * Use this method to simulate a pointer move on a mesh
  110489. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110490. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110491. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110492. * @returns the current scene
  110493. */
  110494. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110495. /**
  110496. * Use this method to simulate a pointer down on a mesh
  110497. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110498. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110499. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110500. * @returns the current scene
  110501. */
  110502. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110503. /**
  110504. * Use this method to simulate a pointer up on a mesh
  110505. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110506. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110507. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110508. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  110509. * @returns the current scene
  110510. */
  110511. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  110512. /**
  110513. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  110514. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  110515. * @returns true if the pointer was captured
  110516. */
  110517. isPointerCaptured(pointerId?: number): boolean;
  110518. /**
  110519. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  110520. * @param attachUp defines if you want to attach events to pointerup
  110521. * @param attachDown defines if you want to attach events to pointerdown
  110522. * @param attachMove defines if you want to attach events to pointermove
  110523. */
  110524. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  110525. /** Detaches all event handlers*/
  110526. detachControl(): void;
  110527. /**
  110528. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  110529. * Delay loaded resources are not taking in account
  110530. * @return true if all required resources are ready
  110531. */
  110532. isReady(): boolean;
  110533. /** Resets all cached information relative to material (including effect and visibility) */
  110534. resetCachedMaterial(): void;
  110535. /**
  110536. * Registers a function to be called before every frame render
  110537. * @param func defines the function to register
  110538. */
  110539. registerBeforeRender(func: () => void): void;
  110540. /**
  110541. * Unregisters a function called before every frame render
  110542. * @param func defines the function to unregister
  110543. */
  110544. unregisterBeforeRender(func: () => void): void;
  110545. /**
  110546. * Registers a function to be called after every frame render
  110547. * @param func defines the function to register
  110548. */
  110549. registerAfterRender(func: () => void): void;
  110550. /**
  110551. * Unregisters a function called after every frame render
  110552. * @param func defines the function to unregister
  110553. */
  110554. unregisterAfterRender(func: () => void): void;
  110555. private _executeOnceBeforeRender;
  110556. /**
  110557. * The provided function will run before render once and will be disposed afterwards.
  110558. * A timeout delay can be provided so that the function will be executed in N ms.
  110559. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  110560. * @param func The function to be executed.
  110561. * @param timeout optional delay in ms
  110562. */
  110563. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  110564. /** @hidden */
  110565. _addPendingData(data: any): void;
  110566. /** @hidden */
  110567. _removePendingData(data: any): void;
  110568. /**
  110569. * Returns the number of items waiting to be loaded
  110570. * @returns the number of items waiting to be loaded
  110571. */
  110572. getWaitingItemsCount(): number;
  110573. /**
  110574. * Returns a boolean indicating if the scene is still loading data
  110575. */
  110576. get isLoading(): boolean;
  110577. /**
  110578. * Registers a function to be executed when the scene is ready
  110579. * @param {Function} func - the function to be executed
  110580. */
  110581. executeWhenReady(func: () => void): void;
  110582. /**
  110583. * Returns a promise that resolves when the scene is ready
  110584. * @returns A promise that resolves when the scene is ready
  110585. */
  110586. whenReadyAsync(): Promise<void>;
  110587. /** @hidden */
  110588. _checkIsReady(): void;
  110589. /**
  110590. * Gets all animatable attached to the scene
  110591. */
  110592. get animatables(): Animatable[];
  110593. /**
  110594. * Resets the last animation time frame.
  110595. * Useful to override when animations start running when loading a scene for the first time.
  110596. */
  110597. resetLastAnimationTimeFrame(): void;
  110598. /**
  110599. * Gets the current view matrix
  110600. * @returns a Matrix
  110601. */
  110602. getViewMatrix(): Matrix;
  110603. /**
  110604. * Gets the current projection matrix
  110605. * @returns a Matrix
  110606. */
  110607. getProjectionMatrix(): Matrix;
  110608. /**
  110609. * Gets the current transform matrix
  110610. * @returns a Matrix made of View * Projection
  110611. */
  110612. getTransformMatrix(): Matrix;
  110613. /**
  110614. * Sets the current transform matrix
  110615. * @param viewL defines the View matrix to use
  110616. * @param projectionL defines the Projection matrix to use
  110617. * @param viewR defines the right View matrix to use (if provided)
  110618. * @param projectionR defines the right Projection matrix to use (if provided)
  110619. */
  110620. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  110621. /**
  110622. * Gets the uniform buffer used to store scene data
  110623. * @returns a UniformBuffer
  110624. */
  110625. getSceneUniformBuffer(): UniformBuffer;
  110626. /**
  110627. * Gets an unique (relatively to the current scene) Id
  110628. * @returns an unique number for the scene
  110629. */
  110630. getUniqueId(): number;
  110631. /**
  110632. * Add a mesh to the list of scene's meshes
  110633. * @param newMesh defines the mesh to add
  110634. * @param recursive if all child meshes should also be added to the scene
  110635. */
  110636. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  110637. /**
  110638. * Remove a mesh for the list of scene's meshes
  110639. * @param toRemove defines the mesh to remove
  110640. * @param recursive if all child meshes should also be removed from the scene
  110641. * @returns the index where the mesh was in the mesh list
  110642. */
  110643. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  110644. /**
  110645. * Add a transform node to the list of scene's transform nodes
  110646. * @param newTransformNode defines the transform node to add
  110647. */
  110648. addTransformNode(newTransformNode: TransformNode): void;
  110649. /**
  110650. * Remove a transform node for the list of scene's transform nodes
  110651. * @param toRemove defines the transform node to remove
  110652. * @returns the index where the transform node was in the transform node list
  110653. */
  110654. removeTransformNode(toRemove: TransformNode): number;
  110655. /**
  110656. * Remove a skeleton for the list of scene's skeletons
  110657. * @param toRemove defines the skeleton to remove
  110658. * @returns the index where the skeleton was in the skeleton list
  110659. */
  110660. removeSkeleton(toRemove: Skeleton): number;
  110661. /**
  110662. * Remove a morph target for the list of scene's morph targets
  110663. * @param toRemove defines the morph target to remove
  110664. * @returns the index where the morph target was in the morph target list
  110665. */
  110666. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  110667. /**
  110668. * Remove a light for the list of scene's lights
  110669. * @param toRemove defines the light to remove
  110670. * @returns the index where the light was in the light list
  110671. */
  110672. removeLight(toRemove: Light): number;
  110673. /**
  110674. * Remove a camera for the list of scene's cameras
  110675. * @param toRemove defines the camera to remove
  110676. * @returns the index where the camera was in the camera list
  110677. */
  110678. removeCamera(toRemove: Camera): number;
  110679. /**
  110680. * Remove a particle system for the list of scene's particle systems
  110681. * @param toRemove defines the particle system to remove
  110682. * @returns the index where the particle system was in the particle system list
  110683. */
  110684. removeParticleSystem(toRemove: IParticleSystem): number;
  110685. /**
  110686. * Remove a animation for the list of scene's animations
  110687. * @param toRemove defines the animation to remove
  110688. * @returns the index where the animation was in the animation list
  110689. */
  110690. removeAnimation(toRemove: Animation): number;
  110691. /**
  110692. * Will stop the animation of the given target
  110693. * @param target - the target
  110694. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  110695. * @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)
  110696. */
  110697. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  110698. /**
  110699. * Removes the given animation group from this scene.
  110700. * @param toRemove The animation group to remove
  110701. * @returns The index of the removed animation group
  110702. */
  110703. removeAnimationGroup(toRemove: AnimationGroup): number;
  110704. /**
  110705. * Removes the given multi-material from this scene.
  110706. * @param toRemove The multi-material to remove
  110707. * @returns The index of the removed multi-material
  110708. */
  110709. removeMultiMaterial(toRemove: MultiMaterial): number;
  110710. /**
  110711. * Removes the given material from this scene.
  110712. * @param toRemove The material to remove
  110713. * @returns The index of the removed material
  110714. */
  110715. removeMaterial(toRemove: Material): number;
  110716. /**
  110717. * Removes the given action manager from this scene.
  110718. * @param toRemove The action manager to remove
  110719. * @returns The index of the removed action manager
  110720. */
  110721. removeActionManager(toRemove: AbstractActionManager): number;
  110722. /**
  110723. * Removes the given texture from this scene.
  110724. * @param toRemove The texture to remove
  110725. * @returns The index of the removed texture
  110726. */
  110727. removeTexture(toRemove: BaseTexture): number;
  110728. /**
  110729. * Adds the given light to this scene
  110730. * @param newLight The light to add
  110731. */
  110732. addLight(newLight: Light): void;
  110733. /**
  110734. * Sorts the list list based on light priorities
  110735. */
  110736. sortLightsByPriority(): void;
  110737. /**
  110738. * Adds the given camera to this scene
  110739. * @param newCamera The camera to add
  110740. */
  110741. addCamera(newCamera: Camera): void;
  110742. /**
  110743. * Adds the given skeleton to this scene
  110744. * @param newSkeleton The skeleton to add
  110745. */
  110746. addSkeleton(newSkeleton: Skeleton): void;
  110747. /**
  110748. * Adds the given particle system to this scene
  110749. * @param newParticleSystem The particle system to add
  110750. */
  110751. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110752. /**
  110753. * Adds the given animation to this scene
  110754. * @param newAnimation The animation to add
  110755. */
  110756. addAnimation(newAnimation: Animation): void;
  110757. /**
  110758. * Adds the given animation group to this scene.
  110759. * @param newAnimationGroup The animation group to add
  110760. */
  110761. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  110762. /**
  110763. * Adds the given multi-material to this scene
  110764. * @param newMultiMaterial The multi-material to add
  110765. */
  110766. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  110767. /**
  110768. * Adds the given material to this scene
  110769. * @param newMaterial The material to add
  110770. */
  110771. addMaterial(newMaterial: Material): void;
  110772. /**
  110773. * Adds the given morph target to this scene
  110774. * @param newMorphTargetManager The morph target to add
  110775. */
  110776. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  110777. /**
  110778. * Adds the given geometry to this scene
  110779. * @param newGeometry The geometry to add
  110780. */
  110781. addGeometry(newGeometry: Geometry): void;
  110782. /**
  110783. * Adds the given action manager to this scene
  110784. * @param newActionManager The action manager to add
  110785. */
  110786. addActionManager(newActionManager: AbstractActionManager): void;
  110787. /**
  110788. * Adds the given texture to this scene.
  110789. * @param newTexture The texture to add
  110790. */
  110791. addTexture(newTexture: BaseTexture): void;
  110792. /**
  110793. * Switch active camera
  110794. * @param newCamera defines the new active camera
  110795. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  110796. */
  110797. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  110798. /**
  110799. * sets the active camera of the scene using its ID
  110800. * @param id defines the camera's ID
  110801. * @return the new active camera or null if none found.
  110802. */
  110803. setActiveCameraByID(id: string): Nullable<Camera>;
  110804. /**
  110805. * sets the active camera of the scene using its name
  110806. * @param name defines the camera's name
  110807. * @returns the new active camera or null if none found.
  110808. */
  110809. setActiveCameraByName(name: string): Nullable<Camera>;
  110810. /**
  110811. * get an animation group using its name
  110812. * @param name defines the material's name
  110813. * @return the animation group or null if none found.
  110814. */
  110815. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  110816. /**
  110817. * Get a material using its unique id
  110818. * @param uniqueId defines the material's unique id
  110819. * @return the material or null if none found.
  110820. */
  110821. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  110822. /**
  110823. * get a material using its id
  110824. * @param id defines the material's ID
  110825. * @return the material or null if none found.
  110826. */
  110827. getMaterialByID(id: string): Nullable<Material>;
  110828. /**
  110829. * Gets a the last added material using a given id
  110830. * @param id defines the material's ID
  110831. * @return the last material with the given id or null if none found.
  110832. */
  110833. getLastMaterialByID(id: string): Nullable<Material>;
  110834. /**
  110835. * Gets a material using its name
  110836. * @param name defines the material's name
  110837. * @return the material or null if none found.
  110838. */
  110839. getMaterialByName(name: string): Nullable<Material>;
  110840. /**
  110841. * Get a texture using its unique id
  110842. * @param uniqueId defines the texture's unique id
  110843. * @return the texture or null if none found.
  110844. */
  110845. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  110846. /**
  110847. * Gets a camera using its id
  110848. * @param id defines the id to look for
  110849. * @returns the camera or null if not found
  110850. */
  110851. getCameraByID(id: string): Nullable<Camera>;
  110852. /**
  110853. * Gets a camera using its unique id
  110854. * @param uniqueId defines the unique id to look for
  110855. * @returns the camera or null if not found
  110856. */
  110857. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  110858. /**
  110859. * Gets a camera using its name
  110860. * @param name defines the camera's name
  110861. * @return the camera or null if none found.
  110862. */
  110863. getCameraByName(name: string): Nullable<Camera>;
  110864. /**
  110865. * Gets a bone using its id
  110866. * @param id defines the bone's id
  110867. * @return the bone or null if not found
  110868. */
  110869. getBoneByID(id: string): Nullable<Bone>;
  110870. /**
  110871. * Gets a bone using its id
  110872. * @param name defines the bone's name
  110873. * @return the bone or null if not found
  110874. */
  110875. getBoneByName(name: string): Nullable<Bone>;
  110876. /**
  110877. * Gets a light node using its name
  110878. * @param name defines the the light's name
  110879. * @return the light or null if none found.
  110880. */
  110881. getLightByName(name: string): Nullable<Light>;
  110882. /**
  110883. * Gets a light node using its id
  110884. * @param id defines the light's id
  110885. * @return the light or null if none found.
  110886. */
  110887. getLightByID(id: string): Nullable<Light>;
  110888. /**
  110889. * Gets a light node using its scene-generated unique ID
  110890. * @param uniqueId defines the light's unique id
  110891. * @return the light or null if none found.
  110892. */
  110893. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  110894. /**
  110895. * Gets a particle system by id
  110896. * @param id defines the particle system id
  110897. * @return the corresponding system or null if none found
  110898. */
  110899. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  110900. /**
  110901. * Gets a geometry using its ID
  110902. * @param id defines the geometry's id
  110903. * @return the geometry or null if none found.
  110904. */
  110905. getGeometryByID(id: string): Nullable<Geometry>;
  110906. private _getGeometryByUniqueID;
  110907. /**
  110908. * Add a new geometry to this scene
  110909. * @param geometry defines the geometry to be added to the scene.
  110910. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  110911. * @return a boolean defining if the geometry was added or not
  110912. */
  110913. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  110914. /**
  110915. * Removes an existing geometry
  110916. * @param geometry defines the geometry to be removed from the scene
  110917. * @return a boolean defining if the geometry was removed or not
  110918. */
  110919. removeGeometry(geometry: Geometry): boolean;
  110920. /**
  110921. * Gets the list of geometries attached to the scene
  110922. * @returns an array of Geometry
  110923. */
  110924. getGeometries(): Geometry[];
  110925. /**
  110926. * Gets the first added mesh found of a given ID
  110927. * @param id defines the id to search for
  110928. * @return the mesh found or null if not found at all
  110929. */
  110930. getMeshByID(id: string): Nullable<AbstractMesh>;
  110931. /**
  110932. * Gets a list of meshes using their id
  110933. * @param id defines the id to search for
  110934. * @returns a list of meshes
  110935. */
  110936. getMeshesByID(id: string): Array<AbstractMesh>;
  110937. /**
  110938. * Gets the first added transform node found of a given ID
  110939. * @param id defines the id to search for
  110940. * @return the found transform node or null if not found at all.
  110941. */
  110942. getTransformNodeByID(id: string): Nullable<TransformNode>;
  110943. /**
  110944. * Gets a transform node with its auto-generated unique id
  110945. * @param uniqueId efines the unique id to search for
  110946. * @return the found transform node or null if not found at all.
  110947. */
  110948. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  110949. /**
  110950. * Gets a list of transform nodes using their id
  110951. * @param id defines the id to search for
  110952. * @returns a list of transform nodes
  110953. */
  110954. getTransformNodesByID(id: string): Array<TransformNode>;
  110955. /**
  110956. * Gets a mesh with its auto-generated unique id
  110957. * @param uniqueId defines the unique id to search for
  110958. * @return the found mesh or null if not found at all.
  110959. */
  110960. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  110961. /**
  110962. * Gets a the last added mesh using a given id
  110963. * @param id defines the id to search for
  110964. * @return the found mesh or null if not found at all.
  110965. */
  110966. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  110967. /**
  110968. * Gets a the last added node (Mesh, Camera, Light) using a given id
  110969. * @param id defines the id to search for
  110970. * @return the found node or null if not found at all
  110971. */
  110972. getLastEntryByID(id: string): Nullable<Node>;
  110973. /**
  110974. * Gets a node (Mesh, Camera, Light) using a given id
  110975. * @param id defines the id to search for
  110976. * @return the found node or null if not found at all
  110977. */
  110978. getNodeByID(id: string): Nullable<Node>;
  110979. /**
  110980. * Gets a node (Mesh, Camera, Light) using a given name
  110981. * @param name defines the name to search for
  110982. * @return the found node or null if not found at all.
  110983. */
  110984. getNodeByName(name: string): Nullable<Node>;
  110985. /**
  110986. * Gets a mesh using a given name
  110987. * @param name defines the name to search for
  110988. * @return the found mesh or null if not found at all.
  110989. */
  110990. getMeshByName(name: string): Nullable<AbstractMesh>;
  110991. /**
  110992. * Gets a transform node using a given name
  110993. * @param name defines the name to search for
  110994. * @return the found transform node or null if not found at all.
  110995. */
  110996. getTransformNodeByName(name: string): Nullable<TransformNode>;
  110997. /**
  110998. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  110999. * @param id defines the id to search for
  111000. * @return the found skeleton or null if not found at all.
  111001. */
  111002. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  111003. /**
  111004. * Gets a skeleton using a given auto generated unique id
  111005. * @param uniqueId defines the unique id to search for
  111006. * @return the found skeleton or null if not found at all.
  111007. */
  111008. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  111009. /**
  111010. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  111011. * @param id defines the id to search for
  111012. * @return the found skeleton or null if not found at all.
  111013. */
  111014. getSkeletonById(id: string): Nullable<Skeleton>;
  111015. /**
  111016. * Gets a skeleton using a given name
  111017. * @param name defines the name to search for
  111018. * @return the found skeleton or null if not found at all.
  111019. */
  111020. getSkeletonByName(name: string): Nullable<Skeleton>;
  111021. /**
  111022. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  111023. * @param id defines the id to search for
  111024. * @return the found morph target manager or null if not found at all.
  111025. */
  111026. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  111027. /**
  111028. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  111029. * @param id defines the id to search for
  111030. * @return the found morph target or null if not found at all.
  111031. */
  111032. getMorphTargetById(id: string): Nullable<MorphTarget>;
  111033. /**
  111034. * Gets a boolean indicating if the given mesh is active
  111035. * @param mesh defines the mesh to look for
  111036. * @returns true if the mesh is in the active list
  111037. */
  111038. isActiveMesh(mesh: AbstractMesh): boolean;
  111039. /**
  111040. * Return a unique id as a string which can serve as an identifier for the scene
  111041. */
  111042. get uid(): string;
  111043. /**
  111044. * Add an externaly attached data from its key.
  111045. * This method call will fail and return false, if such key already exists.
  111046. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  111047. * @param key the unique key that identifies the data
  111048. * @param data the data object to associate to the key for this Engine instance
  111049. * @return true if no such key were already present and the data was added successfully, false otherwise
  111050. */
  111051. addExternalData<T>(key: string, data: T): boolean;
  111052. /**
  111053. * Get an externaly attached data from its key
  111054. * @param key the unique key that identifies the data
  111055. * @return the associated data, if present (can be null), or undefined if not present
  111056. */
  111057. getExternalData<T>(key: string): Nullable<T>;
  111058. /**
  111059. * Get an externaly attached data from its key, create it using a factory if it's not already present
  111060. * @param key the unique key that identifies the data
  111061. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  111062. * @return the associated data, can be null if the factory returned null.
  111063. */
  111064. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  111065. /**
  111066. * Remove an externaly attached data from the Engine instance
  111067. * @param key the unique key that identifies the data
  111068. * @return true if the data was successfully removed, false if it doesn't exist
  111069. */
  111070. removeExternalData(key: string): boolean;
  111071. private _evaluateSubMesh;
  111072. /**
  111073. * Clear the processed materials smart array preventing retention point in material dispose.
  111074. */
  111075. freeProcessedMaterials(): void;
  111076. private _preventFreeActiveMeshesAndRenderingGroups;
  111077. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  111078. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  111079. * when disposing several meshes in a row or a hierarchy of meshes.
  111080. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  111081. */
  111082. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  111083. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  111084. /**
  111085. * Clear the active meshes smart array preventing retention point in mesh dispose.
  111086. */
  111087. freeActiveMeshes(): void;
  111088. /**
  111089. * Clear the info related to rendering groups preventing retention points during dispose.
  111090. */
  111091. freeRenderingGroups(): void;
  111092. /** @hidden */
  111093. _isInIntermediateRendering(): boolean;
  111094. /**
  111095. * Lambda returning the list of potentially active meshes.
  111096. */
  111097. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  111098. /**
  111099. * Lambda returning the list of potentially active sub meshes.
  111100. */
  111101. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  111102. /**
  111103. * Lambda returning the list of potentially intersecting sub meshes.
  111104. */
  111105. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  111106. /**
  111107. * Lambda returning the list of potentially colliding sub meshes.
  111108. */
  111109. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  111110. private _activeMeshesFrozen;
  111111. private _skipEvaluateActiveMeshesCompletely;
  111112. /**
  111113. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  111114. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  111115. * @returns the current scene
  111116. */
  111117. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  111118. /**
  111119. * Use this function to restart evaluating active meshes on every frame
  111120. * @returns the current scene
  111121. */
  111122. unfreezeActiveMeshes(): Scene;
  111123. private _evaluateActiveMeshes;
  111124. private _activeMesh;
  111125. /**
  111126. * Update the transform matrix to update from the current active camera
  111127. * @param force defines a boolean used to force the update even if cache is up to date
  111128. */
  111129. updateTransformMatrix(force?: boolean): void;
  111130. private _bindFrameBuffer;
  111131. /** @hidden */
  111132. _allowPostProcessClearColor: boolean;
  111133. /** @hidden */
  111134. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  111135. private _processSubCameras;
  111136. private _checkIntersections;
  111137. /** @hidden */
  111138. _advancePhysicsEngineStep(step: number): void;
  111139. /**
  111140. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  111141. */
  111142. getDeterministicFrameTime: () => number;
  111143. /** @hidden */
  111144. _animate(): void;
  111145. /** Execute all animations (for a frame) */
  111146. animate(): void;
  111147. /**
  111148. * Render the scene
  111149. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  111150. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  111151. */
  111152. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  111153. /**
  111154. * Freeze all materials
  111155. * A frozen material will not be updatable but should be faster to render
  111156. */
  111157. freezeMaterials(): void;
  111158. /**
  111159. * Unfreeze all materials
  111160. * A frozen material will not be updatable but should be faster to render
  111161. */
  111162. unfreezeMaterials(): void;
  111163. /**
  111164. * Releases all held ressources
  111165. */
  111166. dispose(): void;
  111167. /**
  111168. * Gets if the scene is already disposed
  111169. */
  111170. get isDisposed(): boolean;
  111171. /**
  111172. * Call this function to reduce memory footprint of the scene.
  111173. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  111174. */
  111175. clearCachedVertexData(): void;
  111176. /**
  111177. * This function will remove the local cached buffer data from texture.
  111178. * It will save memory but will prevent the texture from being rebuilt
  111179. */
  111180. cleanCachedTextureBuffer(): void;
  111181. /**
  111182. * Get the world extend vectors with an optional filter
  111183. *
  111184. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  111185. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  111186. */
  111187. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  111188. min: Vector3;
  111189. max: Vector3;
  111190. };
  111191. /**
  111192. * Creates a ray that can be used to pick in the scene
  111193. * @param x defines the x coordinate of the origin (on-screen)
  111194. * @param y defines the y coordinate of the origin (on-screen)
  111195. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111196. * @param camera defines the camera to use for the picking
  111197. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111198. * @returns a Ray
  111199. */
  111200. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  111201. /**
  111202. * Creates a ray that can be used to pick in the scene
  111203. * @param x defines the x coordinate of the origin (on-screen)
  111204. * @param y defines the y coordinate of the origin (on-screen)
  111205. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111206. * @param result defines the ray where to store the picking ray
  111207. * @param camera defines the camera to use for the picking
  111208. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111209. * @returns the current scene
  111210. */
  111211. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  111212. /**
  111213. * Creates a ray that can be used to pick in the scene
  111214. * @param x defines the x coordinate of the origin (on-screen)
  111215. * @param y defines the y coordinate of the origin (on-screen)
  111216. * @param camera defines the camera to use for the picking
  111217. * @returns a Ray
  111218. */
  111219. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  111220. /**
  111221. * Creates a ray that can be used to pick in the scene
  111222. * @param x defines the x coordinate of the origin (on-screen)
  111223. * @param y defines the y coordinate of the origin (on-screen)
  111224. * @param result defines the ray where to store the picking ray
  111225. * @param camera defines the camera to use for the picking
  111226. * @returns the current scene
  111227. */
  111228. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  111229. /** Launch a ray to try to pick a mesh in the scene
  111230. * @param x position on screen
  111231. * @param y position on screen
  111232. * @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
  111233. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  111234. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111236. * @returns a PickingInfo
  111237. */
  111238. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111239. /** Use the given ray to pick a mesh in the scene
  111240. * @param ray The ray to use to pick meshes
  111241. * @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
  111242. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  111243. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111244. * @returns a PickingInfo
  111245. */
  111246. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111247. /**
  111248. * Launch a ray to try to pick a mesh in the scene
  111249. * @param x X position on screen
  111250. * @param y Y position on screen
  111251. * @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
  111252. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111253. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111254. * @returns an array of PickingInfo
  111255. */
  111256. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111257. /**
  111258. * Launch a ray to try to pick a mesh in the scene
  111259. * @param ray Ray to use
  111260. * @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
  111261. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111262. * @returns an array of PickingInfo
  111263. */
  111264. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111265. /**
  111266. * Force the value of meshUnderPointer
  111267. * @param mesh defines the mesh to use
  111268. */
  111269. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111270. /**
  111271. * Gets the mesh under the pointer
  111272. * @returns a Mesh or null if no mesh is under the pointer
  111273. */
  111274. getPointerOverMesh(): Nullable<AbstractMesh>;
  111275. /** @hidden */
  111276. _rebuildGeometries(): void;
  111277. /** @hidden */
  111278. _rebuildTextures(): void;
  111279. private _getByTags;
  111280. /**
  111281. * Get a list of meshes by tags
  111282. * @param tagsQuery defines the tags query to use
  111283. * @param forEach defines a predicate used to filter results
  111284. * @returns an array of Mesh
  111285. */
  111286. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  111287. /**
  111288. * Get a list of cameras by tags
  111289. * @param tagsQuery defines the tags query to use
  111290. * @param forEach defines a predicate used to filter results
  111291. * @returns an array of Camera
  111292. */
  111293. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  111294. /**
  111295. * Get a list of lights by tags
  111296. * @param tagsQuery defines the tags query to use
  111297. * @param forEach defines a predicate used to filter results
  111298. * @returns an array of Light
  111299. */
  111300. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  111301. /**
  111302. * Get a list of materials by tags
  111303. * @param tagsQuery defines the tags query to use
  111304. * @param forEach defines a predicate used to filter results
  111305. * @returns an array of Material
  111306. */
  111307. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  111308. /**
  111309. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  111310. * This allowed control for front to back rendering or reversly depending of the special needs.
  111311. *
  111312. * @param renderingGroupId The rendering group id corresponding to its index
  111313. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  111314. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  111315. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  111316. */
  111317. 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;
  111318. /**
  111319. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  111320. *
  111321. * @param renderingGroupId The rendering group id corresponding to its index
  111322. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111323. * @param depth Automatically clears depth between groups if true and autoClear is true.
  111324. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  111325. */
  111326. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  111327. /**
  111328. * Gets the current auto clear configuration for one rendering group of the rendering
  111329. * manager.
  111330. * @param index the rendering group index to get the information for
  111331. * @returns The auto clear setup for the requested rendering group
  111332. */
  111333. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  111334. private _blockMaterialDirtyMechanism;
  111335. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  111336. get blockMaterialDirtyMechanism(): boolean;
  111337. set blockMaterialDirtyMechanism(value: boolean);
  111338. /**
  111339. * Will flag all materials as dirty to trigger new shader compilation
  111340. * @param flag defines the flag used to specify which material part must be marked as dirty
  111341. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  111342. */
  111343. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  111344. /** @hidden */
  111345. _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;
  111346. /** @hidden */
  111347. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111348. /** @hidden */
  111349. _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;
  111350. /** @hidden */
  111351. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  111352. /** @hidden */
  111353. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  111354. /** @hidden */
  111355. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111356. }
  111357. }
  111358. declare module BABYLON {
  111359. /**
  111360. * Set of assets to keep when moving a scene into an asset container.
  111361. */
  111362. export class KeepAssets extends AbstractScene {
  111363. }
  111364. /**
  111365. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  111366. */
  111367. export class InstantiatedEntries {
  111368. /**
  111369. * List of new root nodes (eg. nodes with no parent)
  111370. */
  111371. rootNodes: TransformNode[];
  111372. /**
  111373. * List of new skeletons
  111374. */
  111375. skeletons: Skeleton[];
  111376. /**
  111377. * List of new animation groups
  111378. */
  111379. animationGroups: AnimationGroup[];
  111380. }
  111381. /**
  111382. * Container with a set of assets that can be added or removed from a scene.
  111383. */
  111384. export class AssetContainer extends AbstractScene {
  111385. private _wasAddedToScene;
  111386. /**
  111387. * The scene the AssetContainer belongs to.
  111388. */
  111389. scene: Scene;
  111390. /**
  111391. * Instantiates an AssetContainer.
  111392. * @param scene The scene the AssetContainer belongs to.
  111393. */
  111394. constructor(scene: Scene);
  111395. /**
  111396. * Instantiate or clone all meshes and add the new ones to the scene.
  111397. * Skeletons and animation groups will all be cloned
  111398. * @param nameFunction defines an optional function used to get new names for clones
  111399. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  111400. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  111401. */
  111402. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  111403. /**
  111404. * Adds all the assets from the container to the scene.
  111405. */
  111406. addAllToScene(): void;
  111407. /**
  111408. * Removes all the assets in the container from the scene
  111409. */
  111410. removeAllFromScene(): void;
  111411. /**
  111412. * Disposes all the assets in the container
  111413. */
  111414. dispose(): void;
  111415. private _moveAssets;
  111416. /**
  111417. * Removes all the assets contained in the scene and adds them to the container.
  111418. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  111419. */
  111420. moveAllFromScene(keepAssets?: KeepAssets): void;
  111421. /**
  111422. * 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.
  111423. * @returns the root mesh
  111424. */
  111425. createRootMesh(): Mesh;
  111426. /**
  111427. * Merge animations from this asset container into a scene
  111428. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111429. * @param animatables set of animatables to retarget to a node from the scene
  111430. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  111431. */
  111432. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  111433. }
  111434. }
  111435. declare module BABYLON {
  111436. /**
  111437. * Defines how the parser contract is defined.
  111438. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  111439. */
  111440. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  111441. /**
  111442. * Defines how the individual parser contract is defined.
  111443. * These parser can parse an individual asset
  111444. */
  111445. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  111446. /**
  111447. * Base class of the scene acting as a container for the different elements composing a scene.
  111448. * This class is dynamically extended by the different components of the scene increasing
  111449. * flexibility and reducing coupling
  111450. */
  111451. export abstract class AbstractScene {
  111452. /**
  111453. * Stores the list of available parsers in the application.
  111454. */
  111455. private static _BabylonFileParsers;
  111456. /**
  111457. * Stores the list of available individual parsers in the application.
  111458. */
  111459. private static _IndividualBabylonFileParsers;
  111460. /**
  111461. * Adds a parser in the list of available ones
  111462. * @param name Defines the name of the parser
  111463. * @param parser Defines the parser to add
  111464. */
  111465. static AddParser(name: string, parser: BabylonFileParser): void;
  111466. /**
  111467. * Gets a general parser from the list of avaialble ones
  111468. * @param name Defines the name of the parser
  111469. * @returns the requested parser or null
  111470. */
  111471. static GetParser(name: string): Nullable<BabylonFileParser>;
  111472. /**
  111473. * Adds n individual parser in the list of available ones
  111474. * @param name Defines the name of the parser
  111475. * @param parser Defines the parser to add
  111476. */
  111477. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  111478. /**
  111479. * Gets an individual parser from the list of avaialble ones
  111480. * @param name Defines the name of the parser
  111481. * @returns the requested parser or null
  111482. */
  111483. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  111484. /**
  111485. * Parser json data and populate both a scene and its associated container object
  111486. * @param jsonData Defines the data to parse
  111487. * @param scene Defines the scene to parse the data for
  111488. * @param container Defines the container attached to the parsing sequence
  111489. * @param rootUrl Defines the root url of the data
  111490. */
  111491. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  111492. /**
  111493. * Gets the list of root nodes (ie. nodes with no parent)
  111494. */
  111495. rootNodes: Node[];
  111496. /** All of the cameras added to this scene
  111497. * @see http://doc.babylonjs.com/babylon101/cameras
  111498. */
  111499. cameras: Camera[];
  111500. /**
  111501. * All of the lights added to this scene
  111502. * @see http://doc.babylonjs.com/babylon101/lights
  111503. */
  111504. lights: Light[];
  111505. /**
  111506. * All of the (abstract) meshes added to this scene
  111507. */
  111508. meshes: AbstractMesh[];
  111509. /**
  111510. * The list of skeletons added to the scene
  111511. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111512. */
  111513. skeletons: Skeleton[];
  111514. /**
  111515. * All of the particle systems added to this scene
  111516. * @see http://doc.babylonjs.com/babylon101/particles
  111517. */
  111518. particleSystems: IParticleSystem[];
  111519. /**
  111520. * Gets a list of Animations associated with the scene
  111521. */
  111522. animations: Animation[];
  111523. /**
  111524. * All of the animation groups added to this scene
  111525. * @see http://doc.babylonjs.com/how_to/group
  111526. */
  111527. animationGroups: AnimationGroup[];
  111528. /**
  111529. * All of the multi-materials added to this scene
  111530. * @see http://doc.babylonjs.com/how_to/multi_materials
  111531. */
  111532. multiMaterials: MultiMaterial[];
  111533. /**
  111534. * All of the materials added to this scene
  111535. * In the context of a Scene, it is not supposed to be modified manually.
  111536. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  111537. * Note also that the order of the Material within the array is not significant and might change.
  111538. * @see http://doc.babylonjs.com/babylon101/materials
  111539. */
  111540. materials: Material[];
  111541. /**
  111542. * The list of morph target managers added to the scene
  111543. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  111544. */
  111545. morphTargetManagers: MorphTargetManager[];
  111546. /**
  111547. * The list of geometries used in the scene.
  111548. */
  111549. geometries: Geometry[];
  111550. /**
  111551. * All of the tranform nodes added to this scene
  111552. * In the context of a Scene, it is not supposed to be modified manually.
  111553. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  111554. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  111555. * @see http://doc.babylonjs.com/how_to/transformnode
  111556. */
  111557. transformNodes: TransformNode[];
  111558. /**
  111559. * ActionManagers available on the scene.
  111560. */
  111561. actionManagers: AbstractActionManager[];
  111562. /**
  111563. * Textures to keep.
  111564. */
  111565. textures: BaseTexture[];
  111566. /**
  111567. * Environment texture for the scene
  111568. */
  111569. environmentTexture: Nullable<BaseTexture>;
  111570. /**
  111571. * @returns all meshes, lights, cameras, transformNodes and bones
  111572. */
  111573. getNodes(): Array<Node>;
  111574. }
  111575. }
  111576. declare module BABYLON {
  111577. /**
  111578. * Interface used to define options for Sound class
  111579. */
  111580. export interface ISoundOptions {
  111581. /**
  111582. * Does the sound autoplay once loaded.
  111583. */
  111584. autoplay?: boolean;
  111585. /**
  111586. * Does the sound loop after it finishes playing once.
  111587. */
  111588. loop?: boolean;
  111589. /**
  111590. * Sound's volume
  111591. */
  111592. volume?: number;
  111593. /**
  111594. * Is it a spatial sound?
  111595. */
  111596. spatialSound?: boolean;
  111597. /**
  111598. * Maximum distance to hear that sound
  111599. */
  111600. maxDistance?: number;
  111601. /**
  111602. * Uses user defined attenuation function
  111603. */
  111604. useCustomAttenuation?: boolean;
  111605. /**
  111606. * Define the roll off factor of spatial sounds.
  111607. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111608. */
  111609. rolloffFactor?: number;
  111610. /**
  111611. * Define the reference distance the sound should be heard perfectly.
  111612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111613. */
  111614. refDistance?: number;
  111615. /**
  111616. * Define the distance attenuation model the sound will follow.
  111617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111618. */
  111619. distanceModel?: string;
  111620. /**
  111621. * Defines the playback speed (1 by default)
  111622. */
  111623. playbackRate?: number;
  111624. /**
  111625. * Defines if the sound is from a streaming source
  111626. */
  111627. streaming?: boolean;
  111628. /**
  111629. * Defines an optional length (in seconds) inside the sound file
  111630. */
  111631. length?: number;
  111632. /**
  111633. * Defines an optional offset (in seconds) inside the sound file
  111634. */
  111635. offset?: number;
  111636. /**
  111637. * If true, URLs will not be required to state the audio file codec to use.
  111638. */
  111639. skipCodecCheck?: boolean;
  111640. }
  111641. /**
  111642. * Defines a sound that can be played in the application.
  111643. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  111644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111645. */
  111646. export class Sound {
  111647. /**
  111648. * The name of the sound in the scene.
  111649. */
  111650. name: string;
  111651. /**
  111652. * Does the sound autoplay once loaded.
  111653. */
  111654. autoplay: boolean;
  111655. /**
  111656. * Does the sound loop after it finishes playing once.
  111657. */
  111658. loop: boolean;
  111659. /**
  111660. * Does the sound use a custom attenuation curve to simulate the falloff
  111661. * happening when the source gets further away from the camera.
  111662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111663. */
  111664. useCustomAttenuation: boolean;
  111665. /**
  111666. * The sound track id this sound belongs to.
  111667. */
  111668. soundTrackId: number;
  111669. /**
  111670. * Is this sound currently played.
  111671. */
  111672. isPlaying: boolean;
  111673. /**
  111674. * Is this sound currently paused.
  111675. */
  111676. isPaused: boolean;
  111677. /**
  111678. * Does this sound enables spatial sound.
  111679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111680. */
  111681. spatialSound: boolean;
  111682. /**
  111683. * Define the reference distance the sound should be heard perfectly.
  111684. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111685. */
  111686. refDistance: number;
  111687. /**
  111688. * Define the roll off factor of spatial sounds.
  111689. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111690. */
  111691. rolloffFactor: number;
  111692. /**
  111693. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  111694. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111695. */
  111696. maxDistance: number;
  111697. /**
  111698. * Define the distance attenuation model the sound will follow.
  111699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111700. */
  111701. distanceModel: string;
  111702. /**
  111703. * @hidden
  111704. * Back Compat
  111705. **/
  111706. onended: () => any;
  111707. /**
  111708. * Observable event when the current playing sound finishes.
  111709. */
  111710. onEndedObservable: Observable<Sound>;
  111711. private _panningModel;
  111712. private _playbackRate;
  111713. private _streaming;
  111714. private _startTime;
  111715. private _startOffset;
  111716. private _position;
  111717. /** @hidden */
  111718. _positionInEmitterSpace: boolean;
  111719. private _localDirection;
  111720. private _volume;
  111721. private _isReadyToPlay;
  111722. private _isDirectional;
  111723. private _readyToPlayCallback;
  111724. private _audioBuffer;
  111725. private _soundSource;
  111726. private _streamingSource;
  111727. private _soundPanner;
  111728. private _soundGain;
  111729. private _inputAudioNode;
  111730. private _outputAudioNode;
  111731. private _coneInnerAngle;
  111732. private _coneOuterAngle;
  111733. private _coneOuterGain;
  111734. private _scene;
  111735. private _connectedTransformNode;
  111736. private _customAttenuationFunction;
  111737. private _registerFunc;
  111738. private _isOutputConnected;
  111739. private _htmlAudioElement;
  111740. private _urlType;
  111741. private _length?;
  111742. private _offset?;
  111743. /** @hidden */
  111744. static _SceneComponentInitialization: (scene: Scene) => void;
  111745. /**
  111746. * Create a sound and attach it to a scene
  111747. * @param name Name of your sound
  111748. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111749. * @param scene defines the scene the sound belongs to
  111750. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  111751. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  111752. */
  111753. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  111754. /**
  111755. * Release the sound and its associated resources
  111756. */
  111757. dispose(): void;
  111758. /**
  111759. * Gets if the sounds is ready to be played or not.
  111760. * @returns true if ready, otherwise false
  111761. */
  111762. isReady(): boolean;
  111763. private _soundLoaded;
  111764. /**
  111765. * Sets the data of the sound from an audiobuffer
  111766. * @param audioBuffer The audioBuffer containing the data
  111767. */
  111768. setAudioBuffer(audioBuffer: AudioBuffer): void;
  111769. /**
  111770. * Updates the current sounds options such as maxdistance, loop...
  111771. * @param options A JSON object containing values named as the object properties
  111772. */
  111773. updateOptions(options: ISoundOptions): void;
  111774. private _createSpatialParameters;
  111775. private _updateSpatialParameters;
  111776. /**
  111777. * Switch the panning model to HRTF:
  111778. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111780. */
  111781. switchPanningModelToHRTF(): void;
  111782. /**
  111783. * Switch the panning model to Equal Power:
  111784. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  111785. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111786. */
  111787. switchPanningModelToEqualPower(): void;
  111788. private _switchPanningModel;
  111789. /**
  111790. * Connect this sound to a sound track audio node like gain...
  111791. * @param soundTrackAudioNode the sound track audio node to connect to
  111792. */
  111793. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  111794. /**
  111795. * Transform this sound into a directional source
  111796. * @param coneInnerAngle Size of the inner cone in degree
  111797. * @param coneOuterAngle Size of the outer cone in degree
  111798. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  111799. */
  111800. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  111801. /**
  111802. * Gets or sets the inner angle for the directional cone.
  111803. */
  111804. get directionalConeInnerAngle(): number;
  111805. /**
  111806. * Gets or sets the inner angle for the directional cone.
  111807. */
  111808. set directionalConeInnerAngle(value: number);
  111809. /**
  111810. * Gets or sets the outer angle for the directional cone.
  111811. */
  111812. get directionalConeOuterAngle(): number;
  111813. /**
  111814. * Gets or sets the outer angle for the directional cone.
  111815. */
  111816. set directionalConeOuterAngle(value: number);
  111817. /**
  111818. * Sets the position of the emitter if spatial sound is enabled
  111819. * @param newPosition Defines the new posisiton
  111820. */
  111821. setPosition(newPosition: Vector3): void;
  111822. /**
  111823. * Sets the local direction of the emitter if spatial sound is enabled
  111824. * @param newLocalDirection Defines the new local direction
  111825. */
  111826. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  111827. private _updateDirection;
  111828. /** @hidden */
  111829. updateDistanceFromListener(): void;
  111830. /**
  111831. * Sets a new custom attenuation function for the sound.
  111832. * @param callback Defines the function used for the attenuation
  111833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111834. */
  111835. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  111836. /**
  111837. * Play the sound
  111838. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  111839. * @param offset (optional) Start the sound at a specific time in seconds
  111840. * @param length (optional) Sound duration (in seconds)
  111841. */
  111842. play(time?: number, offset?: number, length?: number): void;
  111843. private _onended;
  111844. /**
  111845. * Stop the sound
  111846. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  111847. */
  111848. stop(time?: number): void;
  111849. /**
  111850. * Put the sound in pause
  111851. */
  111852. pause(): void;
  111853. /**
  111854. * Sets a dedicated volume for this sounds
  111855. * @param newVolume Define the new volume of the sound
  111856. * @param time Define time for gradual change to new volume
  111857. */
  111858. setVolume(newVolume: number, time?: number): void;
  111859. /**
  111860. * Set the sound play back rate
  111861. * @param newPlaybackRate Define the playback rate the sound should be played at
  111862. */
  111863. setPlaybackRate(newPlaybackRate: number): void;
  111864. /**
  111865. * Gets the volume of the sound.
  111866. * @returns the volume of the sound
  111867. */
  111868. getVolume(): number;
  111869. /**
  111870. * Attach the sound to a dedicated mesh
  111871. * @param transformNode The transform node to connect the sound with
  111872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  111873. */
  111874. attachToMesh(transformNode: TransformNode): void;
  111875. /**
  111876. * Detach the sound from the previously attached mesh
  111877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  111878. */
  111879. detachFromMesh(): void;
  111880. private _onRegisterAfterWorldMatrixUpdate;
  111881. /**
  111882. * Clone the current sound in the scene.
  111883. * @returns the new sound clone
  111884. */
  111885. clone(): Nullable<Sound>;
  111886. /**
  111887. * Gets the current underlying audio buffer containing the data
  111888. * @returns the audio buffer
  111889. */
  111890. getAudioBuffer(): Nullable<AudioBuffer>;
  111891. /**
  111892. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  111893. * @returns the source node
  111894. */
  111895. getSoundSource(): Nullable<AudioBufferSourceNode>;
  111896. /**
  111897. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  111898. * @returns the gain node
  111899. */
  111900. getSoundGain(): Nullable<GainNode>;
  111901. /**
  111902. * Serializes the Sound in a JSON representation
  111903. * @returns the JSON representation of the sound
  111904. */
  111905. serialize(): any;
  111906. /**
  111907. * Parse a JSON representation of a sound to innstantiate in a given scene
  111908. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  111909. * @param scene Define the scene the new parsed sound should be created in
  111910. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  111911. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  111912. * @returns the newly parsed sound
  111913. */
  111914. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  111915. }
  111916. }
  111917. declare module BABYLON {
  111918. /**
  111919. * This defines an action helpful to play a defined sound on a triggered action.
  111920. */
  111921. export class PlaySoundAction extends Action {
  111922. private _sound;
  111923. /**
  111924. * Instantiate the action
  111925. * @param triggerOptions defines the trigger options
  111926. * @param sound defines the sound to play
  111927. * @param condition defines the trigger related conditions
  111928. */
  111929. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111930. /** @hidden */
  111931. _prepare(): void;
  111932. /**
  111933. * Execute the action and play the sound.
  111934. */
  111935. execute(): void;
  111936. /**
  111937. * Serializes the actions and its related information.
  111938. * @param parent defines the object to serialize in
  111939. * @returns the serialized object
  111940. */
  111941. serialize(parent: any): any;
  111942. }
  111943. /**
  111944. * This defines an action helpful to stop a defined sound on a triggered action.
  111945. */
  111946. export class StopSoundAction extends Action {
  111947. private _sound;
  111948. /**
  111949. * Instantiate the action
  111950. * @param triggerOptions defines the trigger options
  111951. * @param sound defines the sound to stop
  111952. * @param condition defines the trigger related conditions
  111953. */
  111954. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  111955. /** @hidden */
  111956. _prepare(): void;
  111957. /**
  111958. * Execute the action and stop the sound.
  111959. */
  111960. execute(): void;
  111961. /**
  111962. * Serializes the actions and its related information.
  111963. * @param parent defines the object to serialize in
  111964. * @returns the serialized object
  111965. */
  111966. serialize(parent: any): any;
  111967. }
  111968. }
  111969. declare module BABYLON {
  111970. /**
  111971. * This defines an action responsible to change the value of a property
  111972. * by interpolating between its current value and the newly set one once triggered.
  111973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  111974. */
  111975. export class InterpolateValueAction extends Action {
  111976. /**
  111977. * Defines the path of the property where the value should be interpolated
  111978. */
  111979. propertyPath: string;
  111980. /**
  111981. * Defines the target value at the end of the interpolation.
  111982. */
  111983. value: any;
  111984. /**
  111985. * Defines the time it will take for the property to interpolate to the value.
  111986. */
  111987. duration: number;
  111988. /**
  111989. * Defines if the other scene animations should be stopped when the action has been triggered
  111990. */
  111991. stopOtherAnimations?: boolean;
  111992. /**
  111993. * Defines a callback raised once the interpolation animation has been done.
  111994. */
  111995. onInterpolationDone?: () => void;
  111996. /**
  111997. * Observable triggered once the interpolation animation has been done.
  111998. */
  111999. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  112000. private _target;
  112001. private _effectiveTarget;
  112002. private _property;
  112003. /**
  112004. * Instantiate the action
  112005. * @param triggerOptions defines the trigger options
  112006. * @param target defines the object containing the value to interpolate
  112007. * @param propertyPath defines the path to the property in the target object
  112008. * @param value defines the target value at the end of the interpolation
  112009. * @param duration deines the time it will take for the property to interpolate to the value.
  112010. * @param condition defines the trigger related conditions
  112011. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  112012. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  112013. */
  112014. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  112015. /** @hidden */
  112016. _prepare(): void;
  112017. /**
  112018. * Execute the action starts the value interpolation.
  112019. */
  112020. execute(): void;
  112021. /**
  112022. * Serializes the actions and its related information.
  112023. * @param parent defines the object to serialize in
  112024. * @returns the serialized object
  112025. */
  112026. serialize(parent: any): any;
  112027. }
  112028. }
  112029. declare module BABYLON {
  112030. /**
  112031. * Options allowed during the creation of a sound track.
  112032. */
  112033. export interface ISoundTrackOptions {
  112034. /**
  112035. * The volume the sound track should take during creation
  112036. */
  112037. volume?: number;
  112038. /**
  112039. * Define if the sound track is the main sound track of the scene
  112040. */
  112041. mainTrack?: boolean;
  112042. }
  112043. /**
  112044. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  112045. * It will be also used in a future release to apply effects on a specific track.
  112046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112047. */
  112048. export class SoundTrack {
  112049. /**
  112050. * The unique identifier of the sound track in the scene.
  112051. */
  112052. id: number;
  112053. /**
  112054. * The list of sounds included in the sound track.
  112055. */
  112056. soundCollection: Array<Sound>;
  112057. private _outputAudioNode;
  112058. private _scene;
  112059. private _connectedAnalyser;
  112060. private _options;
  112061. private _isInitialized;
  112062. /**
  112063. * Creates a new sound track.
  112064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112065. * @param scene Define the scene the sound track belongs to
  112066. * @param options
  112067. */
  112068. constructor(scene: Scene, options?: ISoundTrackOptions);
  112069. private _initializeSoundTrackAudioGraph;
  112070. /**
  112071. * Release the sound track and its associated resources
  112072. */
  112073. dispose(): void;
  112074. /**
  112075. * Adds a sound to this sound track
  112076. * @param sound define the cound to add
  112077. * @ignoreNaming
  112078. */
  112079. AddSound(sound: Sound): void;
  112080. /**
  112081. * Removes a sound to this sound track
  112082. * @param sound define the cound to remove
  112083. * @ignoreNaming
  112084. */
  112085. RemoveSound(sound: Sound): void;
  112086. /**
  112087. * Set a global volume for the full sound track.
  112088. * @param newVolume Define the new volume of the sound track
  112089. */
  112090. setVolume(newVolume: number): void;
  112091. /**
  112092. * Switch the panning model to HRTF:
  112093. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112095. */
  112096. switchPanningModelToHRTF(): void;
  112097. /**
  112098. * Switch the panning model to Equal Power:
  112099. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112101. */
  112102. switchPanningModelToEqualPower(): void;
  112103. /**
  112104. * Connect the sound track to an audio analyser allowing some amazing
  112105. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112107. * @param analyser The analyser to connect to the engine
  112108. */
  112109. connectToAnalyser(analyser: Analyser): void;
  112110. }
  112111. }
  112112. declare module BABYLON {
  112113. interface AbstractScene {
  112114. /**
  112115. * The list of sounds used in the scene.
  112116. */
  112117. sounds: Nullable<Array<Sound>>;
  112118. }
  112119. interface Scene {
  112120. /**
  112121. * @hidden
  112122. * Backing field
  112123. */
  112124. _mainSoundTrack: SoundTrack;
  112125. /**
  112126. * The main sound track played by the scene.
  112127. * It cotains your primary collection of sounds.
  112128. */
  112129. mainSoundTrack: SoundTrack;
  112130. /**
  112131. * The list of sound tracks added to the scene
  112132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112133. */
  112134. soundTracks: Nullable<Array<SoundTrack>>;
  112135. /**
  112136. * Gets a sound using a given name
  112137. * @param name defines the name to search for
  112138. * @return the found sound or null if not found at all.
  112139. */
  112140. getSoundByName(name: string): Nullable<Sound>;
  112141. /**
  112142. * Gets or sets if audio support is enabled
  112143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112144. */
  112145. audioEnabled: boolean;
  112146. /**
  112147. * Gets or sets if audio will be output to headphones
  112148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112149. */
  112150. headphone: boolean;
  112151. /**
  112152. * Gets or sets custom audio listener position provider
  112153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112154. */
  112155. audioListenerPositionProvider: Nullable<() => Vector3>;
  112156. /**
  112157. * Gets or sets a refresh rate when using 3D audio positioning
  112158. */
  112159. audioPositioningRefreshRate: number;
  112160. }
  112161. /**
  112162. * Defines the sound scene component responsible to manage any sounds
  112163. * in a given scene.
  112164. */
  112165. export class AudioSceneComponent implements ISceneSerializableComponent {
  112166. /**
  112167. * The component name helpfull to identify the component in the list of scene components.
  112168. */
  112169. readonly name: string;
  112170. /**
  112171. * The scene the component belongs to.
  112172. */
  112173. scene: Scene;
  112174. private _audioEnabled;
  112175. /**
  112176. * Gets whether audio is enabled or not.
  112177. * Please use related enable/disable method to switch state.
  112178. */
  112179. get audioEnabled(): boolean;
  112180. private _headphone;
  112181. /**
  112182. * Gets whether audio is outputing to headphone or not.
  112183. * Please use the according Switch methods to change output.
  112184. */
  112185. get headphone(): boolean;
  112186. /**
  112187. * Gets or sets a refresh rate when using 3D audio positioning
  112188. */
  112189. audioPositioningRefreshRate: number;
  112190. private _audioListenerPositionProvider;
  112191. /**
  112192. * Gets the current audio listener position provider
  112193. */
  112194. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  112195. /**
  112196. * Sets a custom listener position for all sounds in the scene
  112197. * By default, this is the position of the first active camera
  112198. */
  112199. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  112200. /**
  112201. * Creates a new instance of the component for the given scene
  112202. * @param scene Defines the scene to register the component in
  112203. */
  112204. constructor(scene: Scene);
  112205. /**
  112206. * Registers the component in a given scene
  112207. */
  112208. register(): void;
  112209. /**
  112210. * Rebuilds the elements related to this component in case of
  112211. * context lost for instance.
  112212. */
  112213. rebuild(): void;
  112214. /**
  112215. * Serializes the component data to the specified json object
  112216. * @param serializationObject The object to serialize to
  112217. */
  112218. serialize(serializationObject: any): void;
  112219. /**
  112220. * Adds all the elements from the container to the scene
  112221. * @param container the container holding the elements
  112222. */
  112223. addFromContainer(container: AbstractScene): void;
  112224. /**
  112225. * Removes all the elements in the container from the scene
  112226. * @param container contains the elements to remove
  112227. * @param dispose if the removed element should be disposed (default: false)
  112228. */
  112229. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112230. /**
  112231. * Disposes the component and the associated ressources.
  112232. */
  112233. dispose(): void;
  112234. /**
  112235. * Disables audio in the associated scene.
  112236. */
  112237. disableAudio(): void;
  112238. /**
  112239. * Enables audio in the associated scene.
  112240. */
  112241. enableAudio(): void;
  112242. /**
  112243. * Switch audio to headphone output.
  112244. */
  112245. switchAudioModeForHeadphones(): void;
  112246. /**
  112247. * Switch audio to normal speakers.
  112248. */
  112249. switchAudioModeForNormalSpeakers(): void;
  112250. private _cachedCameraDirection;
  112251. private _cachedCameraPosition;
  112252. private _lastCheck;
  112253. private _afterRender;
  112254. }
  112255. }
  112256. declare module BABYLON {
  112257. /**
  112258. * Wraps one or more Sound objects and selects one with random weight for playback.
  112259. */
  112260. export class WeightedSound {
  112261. /** When true a Sound will be selected and played when the current playing Sound completes. */
  112262. loop: boolean;
  112263. private _coneInnerAngle;
  112264. private _coneOuterAngle;
  112265. private _volume;
  112266. /** A Sound is currently playing. */
  112267. isPlaying: boolean;
  112268. /** A Sound is currently paused. */
  112269. isPaused: boolean;
  112270. private _sounds;
  112271. private _weights;
  112272. private _currentIndex?;
  112273. /**
  112274. * Creates a new WeightedSound from the list of sounds given.
  112275. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  112276. * @param sounds Array of Sounds that will be selected from.
  112277. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  112278. */
  112279. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  112280. /**
  112281. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  112282. */
  112283. get directionalConeInnerAngle(): number;
  112284. /**
  112285. * The size of cone in degress for a directional sound in which there will be no attenuation.
  112286. */
  112287. set directionalConeInnerAngle(value: number);
  112288. /**
  112289. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112290. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112291. */
  112292. get directionalConeOuterAngle(): number;
  112293. /**
  112294. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112295. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112296. */
  112297. set directionalConeOuterAngle(value: number);
  112298. /**
  112299. * Playback volume.
  112300. */
  112301. get volume(): number;
  112302. /**
  112303. * Playback volume.
  112304. */
  112305. set volume(value: number);
  112306. private _onended;
  112307. /**
  112308. * Suspend playback
  112309. */
  112310. pause(): void;
  112311. /**
  112312. * Stop playback
  112313. */
  112314. stop(): void;
  112315. /**
  112316. * Start playback.
  112317. * @param startOffset Position the clip head at a specific time in seconds.
  112318. */
  112319. play(startOffset?: number): void;
  112320. }
  112321. }
  112322. declare module BABYLON {
  112323. /**
  112324. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  112325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112326. */
  112327. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  112328. /**
  112329. * Gets the name of the behavior.
  112330. */
  112331. get name(): string;
  112332. /**
  112333. * The easing function used by animations
  112334. */
  112335. static EasingFunction: BackEase;
  112336. /**
  112337. * The easing mode used by animations
  112338. */
  112339. static EasingMode: number;
  112340. /**
  112341. * The duration of the animation, in milliseconds
  112342. */
  112343. transitionDuration: number;
  112344. /**
  112345. * Length of the distance animated by the transition when lower radius is reached
  112346. */
  112347. lowerRadiusTransitionRange: number;
  112348. /**
  112349. * Length of the distance animated by the transition when upper radius is reached
  112350. */
  112351. upperRadiusTransitionRange: number;
  112352. private _autoTransitionRange;
  112353. /**
  112354. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112355. */
  112356. get autoTransitionRange(): boolean;
  112357. /**
  112358. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112359. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  112360. */
  112361. set autoTransitionRange(value: boolean);
  112362. private _attachedCamera;
  112363. private _onAfterCheckInputsObserver;
  112364. private _onMeshTargetChangedObserver;
  112365. /**
  112366. * Initializes the behavior.
  112367. */
  112368. init(): void;
  112369. /**
  112370. * Attaches the behavior to its arc rotate camera.
  112371. * @param camera Defines the camera to attach the behavior to
  112372. */
  112373. attach(camera: ArcRotateCamera): void;
  112374. /**
  112375. * Detaches the behavior from its current arc rotate camera.
  112376. */
  112377. detach(): void;
  112378. private _radiusIsAnimating;
  112379. private _radiusBounceTransition;
  112380. private _animatables;
  112381. private _cachedWheelPrecision;
  112382. /**
  112383. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  112384. * @param radiusLimit The limit to check against.
  112385. * @return Bool to indicate if at limit.
  112386. */
  112387. private _isRadiusAtLimit;
  112388. /**
  112389. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  112390. * @param radiusDelta The delta by which to animate to. Can be negative.
  112391. */
  112392. private _applyBoundRadiusAnimation;
  112393. /**
  112394. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  112395. */
  112396. protected _clearAnimationLocks(): void;
  112397. /**
  112398. * Stops and removes all animations that have been applied to the camera
  112399. */
  112400. stopAllAnimations(): void;
  112401. }
  112402. }
  112403. declare module BABYLON {
  112404. /**
  112405. * 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.
  112406. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112407. */
  112408. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  112409. /**
  112410. * Gets the name of the behavior.
  112411. */
  112412. get name(): string;
  112413. private _mode;
  112414. private _radiusScale;
  112415. private _positionScale;
  112416. private _defaultElevation;
  112417. private _elevationReturnTime;
  112418. private _elevationReturnWaitTime;
  112419. private _zoomStopsAnimation;
  112420. private _framingTime;
  112421. /**
  112422. * The easing function used by animations
  112423. */
  112424. static EasingFunction: ExponentialEase;
  112425. /**
  112426. * The easing mode used by animations
  112427. */
  112428. static EasingMode: number;
  112429. /**
  112430. * Sets the current mode used by the behavior
  112431. */
  112432. set mode(mode: number);
  112433. /**
  112434. * Gets current mode used by the behavior.
  112435. */
  112436. get mode(): number;
  112437. /**
  112438. * Sets the scale applied to the radius (1 by default)
  112439. */
  112440. set radiusScale(radius: number);
  112441. /**
  112442. * Gets the scale applied to the radius
  112443. */
  112444. get radiusScale(): number;
  112445. /**
  112446. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112447. */
  112448. set positionScale(scale: number);
  112449. /**
  112450. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112451. */
  112452. get positionScale(): number;
  112453. /**
  112454. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112455. * behaviour is triggered, in radians.
  112456. */
  112457. set defaultElevation(elevation: number);
  112458. /**
  112459. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112460. * behaviour is triggered, in radians.
  112461. */
  112462. get defaultElevation(): number;
  112463. /**
  112464. * Sets the time (in milliseconds) taken to return to the default beta position.
  112465. * Negative value indicates camera should not return to default.
  112466. */
  112467. set elevationReturnTime(speed: number);
  112468. /**
  112469. * Gets the time (in milliseconds) taken to return to the default beta position.
  112470. * Negative value indicates camera should not return to default.
  112471. */
  112472. get elevationReturnTime(): number;
  112473. /**
  112474. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112475. */
  112476. set elevationReturnWaitTime(time: number);
  112477. /**
  112478. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112479. */
  112480. get elevationReturnWaitTime(): number;
  112481. /**
  112482. * Sets the flag that indicates if user zooming should stop animation.
  112483. */
  112484. set zoomStopsAnimation(flag: boolean);
  112485. /**
  112486. * Gets the flag that indicates if user zooming should stop animation.
  112487. */
  112488. get zoomStopsAnimation(): boolean;
  112489. /**
  112490. * Sets the transition time when framing the mesh, in milliseconds
  112491. */
  112492. set framingTime(time: number);
  112493. /**
  112494. * Gets the transition time when framing the mesh, in milliseconds
  112495. */
  112496. get framingTime(): number;
  112497. /**
  112498. * Define if the behavior should automatically change the configured
  112499. * camera limits and sensibilities.
  112500. */
  112501. autoCorrectCameraLimitsAndSensibility: boolean;
  112502. private _onPrePointerObservableObserver;
  112503. private _onAfterCheckInputsObserver;
  112504. private _onMeshTargetChangedObserver;
  112505. private _attachedCamera;
  112506. private _isPointerDown;
  112507. private _lastInteractionTime;
  112508. /**
  112509. * Initializes the behavior.
  112510. */
  112511. init(): void;
  112512. /**
  112513. * Attaches the behavior to its arc rotate camera.
  112514. * @param camera Defines the camera to attach the behavior to
  112515. */
  112516. attach(camera: ArcRotateCamera): void;
  112517. /**
  112518. * Detaches the behavior from its current arc rotate camera.
  112519. */
  112520. detach(): void;
  112521. private _animatables;
  112522. private _betaIsAnimating;
  112523. private _betaTransition;
  112524. private _radiusTransition;
  112525. private _vectorTransition;
  112526. /**
  112527. * Targets the given mesh and updates zoom level accordingly.
  112528. * @param mesh The mesh to target.
  112529. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112530. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112531. */
  112532. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112533. /**
  112534. * Targets the given mesh with its children and updates zoom level accordingly.
  112535. * @param mesh The mesh to target.
  112536. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112537. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112538. */
  112539. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112540. /**
  112541. * Targets the given meshes with their children and updates zoom level accordingly.
  112542. * @param meshes The mesh to target.
  112543. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112544. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112545. */
  112546. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112547. /**
  112548. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  112549. * @param minimumWorld Determines the smaller position of the bounding box extend
  112550. * @param maximumWorld Determines the bigger position of the bounding box extend
  112551. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112552. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112553. */
  112554. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112555. /**
  112556. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  112557. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  112558. * frustum width.
  112559. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  112560. * to fully enclose the mesh in the viewing frustum.
  112561. */
  112562. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  112563. /**
  112564. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  112565. * is automatically returned to its default position (expected to be above ground plane).
  112566. */
  112567. private _maintainCameraAboveGround;
  112568. /**
  112569. * Returns the frustum slope based on the canvas ratio and camera FOV
  112570. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  112571. */
  112572. private _getFrustumSlope;
  112573. /**
  112574. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  112575. */
  112576. private _clearAnimationLocks;
  112577. /**
  112578. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112579. */
  112580. private _applyUserInteraction;
  112581. /**
  112582. * Stops and removes all animations that have been applied to the camera
  112583. */
  112584. stopAllAnimations(): void;
  112585. /**
  112586. * Gets a value indicating if the user is moving the camera
  112587. */
  112588. get isUserIsMoving(): boolean;
  112589. /**
  112590. * The camera can move all the way towards the mesh.
  112591. */
  112592. static IgnoreBoundsSizeMode: number;
  112593. /**
  112594. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  112595. */
  112596. static FitFrustumSidesMode: number;
  112597. }
  112598. }
  112599. declare module BABYLON {
  112600. /**
  112601. * Base class for Camera Pointer Inputs.
  112602. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  112603. * for example usage.
  112604. */
  112605. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  112606. /**
  112607. * Defines the camera the input is attached to.
  112608. */
  112609. abstract camera: Camera;
  112610. /**
  112611. * Whether keyboard modifier keys are pressed at time of last mouse event.
  112612. */
  112613. protected _altKey: boolean;
  112614. protected _ctrlKey: boolean;
  112615. protected _metaKey: boolean;
  112616. protected _shiftKey: boolean;
  112617. /**
  112618. * Which mouse buttons were pressed at time of last mouse event.
  112619. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  112620. */
  112621. protected _buttonsPressed: number;
  112622. /**
  112623. * Defines the buttons associated with the input to handle camera move.
  112624. */
  112625. buttons: number[];
  112626. /**
  112627. * Attach the input controls to a specific dom element to get the input from.
  112628. * @param element Defines the element the controls should be listened from
  112629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112630. */
  112631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112632. /**
  112633. * Detach the current controls from the specified dom element.
  112634. * @param element Defines the element to stop listening the inputs from
  112635. */
  112636. detachControl(element: Nullable<HTMLElement>): void;
  112637. /**
  112638. * Gets the class name of the current input.
  112639. * @returns the class name
  112640. */
  112641. getClassName(): string;
  112642. /**
  112643. * Get the friendly name associated with the input class.
  112644. * @returns the input friendly name
  112645. */
  112646. getSimpleName(): string;
  112647. /**
  112648. * Called on pointer POINTERDOUBLETAP event.
  112649. * Override this method to provide functionality on POINTERDOUBLETAP event.
  112650. */
  112651. protected onDoubleTap(type: string): void;
  112652. /**
  112653. * Called on pointer POINTERMOVE event if only a single touch is active.
  112654. * Override this method to provide functionality.
  112655. */
  112656. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112657. /**
  112658. * Called on pointer POINTERMOVE event if multiple touches are active.
  112659. * Override this method to provide functionality.
  112660. */
  112661. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112662. /**
  112663. * Called on JS contextmenu event.
  112664. * Override this method to provide functionality.
  112665. */
  112666. protected onContextMenu(evt: PointerEvent): void;
  112667. /**
  112668. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112669. * press.
  112670. * Override this method to provide functionality.
  112671. */
  112672. protected onButtonDown(evt: PointerEvent): void;
  112673. /**
  112674. * Called each time a new POINTERUP event occurs. Ie, for each button
  112675. * release.
  112676. * Override this method to provide functionality.
  112677. */
  112678. protected onButtonUp(evt: PointerEvent): void;
  112679. /**
  112680. * Called when window becomes inactive.
  112681. * Override this method to provide functionality.
  112682. */
  112683. protected onLostFocus(): void;
  112684. private _pointerInput;
  112685. private _observer;
  112686. private _onLostFocus;
  112687. private pointA;
  112688. private pointB;
  112689. }
  112690. }
  112691. declare module BABYLON {
  112692. /**
  112693. * Manage the pointers inputs to control an arc rotate camera.
  112694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112695. */
  112696. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  112697. /**
  112698. * Defines the camera the input is attached to.
  112699. */
  112700. camera: ArcRotateCamera;
  112701. /**
  112702. * Gets the class name of the current input.
  112703. * @returns the class name
  112704. */
  112705. getClassName(): string;
  112706. /**
  112707. * Defines the buttons associated with the input to handle camera move.
  112708. */
  112709. buttons: number[];
  112710. /**
  112711. * Defines the pointer angular sensibility along the X axis or how fast is
  112712. * the camera rotating.
  112713. */
  112714. angularSensibilityX: number;
  112715. /**
  112716. * Defines the pointer angular sensibility along the Y axis or how fast is
  112717. * the camera rotating.
  112718. */
  112719. angularSensibilityY: number;
  112720. /**
  112721. * Defines the pointer pinch precision or how fast is the camera zooming.
  112722. */
  112723. pinchPrecision: number;
  112724. /**
  112725. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112726. * from 0.
  112727. * It defines the percentage of current camera.radius to use as delta when
  112728. * pinch zoom is used.
  112729. */
  112730. pinchDeltaPercentage: number;
  112731. /**
  112732. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112733. * that any object in the plane at the camera's target point will scale
  112734. * perfectly with finger motion.
  112735. * Overrides pinchDeltaPercentage and pinchPrecision.
  112736. */
  112737. useNaturalPinchZoom: boolean;
  112738. /**
  112739. * Defines the pointer panning sensibility or how fast is the camera moving.
  112740. */
  112741. panningSensibility: number;
  112742. /**
  112743. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112744. */
  112745. multiTouchPanning: boolean;
  112746. /**
  112747. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112748. * zoom (pinch) through multitouch.
  112749. */
  112750. multiTouchPanAndZoom: boolean;
  112751. /**
  112752. * Revers pinch action direction.
  112753. */
  112754. pinchInwards: boolean;
  112755. private _isPanClick;
  112756. private _twoFingerActivityCount;
  112757. private _isPinching;
  112758. /**
  112759. * Called on pointer POINTERMOVE event if only a single touch is active.
  112760. */
  112761. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112762. /**
  112763. * Called on pointer POINTERDOUBLETAP event.
  112764. */
  112765. protected onDoubleTap(type: string): void;
  112766. /**
  112767. * Called on pointer POINTERMOVE event if multiple touches are active.
  112768. */
  112769. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112770. /**
  112771. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112772. * press.
  112773. */
  112774. protected onButtonDown(evt: PointerEvent): void;
  112775. /**
  112776. * Called each time a new POINTERUP event occurs. Ie, for each button
  112777. * release.
  112778. */
  112779. protected onButtonUp(evt: PointerEvent): void;
  112780. /**
  112781. * Called when window becomes inactive.
  112782. */
  112783. protected onLostFocus(): void;
  112784. }
  112785. }
  112786. declare module BABYLON {
  112787. /**
  112788. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  112789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112790. */
  112791. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  112792. /**
  112793. * Defines the camera the input is attached to.
  112794. */
  112795. camera: ArcRotateCamera;
  112796. /**
  112797. * Defines the list of key codes associated with the up action (increase alpha)
  112798. */
  112799. keysUp: number[];
  112800. /**
  112801. * Defines the list of key codes associated with the down action (decrease alpha)
  112802. */
  112803. keysDown: number[];
  112804. /**
  112805. * Defines the list of key codes associated with the left action (increase beta)
  112806. */
  112807. keysLeft: number[];
  112808. /**
  112809. * Defines the list of key codes associated with the right action (decrease beta)
  112810. */
  112811. keysRight: number[];
  112812. /**
  112813. * Defines the list of key codes associated with the reset action.
  112814. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  112815. */
  112816. keysReset: number[];
  112817. /**
  112818. * Defines the panning sensibility of the inputs.
  112819. * (How fast is the camera panning)
  112820. */
  112821. panningSensibility: number;
  112822. /**
  112823. * Defines the zooming sensibility of the inputs.
  112824. * (How fast is the camera zooming)
  112825. */
  112826. zoomingSensibility: number;
  112827. /**
  112828. * Defines whether maintaining the alt key down switch the movement mode from
  112829. * orientation to zoom.
  112830. */
  112831. useAltToZoom: boolean;
  112832. /**
  112833. * Rotation speed of the camera
  112834. */
  112835. angularSpeed: number;
  112836. private _keys;
  112837. private _ctrlPressed;
  112838. private _altPressed;
  112839. private _onCanvasBlurObserver;
  112840. private _onKeyboardObserver;
  112841. private _engine;
  112842. private _scene;
  112843. /**
  112844. * Attach the input controls to a specific dom element to get the input from.
  112845. * @param element Defines the element the controls should be listened from
  112846. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112847. */
  112848. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112849. /**
  112850. * Detach the current controls from the specified dom element.
  112851. * @param element Defines the element to stop listening the inputs from
  112852. */
  112853. detachControl(element: Nullable<HTMLElement>): void;
  112854. /**
  112855. * Update the current camera state depending on the inputs that have been used this frame.
  112856. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112857. */
  112858. checkInputs(): void;
  112859. /**
  112860. * Gets the class name of the current intput.
  112861. * @returns the class name
  112862. */
  112863. getClassName(): string;
  112864. /**
  112865. * Get the friendly name associated with the input class.
  112866. * @returns the input friendly name
  112867. */
  112868. getSimpleName(): string;
  112869. }
  112870. }
  112871. declare module BABYLON {
  112872. /**
  112873. * Manage the mouse wheel inputs to control an arc rotate camera.
  112874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112875. */
  112876. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  112877. /**
  112878. * Defines the camera the input is attached to.
  112879. */
  112880. camera: ArcRotateCamera;
  112881. /**
  112882. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112883. */
  112884. wheelPrecision: number;
  112885. /**
  112886. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  112887. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  112888. */
  112889. wheelDeltaPercentage: number;
  112890. private _wheel;
  112891. private _observer;
  112892. private computeDeltaFromMouseWheelLegacyEvent;
  112893. /**
  112894. * Attach the input controls to a specific dom element to get the input from.
  112895. * @param element Defines the element the controls should be listened from
  112896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112897. */
  112898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112899. /**
  112900. * Detach the current controls from the specified dom element.
  112901. * @param element Defines the element to stop listening the inputs from
  112902. */
  112903. detachControl(element: Nullable<HTMLElement>): void;
  112904. /**
  112905. * Gets the class name of the current intput.
  112906. * @returns the class name
  112907. */
  112908. getClassName(): string;
  112909. /**
  112910. * Get the friendly name associated with the input class.
  112911. * @returns the input friendly name
  112912. */
  112913. getSimpleName(): string;
  112914. }
  112915. }
  112916. declare module BABYLON {
  112917. /**
  112918. * Default Inputs manager for the ArcRotateCamera.
  112919. * It groups all the default supported inputs for ease of use.
  112920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112921. */
  112922. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  112923. /**
  112924. * Instantiates a new ArcRotateCameraInputsManager.
  112925. * @param camera Defines the camera the inputs belong to
  112926. */
  112927. constructor(camera: ArcRotateCamera);
  112928. /**
  112929. * Add mouse wheel input support to the input manager.
  112930. * @returns the current input manager
  112931. */
  112932. addMouseWheel(): ArcRotateCameraInputsManager;
  112933. /**
  112934. * Add pointers input support to the input manager.
  112935. * @returns the current input manager
  112936. */
  112937. addPointers(): ArcRotateCameraInputsManager;
  112938. /**
  112939. * Add keyboard input support to the input manager.
  112940. * @returns the current input manager
  112941. */
  112942. addKeyboard(): ArcRotateCameraInputsManager;
  112943. }
  112944. }
  112945. declare module BABYLON {
  112946. /**
  112947. * This represents an orbital type of camera.
  112948. *
  112949. * 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.
  112950. * 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.
  112951. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  112952. */
  112953. export class ArcRotateCamera extends TargetCamera {
  112954. /**
  112955. * Defines the rotation angle of the camera along the longitudinal axis.
  112956. */
  112957. alpha: number;
  112958. /**
  112959. * Defines the rotation angle of the camera along the latitudinal axis.
  112960. */
  112961. beta: number;
  112962. /**
  112963. * Defines the radius of the camera from it s target point.
  112964. */
  112965. radius: number;
  112966. protected _target: Vector3;
  112967. protected _targetHost: Nullable<AbstractMesh>;
  112968. /**
  112969. * Defines the target point of the camera.
  112970. * The camera looks towards it form the radius distance.
  112971. */
  112972. get target(): Vector3;
  112973. set target(value: Vector3);
  112974. /**
  112975. * Define the current local position of the camera in the scene
  112976. */
  112977. get position(): Vector3;
  112978. set position(newPosition: Vector3);
  112979. protected _upVector: Vector3;
  112980. protected _upToYMatrix: Matrix;
  112981. protected _YToUpMatrix: Matrix;
  112982. /**
  112983. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  112984. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  112985. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  112986. */
  112987. set upVector(vec: Vector3);
  112988. get upVector(): Vector3;
  112989. /**
  112990. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  112991. */
  112992. setMatUp(): void;
  112993. /**
  112994. * Current inertia value on the longitudinal axis.
  112995. * The bigger this number the longer it will take for the camera to stop.
  112996. */
  112997. inertialAlphaOffset: number;
  112998. /**
  112999. * Current inertia value on the latitudinal axis.
  113000. * The bigger this number the longer it will take for the camera to stop.
  113001. */
  113002. inertialBetaOffset: number;
  113003. /**
  113004. * Current inertia value on the radius axis.
  113005. * The bigger this number the longer it will take for the camera to stop.
  113006. */
  113007. inertialRadiusOffset: number;
  113008. /**
  113009. * Minimum allowed angle on the longitudinal axis.
  113010. * This can help limiting how the Camera is able to move in the scene.
  113011. */
  113012. lowerAlphaLimit: Nullable<number>;
  113013. /**
  113014. * Maximum allowed angle on the longitudinal axis.
  113015. * This can help limiting how the Camera is able to move in the scene.
  113016. */
  113017. upperAlphaLimit: Nullable<number>;
  113018. /**
  113019. * Minimum allowed angle on the latitudinal axis.
  113020. * This can help limiting how the Camera is able to move in the scene.
  113021. */
  113022. lowerBetaLimit: number;
  113023. /**
  113024. * Maximum allowed angle on the latitudinal axis.
  113025. * This can help limiting how the Camera is able to move in the scene.
  113026. */
  113027. upperBetaLimit: number;
  113028. /**
  113029. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  113030. * This can help limiting how the Camera is able to move in the scene.
  113031. */
  113032. lowerRadiusLimit: Nullable<number>;
  113033. /**
  113034. * Maximum allowed distance of the camera to the target (The camera can not get further).
  113035. * This can help limiting how the Camera is able to move in the scene.
  113036. */
  113037. upperRadiusLimit: Nullable<number>;
  113038. /**
  113039. * Defines the current inertia value used during panning of the camera along the X axis.
  113040. */
  113041. inertialPanningX: number;
  113042. /**
  113043. * Defines the current inertia value used during panning of the camera along the Y axis.
  113044. */
  113045. inertialPanningY: number;
  113046. /**
  113047. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  113048. * Basically if your fingers moves away from more than this distance you will be considered
  113049. * in pinch mode.
  113050. */
  113051. pinchToPanMaxDistance: number;
  113052. /**
  113053. * Defines the maximum distance the camera can pan.
  113054. * This could help keeping the cammera always in your scene.
  113055. */
  113056. panningDistanceLimit: Nullable<number>;
  113057. /**
  113058. * Defines the target of the camera before paning.
  113059. */
  113060. panningOriginTarget: Vector3;
  113061. /**
  113062. * Defines the value of the inertia used during panning.
  113063. * 0 would mean stop inertia and one would mean no decelleration at all.
  113064. */
  113065. panningInertia: number;
  113066. /**
  113067. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  113068. */
  113069. get angularSensibilityX(): number;
  113070. set angularSensibilityX(value: number);
  113071. /**
  113072. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  113073. */
  113074. get angularSensibilityY(): number;
  113075. set angularSensibilityY(value: number);
  113076. /**
  113077. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  113078. */
  113079. get pinchPrecision(): number;
  113080. set pinchPrecision(value: number);
  113081. /**
  113082. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  113083. * It will be used instead of pinchDeltaPrecision if different from 0.
  113084. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113085. */
  113086. get pinchDeltaPercentage(): number;
  113087. set pinchDeltaPercentage(value: number);
  113088. /**
  113089. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  113090. * and pinch delta percentage.
  113091. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  113092. * that any object in the plane at the camera's target point will scale
  113093. * perfectly with finger motion.
  113094. */
  113095. get useNaturalPinchZoom(): boolean;
  113096. set useNaturalPinchZoom(value: boolean);
  113097. /**
  113098. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  113099. */
  113100. get panningSensibility(): number;
  113101. set panningSensibility(value: number);
  113102. /**
  113103. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  113104. */
  113105. get keysUp(): number[];
  113106. set keysUp(value: number[]);
  113107. /**
  113108. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  113109. */
  113110. get keysDown(): number[];
  113111. set keysDown(value: number[]);
  113112. /**
  113113. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  113114. */
  113115. get keysLeft(): number[];
  113116. set keysLeft(value: number[]);
  113117. /**
  113118. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  113119. */
  113120. get keysRight(): number[];
  113121. set keysRight(value: number[]);
  113122. /**
  113123. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113124. */
  113125. get wheelPrecision(): number;
  113126. set wheelPrecision(value: number);
  113127. /**
  113128. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  113129. * It will be used instead of pinchDeltaPrecision if different from 0.
  113130. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113131. */
  113132. get wheelDeltaPercentage(): number;
  113133. set wheelDeltaPercentage(value: number);
  113134. /**
  113135. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  113136. */
  113137. zoomOnFactor: number;
  113138. /**
  113139. * Defines a screen offset for the camera position.
  113140. */
  113141. targetScreenOffset: Vector2;
  113142. /**
  113143. * Allows the camera to be completely reversed.
  113144. * If false the camera can not arrive upside down.
  113145. */
  113146. allowUpsideDown: boolean;
  113147. /**
  113148. * Define if double tap/click is used to restore the previously saved state of the camera.
  113149. */
  113150. useInputToRestoreState: boolean;
  113151. /** @hidden */
  113152. _viewMatrix: Matrix;
  113153. /** @hidden */
  113154. _useCtrlForPanning: boolean;
  113155. /** @hidden */
  113156. _panningMouseButton: number;
  113157. /**
  113158. * Defines the input associated to the camera.
  113159. */
  113160. inputs: ArcRotateCameraInputsManager;
  113161. /** @hidden */
  113162. _reset: () => void;
  113163. /**
  113164. * Defines the allowed panning axis.
  113165. */
  113166. panningAxis: Vector3;
  113167. protected _localDirection: Vector3;
  113168. protected _transformedDirection: Vector3;
  113169. private _bouncingBehavior;
  113170. /**
  113171. * Gets the bouncing behavior of the camera if it has been enabled.
  113172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113173. */
  113174. get bouncingBehavior(): Nullable<BouncingBehavior>;
  113175. /**
  113176. * Defines if the bouncing behavior of the camera is enabled on the camera.
  113177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113178. */
  113179. get useBouncingBehavior(): boolean;
  113180. set useBouncingBehavior(value: boolean);
  113181. private _framingBehavior;
  113182. /**
  113183. * Gets the framing behavior of the camera if it has been enabled.
  113184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113185. */
  113186. get framingBehavior(): Nullable<FramingBehavior>;
  113187. /**
  113188. * Defines if the framing behavior of the camera is enabled on the camera.
  113189. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113190. */
  113191. get useFramingBehavior(): boolean;
  113192. set useFramingBehavior(value: boolean);
  113193. private _autoRotationBehavior;
  113194. /**
  113195. * Gets the auto rotation behavior of the camera if it has been enabled.
  113196. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113197. */
  113198. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  113199. /**
  113200. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  113201. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113202. */
  113203. get useAutoRotationBehavior(): boolean;
  113204. set useAutoRotationBehavior(value: boolean);
  113205. /**
  113206. * Observable triggered when the mesh target has been changed on the camera.
  113207. */
  113208. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  113209. /**
  113210. * Event raised when the camera is colliding with a mesh.
  113211. */
  113212. onCollide: (collidedMesh: AbstractMesh) => void;
  113213. /**
  113214. * Defines whether the camera should check collision with the objects oh the scene.
  113215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  113216. */
  113217. checkCollisions: boolean;
  113218. /**
  113219. * Defines the collision radius of the camera.
  113220. * This simulates a sphere around the camera.
  113221. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113222. */
  113223. collisionRadius: Vector3;
  113224. protected _collider: Collider;
  113225. protected _previousPosition: Vector3;
  113226. protected _collisionVelocity: Vector3;
  113227. protected _newPosition: Vector3;
  113228. protected _previousAlpha: number;
  113229. protected _previousBeta: number;
  113230. protected _previousRadius: number;
  113231. protected _collisionTriggered: boolean;
  113232. protected _targetBoundingCenter: Nullable<Vector3>;
  113233. private _computationVector;
  113234. /**
  113235. * Instantiates a new ArcRotateCamera in a given scene
  113236. * @param name Defines the name of the camera
  113237. * @param alpha Defines the camera rotation along the logitudinal axis
  113238. * @param beta Defines the camera rotation along the latitudinal axis
  113239. * @param radius Defines the camera distance from its target
  113240. * @param target Defines the camera target
  113241. * @param scene Defines the scene the camera belongs to
  113242. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  113243. */
  113244. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113245. /** @hidden */
  113246. _initCache(): void;
  113247. /** @hidden */
  113248. _updateCache(ignoreParentClass?: boolean): void;
  113249. protected _getTargetPosition(): Vector3;
  113250. private _storedAlpha;
  113251. private _storedBeta;
  113252. private _storedRadius;
  113253. private _storedTarget;
  113254. private _storedTargetScreenOffset;
  113255. /**
  113256. * Stores the current state of the camera (alpha, beta, radius and target)
  113257. * @returns the camera itself
  113258. */
  113259. storeState(): Camera;
  113260. /**
  113261. * @hidden
  113262. * Restored camera state. You must call storeState() first
  113263. */
  113264. _restoreStateValues(): boolean;
  113265. /** @hidden */
  113266. _isSynchronizedViewMatrix(): boolean;
  113267. /**
  113268. * Attached controls to the current camera.
  113269. * @param element Defines the element the controls should be listened from
  113270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113271. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  113272. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  113273. */
  113274. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  113275. /**
  113276. * Detach the current controls from the camera.
  113277. * The camera will stop reacting to inputs.
  113278. * @param element Defines the element to stop listening the inputs from
  113279. */
  113280. detachControl(element: HTMLElement): void;
  113281. /** @hidden */
  113282. _checkInputs(): void;
  113283. protected _checkLimits(): void;
  113284. /**
  113285. * Rebuilds angles (alpha, beta) and radius from the give position and target
  113286. */
  113287. rebuildAnglesAndRadius(): void;
  113288. /**
  113289. * Use a position to define the current camera related information like alpha, beta and radius
  113290. * @param position Defines the position to set the camera at
  113291. */
  113292. setPosition(position: Vector3): void;
  113293. /**
  113294. * Defines the target the camera should look at.
  113295. * This will automatically adapt alpha beta and radius to fit within the new target.
  113296. * @param target Defines the new target as a Vector or a mesh
  113297. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  113298. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  113299. */
  113300. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  113301. /** @hidden */
  113302. _getViewMatrix(): Matrix;
  113303. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  113304. /**
  113305. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  113306. * @param meshes Defines the mesh to zoom on
  113307. * @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)
  113308. */
  113309. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  113310. /**
  113311. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  113312. * The target will be changed but the radius
  113313. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  113314. * @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)
  113315. */
  113316. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  113317. min: Vector3;
  113318. max: Vector3;
  113319. distance: number;
  113320. }, doNotUpdateMaxZ?: boolean): void;
  113321. /**
  113322. * @override
  113323. * Override Camera.createRigCamera
  113324. */
  113325. createRigCamera(name: string, cameraIndex: number): Camera;
  113326. /**
  113327. * @hidden
  113328. * @override
  113329. * Override Camera._updateRigCameras
  113330. */
  113331. _updateRigCameras(): void;
  113332. /**
  113333. * Destroy the camera and release the current resources hold by it.
  113334. */
  113335. dispose(): void;
  113336. /**
  113337. * Gets the current object class name.
  113338. * @return the class name
  113339. */
  113340. getClassName(): string;
  113341. }
  113342. }
  113343. declare module BABYLON {
  113344. /**
  113345. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  113346. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113347. */
  113348. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  113349. /**
  113350. * Gets the name of the behavior.
  113351. */
  113352. get name(): string;
  113353. private _zoomStopsAnimation;
  113354. private _idleRotationSpeed;
  113355. private _idleRotationWaitTime;
  113356. private _idleRotationSpinupTime;
  113357. /**
  113358. * Sets the flag that indicates if user zooming should stop animation.
  113359. */
  113360. set zoomStopsAnimation(flag: boolean);
  113361. /**
  113362. * Gets the flag that indicates if user zooming should stop animation.
  113363. */
  113364. get zoomStopsAnimation(): boolean;
  113365. /**
  113366. * Sets the default speed at which the camera rotates around the model.
  113367. */
  113368. set idleRotationSpeed(speed: number);
  113369. /**
  113370. * Gets the default speed at which the camera rotates around the model.
  113371. */
  113372. get idleRotationSpeed(): number;
  113373. /**
  113374. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  113375. */
  113376. set idleRotationWaitTime(time: number);
  113377. /**
  113378. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  113379. */
  113380. get idleRotationWaitTime(): number;
  113381. /**
  113382. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113383. */
  113384. set idleRotationSpinupTime(time: number);
  113385. /**
  113386. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113387. */
  113388. get idleRotationSpinupTime(): number;
  113389. /**
  113390. * Gets a value indicating if the camera is currently rotating because of this behavior
  113391. */
  113392. get rotationInProgress(): boolean;
  113393. private _onPrePointerObservableObserver;
  113394. private _onAfterCheckInputsObserver;
  113395. private _attachedCamera;
  113396. private _isPointerDown;
  113397. private _lastFrameTime;
  113398. private _lastInteractionTime;
  113399. private _cameraRotationSpeed;
  113400. /**
  113401. * Initializes the behavior.
  113402. */
  113403. init(): void;
  113404. /**
  113405. * Attaches the behavior to its arc rotate camera.
  113406. * @param camera Defines the camera to attach the behavior to
  113407. */
  113408. attach(camera: ArcRotateCamera): void;
  113409. /**
  113410. * Detaches the behavior from its current arc rotate camera.
  113411. */
  113412. detach(): void;
  113413. /**
  113414. * Returns true if user is scrolling.
  113415. * @return true if user is scrolling.
  113416. */
  113417. private _userIsZooming;
  113418. private _lastFrameRadius;
  113419. private _shouldAnimationStopForInteraction;
  113420. /**
  113421. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  113422. */
  113423. private _applyUserInteraction;
  113424. private _userIsMoving;
  113425. }
  113426. }
  113427. declare module BABYLON {
  113428. /**
  113429. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  113430. */
  113431. export class AttachToBoxBehavior implements Behavior<Mesh> {
  113432. private ui;
  113433. /**
  113434. * The name of the behavior
  113435. */
  113436. name: string;
  113437. /**
  113438. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  113439. */
  113440. distanceAwayFromFace: number;
  113441. /**
  113442. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  113443. */
  113444. distanceAwayFromBottomOfFace: number;
  113445. private _faceVectors;
  113446. private _target;
  113447. private _scene;
  113448. private _onRenderObserver;
  113449. private _tmpMatrix;
  113450. private _tmpVector;
  113451. /**
  113452. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  113453. * @param ui The transform node that should be attched to the mesh
  113454. */
  113455. constructor(ui: TransformNode);
  113456. /**
  113457. * Initializes the behavior
  113458. */
  113459. init(): void;
  113460. private _closestFace;
  113461. private _zeroVector;
  113462. private _lookAtTmpMatrix;
  113463. private _lookAtToRef;
  113464. /**
  113465. * Attaches the AttachToBoxBehavior to the passed in mesh
  113466. * @param target The mesh that the specified node will be attached to
  113467. */
  113468. attach(target: Mesh): void;
  113469. /**
  113470. * Detaches the behavior from the mesh
  113471. */
  113472. detach(): void;
  113473. }
  113474. }
  113475. declare module BABYLON {
  113476. /**
  113477. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  113478. */
  113479. export class FadeInOutBehavior implements Behavior<Mesh> {
  113480. /**
  113481. * Time in milliseconds to delay before fading in (Default: 0)
  113482. */
  113483. delay: number;
  113484. /**
  113485. * Time in milliseconds for the mesh to fade in (Default: 300)
  113486. */
  113487. fadeInTime: number;
  113488. private _millisecondsPerFrame;
  113489. private _hovered;
  113490. private _hoverValue;
  113491. private _ownerNode;
  113492. /**
  113493. * Instatiates the FadeInOutBehavior
  113494. */
  113495. constructor();
  113496. /**
  113497. * The name of the behavior
  113498. */
  113499. get name(): string;
  113500. /**
  113501. * Initializes the behavior
  113502. */
  113503. init(): void;
  113504. /**
  113505. * Attaches the fade behavior on the passed in mesh
  113506. * @param ownerNode The mesh that will be faded in/out once attached
  113507. */
  113508. attach(ownerNode: Mesh): void;
  113509. /**
  113510. * Detaches the behavior from the mesh
  113511. */
  113512. detach(): void;
  113513. /**
  113514. * Triggers the mesh to begin fading in or out
  113515. * @param value if the object should fade in or out (true to fade in)
  113516. */
  113517. fadeIn(value: boolean): void;
  113518. private _update;
  113519. private _setAllVisibility;
  113520. }
  113521. }
  113522. declare module BABYLON {
  113523. /**
  113524. * Class containing a set of static utilities functions for managing Pivots
  113525. * @hidden
  113526. */
  113527. export class PivotTools {
  113528. private static _PivotCached;
  113529. private static _OldPivotPoint;
  113530. private static _PivotTranslation;
  113531. private static _PivotTmpVector;
  113532. /** @hidden */
  113533. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  113534. /** @hidden */
  113535. static _RestorePivotPoint(mesh: AbstractMesh): void;
  113536. }
  113537. }
  113538. declare module BABYLON {
  113539. /**
  113540. * Class containing static functions to help procedurally build meshes
  113541. */
  113542. export class PlaneBuilder {
  113543. /**
  113544. * Creates a plane mesh
  113545. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  113546. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  113547. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  113548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113551. * @param name defines the name of the mesh
  113552. * @param options defines the options used to create the mesh
  113553. * @param scene defines the hosting scene
  113554. * @returns the plane mesh
  113555. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  113556. */
  113557. static CreatePlane(name: string, options: {
  113558. size?: number;
  113559. width?: number;
  113560. height?: number;
  113561. sideOrientation?: number;
  113562. frontUVs?: Vector4;
  113563. backUVs?: Vector4;
  113564. updatable?: boolean;
  113565. sourcePlane?: Plane;
  113566. }, scene?: Nullable<Scene>): Mesh;
  113567. }
  113568. }
  113569. declare module BABYLON {
  113570. /**
  113571. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  113572. */
  113573. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  113574. private static _AnyMouseID;
  113575. /**
  113576. * Abstract mesh the behavior is set on
  113577. */
  113578. attachedNode: AbstractMesh;
  113579. private _dragPlane;
  113580. private _scene;
  113581. private _pointerObserver;
  113582. private _beforeRenderObserver;
  113583. private static _planeScene;
  113584. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  113585. /**
  113586. * 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)
  113587. */
  113588. maxDragAngle: number;
  113589. /**
  113590. * @hidden
  113591. */
  113592. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  113593. /**
  113594. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113595. */
  113596. currentDraggingPointerID: number;
  113597. /**
  113598. * The last position where the pointer hit the drag plane in world space
  113599. */
  113600. lastDragPosition: Vector3;
  113601. /**
  113602. * If the behavior is currently in a dragging state
  113603. */
  113604. dragging: boolean;
  113605. /**
  113606. * 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)
  113607. */
  113608. dragDeltaRatio: number;
  113609. /**
  113610. * If the drag plane orientation should be updated during the dragging (Default: true)
  113611. */
  113612. updateDragPlane: boolean;
  113613. private _debugMode;
  113614. private _moving;
  113615. /**
  113616. * Fires each time the attached mesh is dragged with the pointer
  113617. * * delta between last drag position and current drag position in world space
  113618. * * dragDistance along the drag axis
  113619. * * dragPlaneNormal normal of the current drag plane used during the drag
  113620. * * dragPlanePoint in world space where the drag intersects the drag plane
  113621. */
  113622. onDragObservable: Observable<{
  113623. delta: Vector3;
  113624. dragPlanePoint: Vector3;
  113625. dragPlaneNormal: Vector3;
  113626. dragDistance: number;
  113627. pointerId: number;
  113628. }>;
  113629. /**
  113630. * Fires each time a drag begins (eg. mouse down on mesh)
  113631. */
  113632. onDragStartObservable: Observable<{
  113633. dragPlanePoint: Vector3;
  113634. pointerId: number;
  113635. }>;
  113636. /**
  113637. * Fires each time a drag ends (eg. mouse release after drag)
  113638. */
  113639. onDragEndObservable: Observable<{
  113640. dragPlanePoint: Vector3;
  113641. pointerId: number;
  113642. }>;
  113643. /**
  113644. * If the attached mesh should be moved when dragged
  113645. */
  113646. moveAttached: boolean;
  113647. /**
  113648. * If the drag behavior will react to drag events (Default: true)
  113649. */
  113650. enabled: boolean;
  113651. /**
  113652. * If pointer events should start and release the drag (Default: true)
  113653. */
  113654. startAndReleaseDragOnPointerEvents: boolean;
  113655. /**
  113656. * If camera controls should be detached during the drag
  113657. */
  113658. detachCameraControls: boolean;
  113659. /**
  113660. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  113661. */
  113662. useObjectOrientationForDragging: boolean;
  113663. private _options;
  113664. /**
  113665. * Gets the options used by the behavior
  113666. */
  113667. get options(): {
  113668. dragAxis?: Vector3;
  113669. dragPlaneNormal?: Vector3;
  113670. };
  113671. /**
  113672. * Sets the options used by the behavior
  113673. */
  113674. set options(options: {
  113675. dragAxis?: Vector3;
  113676. dragPlaneNormal?: Vector3;
  113677. });
  113678. /**
  113679. * Creates a pointer drag behavior that can be attached to a mesh
  113680. * @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)
  113681. */
  113682. constructor(options?: {
  113683. dragAxis?: Vector3;
  113684. dragPlaneNormal?: Vector3;
  113685. });
  113686. /**
  113687. * Predicate to determine if it is valid to move the object to a new position when it is moved
  113688. */
  113689. validateDrag: (targetPosition: Vector3) => boolean;
  113690. /**
  113691. * The name of the behavior
  113692. */
  113693. get name(): string;
  113694. /**
  113695. * Initializes the behavior
  113696. */
  113697. init(): void;
  113698. private _tmpVector;
  113699. private _alternatePickedPoint;
  113700. private _worldDragAxis;
  113701. private _targetPosition;
  113702. private _attachedElement;
  113703. /**
  113704. * Attaches the drag behavior the passed in mesh
  113705. * @param ownerNode The mesh that will be dragged around once attached
  113706. * @param predicate Predicate to use for pick filtering
  113707. */
  113708. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  113709. /**
  113710. * Force relase the drag action by code.
  113711. */
  113712. releaseDrag(): void;
  113713. private _startDragRay;
  113714. private _lastPointerRay;
  113715. /**
  113716. * Simulates the start of a pointer drag event on the behavior
  113717. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  113718. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  113719. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  113720. */
  113721. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  113722. private _startDrag;
  113723. private _dragDelta;
  113724. private _moveDrag;
  113725. private _pickWithRayOnDragPlane;
  113726. private _pointA;
  113727. private _pointB;
  113728. private _pointC;
  113729. private _lineA;
  113730. private _lineB;
  113731. private _localAxis;
  113732. private _lookAt;
  113733. private _updateDragPlanePosition;
  113734. /**
  113735. * Detaches the behavior from the mesh
  113736. */
  113737. detach(): void;
  113738. }
  113739. }
  113740. declare module BABYLON {
  113741. /**
  113742. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113743. */
  113744. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113745. private _dragBehaviorA;
  113746. private _dragBehaviorB;
  113747. private _startDistance;
  113748. private _initialScale;
  113749. private _targetScale;
  113750. private _ownerNode;
  113751. private _sceneRenderObserver;
  113752. /**
  113753. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  113754. */
  113755. constructor();
  113756. /**
  113757. * The name of the behavior
  113758. */
  113759. get name(): string;
  113760. /**
  113761. * Initializes the behavior
  113762. */
  113763. init(): void;
  113764. private _getCurrentDistance;
  113765. /**
  113766. * Attaches the scale behavior the passed in mesh
  113767. * @param ownerNode The mesh that will be scaled around once attached
  113768. */
  113769. attach(ownerNode: Mesh): void;
  113770. /**
  113771. * Detaches the behavior from the mesh
  113772. */
  113773. detach(): void;
  113774. }
  113775. }
  113776. declare module BABYLON {
  113777. /**
  113778. * 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
  113779. */
  113780. export class SixDofDragBehavior implements Behavior<Mesh> {
  113781. private static _virtualScene;
  113782. private _ownerNode;
  113783. private _sceneRenderObserver;
  113784. private _scene;
  113785. private _targetPosition;
  113786. private _virtualOriginMesh;
  113787. private _virtualDragMesh;
  113788. private _pointerObserver;
  113789. private _moving;
  113790. private _startingOrientation;
  113791. private _attachedElement;
  113792. /**
  113793. * 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)
  113794. */
  113795. private zDragFactor;
  113796. /**
  113797. * If the object should rotate to face the drag origin
  113798. */
  113799. rotateDraggedObject: boolean;
  113800. /**
  113801. * If the behavior is currently in a dragging state
  113802. */
  113803. dragging: boolean;
  113804. /**
  113805. * 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)
  113806. */
  113807. dragDeltaRatio: number;
  113808. /**
  113809. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113810. */
  113811. currentDraggingPointerID: number;
  113812. /**
  113813. * If camera controls should be detached during the drag
  113814. */
  113815. detachCameraControls: boolean;
  113816. /**
  113817. * Fires each time a drag starts
  113818. */
  113819. onDragStartObservable: Observable<{}>;
  113820. /**
  113821. * Fires each time a drag ends (eg. mouse release after drag)
  113822. */
  113823. onDragEndObservable: Observable<{}>;
  113824. /**
  113825. * 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
  113826. */
  113827. constructor();
  113828. /**
  113829. * The name of the behavior
  113830. */
  113831. get name(): string;
  113832. /**
  113833. * Initializes the behavior
  113834. */
  113835. init(): void;
  113836. /**
  113837. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  113838. */
  113839. private get _pointerCamera();
  113840. /**
  113841. * Attaches the scale behavior the passed in mesh
  113842. * @param ownerNode The mesh that will be scaled around once attached
  113843. */
  113844. attach(ownerNode: Mesh): void;
  113845. /**
  113846. * Detaches the behavior from the mesh
  113847. */
  113848. detach(): void;
  113849. }
  113850. }
  113851. declare module BABYLON {
  113852. /**
  113853. * Class used to apply inverse kinematics to bones
  113854. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  113855. */
  113856. export class BoneIKController {
  113857. private static _tmpVecs;
  113858. private static _tmpQuat;
  113859. private static _tmpMats;
  113860. /**
  113861. * Gets or sets the target mesh
  113862. */
  113863. targetMesh: AbstractMesh;
  113864. /** Gets or sets the mesh used as pole */
  113865. poleTargetMesh: AbstractMesh;
  113866. /**
  113867. * Gets or sets the bone used as pole
  113868. */
  113869. poleTargetBone: Nullable<Bone>;
  113870. /**
  113871. * Gets or sets the target position
  113872. */
  113873. targetPosition: Vector3;
  113874. /**
  113875. * Gets or sets the pole target position
  113876. */
  113877. poleTargetPosition: Vector3;
  113878. /**
  113879. * Gets or sets the pole target local offset
  113880. */
  113881. poleTargetLocalOffset: Vector3;
  113882. /**
  113883. * Gets or sets the pole angle
  113884. */
  113885. poleAngle: number;
  113886. /**
  113887. * Gets or sets the mesh associated with the controller
  113888. */
  113889. mesh: AbstractMesh;
  113890. /**
  113891. * 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)
  113892. */
  113893. slerpAmount: number;
  113894. private _bone1Quat;
  113895. private _bone1Mat;
  113896. private _bone2Ang;
  113897. private _bone1;
  113898. private _bone2;
  113899. private _bone1Length;
  113900. private _bone2Length;
  113901. private _maxAngle;
  113902. private _maxReach;
  113903. private _rightHandedSystem;
  113904. private _bendAxis;
  113905. private _slerping;
  113906. private _adjustRoll;
  113907. /**
  113908. * Gets or sets maximum allowed angle
  113909. */
  113910. get maxAngle(): number;
  113911. set maxAngle(value: number);
  113912. /**
  113913. * Creates a new BoneIKController
  113914. * @param mesh defines the mesh to control
  113915. * @param bone defines the bone to control
  113916. * @param options defines options to set up the controller
  113917. */
  113918. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  113919. targetMesh?: AbstractMesh;
  113920. poleTargetMesh?: AbstractMesh;
  113921. poleTargetBone?: Bone;
  113922. poleTargetLocalOffset?: Vector3;
  113923. poleAngle?: number;
  113924. bendAxis?: Vector3;
  113925. maxAngle?: number;
  113926. slerpAmount?: number;
  113927. });
  113928. private _setMaxAngle;
  113929. /**
  113930. * Force the controller to update the bones
  113931. */
  113932. update(): void;
  113933. }
  113934. }
  113935. declare module BABYLON {
  113936. /**
  113937. * Class used to make a bone look toward a point in space
  113938. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  113939. */
  113940. export class BoneLookController {
  113941. private static _tmpVecs;
  113942. private static _tmpQuat;
  113943. private static _tmpMats;
  113944. /**
  113945. * The target Vector3 that the bone will look at
  113946. */
  113947. target: Vector3;
  113948. /**
  113949. * The mesh that the bone is attached to
  113950. */
  113951. mesh: AbstractMesh;
  113952. /**
  113953. * The bone that will be looking to the target
  113954. */
  113955. bone: Bone;
  113956. /**
  113957. * The up axis of the coordinate system that is used when the bone is rotated
  113958. */
  113959. upAxis: Vector3;
  113960. /**
  113961. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  113962. */
  113963. upAxisSpace: Space;
  113964. /**
  113965. * Used to make an adjustment to the yaw of the bone
  113966. */
  113967. adjustYaw: number;
  113968. /**
  113969. * Used to make an adjustment to the pitch of the bone
  113970. */
  113971. adjustPitch: number;
  113972. /**
  113973. * Used to make an adjustment to the roll of the bone
  113974. */
  113975. adjustRoll: number;
  113976. /**
  113977. * 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)
  113978. */
  113979. slerpAmount: number;
  113980. private _minYaw;
  113981. private _maxYaw;
  113982. private _minPitch;
  113983. private _maxPitch;
  113984. private _minYawSin;
  113985. private _minYawCos;
  113986. private _maxYawSin;
  113987. private _maxYawCos;
  113988. private _midYawConstraint;
  113989. private _minPitchTan;
  113990. private _maxPitchTan;
  113991. private _boneQuat;
  113992. private _slerping;
  113993. private _transformYawPitch;
  113994. private _transformYawPitchInv;
  113995. private _firstFrameSkipped;
  113996. private _yawRange;
  113997. private _fowardAxis;
  113998. /**
  113999. * Gets or sets the minimum yaw angle that the bone can look to
  114000. */
  114001. get minYaw(): number;
  114002. set minYaw(value: number);
  114003. /**
  114004. * Gets or sets the maximum yaw angle that the bone can look to
  114005. */
  114006. get maxYaw(): number;
  114007. set maxYaw(value: number);
  114008. /**
  114009. * Gets or sets the minimum pitch angle that the bone can look to
  114010. */
  114011. get minPitch(): number;
  114012. set minPitch(value: number);
  114013. /**
  114014. * Gets or sets the maximum pitch angle that the bone can look to
  114015. */
  114016. get maxPitch(): number;
  114017. set maxPitch(value: number);
  114018. /**
  114019. * Create a BoneLookController
  114020. * @param mesh the mesh that the bone belongs to
  114021. * @param bone the bone that will be looking to the target
  114022. * @param target the target Vector3 to look at
  114023. * @param options optional settings:
  114024. * * maxYaw: the maximum angle the bone will yaw to
  114025. * * minYaw: the minimum angle the bone will yaw to
  114026. * * maxPitch: the maximum angle the bone will pitch to
  114027. * * minPitch: the minimum angle the bone will yaw to
  114028. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  114029. * * upAxis: the up axis of the coordinate system
  114030. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  114031. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  114032. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  114033. * * adjustYaw: used to make an adjustment to the yaw of the bone
  114034. * * adjustPitch: used to make an adjustment to the pitch of the bone
  114035. * * adjustRoll: used to make an adjustment to the roll of the bone
  114036. **/
  114037. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  114038. maxYaw?: number;
  114039. minYaw?: number;
  114040. maxPitch?: number;
  114041. minPitch?: number;
  114042. slerpAmount?: number;
  114043. upAxis?: Vector3;
  114044. upAxisSpace?: Space;
  114045. yawAxis?: Vector3;
  114046. pitchAxis?: Vector3;
  114047. adjustYaw?: number;
  114048. adjustPitch?: number;
  114049. adjustRoll?: number;
  114050. });
  114051. /**
  114052. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  114053. */
  114054. update(): void;
  114055. private _getAngleDiff;
  114056. private _getAngleBetween;
  114057. private _isAngleBetween;
  114058. }
  114059. }
  114060. declare module BABYLON {
  114061. /**
  114062. * Manage the gamepad inputs to control an arc rotate camera.
  114063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114064. */
  114065. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  114066. /**
  114067. * Defines the camera the input is attached to.
  114068. */
  114069. camera: ArcRotateCamera;
  114070. /**
  114071. * Defines the gamepad the input is gathering event from.
  114072. */
  114073. gamepad: Nullable<Gamepad>;
  114074. /**
  114075. * Defines the gamepad rotation sensiblity.
  114076. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114077. */
  114078. gamepadRotationSensibility: number;
  114079. /**
  114080. * Defines the gamepad move sensiblity.
  114081. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114082. */
  114083. gamepadMoveSensibility: number;
  114084. private _yAxisScale;
  114085. /**
  114086. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114087. */
  114088. get invertYAxis(): boolean;
  114089. set invertYAxis(value: boolean);
  114090. private _onGamepadConnectedObserver;
  114091. private _onGamepadDisconnectedObserver;
  114092. /**
  114093. * Attach the input controls to a specific dom element to get the input from.
  114094. * @param element Defines the element the controls should be listened from
  114095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114096. */
  114097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114098. /**
  114099. * Detach the current controls from the specified dom element.
  114100. * @param element Defines the element to stop listening the inputs from
  114101. */
  114102. detachControl(element: Nullable<HTMLElement>): void;
  114103. /**
  114104. * Update the current camera state depending on the inputs that have been used this frame.
  114105. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114106. */
  114107. checkInputs(): void;
  114108. /**
  114109. * Gets the class name of the current intput.
  114110. * @returns the class name
  114111. */
  114112. getClassName(): string;
  114113. /**
  114114. * Get the friendly name associated with the input class.
  114115. * @returns the input friendly name
  114116. */
  114117. getSimpleName(): string;
  114118. }
  114119. }
  114120. declare module BABYLON {
  114121. interface ArcRotateCameraInputsManager {
  114122. /**
  114123. * Add orientation input support to the input manager.
  114124. * @returns the current input manager
  114125. */
  114126. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  114127. }
  114128. /**
  114129. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  114130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114131. */
  114132. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  114133. /**
  114134. * Defines the camera the input is attached to.
  114135. */
  114136. camera: ArcRotateCamera;
  114137. /**
  114138. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  114139. */
  114140. alphaCorrection: number;
  114141. /**
  114142. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  114143. */
  114144. gammaCorrection: number;
  114145. private _alpha;
  114146. private _gamma;
  114147. private _dirty;
  114148. private _deviceOrientationHandler;
  114149. /**
  114150. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  114151. */
  114152. constructor();
  114153. /**
  114154. * Attach the input controls to a specific dom element to get the input from.
  114155. * @param element Defines the element the controls should be listened from
  114156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114157. */
  114158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114159. /** @hidden */
  114160. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  114161. /**
  114162. * Update the current camera state depending on the inputs that have been used this frame.
  114163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114164. */
  114165. checkInputs(): void;
  114166. /**
  114167. * Detach the current controls from the specified dom element.
  114168. * @param element Defines the element to stop listening the inputs from
  114169. */
  114170. detachControl(element: Nullable<HTMLElement>): void;
  114171. /**
  114172. * Gets the class name of the current intput.
  114173. * @returns the class name
  114174. */
  114175. getClassName(): string;
  114176. /**
  114177. * Get the friendly name associated with the input class.
  114178. * @returns the input friendly name
  114179. */
  114180. getSimpleName(): string;
  114181. }
  114182. }
  114183. declare module BABYLON {
  114184. /**
  114185. * Listen to mouse events to control the camera.
  114186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114187. */
  114188. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  114189. /**
  114190. * Defines the camera the input is attached to.
  114191. */
  114192. camera: FlyCamera;
  114193. /**
  114194. * Defines if touch is enabled. (Default is true.)
  114195. */
  114196. touchEnabled: boolean;
  114197. /**
  114198. * Defines the buttons associated with the input to handle camera rotation.
  114199. */
  114200. buttons: number[];
  114201. /**
  114202. * Assign buttons for Yaw control.
  114203. */
  114204. buttonsYaw: number[];
  114205. /**
  114206. * Assign buttons for Pitch control.
  114207. */
  114208. buttonsPitch: number[];
  114209. /**
  114210. * Assign buttons for Roll control.
  114211. */
  114212. buttonsRoll: number[];
  114213. /**
  114214. * Detect if any button is being pressed while mouse is moved.
  114215. * -1 = Mouse locked.
  114216. * 0 = Left button.
  114217. * 1 = Middle Button.
  114218. * 2 = Right Button.
  114219. */
  114220. activeButton: number;
  114221. /**
  114222. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  114223. * Higher values reduce its sensitivity.
  114224. */
  114225. angularSensibility: number;
  114226. private _mousemoveCallback;
  114227. private _observer;
  114228. private _rollObserver;
  114229. private previousPosition;
  114230. private noPreventDefault;
  114231. private element;
  114232. /**
  114233. * Listen to mouse events to control the camera.
  114234. * @param touchEnabled Define if touch is enabled. (Default is true.)
  114235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114236. */
  114237. constructor(touchEnabled?: boolean);
  114238. /**
  114239. * Attach the mouse control to the HTML DOM element.
  114240. * @param element Defines the element that listens to the input events.
  114241. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  114242. */
  114243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114244. /**
  114245. * Detach the current controls from the specified dom element.
  114246. * @param element Defines the element to stop listening the inputs from
  114247. */
  114248. detachControl(element: Nullable<HTMLElement>): void;
  114249. /**
  114250. * Gets the class name of the current input.
  114251. * @returns the class name.
  114252. */
  114253. getClassName(): string;
  114254. /**
  114255. * Get the friendly name associated with the input class.
  114256. * @returns the input's friendly name.
  114257. */
  114258. getSimpleName(): string;
  114259. private _pointerInput;
  114260. private _onMouseMove;
  114261. /**
  114262. * Rotate camera by mouse offset.
  114263. */
  114264. private rotateCamera;
  114265. }
  114266. }
  114267. declare module BABYLON {
  114268. /**
  114269. * Default Inputs manager for the FlyCamera.
  114270. * It groups all the default supported inputs for ease of use.
  114271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114272. */
  114273. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  114274. /**
  114275. * Instantiates a new FlyCameraInputsManager.
  114276. * @param camera Defines the camera the inputs belong to.
  114277. */
  114278. constructor(camera: FlyCamera);
  114279. /**
  114280. * Add keyboard input support to the input manager.
  114281. * @returns the new FlyCameraKeyboardMoveInput().
  114282. */
  114283. addKeyboard(): FlyCameraInputsManager;
  114284. /**
  114285. * Add mouse input support to the input manager.
  114286. * @param touchEnabled Enable touch screen support.
  114287. * @returns the new FlyCameraMouseInput().
  114288. */
  114289. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  114290. }
  114291. }
  114292. declare module BABYLON {
  114293. /**
  114294. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114295. * such as in a 3D Space Shooter or a Flight Simulator.
  114296. */
  114297. export class FlyCamera extends TargetCamera {
  114298. /**
  114299. * Define the collision ellipsoid of the camera.
  114300. * This is helpful for simulating a camera body, like a player's body.
  114301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  114302. */
  114303. ellipsoid: Vector3;
  114304. /**
  114305. * Define an offset for the position of the ellipsoid around the camera.
  114306. * This can be helpful if the camera is attached away from the player's body center,
  114307. * such as at its head.
  114308. */
  114309. ellipsoidOffset: Vector3;
  114310. /**
  114311. * Enable or disable collisions of the camera with the rest of the scene objects.
  114312. */
  114313. checkCollisions: boolean;
  114314. /**
  114315. * Enable or disable gravity on the camera.
  114316. */
  114317. applyGravity: boolean;
  114318. /**
  114319. * Define the current direction the camera is moving to.
  114320. */
  114321. cameraDirection: Vector3;
  114322. /**
  114323. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  114324. * This overrides and empties cameraRotation.
  114325. */
  114326. rotationQuaternion: Quaternion;
  114327. /**
  114328. * Track Roll to maintain the wanted Rolling when looking around.
  114329. */
  114330. _trackRoll: number;
  114331. /**
  114332. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  114333. */
  114334. rollCorrect: number;
  114335. /**
  114336. * Mimic a banked turn, Rolling the camera when Yawing.
  114337. * It's recommended to use rollCorrect = 10 for faster banking correction.
  114338. */
  114339. bankedTurn: boolean;
  114340. /**
  114341. * Limit in radians for how much Roll banking will add. (Default: 90°)
  114342. */
  114343. bankedTurnLimit: number;
  114344. /**
  114345. * Value of 0 disables the banked Roll.
  114346. * Value of 1 is equal to the Yaw angle in radians.
  114347. */
  114348. bankedTurnMultiplier: number;
  114349. /**
  114350. * The inputs manager loads all the input sources, such as keyboard and mouse.
  114351. */
  114352. inputs: FlyCameraInputsManager;
  114353. /**
  114354. * Gets the input sensibility for mouse input.
  114355. * Higher values reduce sensitivity.
  114356. */
  114357. get angularSensibility(): number;
  114358. /**
  114359. * Sets the input sensibility for a mouse input.
  114360. * Higher values reduce sensitivity.
  114361. */
  114362. set angularSensibility(value: number);
  114363. /**
  114364. * Get the keys for camera movement forward.
  114365. */
  114366. get keysForward(): number[];
  114367. /**
  114368. * Set the keys for camera movement forward.
  114369. */
  114370. set keysForward(value: number[]);
  114371. /**
  114372. * Get the keys for camera movement backward.
  114373. */
  114374. get keysBackward(): number[];
  114375. set keysBackward(value: number[]);
  114376. /**
  114377. * Get the keys for camera movement up.
  114378. */
  114379. get keysUp(): number[];
  114380. /**
  114381. * Set the keys for camera movement up.
  114382. */
  114383. set keysUp(value: number[]);
  114384. /**
  114385. * Get the keys for camera movement down.
  114386. */
  114387. get keysDown(): number[];
  114388. /**
  114389. * Set the keys for camera movement down.
  114390. */
  114391. set keysDown(value: number[]);
  114392. /**
  114393. * Get the keys for camera movement left.
  114394. */
  114395. get keysLeft(): number[];
  114396. /**
  114397. * Set the keys for camera movement left.
  114398. */
  114399. set keysLeft(value: number[]);
  114400. /**
  114401. * Set the keys for camera movement right.
  114402. */
  114403. get keysRight(): number[];
  114404. /**
  114405. * Set the keys for camera movement right.
  114406. */
  114407. set keysRight(value: number[]);
  114408. /**
  114409. * Event raised when the camera collides with a mesh in the scene.
  114410. */
  114411. onCollide: (collidedMesh: AbstractMesh) => void;
  114412. private _collider;
  114413. private _needMoveForGravity;
  114414. private _oldPosition;
  114415. private _diffPosition;
  114416. private _newPosition;
  114417. /** @hidden */
  114418. _localDirection: Vector3;
  114419. /** @hidden */
  114420. _transformedDirection: Vector3;
  114421. /**
  114422. * Instantiates a FlyCamera.
  114423. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114424. * such as in a 3D Space Shooter or a Flight Simulator.
  114425. * @param name Define the name of the camera in the scene.
  114426. * @param position Define the starting position of the camera in the scene.
  114427. * @param scene Define the scene the camera belongs to.
  114428. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  114429. */
  114430. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114431. /**
  114432. * Attach a control to the HTML DOM element.
  114433. * @param element Defines the element that listens to the input events.
  114434. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  114435. */
  114436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114437. /**
  114438. * Detach a control from the HTML DOM element.
  114439. * The camera will stop reacting to that input.
  114440. * @param element Defines the element that listens to the input events.
  114441. */
  114442. detachControl(element: HTMLElement): void;
  114443. private _collisionMask;
  114444. /**
  114445. * Get the mask that the camera ignores in collision events.
  114446. */
  114447. get collisionMask(): number;
  114448. /**
  114449. * Set the mask that the camera ignores in collision events.
  114450. */
  114451. set collisionMask(mask: number);
  114452. /** @hidden */
  114453. _collideWithWorld(displacement: Vector3): void;
  114454. /** @hidden */
  114455. private _onCollisionPositionChange;
  114456. /** @hidden */
  114457. _checkInputs(): void;
  114458. /** @hidden */
  114459. _decideIfNeedsToMove(): boolean;
  114460. /** @hidden */
  114461. _updatePosition(): void;
  114462. /**
  114463. * Restore the Roll to its target value at the rate specified.
  114464. * @param rate - Higher means slower restoring.
  114465. * @hidden
  114466. */
  114467. restoreRoll(rate: number): void;
  114468. /**
  114469. * Destroy the camera and release the current resources held by it.
  114470. */
  114471. dispose(): void;
  114472. /**
  114473. * Get the current object class name.
  114474. * @returns the class name.
  114475. */
  114476. getClassName(): string;
  114477. }
  114478. }
  114479. declare module BABYLON {
  114480. /**
  114481. * Listen to keyboard events to control the camera.
  114482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114483. */
  114484. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  114485. /**
  114486. * Defines the camera the input is attached to.
  114487. */
  114488. camera: FlyCamera;
  114489. /**
  114490. * The list of keyboard keys used to control the forward move of the camera.
  114491. */
  114492. keysForward: number[];
  114493. /**
  114494. * The list of keyboard keys used to control the backward move of the camera.
  114495. */
  114496. keysBackward: number[];
  114497. /**
  114498. * The list of keyboard keys used to control the forward move of the camera.
  114499. */
  114500. keysUp: number[];
  114501. /**
  114502. * The list of keyboard keys used to control the backward move of the camera.
  114503. */
  114504. keysDown: number[];
  114505. /**
  114506. * The list of keyboard keys used to control the right strafe move of the camera.
  114507. */
  114508. keysRight: number[];
  114509. /**
  114510. * The list of keyboard keys used to control the left strafe move of the camera.
  114511. */
  114512. keysLeft: number[];
  114513. private _keys;
  114514. private _onCanvasBlurObserver;
  114515. private _onKeyboardObserver;
  114516. private _engine;
  114517. private _scene;
  114518. /**
  114519. * Attach the input controls to a specific dom element to get the input from.
  114520. * @param element Defines the element the controls should be listened from
  114521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114522. */
  114523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114524. /**
  114525. * Detach the current controls from the specified dom element.
  114526. * @param element Defines the element to stop listening the inputs from
  114527. */
  114528. detachControl(element: Nullable<HTMLElement>): void;
  114529. /**
  114530. * Gets the class name of the current intput.
  114531. * @returns the class name
  114532. */
  114533. getClassName(): string;
  114534. /** @hidden */
  114535. _onLostFocus(e: FocusEvent): void;
  114536. /**
  114537. * Get the friendly name associated with the input class.
  114538. * @returns the input friendly name
  114539. */
  114540. getSimpleName(): string;
  114541. /**
  114542. * Update the current camera state depending on the inputs that have been used this frame.
  114543. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114544. */
  114545. checkInputs(): void;
  114546. }
  114547. }
  114548. declare module BABYLON {
  114549. /**
  114550. * Manage the mouse wheel inputs to control a follow camera.
  114551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114552. */
  114553. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  114554. /**
  114555. * Defines the camera the input is attached to.
  114556. */
  114557. camera: FollowCamera;
  114558. /**
  114559. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  114560. */
  114561. axisControlRadius: boolean;
  114562. /**
  114563. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  114564. */
  114565. axisControlHeight: boolean;
  114566. /**
  114567. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  114568. */
  114569. axisControlRotation: boolean;
  114570. /**
  114571. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  114572. * relation to mouseWheel events.
  114573. */
  114574. wheelPrecision: number;
  114575. /**
  114576. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114577. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114578. */
  114579. wheelDeltaPercentage: number;
  114580. private _wheel;
  114581. private _observer;
  114582. /**
  114583. * Attach the input controls to a specific dom element to get the input from.
  114584. * @param element Defines the element the controls should be listened from
  114585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114586. */
  114587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114588. /**
  114589. * Detach the current controls from the specified dom element.
  114590. * @param element Defines the element to stop listening the inputs from
  114591. */
  114592. detachControl(element: Nullable<HTMLElement>): void;
  114593. /**
  114594. * Gets the class name of the current intput.
  114595. * @returns the class name
  114596. */
  114597. getClassName(): string;
  114598. /**
  114599. * Get the friendly name associated with the input class.
  114600. * @returns the input friendly name
  114601. */
  114602. getSimpleName(): string;
  114603. }
  114604. }
  114605. declare module BABYLON {
  114606. /**
  114607. * Manage the pointers inputs to control an follow camera.
  114608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114609. */
  114610. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  114611. /**
  114612. * Defines the camera the input is attached to.
  114613. */
  114614. camera: FollowCamera;
  114615. /**
  114616. * Gets the class name of the current input.
  114617. * @returns the class name
  114618. */
  114619. getClassName(): string;
  114620. /**
  114621. * Defines the pointer angular sensibility along the X axis or how fast is
  114622. * the camera rotating.
  114623. * A negative number will reverse the axis direction.
  114624. */
  114625. angularSensibilityX: number;
  114626. /**
  114627. * Defines the pointer angular sensibility along the Y axis or how fast is
  114628. * the camera rotating.
  114629. * A negative number will reverse the axis direction.
  114630. */
  114631. angularSensibilityY: number;
  114632. /**
  114633. * Defines the pointer pinch precision or how fast is the camera zooming.
  114634. * A negative number will reverse the axis direction.
  114635. */
  114636. pinchPrecision: number;
  114637. /**
  114638. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114639. * from 0.
  114640. * It defines the percentage of current camera.radius to use as delta when
  114641. * pinch zoom is used.
  114642. */
  114643. pinchDeltaPercentage: number;
  114644. /**
  114645. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  114646. */
  114647. axisXControlRadius: boolean;
  114648. /**
  114649. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  114650. */
  114651. axisXControlHeight: boolean;
  114652. /**
  114653. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  114654. */
  114655. axisXControlRotation: boolean;
  114656. /**
  114657. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  114658. */
  114659. axisYControlRadius: boolean;
  114660. /**
  114661. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  114662. */
  114663. axisYControlHeight: boolean;
  114664. /**
  114665. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  114666. */
  114667. axisYControlRotation: boolean;
  114668. /**
  114669. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  114670. */
  114671. axisPinchControlRadius: boolean;
  114672. /**
  114673. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  114674. */
  114675. axisPinchControlHeight: boolean;
  114676. /**
  114677. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  114678. */
  114679. axisPinchControlRotation: boolean;
  114680. /**
  114681. * Log error messages if basic misconfiguration has occurred.
  114682. */
  114683. warningEnable: boolean;
  114684. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114685. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114686. private _warningCounter;
  114687. private _warning;
  114688. }
  114689. }
  114690. declare module BABYLON {
  114691. /**
  114692. * Default Inputs manager for the FollowCamera.
  114693. * It groups all the default supported inputs for ease of use.
  114694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114695. */
  114696. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  114697. /**
  114698. * Instantiates a new FollowCameraInputsManager.
  114699. * @param camera Defines the camera the inputs belong to
  114700. */
  114701. constructor(camera: FollowCamera);
  114702. /**
  114703. * Add keyboard input support to the input manager.
  114704. * @returns the current input manager
  114705. */
  114706. addKeyboard(): FollowCameraInputsManager;
  114707. /**
  114708. * Add mouse wheel input support to the input manager.
  114709. * @returns the current input manager
  114710. */
  114711. addMouseWheel(): FollowCameraInputsManager;
  114712. /**
  114713. * Add pointers input support to the input manager.
  114714. * @returns the current input manager
  114715. */
  114716. addPointers(): FollowCameraInputsManager;
  114717. /**
  114718. * Add orientation input support to the input manager.
  114719. * @returns the current input manager
  114720. */
  114721. addVRDeviceOrientation(): FollowCameraInputsManager;
  114722. }
  114723. }
  114724. declare module BABYLON {
  114725. /**
  114726. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  114727. * an arc rotate version arcFollowCamera are available.
  114728. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114729. */
  114730. export class FollowCamera extends TargetCamera {
  114731. /**
  114732. * Distance the follow camera should follow an object at
  114733. */
  114734. radius: number;
  114735. /**
  114736. * Minimum allowed distance of the camera to the axis of rotation
  114737. * (The camera can not get closer).
  114738. * This can help limiting how the Camera is able to move in the scene.
  114739. */
  114740. lowerRadiusLimit: Nullable<number>;
  114741. /**
  114742. * Maximum allowed distance of the camera to the axis of rotation
  114743. * (The camera can not get further).
  114744. * This can help limiting how the Camera is able to move in the scene.
  114745. */
  114746. upperRadiusLimit: Nullable<number>;
  114747. /**
  114748. * Define a rotation offset between the camera and the object it follows
  114749. */
  114750. rotationOffset: number;
  114751. /**
  114752. * Minimum allowed angle to camera position relative to target object.
  114753. * This can help limiting how the Camera is able to move in the scene.
  114754. */
  114755. lowerRotationOffsetLimit: Nullable<number>;
  114756. /**
  114757. * Maximum allowed angle to camera position relative to target object.
  114758. * This can help limiting how the Camera is able to move in the scene.
  114759. */
  114760. upperRotationOffsetLimit: Nullable<number>;
  114761. /**
  114762. * Define a height offset between the camera and the object it follows.
  114763. * It can help following an object from the top (like a car chaing a plane)
  114764. */
  114765. heightOffset: number;
  114766. /**
  114767. * Minimum allowed height of camera position relative to target object.
  114768. * This can help limiting how the Camera is able to move in the scene.
  114769. */
  114770. lowerHeightOffsetLimit: Nullable<number>;
  114771. /**
  114772. * Maximum allowed height of camera position relative to target object.
  114773. * This can help limiting how the Camera is able to move in the scene.
  114774. */
  114775. upperHeightOffsetLimit: Nullable<number>;
  114776. /**
  114777. * Define how fast the camera can accelerate to follow it s target.
  114778. */
  114779. cameraAcceleration: number;
  114780. /**
  114781. * Define the speed limit of the camera following an object.
  114782. */
  114783. maxCameraSpeed: number;
  114784. /**
  114785. * Define the target of the camera.
  114786. */
  114787. lockedTarget: Nullable<AbstractMesh>;
  114788. /**
  114789. * Defines the input associated with the camera.
  114790. */
  114791. inputs: FollowCameraInputsManager;
  114792. /**
  114793. * Instantiates the follow camera.
  114794. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114795. * @param name Define the name of the camera in the scene
  114796. * @param position Define the position of the camera
  114797. * @param scene Define the scene the camera belong to
  114798. * @param lockedTarget Define the target of the camera
  114799. */
  114800. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  114801. private _follow;
  114802. /**
  114803. * Attached controls to the current camera.
  114804. * @param element Defines the element the controls should be listened from
  114805. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114806. */
  114807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114808. /**
  114809. * Detach the current controls from the camera.
  114810. * The camera will stop reacting to inputs.
  114811. * @param element Defines the element to stop listening the inputs from
  114812. */
  114813. detachControl(element: HTMLElement): void;
  114814. /** @hidden */
  114815. _checkInputs(): void;
  114816. private _checkLimits;
  114817. /**
  114818. * Gets the camera class name.
  114819. * @returns the class name
  114820. */
  114821. getClassName(): string;
  114822. }
  114823. /**
  114824. * Arc Rotate version of the follow camera.
  114825. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  114826. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114827. */
  114828. export class ArcFollowCamera extends TargetCamera {
  114829. /** The longitudinal angle of the camera */
  114830. alpha: number;
  114831. /** The latitudinal angle of the camera */
  114832. beta: number;
  114833. /** The radius of the camera from its target */
  114834. radius: number;
  114835. /** Define the camera target (the messh it should follow) */
  114836. target: Nullable<AbstractMesh>;
  114837. private _cartesianCoordinates;
  114838. /**
  114839. * Instantiates a new ArcFollowCamera
  114840. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114841. * @param name Define the name of the camera
  114842. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  114843. * @param beta Define the rotation angle of the camera around the elevation axis
  114844. * @param radius Define the radius of the camera from its target point
  114845. * @param target Define the target of the camera
  114846. * @param scene Define the scene the camera belongs to
  114847. */
  114848. constructor(name: string,
  114849. /** The longitudinal angle of the camera */
  114850. alpha: number,
  114851. /** The latitudinal angle of the camera */
  114852. beta: number,
  114853. /** The radius of the camera from its target */
  114854. radius: number,
  114855. /** Define the camera target (the messh it should follow) */
  114856. target: Nullable<AbstractMesh>, scene: Scene);
  114857. private _follow;
  114858. /** @hidden */
  114859. _checkInputs(): void;
  114860. /**
  114861. * Returns the class name of the object.
  114862. * It is mostly used internally for serialization purposes.
  114863. */
  114864. getClassName(): string;
  114865. }
  114866. }
  114867. declare module BABYLON {
  114868. /**
  114869. * Manage the keyboard inputs to control the movement of a follow camera.
  114870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114871. */
  114872. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  114873. /**
  114874. * Defines the camera the input is attached to.
  114875. */
  114876. camera: FollowCamera;
  114877. /**
  114878. * Defines the list of key codes associated with the up action (increase heightOffset)
  114879. */
  114880. keysHeightOffsetIncr: number[];
  114881. /**
  114882. * Defines the list of key codes associated with the down action (decrease heightOffset)
  114883. */
  114884. keysHeightOffsetDecr: number[];
  114885. /**
  114886. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  114887. */
  114888. keysHeightOffsetModifierAlt: boolean;
  114889. /**
  114890. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  114891. */
  114892. keysHeightOffsetModifierCtrl: boolean;
  114893. /**
  114894. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  114895. */
  114896. keysHeightOffsetModifierShift: boolean;
  114897. /**
  114898. * Defines the list of key codes associated with the left action (increase rotationOffset)
  114899. */
  114900. keysRotationOffsetIncr: number[];
  114901. /**
  114902. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  114903. */
  114904. keysRotationOffsetDecr: number[];
  114905. /**
  114906. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  114907. */
  114908. keysRotationOffsetModifierAlt: boolean;
  114909. /**
  114910. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  114911. */
  114912. keysRotationOffsetModifierCtrl: boolean;
  114913. /**
  114914. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  114915. */
  114916. keysRotationOffsetModifierShift: boolean;
  114917. /**
  114918. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  114919. */
  114920. keysRadiusIncr: number[];
  114921. /**
  114922. * Defines the list of key codes associated with the zoom-out action (increase radius)
  114923. */
  114924. keysRadiusDecr: number[];
  114925. /**
  114926. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  114927. */
  114928. keysRadiusModifierAlt: boolean;
  114929. /**
  114930. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  114931. */
  114932. keysRadiusModifierCtrl: boolean;
  114933. /**
  114934. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  114935. */
  114936. keysRadiusModifierShift: boolean;
  114937. /**
  114938. * Defines the rate of change of heightOffset.
  114939. */
  114940. heightSensibility: number;
  114941. /**
  114942. * Defines the rate of change of rotationOffset.
  114943. */
  114944. rotationSensibility: number;
  114945. /**
  114946. * Defines the rate of change of radius.
  114947. */
  114948. radiusSensibility: number;
  114949. private _keys;
  114950. private _ctrlPressed;
  114951. private _altPressed;
  114952. private _shiftPressed;
  114953. private _onCanvasBlurObserver;
  114954. private _onKeyboardObserver;
  114955. private _engine;
  114956. private _scene;
  114957. /**
  114958. * Attach the input controls to a specific dom element to get the input from.
  114959. * @param element Defines the element the controls should be listened from
  114960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114961. */
  114962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114963. /**
  114964. * Detach the current controls from the specified dom element.
  114965. * @param element Defines the element to stop listening the inputs from
  114966. */
  114967. detachControl(element: Nullable<HTMLElement>): void;
  114968. /**
  114969. * Update the current camera state depending on the inputs that have been used this frame.
  114970. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114971. */
  114972. checkInputs(): void;
  114973. /**
  114974. * Gets the class name of the current input.
  114975. * @returns the class name
  114976. */
  114977. getClassName(): string;
  114978. /**
  114979. * Get the friendly name associated with the input class.
  114980. * @returns the input friendly name
  114981. */
  114982. getSimpleName(): string;
  114983. /**
  114984. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114985. * allow modification of the heightOffset value.
  114986. */
  114987. private _modifierHeightOffset;
  114988. /**
  114989. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114990. * allow modification of the rotationOffset value.
  114991. */
  114992. private _modifierRotationOffset;
  114993. /**
  114994. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  114995. * allow modification of the radius value.
  114996. */
  114997. private _modifierRadius;
  114998. }
  114999. }
  115000. declare module BABYLON {
  115001. interface FreeCameraInputsManager {
  115002. /**
  115003. * @hidden
  115004. */
  115005. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  115006. /**
  115007. * Add orientation input support to the input manager.
  115008. * @returns the current input manager
  115009. */
  115010. addDeviceOrientation(): FreeCameraInputsManager;
  115011. }
  115012. /**
  115013. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  115014. * Screen rotation is taken into account.
  115015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115016. */
  115017. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  115018. private _camera;
  115019. private _screenOrientationAngle;
  115020. private _constantTranform;
  115021. private _screenQuaternion;
  115022. private _alpha;
  115023. private _beta;
  115024. private _gamma;
  115025. /**
  115026. * Can be used to detect if a device orientation sensor is available on a device
  115027. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  115028. * @returns a promise that will resolve on orientation change
  115029. */
  115030. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  115031. /**
  115032. * @hidden
  115033. */
  115034. _onDeviceOrientationChangedObservable: Observable<void>;
  115035. /**
  115036. * Instantiates a new input
  115037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115038. */
  115039. constructor();
  115040. /**
  115041. * Define the camera controlled by the input.
  115042. */
  115043. get camera(): FreeCamera;
  115044. set camera(camera: FreeCamera);
  115045. /**
  115046. * Attach the input controls to a specific dom element to get the input from.
  115047. * @param element Defines the element the controls should be listened from
  115048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115049. */
  115050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115051. private _orientationChanged;
  115052. private _deviceOrientation;
  115053. /**
  115054. * Detach the current controls from the specified dom element.
  115055. * @param element Defines the element to stop listening the inputs from
  115056. */
  115057. detachControl(element: Nullable<HTMLElement>): void;
  115058. /**
  115059. * Update the current camera state depending on the inputs that have been used this frame.
  115060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115061. */
  115062. checkInputs(): void;
  115063. /**
  115064. * Gets the class name of the current intput.
  115065. * @returns the class name
  115066. */
  115067. getClassName(): string;
  115068. /**
  115069. * Get the friendly name associated with the input class.
  115070. * @returns the input friendly name
  115071. */
  115072. getSimpleName(): string;
  115073. }
  115074. }
  115075. declare module BABYLON {
  115076. /**
  115077. * Manage the gamepad inputs to control a free camera.
  115078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115079. */
  115080. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  115081. /**
  115082. * Define the camera the input is attached to.
  115083. */
  115084. camera: FreeCamera;
  115085. /**
  115086. * Define the Gamepad controlling the input
  115087. */
  115088. gamepad: Nullable<Gamepad>;
  115089. /**
  115090. * Defines the gamepad rotation sensiblity.
  115091. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115092. */
  115093. gamepadAngularSensibility: number;
  115094. /**
  115095. * Defines the gamepad move sensiblity.
  115096. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115097. */
  115098. gamepadMoveSensibility: number;
  115099. private _yAxisScale;
  115100. /**
  115101. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  115102. */
  115103. get invertYAxis(): boolean;
  115104. set invertYAxis(value: boolean);
  115105. private _onGamepadConnectedObserver;
  115106. private _onGamepadDisconnectedObserver;
  115107. private _cameraTransform;
  115108. private _deltaTransform;
  115109. private _vector3;
  115110. private _vector2;
  115111. /**
  115112. * Attach the input controls to a specific dom element to get the input from.
  115113. * @param element Defines the element the controls should be listened from
  115114. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115115. */
  115116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115117. /**
  115118. * Detach the current controls from the specified dom element.
  115119. * @param element Defines the element to stop listening the inputs from
  115120. */
  115121. detachControl(element: Nullable<HTMLElement>): void;
  115122. /**
  115123. * Update the current camera state depending on the inputs that have been used this frame.
  115124. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115125. */
  115126. checkInputs(): void;
  115127. /**
  115128. * Gets the class name of the current intput.
  115129. * @returns the class name
  115130. */
  115131. getClassName(): string;
  115132. /**
  115133. * Get the friendly name associated with the input class.
  115134. * @returns the input friendly name
  115135. */
  115136. getSimpleName(): string;
  115137. }
  115138. }
  115139. declare module BABYLON {
  115140. /**
  115141. * Defines the potential axis of a Joystick
  115142. */
  115143. export enum JoystickAxis {
  115144. /** X axis */
  115145. X = 0,
  115146. /** Y axis */
  115147. Y = 1,
  115148. /** Z axis */
  115149. Z = 2
  115150. }
  115151. /**
  115152. * Class used to define virtual joystick (used in touch mode)
  115153. */
  115154. export class VirtualJoystick {
  115155. /**
  115156. * Gets or sets a boolean indicating that left and right values must be inverted
  115157. */
  115158. reverseLeftRight: boolean;
  115159. /**
  115160. * Gets or sets a boolean indicating that up and down values must be inverted
  115161. */
  115162. reverseUpDown: boolean;
  115163. /**
  115164. * Gets the offset value for the position (ie. the change of the position value)
  115165. */
  115166. deltaPosition: Vector3;
  115167. /**
  115168. * Gets a boolean indicating if the virtual joystick was pressed
  115169. */
  115170. pressed: boolean;
  115171. /**
  115172. * Canvas the virtual joystick will render onto, default z-index of this is 5
  115173. */
  115174. static Canvas: Nullable<HTMLCanvasElement>;
  115175. private static _globalJoystickIndex;
  115176. private static vjCanvasContext;
  115177. private static vjCanvasWidth;
  115178. private static vjCanvasHeight;
  115179. private static halfWidth;
  115180. private _action;
  115181. private _axisTargetedByLeftAndRight;
  115182. private _axisTargetedByUpAndDown;
  115183. private _joystickSensibility;
  115184. private _inversedSensibility;
  115185. private _joystickPointerID;
  115186. private _joystickColor;
  115187. private _joystickPointerPos;
  115188. private _joystickPreviousPointerPos;
  115189. private _joystickPointerStartPos;
  115190. private _deltaJoystickVector;
  115191. private _leftJoystick;
  115192. private _touches;
  115193. private _onPointerDownHandlerRef;
  115194. private _onPointerMoveHandlerRef;
  115195. private _onPointerUpHandlerRef;
  115196. private _onResize;
  115197. /**
  115198. * Creates a new virtual joystick
  115199. * @param leftJoystick defines that the joystick is for left hand (false by default)
  115200. */
  115201. constructor(leftJoystick?: boolean);
  115202. /**
  115203. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  115204. * @param newJoystickSensibility defines the new sensibility
  115205. */
  115206. setJoystickSensibility(newJoystickSensibility: number): void;
  115207. private _onPointerDown;
  115208. private _onPointerMove;
  115209. private _onPointerUp;
  115210. /**
  115211. * Change the color of the virtual joystick
  115212. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  115213. */
  115214. setJoystickColor(newColor: string): void;
  115215. /**
  115216. * Defines a callback to call when the joystick is touched
  115217. * @param action defines the callback
  115218. */
  115219. setActionOnTouch(action: () => any): void;
  115220. /**
  115221. * Defines which axis you'd like to control for left & right
  115222. * @param axis defines the axis to use
  115223. */
  115224. setAxisForLeftRight(axis: JoystickAxis): void;
  115225. /**
  115226. * Defines which axis you'd like to control for up & down
  115227. * @param axis defines the axis to use
  115228. */
  115229. setAxisForUpDown(axis: JoystickAxis): void;
  115230. private _drawVirtualJoystick;
  115231. /**
  115232. * Release internal HTML canvas
  115233. */
  115234. releaseCanvas(): void;
  115235. }
  115236. }
  115237. declare module BABYLON {
  115238. interface FreeCameraInputsManager {
  115239. /**
  115240. * Add virtual joystick input support to the input manager.
  115241. * @returns the current input manager
  115242. */
  115243. addVirtualJoystick(): FreeCameraInputsManager;
  115244. }
  115245. /**
  115246. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  115247. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115248. */
  115249. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  115250. /**
  115251. * Defines the camera the input is attached to.
  115252. */
  115253. camera: FreeCamera;
  115254. private _leftjoystick;
  115255. private _rightjoystick;
  115256. /**
  115257. * Gets the left stick of the virtual joystick.
  115258. * @returns The virtual Joystick
  115259. */
  115260. getLeftJoystick(): VirtualJoystick;
  115261. /**
  115262. * Gets the right stick of the virtual joystick.
  115263. * @returns The virtual Joystick
  115264. */
  115265. getRightJoystick(): VirtualJoystick;
  115266. /**
  115267. * Update the current camera state depending on the inputs that have been used this frame.
  115268. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115269. */
  115270. checkInputs(): void;
  115271. /**
  115272. * Attach the input controls to a specific dom element to get the input from.
  115273. * @param element Defines the element the controls should be listened from
  115274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115275. */
  115276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115277. /**
  115278. * Detach the current controls from the specified dom element.
  115279. * @param element Defines the element to stop listening the inputs from
  115280. */
  115281. detachControl(element: Nullable<HTMLElement>): void;
  115282. /**
  115283. * Gets the class name of the current intput.
  115284. * @returns the class name
  115285. */
  115286. getClassName(): string;
  115287. /**
  115288. * Get the friendly name associated with the input class.
  115289. * @returns the input friendly name
  115290. */
  115291. getSimpleName(): string;
  115292. }
  115293. }
  115294. declare module BABYLON {
  115295. /**
  115296. * This represents a FPS type of camera controlled by touch.
  115297. * This is like a universal camera minus the Gamepad controls.
  115298. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115299. */
  115300. export class TouchCamera extends FreeCamera {
  115301. /**
  115302. * Defines the touch sensibility for rotation.
  115303. * The higher the faster.
  115304. */
  115305. get touchAngularSensibility(): number;
  115306. set touchAngularSensibility(value: number);
  115307. /**
  115308. * Defines the touch sensibility for move.
  115309. * The higher the faster.
  115310. */
  115311. get touchMoveSensibility(): number;
  115312. set touchMoveSensibility(value: number);
  115313. /**
  115314. * Instantiates a new touch camera.
  115315. * This represents a FPS type of camera controlled by touch.
  115316. * This is like a universal camera minus the Gamepad controls.
  115317. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115318. * @param name Define the name of the camera in the scene
  115319. * @param position Define the start position of the camera in the scene
  115320. * @param scene Define the scene the camera belongs to
  115321. */
  115322. constructor(name: string, position: Vector3, scene: Scene);
  115323. /**
  115324. * Gets the current object class name.
  115325. * @return the class name
  115326. */
  115327. getClassName(): string;
  115328. /** @hidden */
  115329. _setupInputs(): void;
  115330. }
  115331. }
  115332. declare module BABYLON {
  115333. /**
  115334. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  115335. * being tilted forward or back and left or right.
  115336. */
  115337. export class DeviceOrientationCamera extends FreeCamera {
  115338. private _initialQuaternion;
  115339. private _quaternionCache;
  115340. private _tmpDragQuaternion;
  115341. private _disablePointerInputWhenUsingDeviceOrientation;
  115342. /**
  115343. * Creates a new device orientation camera
  115344. * @param name The name of the camera
  115345. * @param position The start position camera
  115346. * @param scene The scene the camera belongs to
  115347. */
  115348. constructor(name: string, position: Vector3, scene: Scene);
  115349. /**
  115350. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  115351. */
  115352. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  115353. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  115354. private _dragFactor;
  115355. /**
  115356. * Enabled turning on the y axis when the orientation sensor is active
  115357. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  115358. */
  115359. enableHorizontalDragging(dragFactor?: number): void;
  115360. /**
  115361. * Gets the current instance class name ("DeviceOrientationCamera").
  115362. * This helps avoiding instanceof at run time.
  115363. * @returns the class name
  115364. */
  115365. getClassName(): string;
  115366. /**
  115367. * @hidden
  115368. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  115369. */
  115370. _checkInputs(): void;
  115371. /**
  115372. * Reset the camera to its default orientation on the specified axis only.
  115373. * @param axis The axis to reset
  115374. */
  115375. resetToCurrentRotation(axis?: Axis): void;
  115376. }
  115377. }
  115378. declare module BABYLON {
  115379. /**
  115380. * Defines supported buttons for XBox360 compatible gamepads
  115381. */
  115382. export enum Xbox360Button {
  115383. /** A */
  115384. A = 0,
  115385. /** B */
  115386. B = 1,
  115387. /** X */
  115388. X = 2,
  115389. /** Y */
  115390. Y = 3,
  115391. /** Left button */
  115392. LB = 4,
  115393. /** Right button */
  115394. RB = 5,
  115395. /** Back */
  115396. Back = 8,
  115397. /** Start */
  115398. Start = 9,
  115399. /** Left stick */
  115400. LeftStick = 10,
  115401. /** Right stick */
  115402. RightStick = 11
  115403. }
  115404. /** Defines values for XBox360 DPad */
  115405. export enum Xbox360Dpad {
  115406. /** Up */
  115407. Up = 12,
  115408. /** Down */
  115409. Down = 13,
  115410. /** Left */
  115411. Left = 14,
  115412. /** Right */
  115413. Right = 15
  115414. }
  115415. /**
  115416. * Defines a XBox360 gamepad
  115417. */
  115418. export class Xbox360Pad extends Gamepad {
  115419. private _leftTrigger;
  115420. private _rightTrigger;
  115421. private _onlefttriggerchanged;
  115422. private _onrighttriggerchanged;
  115423. private _onbuttondown;
  115424. private _onbuttonup;
  115425. private _ondpaddown;
  115426. private _ondpadup;
  115427. /** Observable raised when a button is pressed */
  115428. onButtonDownObservable: Observable<Xbox360Button>;
  115429. /** Observable raised when a button is released */
  115430. onButtonUpObservable: Observable<Xbox360Button>;
  115431. /** Observable raised when a pad is pressed */
  115432. onPadDownObservable: Observable<Xbox360Dpad>;
  115433. /** Observable raised when a pad is released */
  115434. onPadUpObservable: Observable<Xbox360Dpad>;
  115435. private _buttonA;
  115436. private _buttonB;
  115437. private _buttonX;
  115438. private _buttonY;
  115439. private _buttonBack;
  115440. private _buttonStart;
  115441. private _buttonLB;
  115442. private _buttonRB;
  115443. private _buttonLeftStick;
  115444. private _buttonRightStick;
  115445. private _dPadUp;
  115446. private _dPadDown;
  115447. private _dPadLeft;
  115448. private _dPadRight;
  115449. private _isXboxOnePad;
  115450. /**
  115451. * Creates a new XBox360 gamepad object
  115452. * @param id defines the id of this gamepad
  115453. * @param index defines its index
  115454. * @param gamepad defines the internal HTML gamepad object
  115455. * @param xboxOne defines if it is a XBox One gamepad
  115456. */
  115457. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  115458. /**
  115459. * Defines the callback to call when left trigger is pressed
  115460. * @param callback defines the callback to use
  115461. */
  115462. onlefttriggerchanged(callback: (value: number) => void): void;
  115463. /**
  115464. * Defines the callback to call when right trigger is pressed
  115465. * @param callback defines the callback to use
  115466. */
  115467. onrighttriggerchanged(callback: (value: number) => void): void;
  115468. /**
  115469. * Gets the left trigger value
  115470. */
  115471. get leftTrigger(): number;
  115472. /**
  115473. * Sets the left trigger value
  115474. */
  115475. set leftTrigger(newValue: number);
  115476. /**
  115477. * Gets the right trigger value
  115478. */
  115479. get rightTrigger(): number;
  115480. /**
  115481. * Sets the right trigger value
  115482. */
  115483. set rightTrigger(newValue: number);
  115484. /**
  115485. * Defines the callback to call when a button is pressed
  115486. * @param callback defines the callback to use
  115487. */
  115488. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  115489. /**
  115490. * Defines the callback to call when a button is released
  115491. * @param callback defines the callback to use
  115492. */
  115493. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  115494. /**
  115495. * Defines the callback to call when a pad is pressed
  115496. * @param callback defines the callback to use
  115497. */
  115498. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  115499. /**
  115500. * Defines the callback to call when a pad is released
  115501. * @param callback defines the callback to use
  115502. */
  115503. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  115504. private _setButtonValue;
  115505. private _setDPadValue;
  115506. /**
  115507. * Gets the value of the `A` button
  115508. */
  115509. get buttonA(): number;
  115510. /**
  115511. * Sets the value of the `A` button
  115512. */
  115513. set buttonA(value: number);
  115514. /**
  115515. * Gets the value of the `B` button
  115516. */
  115517. get buttonB(): number;
  115518. /**
  115519. * Sets the value of the `B` button
  115520. */
  115521. set buttonB(value: number);
  115522. /**
  115523. * Gets the value of the `X` button
  115524. */
  115525. get buttonX(): number;
  115526. /**
  115527. * Sets the value of the `X` button
  115528. */
  115529. set buttonX(value: number);
  115530. /**
  115531. * Gets the value of the `Y` button
  115532. */
  115533. get buttonY(): number;
  115534. /**
  115535. * Sets the value of the `Y` button
  115536. */
  115537. set buttonY(value: number);
  115538. /**
  115539. * Gets the value of the `Start` button
  115540. */
  115541. get buttonStart(): number;
  115542. /**
  115543. * Sets the value of the `Start` button
  115544. */
  115545. set buttonStart(value: number);
  115546. /**
  115547. * Gets the value of the `Back` button
  115548. */
  115549. get buttonBack(): number;
  115550. /**
  115551. * Sets the value of the `Back` button
  115552. */
  115553. set buttonBack(value: number);
  115554. /**
  115555. * Gets the value of the `Left` button
  115556. */
  115557. get buttonLB(): number;
  115558. /**
  115559. * Sets the value of the `Left` button
  115560. */
  115561. set buttonLB(value: number);
  115562. /**
  115563. * Gets the value of the `Right` button
  115564. */
  115565. get buttonRB(): number;
  115566. /**
  115567. * Sets the value of the `Right` button
  115568. */
  115569. set buttonRB(value: number);
  115570. /**
  115571. * Gets the value of the Left joystick
  115572. */
  115573. get buttonLeftStick(): number;
  115574. /**
  115575. * Sets the value of the Left joystick
  115576. */
  115577. set buttonLeftStick(value: number);
  115578. /**
  115579. * Gets the value of the Right joystick
  115580. */
  115581. get buttonRightStick(): number;
  115582. /**
  115583. * Sets the value of the Right joystick
  115584. */
  115585. set buttonRightStick(value: number);
  115586. /**
  115587. * Gets the value of D-pad up
  115588. */
  115589. get dPadUp(): number;
  115590. /**
  115591. * Sets the value of D-pad up
  115592. */
  115593. set dPadUp(value: number);
  115594. /**
  115595. * Gets the value of D-pad down
  115596. */
  115597. get dPadDown(): number;
  115598. /**
  115599. * Sets the value of D-pad down
  115600. */
  115601. set dPadDown(value: number);
  115602. /**
  115603. * Gets the value of D-pad left
  115604. */
  115605. get dPadLeft(): number;
  115606. /**
  115607. * Sets the value of D-pad left
  115608. */
  115609. set dPadLeft(value: number);
  115610. /**
  115611. * Gets the value of D-pad right
  115612. */
  115613. get dPadRight(): number;
  115614. /**
  115615. * Sets the value of D-pad right
  115616. */
  115617. set dPadRight(value: number);
  115618. /**
  115619. * Force the gamepad to synchronize with device values
  115620. */
  115621. update(): void;
  115622. /**
  115623. * Disposes the gamepad
  115624. */
  115625. dispose(): void;
  115626. }
  115627. }
  115628. declare module BABYLON {
  115629. /**
  115630. * Defines supported buttons for DualShock compatible gamepads
  115631. */
  115632. export enum DualShockButton {
  115633. /** Cross */
  115634. Cross = 0,
  115635. /** Circle */
  115636. Circle = 1,
  115637. /** Square */
  115638. Square = 2,
  115639. /** Triangle */
  115640. Triangle = 3,
  115641. /** L1 */
  115642. L1 = 4,
  115643. /** R1 */
  115644. R1 = 5,
  115645. /** Share */
  115646. Share = 8,
  115647. /** Options */
  115648. Options = 9,
  115649. /** Left stick */
  115650. LeftStick = 10,
  115651. /** Right stick */
  115652. RightStick = 11
  115653. }
  115654. /** Defines values for DualShock DPad */
  115655. export enum DualShockDpad {
  115656. /** Up */
  115657. Up = 12,
  115658. /** Down */
  115659. Down = 13,
  115660. /** Left */
  115661. Left = 14,
  115662. /** Right */
  115663. Right = 15
  115664. }
  115665. /**
  115666. * Defines a DualShock gamepad
  115667. */
  115668. export class DualShockPad extends Gamepad {
  115669. private _leftTrigger;
  115670. private _rightTrigger;
  115671. private _onlefttriggerchanged;
  115672. private _onrighttriggerchanged;
  115673. private _onbuttondown;
  115674. private _onbuttonup;
  115675. private _ondpaddown;
  115676. private _ondpadup;
  115677. /** Observable raised when a button is pressed */
  115678. onButtonDownObservable: Observable<DualShockButton>;
  115679. /** Observable raised when a button is released */
  115680. onButtonUpObservable: Observable<DualShockButton>;
  115681. /** Observable raised when a pad is pressed */
  115682. onPadDownObservable: Observable<DualShockDpad>;
  115683. /** Observable raised when a pad is released */
  115684. onPadUpObservable: Observable<DualShockDpad>;
  115685. private _buttonCross;
  115686. private _buttonCircle;
  115687. private _buttonSquare;
  115688. private _buttonTriangle;
  115689. private _buttonShare;
  115690. private _buttonOptions;
  115691. private _buttonL1;
  115692. private _buttonR1;
  115693. private _buttonLeftStick;
  115694. private _buttonRightStick;
  115695. private _dPadUp;
  115696. private _dPadDown;
  115697. private _dPadLeft;
  115698. private _dPadRight;
  115699. /**
  115700. * Creates a new DualShock gamepad object
  115701. * @param id defines the id of this gamepad
  115702. * @param index defines its index
  115703. * @param gamepad defines the internal HTML gamepad object
  115704. */
  115705. constructor(id: string, index: number, gamepad: any);
  115706. /**
  115707. * Defines the callback to call when left trigger is pressed
  115708. * @param callback defines the callback to use
  115709. */
  115710. onlefttriggerchanged(callback: (value: number) => void): void;
  115711. /**
  115712. * Defines the callback to call when right trigger is pressed
  115713. * @param callback defines the callback to use
  115714. */
  115715. onrighttriggerchanged(callback: (value: number) => void): void;
  115716. /**
  115717. * Gets the left trigger value
  115718. */
  115719. get leftTrigger(): number;
  115720. /**
  115721. * Sets the left trigger value
  115722. */
  115723. set leftTrigger(newValue: number);
  115724. /**
  115725. * Gets the right trigger value
  115726. */
  115727. get rightTrigger(): number;
  115728. /**
  115729. * Sets the right trigger value
  115730. */
  115731. set rightTrigger(newValue: number);
  115732. /**
  115733. * Defines the callback to call when a button is pressed
  115734. * @param callback defines the callback to use
  115735. */
  115736. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  115737. /**
  115738. * Defines the callback to call when a button is released
  115739. * @param callback defines the callback to use
  115740. */
  115741. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  115742. /**
  115743. * Defines the callback to call when a pad is pressed
  115744. * @param callback defines the callback to use
  115745. */
  115746. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115747. /**
  115748. * Defines the callback to call when a pad is released
  115749. * @param callback defines the callback to use
  115750. */
  115751. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  115752. private _setButtonValue;
  115753. private _setDPadValue;
  115754. /**
  115755. * Gets the value of the `Cross` button
  115756. */
  115757. get buttonCross(): number;
  115758. /**
  115759. * Sets the value of the `Cross` button
  115760. */
  115761. set buttonCross(value: number);
  115762. /**
  115763. * Gets the value of the `Circle` button
  115764. */
  115765. get buttonCircle(): number;
  115766. /**
  115767. * Sets the value of the `Circle` button
  115768. */
  115769. set buttonCircle(value: number);
  115770. /**
  115771. * Gets the value of the `Square` button
  115772. */
  115773. get buttonSquare(): number;
  115774. /**
  115775. * Sets the value of the `Square` button
  115776. */
  115777. set buttonSquare(value: number);
  115778. /**
  115779. * Gets the value of the `Triangle` button
  115780. */
  115781. get buttonTriangle(): number;
  115782. /**
  115783. * Sets the value of the `Triangle` button
  115784. */
  115785. set buttonTriangle(value: number);
  115786. /**
  115787. * Gets the value of the `Options` button
  115788. */
  115789. get buttonOptions(): number;
  115790. /**
  115791. * Sets the value of the `Options` button
  115792. */
  115793. set buttonOptions(value: number);
  115794. /**
  115795. * Gets the value of the `Share` button
  115796. */
  115797. get buttonShare(): number;
  115798. /**
  115799. * Sets the value of the `Share` button
  115800. */
  115801. set buttonShare(value: number);
  115802. /**
  115803. * Gets the value of the `L1` button
  115804. */
  115805. get buttonL1(): number;
  115806. /**
  115807. * Sets the value of the `L1` button
  115808. */
  115809. set buttonL1(value: number);
  115810. /**
  115811. * Gets the value of the `R1` button
  115812. */
  115813. get buttonR1(): number;
  115814. /**
  115815. * Sets the value of the `R1` button
  115816. */
  115817. set buttonR1(value: number);
  115818. /**
  115819. * Gets the value of the Left joystick
  115820. */
  115821. get buttonLeftStick(): number;
  115822. /**
  115823. * Sets the value of the Left joystick
  115824. */
  115825. set buttonLeftStick(value: number);
  115826. /**
  115827. * Gets the value of the Right joystick
  115828. */
  115829. get buttonRightStick(): number;
  115830. /**
  115831. * Sets the value of the Right joystick
  115832. */
  115833. set buttonRightStick(value: number);
  115834. /**
  115835. * Gets the value of D-pad up
  115836. */
  115837. get dPadUp(): number;
  115838. /**
  115839. * Sets the value of D-pad up
  115840. */
  115841. set dPadUp(value: number);
  115842. /**
  115843. * Gets the value of D-pad down
  115844. */
  115845. get dPadDown(): number;
  115846. /**
  115847. * Sets the value of D-pad down
  115848. */
  115849. set dPadDown(value: number);
  115850. /**
  115851. * Gets the value of D-pad left
  115852. */
  115853. get dPadLeft(): number;
  115854. /**
  115855. * Sets the value of D-pad left
  115856. */
  115857. set dPadLeft(value: number);
  115858. /**
  115859. * Gets the value of D-pad right
  115860. */
  115861. get dPadRight(): number;
  115862. /**
  115863. * Sets the value of D-pad right
  115864. */
  115865. set dPadRight(value: number);
  115866. /**
  115867. * Force the gamepad to synchronize with device values
  115868. */
  115869. update(): void;
  115870. /**
  115871. * Disposes the gamepad
  115872. */
  115873. dispose(): void;
  115874. }
  115875. }
  115876. declare module BABYLON {
  115877. /**
  115878. * Manager for handling gamepads
  115879. */
  115880. export class GamepadManager {
  115881. private _scene?;
  115882. private _babylonGamepads;
  115883. private _oneGamepadConnected;
  115884. /** @hidden */
  115885. _isMonitoring: boolean;
  115886. private _gamepadEventSupported;
  115887. private _gamepadSupport?;
  115888. /**
  115889. * observable to be triggered when the gamepad controller has been connected
  115890. */
  115891. onGamepadConnectedObservable: Observable<Gamepad>;
  115892. /**
  115893. * observable to be triggered when the gamepad controller has been disconnected
  115894. */
  115895. onGamepadDisconnectedObservable: Observable<Gamepad>;
  115896. private _onGamepadConnectedEvent;
  115897. private _onGamepadDisconnectedEvent;
  115898. /**
  115899. * Initializes the gamepad manager
  115900. * @param _scene BabylonJS scene
  115901. */
  115902. constructor(_scene?: Scene | undefined);
  115903. /**
  115904. * The gamepads in the game pad manager
  115905. */
  115906. get gamepads(): Gamepad[];
  115907. /**
  115908. * Get the gamepad controllers based on type
  115909. * @param type The type of gamepad controller
  115910. * @returns Nullable gamepad
  115911. */
  115912. getGamepadByType(type?: number): Nullable<Gamepad>;
  115913. /**
  115914. * Disposes the gamepad manager
  115915. */
  115916. dispose(): void;
  115917. private _addNewGamepad;
  115918. private _startMonitoringGamepads;
  115919. private _stopMonitoringGamepads;
  115920. /** @hidden */
  115921. _checkGamepadsStatus(): void;
  115922. private _updateGamepadObjects;
  115923. }
  115924. }
  115925. declare module BABYLON {
  115926. interface Scene {
  115927. /** @hidden */
  115928. _gamepadManager: Nullable<GamepadManager>;
  115929. /**
  115930. * Gets the gamepad manager associated with the scene
  115931. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  115932. */
  115933. gamepadManager: GamepadManager;
  115934. }
  115935. /**
  115936. * Interface representing a free camera inputs manager
  115937. */
  115938. interface FreeCameraInputsManager {
  115939. /**
  115940. * Adds gamepad input support to the FreeCameraInputsManager.
  115941. * @returns the FreeCameraInputsManager
  115942. */
  115943. addGamepad(): FreeCameraInputsManager;
  115944. }
  115945. /**
  115946. * Interface representing an arc rotate camera inputs manager
  115947. */
  115948. interface ArcRotateCameraInputsManager {
  115949. /**
  115950. * Adds gamepad input support to the ArcRotateCamera InputManager.
  115951. * @returns the camera inputs manager
  115952. */
  115953. addGamepad(): ArcRotateCameraInputsManager;
  115954. }
  115955. /**
  115956. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  115957. */
  115958. export class GamepadSystemSceneComponent implements ISceneComponent {
  115959. /**
  115960. * The component name helpfull to identify the component in the list of scene components.
  115961. */
  115962. readonly name: string;
  115963. /**
  115964. * The scene the component belongs to.
  115965. */
  115966. scene: Scene;
  115967. /**
  115968. * Creates a new instance of the component for the given scene
  115969. * @param scene Defines the scene to register the component in
  115970. */
  115971. constructor(scene: Scene);
  115972. /**
  115973. * Registers the component in a given scene
  115974. */
  115975. register(): void;
  115976. /**
  115977. * Rebuilds the elements related to this component in case of
  115978. * context lost for instance.
  115979. */
  115980. rebuild(): void;
  115981. /**
  115982. * Disposes the component and the associated ressources
  115983. */
  115984. dispose(): void;
  115985. private _beforeCameraUpdate;
  115986. }
  115987. }
  115988. declare module BABYLON {
  115989. /**
  115990. * 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,
  115991. * which still works and will still be found in many Playgrounds.
  115992. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115993. */
  115994. export class UniversalCamera extends TouchCamera {
  115995. /**
  115996. * Defines the gamepad rotation sensiblity.
  115997. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115998. */
  115999. get gamepadAngularSensibility(): number;
  116000. set gamepadAngularSensibility(value: number);
  116001. /**
  116002. * Defines the gamepad move sensiblity.
  116003. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116004. */
  116005. get gamepadMoveSensibility(): number;
  116006. set gamepadMoveSensibility(value: number);
  116007. /**
  116008. * 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,
  116009. * which still works and will still be found in many Playgrounds.
  116010. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116011. * @param name Define the name of the camera in the scene
  116012. * @param position Define the start position of the camera in the scene
  116013. * @param scene Define the scene the camera belongs to
  116014. */
  116015. constructor(name: string, position: Vector3, scene: Scene);
  116016. /**
  116017. * Gets the current object class name.
  116018. * @return the class name
  116019. */
  116020. getClassName(): string;
  116021. }
  116022. }
  116023. declare module BABYLON {
  116024. /**
  116025. * This represents a FPS type of camera. This is only here for back compat purpose.
  116026. * Please use the UniversalCamera instead as both are identical.
  116027. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116028. */
  116029. export class GamepadCamera extends UniversalCamera {
  116030. /**
  116031. * Instantiates a new Gamepad Camera
  116032. * This represents a FPS type of camera. This is only here for back compat purpose.
  116033. * Please use the UniversalCamera instead as both are identical.
  116034. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116035. * @param name Define the name of the camera in the scene
  116036. * @param position Define the start position of the camera in the scene
  116037. * @param scene Define the scene the camera belongs to
  116038. */
  116039. constructor(name: string, position: Vector3, scene: Scene);
  116040. /**
  116041. * Gets the current object class name.
  116042. * @return the class name
  116043. */
  116044. getClassName(): string;
  116045. }
  116046. }
  116047. declare module BABYLON {
  116048. /** @hidden */
  116049. export var passPixelShader: {
  116050. name: string;
  116051. shader: string;
  116052. };
  116053. }
  116054. declare module BABYLON {
  116055. /** @hidden */
  116056. export var passCubePixelShader: {
  116057. name: string;
  116058. shader: string;
  116059. };
  116060. }
  116061. declare module BABYLON {
  116062. /**
  116063. * PassPostProcess which produces an output the same as it's input
  116064. */
  116065. export class PassPostProcess extends PostProcess {
  116066. /**
  116067. * Creates the PassPostProcess
  116068. * @param name The name of the effect.
  116069. * @param options The required width/height ratio to downsize to before computing the render pass.
  116070. * @param camera The camera to apply the render pass to.
  116071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116072. * @param engine The engine which the post process will be applied. (default: current engine)
  116073. * @param reusable If the post process can be reused on the same frame. (default: false)
  116074. * @param textureType The type of texture to be used when performing the post processing.
  116075. * @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)
  116076. */
  116077. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116078. }
  116079. /**
  116080. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  116081. */
  116082. export class PassCubePostProcess extends PostProcess {
  116083. private _face;
  116084. /**
  116085. * Gets or sets the cube face to display.
  116086. * * 0 is +X
  116087. * * 1 is -X
  116088. * * 2 is +Y
  116089. * * 3 is -Y
  116090. * * 4 is +Z
  116091. * * 5 is -Z
  116092. */
  116093. get face(): number;
  116094. set face(value: number);
  116095. /**
  116096. * Creates the PassCubePostProcess
  116097. * @param name The name of the effect.
  116098. * @param options The required width/height ratio to downsize to before computing the render pass.
  116099. * @param camera The camera to apply the render pass to.
  116100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116101. * @param engine The engine which the post process will be applied. (default: current engine)
  116102. * @param reusable If the post process can be reused on the same frame. (default: false)
  116103. * @param textureType The type of texture to be used when performing the post processing.
  116104. * @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)
  116105. */
  116106. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116107. }
  116108. }
  116109. declare module BABYLON {
  116110. /** @hidden */
  116111. export var anaglyphPixelShader: {
  116112. name: string;
  116113. shader: string;
  116114. };
  116115. }
  116116. declare module BABYLON {
  116117. /**
  116118. * Postprocess used to generate anaglyphic rendering
  116119. */
  116120. export class AnaglyphPostProcess extends PostProcess {
  116121. private _passedProcess;
  116122. /**
  116123. * Creates a new AnaglyphPostProcess
  116124. * @param name defines postprocess name
  116125. * @param options defines creation options or target ratio scale
  116126. * @param rigCameras defines cameras using this postprocess
  116127. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116128. * @param engine defines hosting engine
  116129. * @param reusable defines if the postprocess will be reused multiple times per frame
  116130. */
  116131. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  116132. }
  116133. }
  116134. declare module BABYLON {
  116135. /**
  116136. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  116137. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116138. */
  116139. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  116140. /**
  116141. * Creates a new AnaglyphArcRotateCamera
  116142. * @param name defines camera name
  116143. * @param alpha defines alpha angle (in radians)
  116144. * @param beta defines beta angle (in radians)
  116145. * @param radius defines radius
  116146. * @param target defines camera target
  116147. * @param interaxialDistance defines distance between each color axis
  116148. * @param scene defines the hosting scene
  116149. */
  116150. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  116151. /**
  116152. * Gets camera class name
  116153. * @returns AnaglyphArcRotateCamera
  116154. */
  116155. getClassName(): string;
  116156. }
  116157. }
  116158. declare module BABYLON {
  116159. /**
  116160. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  116161. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116162. */
  116163. export class AnaglyphFreeCamera extends FreeCamera {
  116164. /**
  116165. * Creates a new AnaglyphFreeCamera
  116166. * @param name defines camera name
  116167. * @param position defines initial position
  116168. * @param interaxialDistance defines distance between each color axis
  116169. * @param scene defines the hosting scene
  116170. */
  116171. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116172. /**
  116173. * Gets camera class name
  116174. * @returns AnaglyphFreeCamera
  116175. */
  116176. getClassName(): string;
  116177. }
  116178. }
  116179. declare module BABYLON {
  116180. /**
  116181. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  116182. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116183. */
  116184. export class AnaglyphGamepadCamera extends GamepadCamera {
  116185. /**
  116186. * Creates a new AnaglyphGamepadCamera
  116187. * @param name defines camera name
  116188. * @param position defines initial position
  116189. * @param interaxialDistance defines distance between each color axis
  116190. * @param scene defines the hosting scene
  116191. */
  116192. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116193. /**
  116194. * Gets camera class name
  116195. * @returns AnaglyphGamepadCamera
  116196. */
  116197. getClassName(): string;
  116198. }
  116199. }
  116200. declare module BABYLON {
  116201. /**
  116202. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  116203. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116204. */
  116205. export class AnaglyphUniversalCamera extends UniversalCamera {
  116206. /**
  116207. * Creates a new AnaglyphUniversalCamera
  116208. * @param name defines camera name
  116209. * @param position defines initial position
  116210. * @param interaxialDistance defines distance between each color axis
  116211. * @param scene defines the hosting scene
  116212. */
  116213. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116214. /**
  116215. * Gets camera class name
  116216. * @returns AnaglyphUniversalCamera
  116217. */
  116218. getClassName(): string;
  116219. }
  116220. }
  116221. declare module BABYLON {
  116222. /** @hidden */
  116223. export var stereoscopicInterlacePixelShader: {
  116224. name: string;
  116225. shader: string;
  116226. };
  116227. }
  116228. declare module BABYLON {
  116229. /**
  116230. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  116231. */
  116232. export class StereoscopicInterlacePostProcessI extends PostProcess {
  116233. private _stepSize;
  116234. private _passedProcess;
  116235. /**
  116236. * Initializes a StereoscopicInterlacePostProcessI
  116237. * @param name The name of the effect.
  116238. * @param rigCameras The rig cameras to be appled to the post process
  116239. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  116240. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  116241. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116242. * @param engine The engine which the post process will be applied. (default: current engine)
  116243. * @param reusable If the post process can be reused on the same frame. (default: false)
  116244. */
  116245. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116246. }
  116247. /**
  116248. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  116249. */
  116250. export class StereoscopicInterlacePostProcess extends PostProcess {
  116251. private _stepSize;
  116252. private _passedProcess;
  116253. /**
  116254. * Initializes a StereoscopicInterlacePostProcess
  116255. * @param name The name of the effect.
  116256. * @param rigCameras The rig cameras to be appled to the post process
  116257. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  116258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116259. * @param engine The engine which the post process will be applied. (default: current engine)
  116260. * @param reusable If the post process can be reused on the same frame. (default: false)
  116261. */
  116262. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116263. }
  116264. }
  116265. declare module BABYLON {
  116266. /**
  116267. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  116268. * @see http://doc.babylonjs.com/features/cameras
  116269. */
  116270. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  116271. /**
  116272. * Creates a new StereoscopicArcRotateCamera
  116273. * @param name defines camera name
  116274. * @param alpha defines alpha angle (in radians)
  116275. * @param beta defines beta angle (in radians)
  116276. * @param radius defines radius
  116277. * @param target defines camera target
  116278. * @param interaxialDistance defines distance between each color axis
  116279. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116280. * @param scene defines the hosting scene
  116281. */
  116282. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116283. /**
  116284. * Gets camera class name
  116285. * @returns StereoscopicArcRotateCamera
  116286. */
  116287. getClassName(): string;
  116288. }
  116289. }
  116290. declare module BABYLON {
  116291. /**
  116292. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  116293. * @see http://doc.babylonjs.com/features/cameras
  116294. */
  116295. export class StereoscopicFreeCamera extends FreeCamera {
  116296. /**
  116297. * Creates a new StereoscopicFreeCamera
  116298. * @param name defines camera name
  116299. * @param position defines initial position
  116300. * @param interaxialDistance defines distance between each color axis
  116301. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116302. * @param scene defines the hosting scene
  116303. */
  116304. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116305. /**
  116306. * Gets camera class name
  116307. * @returns StereoscopicFreeCamera
  116308. */
  116309. getClassName(): string;
  116310. }
  116311. }
  116312. declare module BABYLON {
  116313. /**
  116314. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  116315. * @see http://doc.babylonjs.com/features/cameras
  116316. */
  116317. export class StereoscopicGamepadCamera extends GamepadCamera {
  116318. /**
  116319. * Creates a new StereoscopicGamepadCamera
  116320. * @param name defines camera name
  116321. * @param position defines initial position
  116322. * @param interaxialDistance defines distance between each color axis
  116323. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116324. * @param scene defines the hosting scene
  116325. */
  116326. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116327. /**
  116328. * Gets camera class name
  116329. * @returns StereoscopicGamepadCamera
  116330. */
  116331. getClassName(): string;
  116332. }
  116333. }
  116334. declare module BABYLON {
  116335. /**
  116336. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  116337. * @see http://doc.babylonjs.com/features/cameras
  116338. */
  116339. export class StereoscopicUniversalCamera extends UniversalCamera {
  116340. /**
  116341. * Creates a new StereoscopicUniversalCamera
  116342. * @param name defines camera name
  116343. * @param position defines initial position
  116344. * @param interaxialDistance defines distance between each color axis
  116345. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116346. * @param scene defines the hosting scene
  116347. */
  116348. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116349. /**
  116350. * Gets camera class name
  116351. * @returns StereoscopicUniversalCamera
  116352. */
  116353. getClassName(): string;
  116354. }
  116355. }
  116356. declare module BABYLON {
  116357. /**
  116358. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  116359. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116360. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116361. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116362. */
  116363. export class VirtualJoysticksCamera extends FreeCamera {
  116364. /**
  116365. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  116366. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116367. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116368. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116369. * @param name Define the name of the camera in the scene
  116370. * @param position Define the start position of the camera in the scene
  116371. * @param scene Define the scene the camera belongs to
  116372. */
  116373. constructor(name: string, position: Vector3, scene: Scene);
  116374. /**
  116375. * Gets the current object class name.
  116376. * @return the class name
  116377. */
  116378. getClassName(): string;
  116379. }
  116380. }
  116381. declare module BABYLON {
  116382. /**
  116383. * This represents all the required metrics to create a VR camera.
  116384. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  116385. */
  116386. export class VRCameraMetrics {
  116387. /**
  116388. * Define the horizontal resolution off the screen.
  116389. */
  116390. hResolution: number;
  116391. /**
  116392. * Define the vertical resolution off the screen.
  116393. */
  116394. vResolution: number;
  116395. /**
  116396. * Define the horizontal screen size.
  116397. */
  116398. hScreenSize: number;
  116399. /**
  116400. * Define the vertical screen size.
  116401. */
  116402. vScreenSize: number;
  116403. /**
  116404. * Define the vertical screen center position.
  116405. */
  116406. vScreenCenter: number;
  116407. /**
  116408. * Define the distance of the eyes to the screen.
  116409. */
  116410. eyeToScreenDistance: number;
  116411. /**
  116412. * Define the distance between both lenses
  116413. */
  116414. lensSeparationDistance: number;
  116415. /**
  116416. * Define the distance between both viewer's eyes.
  116417. */
  116418. interpupillaryDistance: number;
  116419. /**
  116420. * Define the distortion factor of the VR postprocess.
  116421. * Please, touch with care.
  116422. */
  116423. distortionK: number[];
  116424. /**
  116425. * Define the chromatic aberration correction factors for the VR post process.
  116426. */
  116427. chromaAbCorrection: number[];
  116428. /**
  116429. * Define the scale factor of the post process.
  116430. * The smaller the better but the slower.
  116431. */
  116432. postProcessScaleFactor: number;
  116433. /**
  116434. * Define an offset for the lens center.
  116435. */
  116436. lensCenterOffset: number;
  116437. /**
  116438. * Define if the current vr camera should compensate the distortion of the lense or not.
  116439. */
  116440. compensateDistortion: boolean;
  116441. /**
  116442. * Defines if multiview should be enabled when rendering (Default: false)
  116443. */
  116444. multiviewEnabled: boolean;
  116445. /**
  116446. * Gets the rendering aspect ratio based on the provided resolutions.
  116447. */
  116448. get aspectRatio(): number;
  116449. /**
  116450. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  116451. */
  116452. get aspectRatioFov(): number;
  116453. /**
  116454. * @hidden
  116455. */
  116456. get leftHMatrix(): Matrix;
  116457. /**
  116458. * @hidden
  116459. */
  116460. get rightHMatrix(): Matrix;
  116461. /**
  116462. * @hidden
  116463. */
  116464. get leftPreViewMatrix(): Matrix;
  116465. /**
  116466. * @hidden
  116467. */
  116468. get rightPreViewMatrix(): Matrix;
  116469. /**
  116470. * Get the default VRMetrics based on the most generic setup.
  116471. * @returns the default vr metrics
  116472. */
  116473. static GetDefault(): VRCameraMetrics;
  116474. }
  116475. }
  116476. declare module BABYLON {
  116477. /** @hidden */
  116478. export var vrDistortionCorrectionPixelShader: {
  116479. name: string;
  116480. shader: string;
  116481. };
  116482. }
  116483. declare module BABYLON {
  116484. /**
  116485. * VRDistortionCorrectionPostProcess used for mobile VR
  116486. */
  116487. export class VRDistortionCorrectionPostProcess extends PostProcess {
  116488. private _isRightEye;
  116489. private _distortionFactors;
  116490. private _postProcessScaleFactor;
  116491. private _lensCenterOffset;
  116492. private _scaleIn;
  116493. private _scaleFactor;
  116494. private _lensCenter;
  116495. /**
  116496. * Initializes the VRDistortionCorrectionPostProcess
  116497. * @param name The name of the effect.
  116498. * @param camera The camera to apply the render pass to.
  116499. * @param isRightEye If this is for the right eye distortion
  116500. * @param vrMetrics All the required metrics for the VR camera
  116501. */
  116502. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  116503. }
  116504. }
  116505. declare module BABYLON {
  116506. /**
  116507. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  116508. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116509. */
  116510. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  116511. /**
  116512. * Creates a new VRDeviceOrientationArcRotateCamera
  116513. * @param name defines camera name
  116514. * @param alpha defines the camera rotation along the logitudinal axis
  116515. * @param beta defines the camera rotation along the latitudinal axis
  116516. * @param radius defines the camera distance from its target
  116517. * @param target defines the camera target
  116518. * @param scene defines the scene the camera belongs to
  116519. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116520. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116521. */
  116522. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116523. /**
  116524. * Gets camera class name
  116525. * @returns VRDeviceOrientationArcRotateCamera
  116526. */
  116527. getClassName(): string;
  116528. }
  116529. }
  116530. declare module BABYLON {
  116531. /**
  116532. * Camera used to simulate VR rendering (based on FreeCamera)
  116533. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116534. */
  116535. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  116536. /**
  116537. * Creates a new VRDeviceOrientationFreeCamera
  116538. * @param name defines camera name
  116539. * @param position defines the start position of the camera
  116540. * @param scene defines the scene the camera belongs to
  116541. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116542. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116543. */
  116544. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116545. /**
  116546. * Gets camera class name
  116547. * @returns VRDeviceOrientationFreeCamera
  116548. */
  116549. getClassName(): string;
  116550. }
  116551. }
  116552. declare module BABYLON {
  116553. /**
  116554. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  116555. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116556. */
  116557. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  116558. /**
  116559. * Creates a new VRDeviceOrientationGamepadCamera
  116560. * @param name defines camera name
  116561. * @param position defines the start position of the camera
  116562. * @param scene defines the scene the camera belongs to
  116563. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116564. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116565. */
  116566. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116567. /**
  116568. * Gets camera class name
  116569. * @returns VRDeviceOrientationGamepadCamera
  116570. */
  116571. getClassName(): string;
  116572. }
  116573. }
  116574. declare module BABYLON {
  116575. /** @hidden */
  116576. export var imageProcessingPixelShader: {
  116577. name: string;
  116578. shader: string;
  116579. };
  116580. }
  116581. declare module BABYLON {
  116582. /**
  116583. * ImageProcessingPostProcess
  116584. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116585. */
  116586. export class ImageProcessingPostProcess extends PostProcess {
  116587. /**
  116588. * Default configuration related to image processing available in the PBR Material.
  116589. */
  116590. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116591. /**
  116592. * Gets the image processing configuration used either in this material.
  116593. */
  116594. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116595. /**
  116596. * Sets the Default image processing configuration used either in the this material.
  116597. *
  116598. * If sets to null, the scene one is in use.
  116599. */
  116600. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  116601. /**
  116602. * Keep track of the image processing observer to allow dispose and replace.
  116603. */
  116604. private _imageProcessingObserver;
  116605. /**
  116606. * Attaches a new image processing configuration to the PBR Material.
  116607. * @param configuration
  116608. */
  116609. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  116610. /**
  116611. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116612. */
  116613. get colorCurves(): Nullable<ColorCurves>;
  116614. /**
  116615. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116616. */
  116617. set colorCurves(value: Nullable<ColorCurves>);
  116618. /**
  116619. * Gets wether the color curves effect is enabled.
  116620. */
  116621. get colorCurvesEnabled(): boolean;
  116622. /**
  116623. * Sets wether the color curves effect is enabled.
  116624. */
  116625. set colorCurvesEnabled(value: boolean);
  116626. /**
  116627. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116628. */
  116629. get colorGradingTexture(): Nullable<BaseTexture>;
  116630. /**
  116631. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116632. */
  116633. set colorGradingTexture(value: Nullable<BaseTexture>);
  116634. /**
  116635. * Gets wether the color grading effect is enabled.
  116636. */
  116637. get colorGradingEnabled(): boolean;
  116638. /**
  116639. * Gets wether the color grading effect is enabled.
  116640. */
  116641. set colorGradingEnabled(value: boolean);
  116642. /**
  116643. * Gets exposure used in the effect.
  116644. */
  116645. get exposure(): number;
  116646. /**
  116647. * Sets exposure used in the effect.
  116648. */
  116649. set exposure(value: number);
  116650. /**
  116651. * Gets wether tonemapping is enabled or not.
  116652. */
  116653. get toneMappingEnabled(): boolean;
  116654. /**
  116655. * Sets wether tonemapping is enabled or not
  116656. */
  116657. set toneMappingEnabled(value: boolean);
  116658. /**
  116659. * Gets the type of tone mapping effect.
  116660. */
  116661. get toneMappingType(): number;
  116662. /**
  116663. * Sets the type of tone mapping effect.
  116664. */
  116665. set toneMappingType(value: number);
  116666. /**
  116667. * Gets contrast used in the effect.
  116668. */
  116669. get contrast(): number;
  116670. /**
  116671. * Sets contrast used in the effect.
  116672. */
  116673. set contrast(value: number);
  116674. /**
  116675. * Gets Vignette stretch size.
  116676. */
  116677. get vignetteStretch(): number;
  116678. /**
  116679. * Sets Vignette stretch size.
  116680. */
  116681. set vignetteStretch(value: number);
  116682. /**
  116683. * Gets Vignette centre X Offset.
  116684. */
  116685. get vignetteCentreX(): number;
  116686. /**
  116687. * Sets Vignette centre X Offset.
  116688. */
  116689. set vignetteCentreX(value: number);
  116690. /**
  116691. * Gets Vignette centre Y Offset.
  116692. */
  116693. get vignetteCentreY(): number;
  116694. /**
  116695. * Sets Vignette centre Y Offset.
  116696. */
  116697. set vignetteCentreY(value: number);
  116698. /**
  116699. * Gets Vignette weight or intensity of the vignette effect.
  116700. */
  116701. get vignetteWeight(): number;
  116702. /**
  116703. * Sets Vignette weight or intensity of the vignette effect.
  116704. */
  116705. set vignetteWeight(value: number);
  116706. /**
  116707. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116708. * if vignetteEnabled is set to true.
  116709. */
  116710. get vignetteColor(): Color4;
  116711. /**
  116712. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116713. * if vignetteEnabled is set to true.
  116714. */
  116715. set vignetteColor(value: Color4);
  116716. /**
  116717. * Gets Camera field of view used by the Vignette effect.
  116718. */
  116719. get vignetteCameraFov(): number;
  116720. /**
  116721. * Sets Camera field of view used by the Vignette effect.
  116722. */
  116723. set vignetteCameraFov(value: number);
  116724. /**
  116725. * Gets the vignette blend mode allowing different kind of effect.
  116726. */
  116727. get vignetteBlendMode(): number;
  116728. /**
  116729. * Sets the vignette blend mode allowing different kind of effect.
  116730. */
  116731. set vignetteBlendMode(value: number);
  116732. /**
  116733. * Gets wether the vignette effect is enabled.
  116734. */
  116735. get vignetteEnabled(): boolean;
  116736. /**
  116737. * Sets wether the vignette effect is enabled.
  116738. */
  116739. set vignetteEnabled(value: boolean);
  116740. private _fromLinearSpace;
  116741. /**
  116742. * Gets wether the input of the processing is in Gamma or Linear Space.
  116743. */
  116744. get fromLinearSpace(): boolean;
  116745. /**
  116746. * Sets wether the input of the processing is in Gamma or Linear Space.
  116747. */
  116748. set fromLinearSpace(value: boolean);
  116749. /**
  116750. * Defines cache preventing GC.
  116751. */
  116752. private _defines;
  116753. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  116754. /**
  116755. * "ImageProcessingPostProcess"
  116756. * @returns "ImageProcessingPostProcess"
  116757. */
  116758. getClassName(): string;
  116759. protected _updateParameters(): void;
  116760. dispose(camera?: Camera): void;
  116761. }
  116762. }
  116763. declare module BABYLON {
  116764. /**
  116765. * Class containing static functions to help procedurally build meshes
  116766. */
  116767. export class GroundBuilder {
  116768. /**
  116769. * Creates a ground mesh
  116770. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116771. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116773. * @param name defines the name of the mesh
  116774. * @param options defines the options used to create the mesh
  116775. * @param scene defines the hosting scene
  116776. * @returns the ground mesh
  116777. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116778. */
  116779. static CreateGround(name: string, options: {
  116780. width?: number;
  116781. height?: number;
  116782. subdivisions?: number;
  116783. subdivisionsX?: number;
  116784. subdivisionsY?: number;
  116785. updatable?: boolean;
  116786. }, scene: any): Mesh;
  116787. /**
  116788. * Creates a tiled ground mesh
  116789. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116790. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116791. * * 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
  116792. * * 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
  116793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116794. * @param name defines the name of the mesh
  116795. * @param options defines the options used to create the mesh
  116796. * @param scene defines the hosting scene
  116797. * @returns the tiled ground mesh
  116798. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116799. */
  116800. static CreateTiledGround(name: string, options: {
  116801. xmin: number;
  116802. zmin: number;
  116803. xmax: number;
  116804. zmax: number;
  116805. subdivisions?: {
  116806. w: number;
  116807. h: number;
  116808. };
  116809. precision?: {
  116810. w: number;
  116811. h: number;
  116812. };
  116813. updatable?: boolean;
  116814. }, scene?: Nullable<Scene>): Mesh;
  116815. /**
  116816. * Creates a ground mesh from a height map
  116817. * * The parameter `url` sets the URL of the height map image resource.
  116818. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116819. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116820. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116821. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116822. * * 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.
  116823. * * 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).
  116824. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116826. * @param name defines the name of the mesh
  116827. * @param url defines the url to the height map
  116828. * @param options defines the options used to create the mesh
  116829. * @param scene defines the hosting scene
  116830. * @returns the ground mesh
  116831. * @see https://doc.babylonjs.com/babylon101/height_map
  116832. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116833. */
  116834. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116835. width?: number;
  116836. height?: number;
  116837. subdivisions?: number;
  116838. minHeight?: number;
  116839. maxHeight?: number;
  116840. colorFilter?: Color3;
  116841. alphaFilter?: number;
  116842. updatable?: boolean;
  116843. onReady?: (mesh: GroundMesh) => void;
  116844. }, scene?: Nullable<Scene>): GroundMesh;
  116845. }
  116846. }
  116847. declare module BABYLON {
  116848. /**
  116849. * Class containing static functions to help procedurally build meshes
  116850. */
  116851. export class TorusBuilder {
  116852. /**
  116853. * Creates a torus mesh
  116854. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  116855. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  116856. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  116857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116860. * @param name defines the name of the mesh
  116861. * @param options defines the options used to create the mesh
  116862. * @param scene defines the hosting scene
  116863. * @returns the torus mesh
  116864. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  116865. */
  116866. static CreateTorus(name: string, options: {
  116867. diameter?: number;
  116868. thickness?: number;
  116869. tessellation?: number;
  116870. updatable?: boolean;
  116871. sideOrientation?: number;
  116872. frontUVs?: Vector4;
  116873. backUVs?: Vector4;
  116874. }, scene: any): Mesh;
  116875. }
  116876. }
  116877. declare module BABYLON {
  116878. /**
  116879. * Class containing static functions to help procedurally build meshes
  116880. */
  116881. export class CylinderBuilder {
  116882. /**
  116883. * Creates a cylinder or a cone mesh
  116884. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  116885. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  116886. * * 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.
  116887. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  116888. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  116889. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  116890. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  116891. * * 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).
  116892. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  116893. * * 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).
  116894. * * 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
  116895. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  116896. * * 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
  116897. * * 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.
  116898. * * If `enclose` is false, a ring surface is one element.
  116899. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  116900. * * 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
  116901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116904. * @param name defines the name of the mesh
  116905. * @param options defines the options used to create the mesh
  116906. * @param scene defines the hosting scene
  116907. * @returns the cylinder mesh
  116908. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  116909. */
  116910. static CreateCylinder(name: string, options: {
  116911. height?: number;
  116912. diameterTop?: number;
  116913. diameterBottom?: number;
  116914. diameter?: number;
  116915. tessellation?: number;
  116916. subdivisions?: number;
  116917. arc?: number;
  116918. faceColors?: Color4[];
  116919. faceUV?: Vector4[];
  116920. updatable?: boolean;
  116921. hasRings?: boolean;
  116922. enclose?: boolean;
  116923. cap?: number;
  116924. sideOrientation?: number;
  116925. frontUVs?: Vector4;
  116926. backUVs?: Vector4;
  116927. }, scene: any): Mesh;
  116928. }
  116929. }
  116930. declare module BABYLON {
  116931. /**
  116932. * States of the webXR experience
  116933. */
  116934. export enum WebXRState {
  116935. /**
  116936. * Transitioning to being in XR mode
  116937. */
  116938. ENTERING_XR = 0,
  116939. /**
  116940. * Transitioning to non XR mode
  116941. */
  116942. EXITING_XR = 1,
  116943. /**
  116944. * In XR mode and presenting
  116945. */
  116946. IN_XR = 2,
  116947. /**
  116948. * Not entered XR mode
  116949. */
  116950. NOT_IN_XR = 3
  116951. }
  116952. /**
  116953. * Abstraction of the XR render target
  116954. */
  116955. export interface WebXRRenderTarget extends IDisposable {
  116956. /**
  116957. * xrpresent context of the canvas which can be used to display/mirror xr content
  116958. */
  116959. canvasContext: WebGLRenderingContext;
  116960. /**
  116961. * xr layer for the canvas
  116962. */
  116963. xrLayer: Nullable<XRWebGLLayer>;
  116964. /**
  116965. * Initializes the xr layer for the session
  116966. * @param xrSession xr session
  116967. * @returns a promise that will resolve once the XR Layer has been created
  116968. */
  116969. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  116970. }
  116971. }
  116972. declare module BABYLON {
  116973. /**
  116974. * COnfiguration object for WebXR output canvas
  116975. */
  116976. export class WebXRManagedOutputCanvasOptions {
  116977. /**
  116978. * An optional canvas in case you wish to create it yourself and provide it here.
  116979. * If not provided, a new canvas will be created
  116980. */
  116981. canvasElement?: HTMLCanvasElement;
  116982. /**
  116983. * Options for this XR Layer output
  116984. */
  116985. canvasOptions?: XRWebGLLayerOptions;
  116986. /**
  116987. * CSS styling for a newly created canvas (if not provided)
  116988. */
  116989. newCanvasCssStyle?: string;
  116990. /**
  116991. * Get the default values of the configuration object
  116992. * @returns default values of this configuration object
  116993. */
  116994. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  116995. }
  116996. /**
  116997. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  116998. */
  116999. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  117000. private _options;
  117001. private _canvas;
  117002. private _engine;
  117003. /**
  117004. * Rendering context of the canvas which can be used to display/mirror xr content
  117005. */
  117006. canvasContext: WebGLRenderingContext;
  117007. /**
  117008. * xr layer for the canvas
  117009. */
  117010. xrLayer: Nullable<XRWebGLLayer>;
  117011. /**
  117012. * Initializes the canvas to be added/removed upon entering/exiting xr
  117013. * @param _xrSessionManager The XR Session manager
  117014. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  117015. */
  117016. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  117017. /**
  117018. * Disposes of the object
  117019. */
  117020. dispose(): void;
  117021. /**
  117022. * Initializes the xr layer for the session
  117023. * @param xrSession xr session
  117024. * @returns a promise that will resolve once the XR Layer has been created
  117025. */
  117026. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117027. private _addCanvas;
  117028. private _removeCanvas;
  117029. private _setManagedOutputCanvas;
  117030. }
  117031. }
  117032. declare module BABYLON {
  117033. /**
  117034. * Manages an XRSession to work with Babylon's engine
  117035. * @see https://doc.babylonjs.com/how_to/webxr
  117036. */
  117037. export class WebXRSessionManager implements IDisposable {
  117038. /** The scene which the session should be created for */
  117039. scene: Scene;
  117040. private _referenceSpace;
  117041. private _rttProvider;
  117042. private _sessionEnded;
  117043. private _xrNavigator;
  117044. private baseLayer;
  117045. /**
  117046. * The base reference space from which the session started. good if you want to reset your
  117047. * reference space
  117048. */
  117049. baseReferenceSpace: XRReferenceSpace;
  117050. /**
  117051. * Current XR frame
  117052. */
  117053. currentFrame: Nullable<XRFrame>;
  117054. /** WebXR timestamp updated every frame */
  117055. currentTimestamp: number;
  117056. /**
  117057. * Used just in case of a failure to initialize an immersive session.
  117058. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  117059. */
  117060. defaultHeightCompensation: number;
  117061. /**
  117062. * Fires every time a new xrFrame arrives which can be used to update the camera
  117063. */
  117064. onXRFrameObservable: Observable<XRFrame>;
  117065. /**
  117066. * Fires when the reference space changed
  117067. */
  117068. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  117069. /**
  117070. * Fires when the xr session is ended either by the device or manually done
  117071. */
  117072. onXRSessionEnded: Observable<any>;
  117073. /**
  117074. * Fires when the xr session is ended either by the device or manually done
  117075. */
  117076. onXRSessionInit: Observable<XRSession>;
  117077. /**
  117078. * Underlying xr session
  117079. */
  117080. session: XRSession;
  117081. /**
  117082. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  117083. * or get the offset the player is currently at.
  117084. */
  117085. viewerReferenceSpace: XRReferenceSpace;
  117086. /**
  117087. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  117088. * @param scene The scene which the session should be created for
  117089. */
  117090. constructor(
  117091. /** The scene which the session should be created for */
  117092. scene: Scene);
  117093. /**
  117094. * The current reference space used in this session. This reference space can constantly change!
  117095. * It is mainly used to offset the camera's position.
  117096. */
  117097. get referenceSpace(): XRReferenceSpace;
  117098. /**
  117099. * Set a new reference space and triggers the observable
  117100. */
  117101. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  117102. /**
  117103. * Disposes of the session manager
  117104. */
  117105. dispose(): void;
  117106. /**
  117107. * Stops the xrSession and restores the render loop
  117108. * @returns Promise which resolves after it exits XR
  117109. */
  117110. exitXRAsync(): Promise<void>;
  117111. /**
  117112. * Gets the correct render target texture to be rendered this frame for this eye
  117113. * @param eye the eye for which to get the render target
  117114. * @returns the render target for the specified eye
  117115. */
  117116. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  117117. /**
  117118. * Creates a WebXRRenderTarget object for the XR session
  117119. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  117120. * @param options optional options to provide when creating a new render target
  117121. * @returns a WebXR render target to which the session can render
  117122. */
  117123. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  117124. /**
  117125. * Initializes the manager
  117126. * After initialization enterXR can be called to start an XR session
  117127. * @returns Promise which resolves after it is initialized
  117128. */
  117129. initializeAsync(): Promise<void>;
  117130. /**
  117131. * Initializes an xr session
  117132. * @param xrSessionMode mode to initialize
  117133. * @param xrSessionInit defines optional and required values to pass to the session builder
  117134. * @returns a promise which will resolve once the session has been initialized
  117135. */
  117136. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  117137. /**
  117138. * Checks if a session would be supported for the creation options specified
  117139. * @param sessionMode session mode to check if supported eg. immersive-vr
  117140. * @returns A Promise that resolves to true if supported and false if not
  117141. */
  117142. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117143. /**
  117144. * Resets the reference space to the one started the session
  117145. */
  117146. resetReferenceSpace(): void;
  117147. /**
  117148. * Starts rendering to the xr layer
  117149. */
  117150. runXRRenderLoop(): void;
  117151. /**
  117152. * Sets the reference space on the xr session
  117153. * @param referenceSpaceType space to set
  117154. * @returns a promise that will resolve once the reference space has been set
  117155. */
  117156. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  117157. /**
  117158. * Updates the render state of the session
  117159. * @param state state to set
  117160. * @returns a promise that resolves once the render state has been updated
  117161. */
  117162. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  117163. /**
  117164. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  117165. * @param sessionMode defines the session to test
  117166. * @returns a promise with boolean as final value
  117167. */
  117168. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117169. private _createRenderTargetTexture;
  117170. }
  117171. }
  117172. declare module BABYLON {
  117173. /**
  117174. * WebXR Camera which holds the views for the xrSession
  117175. * @see https://doc.babylonjs.com/how_to/webxr_camera
  117176. */
  117177. export class WebXRCamera extends FreeCamera {
  117178. private _xrSessionManager;
  117179. private _firstFrame;
  117180. private _referenceQuaternion;
  117181. private _referencedPosition;
  117182. private _xrInvPositionCache;
  117183. private _xrInvQuaternionCache;
  117184. /**
  117185. * Should position compensation execute on first frame.
  117186. * This is used when copying the position from a native (non XR) camera
  117187. */
  117188. compensateOnFirstFrame: boolean;
  117189. /**
  117190. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  117191. * @param name the name of the camera
  117192. * @param scene the scene to add the camera to
  117193. * @param _xrSessionManager a constructed xr session manager
  117194. */
  117195. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  117196. /**
  117197. * Return the user's height, unrelated to the current ground.
  117198. * This will be the y position of this camera, when ground level is 0.
  117199. */
  117200. get realWorldHeight(): number;
  117201. /** @hidden */
  117202. _updateForDualEyeDebugging(): void;
  117203. /**
  117204. * Sets this camera's transformation based on a non-vr camera
  117205. * @param otherCamera the non-vr camera to copy the transformation from
  117206. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  117207. */
  117208. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  117209. /**
  117210. * Gets the current instance class name ("WebXRCamera").
  117211. * @returns the class name
  117212. */
  117213. getClassName(): string;
  117214. private _updateFromXRSession;
  117215. private _updateNumberOfRigCameras;
  117216. private _updateReferenceSpace;
  117217. private _updateReferenceSpaceOffset;
  117218. }
  117219. }
  117220. declare module BABYLON {
  117221. /**
  117222. * Defining the interface required for a (webxr) feature
  117223. */
  117224. export interface IWebXRFeature extends IDisposable {
  117225. /**
  117226. * Is this feature attached
  117227. */
  117228. attached: boolean;
  117229. /**
  117230. * Should auto-attach be disabled?
  117231. */
  117232. disableAutoAttach: boolean;
  117233. /**
  117234. * Attach the feature to the session
  117235. * Will usually be called by the features manager
  117236. *
  117237. * @param force should attachment be forced (even when already attached)
  117238. * @returns true if successful.
  117239. */
  117240. attach(force?: boolean): boolean;
  117241. /**
  117242. * Detach the feature from the session
  117243. * Will usually be called by the features manager
  117244. *
  117245. * @returns true if successful.
  117246. */
  117247. detach(): boolean;
  117248. }
  117249. /**
  117250. * A list of the currently available features without referencing them
  117251. */
  117252. export class WebXRFeatureName {
  117253. /**
  117254. * The name of the anchor system feature
  117255. */
  117256. static ANCHOR_SYSTEM: string;
  117257. /**
  117258. * The name of the background remover feature
  117259. */
  117260. static BACKGROUND_REMOVER: string;
  117261. /**
  117262. * The name of the hit test feature
  117263. */
  117264. static HIT_TEST: string;
  117265. /**
  117266. * physics impostors for xr controllers feature
  117267. */
  117268. static PHYSICS_CONTROLLERS: string;
  117269. /**
  117270. * The name of the plane detection feature
  117271. */
  117272. static PLANE_DETECTION: string;
  117273. /**
  117274. * The name of the pointer selection feature
  117275. */
  117276. static POINTER_SELECTION: string;
  117277. /**
  117278. * The name of the teleportation feature
  117279. */
  117280. static TELEPORTATION: string;
  117281. }
  117282. /**
  117283. * Defining the constructor of a feature. Used to register the modules.
  117284. */
  117285. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  117286. /**
  117287. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  117288. * It is mainly used in AR sessions.
  117289. *
  117290. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  117291. */
  117292. export class WebXRFeaturesManager implements IDisposable {
  117293. private _xrSessionManager;
  117294. private static readonly _AvailableFeatures;
  117295. private _features;
  117296. /**
  117297. * constructs a new features manages.
  117298. *
  117299. * @param _xrSessionManager an instance of WebXRSessionManager
  117300. */
  117301. constructor(_xrSessionManager: WebXRSessionManager);
  117302. /**
  117303. * Used to register a module. After calling this function a developer can use this feature in the scene.
  117304. * Mainly used internally.
  117305. *
  117306. * @param featureName the name of the feature to register
  117307. * @param constructorFunction the function used to construct the module
  117308. * @param version the (babylon) version of the module
  117309. * @param stable is that a stable version of this module
  117310. */
  117311. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  117312. /**
  117313. * Returns a constructor of a specific feature.
  117314. *
  117315. * @param featureName the name of the feature to construct
  117316. * @param version the version of the feature to load
  117317. * @param xrSessionManager the xrSessionManager. Used to construct the module
  117318. * @param options optional options provided to the module.
  117319. * @returns a function that, when called, will return a new instance of this feature
  117320. */
  117321. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  117322. /**
  117323. * Can be used to return the list of features currently registered
  117324. *
  117325. * @returns an Array of available features
  117326. */
  117327. static GetAvailableFeatures(): string[];
  117328. /**
  117329. * Gets the versions available for a specific feature
  117330. * @param featureName the name of the feature
  117331. * @returns an array with the available versions
  117332. */
  117333. static GetAvailableVersions(featureName: string): string[];
  117334. /**
  117335. * Return the latest unstable version of this feature
  117336. * @param featureName the name of the feature to search
  117337. * @returns the version number. if not found will return -1
  117338. */
  117339. static GetLatestVersionOfFeature(featureName: string): number;
  117340. /**
  117341. * Return the latest stable version of this feature
  117342. * @param featureName the name of the feature to search
  117343. * @returns the version number. if not found will return -1
  117344. */
  117345. static GetStableVersionOfFeature(featureName: string): number;
  117346. /**
  117347. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  117348. * Can be used during a session to start a feature
  117349. * @param featureName the name of feature to attach
  117350. */
  117351. attachFeature(featureName: string): void;
  117352. /**
  117353. * Can be used inside a session or when the session ends to detach a specific feature
  117354. * @param featureName the name of the feature to detach
  117355. */
  117356. detachFeature(featureName: string): void;
  117357. /**
  117358. * Used to disable an already-enabled feature
  117359. * The feature will be disposed and will be recreated once enabled.
  117360. * @param featureName the feature to disable
  117361. * @returns true if disable was successful
  117362. */
  117363. disableFeature(featureName: string | {
  117364. Name: string;
  117365. }): boolean;
  117366. /**
  117367. * dispose this features manager
  117368. */
  117369. dispose(): void;
  117370. /**
  117371. * 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.
  117372. * 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.
  117373. *
  117374. * @param featureName the name of the feature to load or the class of the feature
  117375. * @param version optional version to load. if not provided the latest version will be enabled
  117376. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  117377. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  117378. * @returns a new constructed feature or throws an error if feature not found.
  117379. */
  117380. enableFeature(featureName: string | {
  117381. Name: string;
  117382. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  117383. /**
  117384. * get the implementation of an enabled feature.
  117385. * @param featureName the name of the feature to load
  117386. * @returns the feature class, if found
  117387. */
  117388. getEnabledFeature(featureName: string): IWebXRFeature;
  117389. /**
  117390. * Get the list of enabled features
  117391. * @returns an array of enabled features
  117392. */
  117393. getEnabledFeatures(): string[];
  117394. }
  117395. }
  117396. declare module BABYLON {
  117397. /**
  117398. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  117399. * @see https://doc.babylonjs.com/how_to/webxr
  117400. */
  117401. export class WebXRExperienceHelper implements IDisposable {
  117402. private scene;
  117403. private _nonVRCamera;
  117404. private _originalSceneAutoClear;
  117405. private _supported;
  117406. /**
  117407. * Camera used to render xr content
  117408. */
  117409. camera: WebXRCamera;
  117410. /** A features manager for this xr session */
  117411. featuresManager: WebXRFeaturesManager;
  117412. /**
  117413. * Observers registered here will be triggered after the camera's initial transformation is set
  117414. * This can be used to set a different ground level or an extra rotation.
  117415. *
  117416. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  117417. * to the position set after this observable is done executing.
  117418. */
  117419. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  117420. /**
  117421. * Fires when the state of the experience helper has changed
  117422. */
  117423. onStateChangedObservable: Observable<WebXRState>;
  117424. /** Session manager used to keep track of xr session */
  117425. sessionManager: WebXRSessionManager;
  117426. /**
  117427. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  117428. */
  117429. state: WebXRState;
  117430. /**
  117431. * Creates a WebXRExperienceHelper
  117432. * @param scene The scene the helper should be created in
  117433. */
  117434. private constructor();
  117435. /**
  117436. * Creates the experience helper
  117437. * @param scene the scene to attach the experience helper to
  117438. * @returns a promise for the experience helper
  117439. */
  117440. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  117441. /**
  117442. * Disposes of the experience helper
  117443. */
  117444. dispose(): void;
  117445. /**
  117446. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  117447. * @param sessionMode options for the XR session
  117448. * @param referenceSpaceType frame of reference of the XR session
  117449. * @param renderTarget the output canvas that will be used to enter XR mode
  117450. * @returns promise that resolves after xr mode has entered
  117451. */
  117452. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  117453. /**
  117454. * Exits XR mode and returns the scene to its original state
  117455. * @returns promise that resolves after xr mode has exited
  117456. */
  117457. exitXRAsync(): Promise<void>;
  117458. private _nonXRToXRCamera;
  117459. private _setState;
  117460. }
  117461. }
  117462. declare module BABYLON {
  117463. /**
  117464. * X-Y values for axes in WebXR
  117465. */
  117466. export interface IWebXRMotionControllerAxesValue {
  117467. /**
  117468. * The value of the x axis
  117469. */
  117470. x: number;
  117471. /**
  117472. * The value of the y-axis
  117473. */
  117474. y: number;
  117475. }
  117476. /**
  117477. * changed / previous values for the values of this component
  117478. */
  117479. export interface IWebXRMotionControllerComponentChangesValues<T> {
  117480. /**
  117481. * current (this frame) value
  117482. */
  117483. current: T;
  117484. /**
  117485. * previous (last change) value
  117486. */
  117487. previous: T;
  117488. }
  117489. /**
  117490. * Represents changes in the component between current frame and last values recorded
  117491. */
  117492. export interface IWebXRMotionControllerComponentChanges {
  117493. /**
  117494. * will be populated with previous and current values if axes changed
  117495. */
  117496. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  117497. /**
  117498. * will be populated with previous and current values if pressed changed
  117499. */
  117500. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117501. /**
  117502. * will be populated with previous and current values if touched changed
  117503. */
  117504. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117505. /**
  117506. * will be populated with previous and current values if value changed
  117507. */
  117508. value?: IWebXRMotionControllerComponentChangesValues<number>;
  117509. }
  117510. /**
  117511. * This class represents a single component (for example button or thumbstick) of a motion controller
  117512. */
  117513. export class WebXRControllerComponent implements IDisposable {
  117514. /**
  117515. * the id of this component
  117516. */
  117517. id: string;
  117518. /**
  117519. * the type of the component
  117520. */
  117521. type: MotionControllerComponentType;
  117522. private _buttonIndex;
  117523. private _axesIndices;
  117524. private _axes;
  117525. private _changes;
  117526. private _currentValue;
  117527. private _hasChanges;
  117528. private _pressed;
  117529. private _touched;
  117530. /**
  117531. * button component type
  117532. */
  117533. static BUTTON_TYPE: MotionControllerComponentType;
  117534. /**
  117535. * squeeze component type
  117536. */
  117537. static SQUEEZE_TYPE: MotionControllerComponentType;
  117538. /**
  117539. * Thumbstick component type
  117540. */
  117541. static THUMBSTICK_TYPE: MotionControllerComponentType;
  117542. /**
  117543. * Touchpad component type
  117544. */
  117545. static TOUCHPAD_TYPE: MotionControllerComponentType;
  117546. /**
  117547. * trigger component type
  117548. */
  117549. static TRIGGER_TYPE: MotionControllerComponentType;
  117550. /**
  117551. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  117552. * the axes data changes
  117553. */
  117554. onAxisValueChangedObservable: Observable<{
  117555. x: number;
  117556. y: number;
  117557. }>;
  117558. /**
  117559. * Observers registered here will be triggered when the state of a button changes
  117560. * State change is either pressed / touched / value
  117561. */
  117562. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  117563. /**
  117564. * Creates a new component for a motion controller.
  117565. * It is created by the motion controller itself
  117566. *
  117567. * @param id the id of this component
  117568. * @param type the type of the component
  117569. * @param _buttonIndex index in the buttons array of the gamepad
  117570. * @param _axesIndices indices of the values in the axes array of the gamepad
  117571. */
  117572. constructor(
  117573. /**
  117574. * the id of this component
  117575. */
  117576. id: string,
  117577. /**
  117578. * the type of the component
  117579. */
  117580. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  117581. /**
  117582. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  117583. */
  117584. get axes(): IWebXRMotionControllerAxesValue;
  117585. /**
  117586. * Get the changes. Elements will be populated only if they changed with their previous and current value
  117587. */
  117588. get changes(): IWebXRMotionControllerComponentChanges;
  117589. /**
  117590. * Return whether or not the component changed the last frame
  117591. */
  117592. get hasChanges(): boolean;
  117593. /**
  117594. * is the button currently pressed
  117595. */
  117596. get pressed(): boolean;
  117597. /**
  117598. * is the button currently touched
  117599. */
  117600. get touched(): boolean;
  117601. /**
  117602. * Get the current value of this component
  117603. */
  117604. get value(): number;
  117605. /**
  117606. * Dispose this component
  117607. */
  117608. dispose(): void;
  117609. /**
  117610. * Are there axes correlating to this component
  117611. * @return true is axes data is available
  117612. */
  117613. isAxes(): boolean;
  117614. /**
  117615. * Is this component a button (hence - pressable)
  117616. * @returns true if can be pressed
  117617. */
  117618. isButton(): boolean;
  117619. /**
  117620. * update this component using the gamepad object it is in. Called on every frame
  117621. * @param nativeController the native gamepad controller object
  117622. */
  117623. update(nativeController: IMinimalMotionControllerObject): void;
  117624. }
  117625. }
  117626. declare module BABYLON {
  117627. /**
  117628. * Class used to represent data loading progression
  117629. */
  117630. export class SceneLoaderProgressEvent {
  117631. /** defines if data length to load can be evaluated */
  117632. readonly lengthComputable: boolean;
  117633. /** defines the loaded data length */
  117634. readonly loaded: number;
  117635. /** defines the data length to load */
  117636. readonly total: number;
  117637. /**
  117638. * Create a new progress event
  117639. * @param lengthComputable defines if data length to load can be evaluated
  117640. * @param loaded defines the loaded data length
  117641. * @param total defines the data length to load
  117642. */
  117643. constructor(
  117644. /** defines if data length to load can be evaluated */
  117645. lengthComputable: boolean,
  117646. /** defines the loaded data length */
  117647. loaded: number,
  117648. /** defines the data length to load */
  117649. total: number);
  117650. /**
  117651. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  117652. * @param event defines the source event
  117653. * @returns a new SceneLoaderProgressEvent
  117654. */
  117655. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  117656. }
  117657. /**
  117658. * Interface used by SceneLoader plugins to define supported file extensions
  117659. */
  117660. export interface ISceneLoaderPluginExtensions {
  117661. /**
  117662. * Defines the list of supported extensions
  117663. */
  117664. [extension: string]: {
  117665. isBinary: boolean;
  117666. };
  117667. }
  117668. /**
  117669. * Interface used by SceneLoader plugin factory
  117670. */
  117671. export interface ISceneLoaderPluginFactory {
  117672. /**
  117673. * Defines the name of the factory
  117674. */
  117675. name: string;
  117676. /**
  117677. * Function called to create a new plugin
  117678. * @return the new plugin
  117679. */
  117680. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  117681. /**
  117682. * The callback that returns true if the data can be directly loaded.
  117683. * @param data string containing the file data
  117684. * @returns if the data can be loaded directly
  117685. */
  117686. canDirectLoad?(data: string): boolean;
  117687. }
  117688. /**
  117689. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  117690. */
  117691. export interface ISceneLoaderPluginBase {
  117692. /**
  117693. * The friendly name of this plugin.
  117694. */
  117695. name: string;
  117696. /**
  117697. * The file extensions supported by this plugin.
  117698. */
  117699. extensions: string | ISceneLoaderPluginExtensions;
  117700. /**
  117701. * The callback called when loading from a url.
  117702. * @param scene scene loading this url
  117703. * @param url url to load
  117704. * @param onSuccess callback called when the file successfully loads
  117705. * @param onProgress callback called while file is loading (if the server supports this mode)
  117706. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117707. * @param onError callback called when the file fails to load
  117708. * @returns a file request object
  117709. */
  117710. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117711. /**
  117712. * The callback called when loading from a file object.
  117713. * @param scene scene loading this file
  117714. * @param file defines the file to load
  117715. * @param onSuccess defines the callback to call when data is loaded
  117716. * @param onProgress defines the callback to call during loading process
  117717. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117718. * @param onError defines the callback to call when an error occurs
  117719. * @returns a file request object
  117720. */
  117721. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117722. /**
  117723. * The callback that returns true if the data can be directly loaded.
  117724. * @param data string containing the file data
  117725. * @returns if the data can be loaded directly
  117726. */
  117727. canDirectLoad?(data: string): boolean;
  117728. /**
  117729. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  117730. * @param scene scene loading this data
  117731. * @param data string containing the data
  117732. * @returns data to pass to the plugin
  117733. */
  117734. directLoad?(scene: Scene, data: string): any;
  117735. /**
  117736. * The callback that allows custom handling of the root url based on the response url.
  117737. * @param rootUrl the original root url
  117738. * @param responseURL the response url if available
  117739. * @returns the new root url
  117740. */
  117741. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  117742. }
  117743. /**
  117744. * Interface used to define a SceneLoader plugin
  117745. */
  117746. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117747. /**
  117748. * Import meshes into a scene.
  117749. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117750. * @param scene The scene to import into
  117751. * @param data The data to import
  117752. * @param rootUrl The root url for scene and resources
  117753. * @param meshes The meshes array to import into
  117754. * @param particleSystems The particle systems array to import into
  117755. * @param skeletons The skeletons array to import into
  117756. * @param onError The callback when import fails
  117757. * @returns True if successful or false otherwise
  117758. */
  117759. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  117760. /**
  117761. * Load into a scene.
  117762. * @param scene The scene to load into
  117763. * @param data The data to import
  117764. * @param rootUrl The root url for scene and resources
  117765. * @param onError The callback when import fails
  117766. * @returns True if successful or false otherwise
  117767. */
  117768. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  117769. /**
  117770. * Load into an asset container.
  117771. * @param scene The scene to load into
  117772. * @param data The data to import
  117773. * @param rootUrl The root url for scene and resources
  117774. * @param onError The callback when import fails
  117775. * @returns The loaded asset container
  117776. */
  117777. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  117778. }
  117779. /**
  117780. * Interface used to define an async SceneLoader plugin
  117781. */
  117782. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  117783. /**
  117784. * Import meshes into a scene.
  117785. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117786. * @param scene The scene to import into
  117787. * @param data The data to import
  117788. * @param rootUrl The root url for scene and resources
  117789. * @param onProgress The callback when the load progresses
  117790. * @param fileName Defines the name of the file to load
  117791. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  117792. */
  117793. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  117794. meshes: AbstractMesh[];
  117795. particleSystems: IParticleSystem[];
  117796. skeletons: Skeleton[];
  117797. animationGroups: AnimationGroup[];
  117798. }>;
  117799. /**
  117800. * Load into a scene.
  117801. * @param scene The scene to load into
  117802. * @param data The data to import
  117803. * @param rootUrl The root url for scene and resources
  117804. * @param onProgress The callback when the load progresses
  117805. * @param fileName Defines the name of the file to load
  117806. * @returns Nothing
  117807. */
  117808. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  117809. /**
  117810. * Load into an asset container.
  117811. * @param scene The scene to load into
  117812. * @param data The data to import
  117813. * @param rootUrl The root url for scene and resources
  117814. * @param onProgress The callback when the load progresses
  117815. * @param fileName Defines the name of the file to load
  117816. * @returns The loaded asset container
  117817. */
  117818. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  117819. }
  117820. /**
  117821. * Mode that determines how to handle old animation groups before loading new ones.
  117822. */
  117823. export enum SceneLoaderAnimationGroupLoadingMode {
  117824. /**
  117825. * Reset all old animations to initial state then dispose them.
  117826. */
  117827. Clean = 0,
  117828. /**
  117829. * Stop all old animations.
  117830. */
  117831. Stop = 1,
  117832. /**
  117833. * Restart old animations from first frame.
  117834. */
  117835. Sync = 2,
  117836. /**
  117837. * Old animations remains untouched.
  117838. */
  117839. NoSync = 3
  117840. }
  117841. /**
  117842. * Class used to load scene from various file formats using registered plugins
  117843. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  117844. */
  117845. export class SceneLoader {
  117846. /**
  117847. * No logging while loading
  117848. */
  117849. static readonly NO_LOGGING: number;
  117850. /**
  117851. * Minimal logging while loading
  117852. */
  117853. static readonly MINIMAL_LOGGING: number;
  117854. /**
  117855. * Summary logging while loading
  117856. */
  117857. static readonly SUMMARY_LOGGING: number;
  117858. /**
  117859. * Detailled logging while loading
  117860. */
  117861. static readonly DETAILED_LOGGING: number;
  117862. /**
  117863. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  117864. */
  117865. static get ForceFullSceneLoadingForIncremental(): boolean;
  117866. static set ForceFullSceneLoadingForIncremental(value: boolean);
  117867. /**
  117868. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  117869. */
  117870. static get ShowLoadingScreen(): boolean;
  117871. static set ShowLoadingScreen(value: boolean);
  117872. /**
  117873. * Defines the current logging level (while loading the scene)
  117874. * @ignorenaming
  117875. */
  117876. static get loggingLevel(): number;
  117877. static set loggingLevel(value: number);
  117878. /**
  117879. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  117880. */
  117881. static get CleanBoneMatrixWeights(): boolean;
  117882. static set CleanBoneMatrixWeights(value: boolean);
  117883. /**
  117884. * Event raised when a plugin is used to load a scene
  117885. */
  117886. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  117887. private static _registeredPlugins;
  117888. private static _getDefaultPlugin;
  117889. private static _getPluginForExtension;
  117890. private static _getPluginForDirectLoad;
  117891. private static _getPluginForFilename;
  117892. private static _getDirectLoad;
  117893. private static _loadData;
  117894. private static _getFileInfo;
  117895. /**
  117896. * Gets a plugin that can load the given extension
  117897. * @param extension defines the extension to load
  117898. * @returns a plugin or null if none works
  117899. */
  117900. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  117901. /**
  117902. * Gets a boolean indicating that the given extension can be loaded
  117903. * @param extension defines the extension to load
  117904. * @returns true if the extension is supported
  117905. */
  117906. static IsPluginForExtensionAvailable(extension: string): boolean;
  117907. /**
  117908. * Adds a new plugin to the list of registered plugins
  117909. * @param plugin defines the plugin to add
  117910. */
  117911. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  117912. /**
  117913. * Import meshes into a scene
  117914. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117915. * @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)
  117916. * @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)
  117917. * @param scene the instance of BABYLON.Scene to append to
  117918. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  117919. * @param onProgress a callback with a progress event for each file being loaded
  117920. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117921. * @param pluginExtension the extension used to determine the plugin
  117922. * @returns The loaded plugin
  117923. */
  117924. 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>;
  117925. /**
  117926. * Import meshes into a scene
  117927. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117928. * @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)
  117929. * @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)
  117930. * @param scene the instance of BABYLON.Scene to append to
  117931. * @param onProgress a callback with a progress event for each file being loaded
  117932. * @param pluginExtension the extension used to determine the plugin
  117933. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  117934. */
  117935. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  117936. meshes: AbstractMesh[];
  117937. particleSystems: IParticleSystem[];
  117938. skeletons: Skeleton[];
  117939. animationGroups: AnimationGroup[];
  117940. }>;
  117941. /**
  117942. * Load a scene
  117943. * @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)
  117944. * @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)
  117945. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117946. * @param onSuccess a callback with the scene when import succeeds
  117947. * @param onProgress a callback with a progress event for each file being loaded
  117948. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117949. * @param pluginExtension the extension used to determine the plugin
  117950. * @returns The loaded plugin
  117951. */
  117952. 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>;
  117953. /**
  117954. * Load a scene
  117955. * @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)
  117956. * @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)
  117957. * @param engine is the instance of BABYLON.Engine to use to create the scene
  117958. * @param onProgress a callback with a progress event for each file being loaded
  117959. * @param pluginExtension the extension used to determine the plugin
  117960. * @returns The loaded scene
  117961. */
  117962. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117963. /**
  117964. * Append a scene
  117965. * @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)
  117966. * @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)
  117967. * @param scene is the instance of BABYLON.Scene to append to
  117968. * @param onSuccess a callback with the scene when import succeeds
  117969. * @param onProgress a callback with a progress event for each file being loaded
  117970. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117971. * @param pluginExtension the extension used to determine the plugin
  117972. * @returns The loaded plugin
  117973. */
  117974. 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>;
  117975. /**
  117976. * Append a scene
  117977. * @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)
  117978. * @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)
  117979. * @param scene is the instance of BABYLON.Scene to append to
  117980. * @param onProgress a callback with a progress event for each file being loaded
  117981. * @param pluginExtension the extension used to determine the plugin
  117982. * @returns The given scene
  117983. */
  117984. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  117985. /**
  117986. * Load a scene into an asset container
  117987. * @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)
  117988. * @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)
  117989. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117990. * @param onSuccess a callback with the scene when import succeeds
  117991. * @param onProgress a callback with a progress event for each file being loaded
  117992. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  117993. * @param pluginExtension the extension used to determine the plugin
  117994. * @returns The loaded plugin
  117995. */
  117996. 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>;
  117997. /**
  117998. * Load a scene into an asset container
  117999. * @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)
  118000. * @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)
  118001. * @param scene is the instance of Scene to append to
  118002. * @param onProgress a callback with a progress event for each file being loaded
  118003. * @param pluginExtension the extension used to determine the plugin
  118004. * @returns The loaded asset container
  118005. */
  118006. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  118007. /**
  118008. * Import animations from a file into a scene
  118009. * @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)
  118010. * @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)
  118011. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118012. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118013. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118014. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118015. * @param onSuccess a callback with the scene when import succeeds
  118016. * @param onProgress a callback with a progress event for each file being loaded
  118017. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118018. */
  118019. 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;
  118020. /**
  118021. * Import animations from a file into a scene
  118022. * @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)
  118023. * @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)
  118024. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118025. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118026. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118027. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118028. * @param onSuccess a callback with the scene when import succeeds
  118029. * @param onProgress a callback with a progress event for each file being loaded
  118030. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118031. * @returns the updated scene with imported animations
  118032. */
  118033. 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>;
  118034. }
  118035. }
  118036. declare module BABYLON {
  118037. /**
  118038. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  118039. */
  118040. export type MotionControllerHandness = "none" | "left" | "right";
  118041. /**
  118042. * The type of components available in motion controllers.
  118043. * This is not the name of the component.
  118044. */
  118045. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  118046. /**
  118047. * The state of a controller component
  118048. */
  118049. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  118050. /**
  118051. * The schema of motion controller layout.
  118052. * No object will be initialized using this interface
  118053. * This is used just to define the profile.
  118054. */
  118055. export interface IMotionControllerLayout {
  118056. /**
  118057. * Path to load the assets. Usually relative to the base path
  118058. */
  118059. assetPath: string;
  118060. /**
  118061. * Available components (unsorted)
  118062. */
  118063. components: {
  118064. /**
  118065. * A map of component Ids
  118066. */
  118067. [componentId: string]: {
  118068. /**
  118069. * The type of input the component outputs
  118070. */
  118071. type: MotionControllerComponentType;
  118072. /**
  118073. * The indices of this component in the gamepad object
  118074. */
  118075. gamepadIndices: {
  118076. /**
  118077. * Index of button
  118078. */
  118079. button?: number;
  118080. /**
  118081. * If available, index of x-axis
  118082. */
  118083. xAxis?: number;
  118084. /**
  118085. * If available, index of y-axis
  118086. */
  118087. yAxis?: number;
  118088. };
  118089. /**
  118090. * The mesh's root node name
  118091. */
  118092. rootNodeName: string;
  118093. /**
  118094. * Animation definitions for this model
  118095. */
  118096. visualResponses: {
  118097. [stateKey: string]: {
  118098. /**
  118099. * What property will be animated
  118100. */
  118101. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  118102. /**
  118103. * What states influence this visual response
  118104. */
  118105. states: MotionControllerComponentStateType[];
  118106. /**
  118107. * Type of animation - movement or visibility
  118108. */
  118109. valueNodeProperty: "transform" | "visibility";
  118110. /**
  118111. * Base node name to move. Its position will be calculated according to the min and max nodes
  118112. */
  118113. valueNodeName?: string;
  118114. /**
  118115. * Minimum movement node
  118116. */
  118117. minNodeName?: string;
  118118. /**
  118119. * Max movement node
  118120. */
  118121. maxNodeName?: string;
  118122. };
  118123. };
  118124. /**
  118125. * If touch enabled, what is the name of node to display user feedback
  118126. */
  118127. touchPointNodeName?: string;
  118128. };
  118129. };
  118130. /**
  118131. * Is it xr standard mapping or not
  118132. */
  118133. gamepadMapping: "" | "xr-standard";
  118134. /**
  118135. * Base root node of this entire model
  118136. */
  118137. rootNodeName: string;
  118138. /**
  118139. * Defines the main button component id
  118140. */
  118141. selectComponentId: string;
  118142. }
  118143. /**
  118144. * A definition for the layout map in the input profile
  118145. */
  118146. export interface IMotionControllerLayoutMap {
  118147. /**
  118148. * Layouts with handness type as a key
  118149. */
  118150. [handness: string]: IMotionControllerLayout;
  118151. }
  118152. /**
  118153. * The XR Input profile schema
  118154. * Profiles can be found here:
  118155. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  118156. */
  118157. export interface IMotionControllerProfile {
  118158. /**
  118159. * fallback profiles for this profileId
  118160. */
  118161. fallbackProfileIds: string[];
  118162. /**
  118163. * The layout map, with handness as key
  118164. */
  118165. layouts: IMotionControllerLayoutMap;
  118166. /**
  118167. * The id of this profile
  118168. * correlates to the profile(s) in the xrInput.profiles array
  118169. */
  118170. profileId: string;
  118171. }
  118172. /**
  118173. * A helper-interface for the 3 meshes needed for controller button animation
  118174. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  118175. */
  118176. export interface IMotionControllerButtonMeshMap {
  118177. /**
  118178. * the mesh that defines the pressed value mesh position.
  118179. * This is used to find the max-position of this button
  118180. */
  118181. pressedMesh: AbstractMesh;
  118182. /**
  118183. * the mesh that defines the unpressed value mesh position.
  118184. * This is used to find the min (or initial) position of this button
  118185. */
  118186. unpressedMesh: AbstractMesh;
  118187. /**
  118188. * The mesh that will be changed when value changes
  118189. */
  118190. valueMesh: AbstractMesh;
  118191. }
  118192. /**
  118193. * A helper-interface for the 3 meshes needed for controller axis animation.
  118194. * This will be expanded when touchpad animations are fully supported
  118195. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  118196. */
  118197. export interface IMotionControllerMeshMap {
  118198. /**
  118199. * the mesh that defines the maximum value mesh position.
  118200. */
  118201. maxMesh?: AbstractMesh;
  118202. /**
  118203. * the mesh that defines the minimum value mesh position.
  118204. */
  118205. minMesh?: AbstractMesh;
  118206. /**
  118207. * The mesh that will be changed when axis value changes
  118208. */
  118209. valueMesh: AbstractMesh;
  118210. }
  118211. /**
  118212. * The elements needed for change-detection of the gamepad objects in motion controllers
  118213. */
  118214. export interface IMinimalMotionControllerObject {
  118215. /**
  118216. * Available axes of this controller
  118217. */
  118218. axes: number[];
  118219. /**
  118220. * An array of available buttons
  118221. */
  118222. buttons: Array<{
  118223. /**
  118224. * Value of the button/trigger
  118225. */
  118226. value: number;
  118227. /**
  118228. * If the button/trigger is currently touched
  118229. */
  118230. touched: boolean;
  118231. /**
  118232. * If the button/trigger is currently pressed
  118233. */
  118234. pressed: boolean;
  118235. }>;
  118236. }
  118237. /**
  118238. * An Abstract Motion controller
  118239. * This class receives an xrInput and a profile layout and uses those to initialize the components
  118240. * Each component has an observable to check for changes in value and state
  118241. */
  118242. export abstract class WebXRAbstractMotionController implements IDisposable {
  118243. protected scene: Scene;
  118244. protected layout: IMotionControllerLayout;
  118245. /**
  118246. * The gamepad object correlating to this controller
  118247. */
  118248. gamepadObject: IMinimalMotionControllerObject;
  118249. /**
  118250. * handness (left/right/none) of this controller
  118251. */
  118252. handness: MotionControllerHandness;
  118253. private _initComponent;
  118254. private _modelReady;
  118255. /**
  118256. * A map of components (WebXRControllerComponent) in this motion controller
  118257. * Components have a ComponentType and can also have both button and axis definitions
  118258. */
  118259. readonly components: {
  118260. [id: string]: WebXRControllerComponent;
  118261. };
  118262. /**
  118263. * Disable the model's animation. Can be set at any time.
  118264. */
  118265. disableAnimation: boolean;
  118266. /**
  118267. * Observers registered here will be triggered when the model of this controller is done loading
  118268. */
  118269. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  118270. /**
  118271. * The profile id of this motion controller
  118272. */
  118273. abstract profileId: string;
  118274. /**
  118275. * The root mesh of the model. It is null if the model was not yet initialized
  118276. */
  118277. rootMesh: Nullable<AbstractMesh>;
  118278. /**
  118279. * constructs a new abstract motion controller
  118280. * @param scene the scene to which the model of the controller will be added
  118281. * @param layout The profile layout to load
  118282. * @param gamepadObject The gamepad object correlating to this controller
  118283. * @param handness handness (left/right/none) of this controller
  118284. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  118285. */
  118286. constructor(scene: Scene, layout: IMotionControllerLayout,
  118287. /**
  118288. * The gamepad object correlating to this controller
  118289. */
  118290. gamepadObject: IMinimalMotionControllerObject,
  118291. /**
  118292. * handness (left/right/none) of this controller
  118293. */
  118294. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  118295. /**
  118296. * Dispose this controller, the model mesh and all its components
  118297. */
  118298. dispose(): void;
  118299. /**
  118300. * Returns all components of specific type
  118301. * @param type the type to search for
  118302. * @return an array of components with this type
  118303. */
  118304. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  118305. /**
  118306. * get a component based an its component id as defined in layout.components
  118307. * @param id the id of the component
  118308. * @returns the component correlates to the id or undefined if not found
  118309. */
  118310. getComponent(id: string): WebXRControllerComponent;
  118311. /**
  118312. * Get the list of components available in this motion controller
  118313. * @returns an array of strings correlating to available components
  118314. */
  118315. getComponentIds(): string[];
  118316. /**
  118317. * Get the first component of specific type
  118318. * @param type type of component to find
  118319. * @return a controller component or null if not found
  118320. */
  118321. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  118322. /**
  118323. * Get the main (Select) component of this controller as defined in the layout
  118324. * @returns the main component of this controller
  118325. */
  118326. getMainComponent(): WebXRControllerComponent;
  118327. /**
  118328. * Loads the model correlating to this controller
  118329. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  118330. * @returns A promise fulfilled with the result of the model loading
  118331. */
  118332. loadModel(): Promise<boolean>;
  118333. /**
  118334. * Update this model using the current XRFrame
  118335. * @param xrFrame the current xr frame to use and update the model
  118336. */
  118337. updateFromXRFrame(xrFrame: XRFrame): void;
  118338. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118339. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118340. /**
  118341. * Moves the axis on the controller mesh based on its current state
  118342. * @param axis the index of the axis
  118343. * @param axisValue the value of the axis which determines the meshes new position
  118344. * @hidden
  118345. */
  118346. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  118347. /**
  118348. * Update the model itself with the current frame data
  118349. * @param xrFrame the frame to use for updating the model mesh
  118350. */
  118351. protected updateModel(xrFrame: XRFrame): void;
  118352. /**
  118353. * Get the filename and path for this controller's model
  118354. * @returns a map of filename and path
  118355. */
  118356. protected abstract _getFilenameAndPath(): {
  118357. filename: string;
  118358. path: string;
  118359. };
  118360. /**
  118361. * This function is called before the mesh is loaded. It checks for loading constraints.
  118362. * For example, this function can check if the GLB loader is available
  118363. * If this function returns false, the generic controller will be loaded instead
  118364. * @returns Is the client ready to load the mesh
  118365. */
  118366. protected abstract _getModelLoadingConstraints(): boolean;
  118367. /**
  118368. * This function will be called after the model was successfully loaded and can be used
  118369. * for mesh transformations before it is available for the user
  118370. * @param meshes the loaded meshes
  118371. */
  118372. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  118373. /**
  118374. * Set the root mesh for this controller. Important for the WebXR controller class
  118375. * @param meshes the loaded meshes
  118376. */
  118377. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  118378. /**
  118379. * A function executed each frame that updates the mesh (if needed)
  118380. * @param xrFrame the current xrFrame
  118381. */
  118382. protected abstract _updateModel(xrFrame: XRFrame): void;
  118383. private _getGenericFilenameAndPath;
  118384. private _getGenericParentMesh;
  118385. }
  118386. }
  118387. declare module BABYLON {
  118388. /**
  118389. * A generic trigger-only motion controller for WebXR
  118390. */
  118391. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  118392. /**
  118393. * Static version of the profile id of this controller
  118394. */
  118395. static ProfileId: string;
  118396. profileId: string;
  118397. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  118398. protected _getFilenameAndPath(): {
  118399. filename: string;
  118400. path: string;
  118401. };
  118402. protected _getModelLoadingConstraints(): boolean;
  118403. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  118404. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118405. protected _updateModel(): void;
  118406. }
  118407. }
  118408. declare module BABYLON {
  118409. /**
  118410. * Class containing static functions to help procedurally build meshes
  118411. */
  118412. export class SphereBuilder {
  118413. /**
  118414. * Creates a sphere mesh
  118415. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118416. * * 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`)
  118417. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118418. * * 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
  118419. * * 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)
  118420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118423. * @param name defines the name of the mesh
  118424. * @param options defines the options used to create the mesh
  118425. * @param scene defines the hosting scene
  118426. * @returns the sphere mesh
  118427. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118428. */
  118429. static CreateSphere(name: string, options: {
  118430. segments?: number;
  118431. diameter?: number;
  118432. diameterX?: number;
  118433. diameterY?: number;
  118434. diameterZ?: number;
  118435. arc?: number;
  118436. slice?: number;
  118437. sideOrientation?: number;
  118438. frontUVs?: Vector4;
  118439. backUVs?: Vector4;
  118440. updatable?: boolean;
  118441. }, scene?: Nullable<Scene>): Mesh;
  118442. }
  118443. }
  118444. declare module BABYLON {
  118445. /**
  118446. * A profiled motion controller has its profile loaded from an online repository.
  118447. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  118448. */
  118449. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  118450. private _repositoryUrl;
  118451. private _buttonMeshMapping;
  118452. private _touchDots;
  118453. /**
  118454. * The profile ID of this controller. Will be populated when the controller initializes.
  118455. */
  118456. profileId: string;
  118457. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  118458. dispose(): void;
  118459. protected _getFilenameAndPath(): {
  118460. filename: string;
  118461. path: string;
  118462. };
  118463. protected _getModelLoadingConstraints(): boolean;
  118464. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118465. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118466. protected _updateModel(_xrFrame: XRFrame): void;
  118467. }
  118468. }
  118469. declare module BABYLON {
  118470. /**
  118471. * A construction function type to create a new controller based on an xrInput object
  118472. */
  118473. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  118474. /**
  118475. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  118476. *
  118477. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  118478. * it should be replaced with auto-loaded controllers.
  118479. *
  118480. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  118481. */
  118482. export class WebXRMotionControllerManager {
  118483. private static _AvailableControllers;
  118484. private static _Fallbacks;
  118485. private static _ProfileLoadingPromises;
  118486. private static _ProfilesList;
  118487. /**
  118488. * The base URL of the online controller repository. Can be changed at any time.
  118489. */
  118490. static BaseRepositoryUrl: string;
  118491. /**
  118492. * Which repository gets priority - local or online
  118493. */
  118494. static PrioritizeOnlineRepository: boolean;
  118495. /**
  118496. * Use the online repository, or use only locally-defined controllers
  118497. */
  118498. static UseOnlineRepository: boolean;
  118499. /**
  118500. * Clear the cache used for profile loading and reload when requested again
  118501. */
  118502. static ClearProfilesCache(): void;
  118503. /**
  118504. * Register the default fallbacks.
  118505. * This function is called automatically when this file is imported.
  118506. */
  118507. static DefaultFallbacks(): void;
  118508. /**
  118509. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  118510. * @param profileId the profile to which a fallback needs to be found
  118511. * @return an array with corresponding fallback profiles
  118512. */
  118513. static FindFallbackWithProfileId(profileId: string): string[];
  118514. /**
  118515. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  118516. * The order of search:
  118517. *
  118518. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  118519. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  118520. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  118521. * 4) return the generic trigger controller if none were found
  118522. *
  118523. * @param xrInput the xrInput to which a new controller is initialized
  118524. * @param scene the scene to which the model will be added
  118525. * @param forceProfile force a certain profile for this controller
  118526. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  118527. */
  118528. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  118529. /**
  118530. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  118531. *
  118532. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  118533. *
  118534. * @param type the profile type to register
  118535. * @param constructFunction the function to be called when loading this profile
  118536. */
  118537. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  118538. /**
  118539. * Register a fallback to a specific profile.
  118540. * @param profileId the profileId that will receive the fallbacks
  118541. * @param fallbacks A list of fallback profiles
  118542. */
  118543. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  118544. /**
  118545. * Will update the list of profiles available in the repository
  118546. * @return a promise that resolves to a map of profiles available online
  118547. */
  118548. static UpdateProfilesList(): Promise<{
  118549. [profile: string]: string;
  118550. }>;
  118551. private static _LoadProfileFromRepository;
  118552. private static _LoadProfilesFromAvailableControllers;
  118553. }
  118554. }
  118555. declare module BABYLON {
  118556. /**
  118557. * Configuration options for the WebXR controller creation
  118558. */
  118559. export interface IWebXRControllerOptions {
  118560. /**
  118561. * Should the controller mesh be animated when a user interacts with it
  118562. * The pressed buttons / thumbstick and touchpad animations will be disabled
  118563. */
  118564. disableMotionControllerAnimation?: boolean;
  118565. /**
  118566. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  118567. */
  118568. doNotLoadControllerMesh?: boolean;
  118569. /**
  118570. * Force a specific controller type for this controller.
  118571. * This can be used when creating your own profile or when testing different controllers
  118572. */
  118573. forceControllerProfile?: string;
  118574. }
  118575. /**
  118576. * Represents an XR controller
  118577. */
  118578. export class WebXRInputSource {
  118579. private _scene;
  118580. /** The underlying input source for the controller */
  118581. inputSource: XRInputSource;
  118582. private _options;
  118583. private _tmpQuaternion;
  118584. private _tmpVector;
  118585. private _uniqueId;
  118586. /**
  118587. * 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
  118588. */
  118589. grip?: AbstractMesh;
  118590. /**
  118591. * If available, this is the gamepad object related to this controller.
  118592. * Using this object it is possible to get click events and trackpad changes of the
  118593. * webxr controller that is currently being used.
  118594. */
  118595. motionController?: WebXRAbstractMotionController;
  118596. /**
  118597. * Event that fires when the controller is removed/disposed.
  118598. * The object provided as event data is this controller, after associated assets were disposed.
  118599. * uniqueId is still available.
  118600. */
  118601. onDisposeObservable: Observable<WebXRInputSource>;
  118602. /**
  118603. * Will be triggered when the mesh associated with the motion controller is done loading.
  118604. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  118605. * A shortened version of controller -> motion controller -> on mesh loaded.
  118606. */
  118607. onMeshLoadedObservable: Observable<AbstractMesh>;
  118608. /**
  118609. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  118610. */
  118611. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  118612. /**
  118613. * Pointer which can be used to select objects or attach a visible laser to
  118614. */
  118615. pointer: AbstractMesh;
  118616. /**
  118617. * Creates the controller
  118618. * @see https://doc.babylonjs.com/how_to/webxr
  118619. * @param _scene the scene which the controller should be associated to
  118620. * @param inputSource the underlying input source for the controller
  118621. * @param _options options for this controller creation
  118622. */
  118623. constructor(_scene: Scene,
  118624. /** The underlying input source for the controller */
  118625. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  118626. /**
  118627. * Get this controllers unique id
  118628. */
  118629. get uniqueId(): string;
  118630. /**
  118631. * Disposes of the object
  118632. */
  118633. dispose(): void;
  118634. /**
  118635. * Gets a world space ray coming from the pointer or grip
  118636. * @param result the resulting ray
  118637. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  118638. */
  118639. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  118640. /**
  118641. * Updates the controller pose based on the given XRFrame
  118642. * @param xrFrame xr frame to update the pose with
  118643. * @param referenceSpace reference space to use
  118644. */
  118645. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  118646. }
  118647. }
  118648. declare module BABYLON {
  118649. /**
  118650. * The schema for initialization options of the XR Input class
  118651. */
  118652. export interface IWebXRInputOptions {
  118653. /**
  118654. * If set to true no model will be automatically loaded
  118655. */
  118656. doNotLoadControllerMeshes?: boolean;
  118657. /**
  118658. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  118659. * If not found, the xr input profile data will be used.
  118660. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  118661. */
  118662. forceInputProfile?: string;
  118663. /**
  118664. * Do not send a request to the controller repository to load the profile.
  118665. *
  118666. * Instead, use the controllers available in babylon itself.
  118667. */
  118668. disableOnlineControllerRepository?: boolean;
  118669. /**
  118670. * A custom URL for the controllers repository
  118671. */
  118672. customControllersRepositoryURL?: string;
  118673. /**
  118674. * Should the controller model's components not move according to the user input
  118675. */
  118676. disableControllerAnimation?: boolean;
  118677. }
  118678. /**
  118679. * XR input used to track XR inputs such as controllers/rays
  118680. */
  118681. export class WebXRInput implements IDisposable {
  118682. /**
  118683. * the xr session manager for this session
  118684. */
  118685. xrSessionManager: WebXRSessionManager;
  118686. /**
  118687. * the WebXR camera for this session. Mainly used for teleportation
  118688. */
  118689. xrCamera: WebXRCamera;
  118690. private readonly options;
  118691. /**
  118692. * XR controllers being tracked
  118693. */
  118694. controllers: Array<WebXRInputSource>;
  118695. private _frameObserver;
  118696. private _sessionEndedObserver;
  118697. private _sessionInitObserver;
  118698. /**
  118699. * Event when a controller has been connected/added
  118700. */
  118701. onControllerAddedObservable: Observable<WebXRInputSource>;
  118702. /**
  118703. * Event when a controller has been removed/disconnected
  118704. */
  118705. onControllerRemovedObservable: Observable<WebXRInputSource>;
  118706. /**
  118707. * Initializes the WebXRInput
  118708. * @param xrSessionManager the xr session manager for this session
  118709. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  118710. * @param options = initialization options for this xr input
  118711. */
  118712. constructor(
  118713. /**
  118714. * the xr session manager for this session
  118715. */
  118716. xrSessionManager: WebXRSessionManager,
  118717. /**
  118718. * the WebXR camera for this session. Mainly used for teleportation
  118719. */
  118720. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  118721. private _onInputSourcesChange;
  118722. private _addAndRemoveControllers;
  118723. /**
  118724. * Disposes of the object
  118725. */
  118726. dispose(): void;
  118727. }
  118728. }
  118729. declare module BABYLON {
  118730. /**
  118731. * This is the base class for all WebXR features.
  118732. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  118733. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  118734. */
  118735. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  118736. protected _xrSessionManager: WebXRSessionManager;
  118737. private _attached;
  118738. private _removeOnDetach;
  118739. /**
  118740. * Should auto-attach be disabled?
  118741. */
  118742. disableAutoAttach: boolean;
  118743. /**
  118744. * Construct a new (abstract) WebXR feature
  118745. * @param _xrSessionManager the xr session manager for this feature
  118746. */
  118747. constructor(_xrSessionManager: WebXRSessionManager);
  118748. /**
  118749. * Is this feature attached
  118750. */
  118751. get attached(): boolean;
  118752. /**
  118753. * attach this feature
  118754. *
  118755. * @param force should attachment be forced (even when already attached)
  118756. * @returns true if successful, false is failed or already attached
  118757. */
  118758. attach(force?: boolean): boolean;
  118759. /**
  118760. * detach this feature.
  118761. *
  118762. * @returns true if successful, false if failed or already detached
  118763. */
  118764. detach(): boolean;
  118765. /**
  118766. * Dispose this feature and all of the resources attached
  118767. */
  118768. dispose(): void;
  118769. /**
  118770. * This is used to register callbacks that will automatically be removed when detach is called.
  118771. * @param observable the observable to which the observer will be attached
  118772. * @param callback the callback to register
  118773. */
  118774. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  118775. /**
  118776. * Code in this function will be executed on each xrFrame received from the browser.
  118777. * This function will not execute after the feature is detached.
  118778. * @param _xrFrame the current frame
  118779. */
  118780. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  118781. }
  118782. }
  118783. declare module BABYLON {
  118784. /**
  118785. * Renders a layer on top of an existing scene
  118786. */
  118787. export class UtilityLayerRenderer implements IDisposable {
  118788. /** the original scene that will be rendered on top of */
  118789. originalScene: Scene;
  118790. private _pointerCaptures;
  118791. private _lastPointerEvents;
  118792. private static _DefaultUtilityLayer;
  118793. private static _DefaultKeepDepthUtilityLayer;
  118794. private _sharedGizmoLight;
  118795. private _renderCamera;
  118796. /**
  118797. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  118798. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  118799. * @returns the camera that is used when rendering the utility layer
  118800. */
  118801. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  118802. /**
  118803. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  118804. * @param cam the camera that should be used when rendering the utility layer
  118805. */
  118806. setRenderCamera(cam: Nullable<Camera>): void;
  118807. /**
  118808. * @hidden
  118809. * Light which used by gizmos to get light shading
  118810. */
  118811. _getSharedGizmoLight(): HemisphericLight;
  118812. /**
  118813. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  118814. */
  118815. pickUtilitySceneFirst: boolean;
  118816. /**
  118817. * 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)
  118818. */
  118819. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  118820. /**
  118821. * 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)
  118822. */
  118823. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  118824. /**
  118825. * The scene that is rendered on top of the original scene
  118826. */
  118827. utilityLayerScene: Scene;
  118828. /**
  118829. * If the utility layer should automatically be rendered on top of existing scene
  118830. */
  118831. shouldRender: boolean;
  118832. /**
  118833. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  118834. */
  118835. onlyCheckPointerDownEvents: boolean;
  118836. /**
  118837. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  118838. */
  118839. processAllEvents: boolean;
  118840. /**
  118841. * Observable raised when the pointer move from the utility layer scene to the main scene
  118842. */
  118843. onPointerOutObservable: Observable<number>;
  118844. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  118845. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  118846. private _afterRenderObserver;
  118847. private _sceneDisposeObserver;
  118848. private _originalPointerObserver;
  118849. /**
  118850. * Instantiates a UtilityLayerRenderer
  118851. * @param originalScene the original scene that will be rendered on top of
  118852. * @param handleEvents boolean indicating if the utility layer should handle events
  118853. */
  118854. constructor(
  118855. /** the original scene that will be rendered on top of */
  118856. originalScene: Scene, handleEvents?: boolean);
  118857. private _notifyObservers;
  118858. /**
  118859. * Renders the utility layers scene on top of the original scene
  118860. */
  118861. render(): void;
  118862. /**
  118863. * Disposes of the renderer
  118864. */
  118865. dispose(): void;
  118866. private _updateCamera;
  118867. }
  118868. }
  118869. declare module BABYLON {
  118870. /**
  118871. * Options interface for the pointer selection module
  118872. */
  118873. export interface IWebXRControllerPointerSelectionOptions {
  118874. /**
  118875. * if provided, this scene will be used to render meshes.
  118876. */
  118877. customUtilityLayerScene?: Scene;
  118878. /**
  118879. * 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)
  118880. * If not disabled, the last picked point will be used to execute a pointer up event
  118881. * If disabled, pointer up event will be triggered right after the pointer down event.
  118882. * Used in screen and gaze target ray mode only
  118883. */
  118884. disablePointerUpOnTouchOut: boolean;
  118885. /**
  118886. * For gaze mode (time to select instead of press)
  118887. */
  118888. forceGazeMode: boolean;
  118889. /**
  118890. * 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
  118891. * to start a new countdown to the pointer down event.
  118892. * Defaults to 1.
  118893. */
  118894. gazeModePointerMovedFactor?: number;
  118895. /**
  118896. * Different button type to use instead of the main component
  118897. */
  118898. overrideButtonId?: string;
  118899. /**
  118900. * use this rendering group id for the meshes (optional)
  118901. */
  118902. renderingGroupId?: number;
  118903. /**
  118904. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  118905. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  118906. * 3000 means 3 seconds between pointing at something and selecting it
  118907. */
  118908. timeToSelect?: number;
  118909. /**
  118910. * Should meshes created here be added to a utility layer or the main scene
  118911. */
  118912. useUtilityLayer?: boolean;
  118913. /**
  118914. * the xr input to use with this pointer selection
  118915. */
  118916. xrInput: WebXRInput;
  118917. }
  118918. /**
  118919. * A module that will enable pointer selection for motion controllers of XR Input Sources
  118920. */
  118921. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  118922. private readonly _options;
  118923. private static _idCounter;
  118924. private _attachController;
  118925. private _controllers;
  118926. private _scene;
  118927. private _tmpVectorForPickCompare;
  118928. /**
  118929. * The module's name
  118930. */
  118931. static readonly Name: string;
  118932. /**
  118933. * The (Babylon) version of this module.
  118934. * This is an integer representing the implementation version.
  118935. * This number does not correspond to the WebXR specs version
  118936. */
  118937. static readonly Version: number;
  118938. /**
  118939. * Disable lighting on the laser pointer (so it will always be visible)
  118940. */
  118941. disablePointerLighting: boolean;
  118942. /**
  118943. * Disable lighting on the selection mesh (so it will always be visible)
  118944. */
  118945. disableSelectionMeshLighting: boolean;
  118946. /**
  118947. * Should the laser pointer be displayed
  118948. */
  118949. displayLaserPointer: boolean;
  118950. /**
  118951. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  118952. */
  118953. displaySelectionMesh: boolean;
  118954. /**
  118955. * This color will be set to the laser pointer when selection is triggered
  118956. */
  118957. laserPointerPickedColor: Color3;
  118958. /**
  118959. * Default color of the laser pointer
  118960. */
  118961. lasterPointerDefaultColor: Color3;
  118962. /**
  118963. * default color of the selection ring
  118964. */
  118965. selectionMeshDefaultColor: Color3;
  118966. /**
  118967. * This color will be applied to the selection ring when selection is triggered
  118968. */
  118969. selectionMeshPickedColor: Color3;
  118970. /**
  118971. * Optional filter to be used for ray selection. This predicate shares behavior with
  118972. * scene.pointerMovePredicate which takes priority if it is also assigned.
  118973. */
  118974. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118975. /**
  118976. * constructs a new background remover module
  118977. * @param _xrSessionManager the session manager for this module
  118978. * @param _options read-only options to be used in this module
  118979. */
  118980. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  118981. /**
  118982. * attach this feature
  118983. * Will usually be called by the features manager
  118984. *
  118985. * @returns true if successful.
  118986. */
  118987. attach(): boolean;
  118988. /**
  118989. * detach this feature.
  118990. * Will usually be called by the features manager
  118991. *
  118992. * @returns true if successful.
  118993. */
  118994. detach(): boolean;
  118995. /**
  118996. * Will get the mesh under a specific pointer.
  118997. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  118998. * @param controllerId the controllerId to check
  118999. * @returns The mesh under pointer or null if no mesh is under the pointer
  119000. */
  119001. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  119002. /**
  119003. * Get the xr controller that correlates to the pointer id in the pointer event
  119004. *
  119005. * @param id the pointer id to search for
  119006. * @returns the controller that correlates to this id or null if not found
  119007. */
  119008. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  119009. protected _onXRFrame(_xrFrame: XRFrame): void;
  119010. private _attachGazeMode;
  119011. private _attachScreenRayMode;
  119012. private _attachTrackedPointerRayMode;
  119013. private _convertNormalToDirectionOfRay;
  119014. private _detachController;
  119015. private _generateNewMeshPair;
  119016. private _pickingMoved;
  119017. private _updatePointerDistance;
  119018. }
  119019. }
  119020. declare module BABYLON {
  119021. /**
  119022. * Button which can be used to enter a different mode of XR
  119023. */
  119024. export class WebXREnterExitUIButton {
  119025. /** button element */
  119026. element: HTMLElement;
  119027. /** XR initialization options for the button */
  119028. sessionMode: XRSessionMode;
  119029. /** Reference space type */
  119030. referenceSpaceType: XRReferenceSpaceType;
  119031. /**
  119032. * Creates a WebXREnterExitUIButton
  119033. * @param element button element
  119034. * @param sessionMode XR initialization session mode
  119035. * @param referenceSpaceType the type of reference space to be used
  119036. */
  119037. constructor(
  119038. /** button element */
  119039. element: HTMLElement,
  119040. /** XR initialization options for the button */
  119041. sessionMode: XRSessionMode,
  119042. /** Reference space type */
  119043. referenceSpaceType: XRReferenceSpaceType);
  119044. /**
  119045. * Extendable function which can be used to update the button's visuals when the state changes
  119046. * @param activeButton the current active button in the UI
  119047. */
  119048. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  119049. }
  119050. /**
  119051. * Options to create the webXR UI
  119052. */
  119053. export class WebXREnterExitUIOptions {
  119054. /**
  119055. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  119056. */
  119057. customButtons?: Array<WebXREnterExitUIButton>;
  119058. /**
  119059. * A reference space type to use when creating the default button.
  119060. * Default is local-floor
  119061. */
  119062. referenceSpaceType?: XRReferenceSpaceType;
  119063. /**
  119064. * Context to enter xr with
  119065. */
  119066. renderTarget?: Nullable<WebXRRenderTarget>;
  119067. /**
  119068. * A session mode to use when creating the default button.
  119069. * Default is immersive-vr
  119070. */
  119071. sessionMode?: XRSessionMode;
  119072. }
  119073. /**
  119074. * UI to allow the user to enter/exit XR mode
  119075. */
  119076. export class WebXREnterExitUI implements IDisposable {
  119077. private scene;
  119078. /** version of the options passed to this UI */
  119079. options: WebXREnterExitUIOptions;
  119080. private _activeButton;
  119081. private _buttons;
  119082. private _overlay;
  119083. /**
  119084. * Fired every time the active button is changed.
  119085. *
  119086. * When xr is entered via a button that launches xr that button will be the callback parameter
  119087. *
  119088. * When exiting xr the callback parameter will be null)
  119089. */
  119090. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  119091. /**
  119092. *
  119093. * @param scene babylon scene object to use
  119094. * @param options (read-only) version of the options passed to this UI
  119095. */
  119096. private constructor();
  119097. /**
  119098. * Creates UI to allow the user to enter/exit XR mode
  119099. * @param scene the scene to add the ui to
  119100. * @param helper the xr experience helper to enter/exit xr with
  119101. * @param options options to configure the UI
  119102. * @returns the created ui
  119103. */
  119104. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  119105. /**
  119106. * Disposes of the XR UI component
  119107. */
  119108. dispose(): void;
  119109. private _updateButtons;
  119110. }
  119111. }
  119112. declare module BABYLON {
  119113. /**
  119114. * Class containing static functions to help procedurally build meshes
  119115. */
  119116. export class LinesBuilder {
  119117. /**
  119118. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119119. * * 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
  119120. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119121. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119122. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119123. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119124. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119125. * * 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
  119126. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119129. * @param name defines the name of the new line system
  119130. * @param options defines the options used to create the line system
  119131. * @param scene defines the hosting scene
  119132. * @returns a new line system mesh
  119133. */
  119134. static CreateLineSystem(name: string, options: {
  119135. lines: Vector3[][];
  119136. updatable?: boolean;
  119137. instance?: Nullable<LinesMesh>;
  119138. colors?: Nullable<Color4[][]>;
  119139. useVertexAlpha?: boolean;
  119140. }, scene: Nullable<Scene>): LinesMesh;
  119141. /**
  119142. * Creates a line mesh
  119143. * 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
  119144. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119145. * * The parameter `points` is an array successive Vector3
  119146. * * 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
  119147. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119148. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119149. * * When updating an instance, remember that only point positions can change, not the number of points
  119150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119152. * @param name defines the name of the new line system
  119153. * @param options defines the options used to create the line system
  119154. * @param scene defines the hosting scene
  119155. * @returns a new line mesh
  119156. */
  119157. static CreateLines(name: string, options: {
  119158. points: Vector3[];
  119159. updatable?: boolean;
  119160. instance?: Nullable<LinesMesh>;
  119161. colors?: Color4[];
  119162. useVertexAlpha?: boolean;
  119163. }, scene?: Nullable<Scene>): LinesMesh;
  119164. /**
  119165. * Creates a dashed line mesh
  119166. * * 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
  119167. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119168. * * The parameter `points` is an array successive Vector3
  119169. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119170. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119171. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119172. * * 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
  119173. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119174. * * When updating an instance, remember that only point positions can change, not the number of points
  119175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119176. * @param name defines the name of the mesh
  119177. * @param options defines the options used to create the mesh
  119178. * @param scene defines the hosting scene
  119179. * @returns the dashed line mesh
  119180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119181. */
  119182. static CreateDashedLines(name: string, options: {
  119183. points: Vector3[];
  119184. dashSize?: number;
  119185. gapSize?: number;
  119186. dashNb?: number;
  119187. updatable?: boolean;
  119188. instance?: LinesMesh;
  119189. useVertexAlpha?: boolean;
  119190. }, scene?: Nullable<Scene>): LinesMesh;
  119191. }
  119192. }
  119193. declare module BABYLON {
  119194. /**
  119195. * The options container for the teleportation module
  119196. */
  119197. export interface IWebXRTeleportationOptions {
  119198. /**
  119199. * if provided, this scene will be used to render meshes.
  119200. */
  119201. customUtilityLayerScene?: Scene;
  119202. /**
  119203. * Values to configure the default target mesh
  119204. */
  119205. defaultTargetMeshOptions?: {
  119206. /**
  119207. * Fill color of the teleportation area
  119208. */
  119209. teleportationFillColor?: string;
  119210. /**
  119211. * Border color for the teleportation area
  119212. */
  119213. teleportationBorderColor?: string;
  119214. /**
  119215. * Disable the mesh's animation sequence
  119216. */
  119217. disableAnimation?: boolean;
  119218. /**
  119219. * Disable lighting on the material or the ring and arrow
  119220. */
  119221. disableLighting?: boolean;
  119222. /**
  119223. * Override the default material of the torus and arrow
  119224. */
  119225. torusArrowMaterial?: Material;
  119226. };
  119227. /**
  119228. * A list of meshes to use as floor meshes.
  119229. * Meshes can be added and removed after initializing the feature using the
  119230. * addFloorMesh and removeFloorMesh functions
  119231. * If empty, rotation will still work
  119232. */
  119233. floorMeshes?: AbstractMesh[];
  119234. /**
  119235. * use this rendering group id for the meshes (optional)
  119236. */
  119237. renderingGroupId?: number;
  119238. /**
  119239. * Should teleportation move only to snap points
  119240. */
  119241. snapPointsOnly?: boolean;
  119242. /**
  119243. * An array of points to which the teleportation will snap to.
  119244. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  119245. */
  119246. snapPositions?: Vector3[];
  119247. /**
  119248. * How close should the teleportation ray be in order to snap to position.
  119249. * Default to 0.8 units (meters)
  119250. */
  119251. snapToPositionRadius?: number;
  119252. /**
  119253. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  119254. * If you want to support rotation, make sure your mesh has a direction indicator.
  119255. *
  119256. * When left untouched, the default mesh will be initialized.
  119257. */
  119258. teleportationTargetMesh?: AbstractMesh;
  119259. /**
  119260. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  119261. */
  119262. timeToTeleport?: number;
  119263. /**
  119264. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  119265. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  119266. */
  119267. useMainComponentOnly?: boolean;
  119268. /**
  119269. * Should meshes created here be added to a utility layer or the main scene
  119270. */
  119271. useUtilityLayer?: boolean;
  119272. /**
  119273. * Babylon XR Input class for controller
  119274. */
  119275. xrInput: WebXRInput;
  119276. }
  119277. /**
  119278. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  119279. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  119280. * the input of the attached controllers.
  119281. */
  119282. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  119283. private _options;
  119284. private _controllers;
  119285. private _currentTeleportationControllerId;
  119286. private _floorMeshes;
  119287. private _quadraticBezierCurve;
  119288. private _selectionFeature;
  119289. private _snapToPositions;
  119290. private _snappedToPoint;
  119291. private _teleportationRingMaterial?;
  119292. private _tmpRay;
  119293. private _tmpVector;
  119294. /**
  119295. * The module's name
  119296. */
  119297. static readonly Name: string;
  119298. /**
  119299. * The (Babylon) version of this module.
  119300. * This is an integer representing the implementation version.
  119301. * This number does not correspond to the webxr specs version
  119302. */
  119303. static readonly Version: number;
  119304. /**
  119305. * Is movement backwards enabled
  119306. */
  119307. backwardsMovementEnabled: boolean;
  119308. /**
  119309. * Distance to travel when moving backwards
  119310. */
  119311. backwardsTeleportationDistance: number;
  119312. /**
  119313. * The distance from the user to the inspection point in the direction of the controller
  119314. * A higher number will allow the user to move further
  119315. * defaults to 5 (meters, in xr units)
  119316. */
  119317. parabolicCheckRadius: number;
  119318. /**
  119319. * Should the module support parabolic ray on top of direct ray
  119320. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  119321. * Very helpful when moving between floors / different heights
  119322. */
  119323. parabolicRayEnabled: boolean;
  119324. /**
  119325. * How much rotation should be applied when rotating right and left
  119326. */
  119327. rotationAngle: number;
  119328. /**
  119329. * Is rotation enabled when moving forward?
  119330. * Disabling this feature will prevent the user from deciding the direction when teleporting
  119331. */
  119332. rotationEnabled: boolean;
  119333. /**
  119334. * constructs a new anchor system
  119335. * @param _xrSessionManager an instance of WebXRSessionManager
  119336. * @param _options configuration object for this feature
  119337. */
  119338. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  119339. /**
  119340. * Get the snapPointsOnly flag
  119341. */
  119342. get snapPointsOnly(): boolean;
  119343. /**
  119344. * Sets the snapPointsOnly flag
  119345. * @param snapToPoints should teleportation be exclusively to snap points
  119346. */
  119347. set snapPointsOnly(snapToPoints: boolean);
  119348. /**
  119349. * Add a new mesh to the floor meshes array
  119350. * @param mesh the mesh to use as floor mesh
  119351. */
  119352. addFloorMesh(mesh: AbstractMesh): void;
  119353. /**
  119354. * Add a new snap-to point to fix teleportation to this position
  119355. * @param newSnapPoint The new Snap-To point
  119356. */
  119357. addSnapPoint(newSnapPoint: Vector3): void;
  119358. attach(): boolean;
  119359. detach(): boolean;
  119360. dispose(): void;
  119361. /**
  119362. * Remove a mesh from the floor meshes array
  119363. * @param mesh the mesh to remove
  119364. */
  119365. removeFloorMesh(mesh: AbstractMesh): void;
  119366. /**
  119367. * Remove a mesh from the floor meshes array using its name
  119368. * @param name the mesh name to remove
  119369. */
  119370. removeFloorMeshByName(name: string): void;
  119371. /**
  119372. * 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
  119373. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  119374. * @returns was the point found and removed or not
  119375. */
  119376. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  119377. /**
  119378. * This function sets a selection feature that will be disabled when
  119379. * the forward ray is shown and will be reattached when hidden.
  119380. * This is used to remove the selection rays when moving.
  119381. * @param selectionFeature the feature to disable when forward movement is enabled
  119382. */
  119383. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  119384. protected _onXRFrame(_xrFrame: XRFrame): void;
  119385. private _attachController;
  119386. private _createDefaultTargetMesh;
  119387. private _detachController;
  119388. private _findClosestSnapPointWithRadius;
  119389. private _setTargetMeshPosition;
  119390. private _setTargetMeshVisibility;
  119391. private _showParabolicPath;
  119392. private _teleportForward;
  119393. }
  119394. }
  119395. declare module BABYLON {
  119396. /**
  119397. * Options for the default xr helper
  119398. */
  119399. export class WebXRDefaultExperienceOptions {
  119400. /**
  119401. * Enable or disable default UI to enter XR
  119402. */
  119403. disableDefaultUI?: boolean;
  119404. /**
  119405. * Should teleportation not initialize. defaults to false.
  119406. */
  119407. disableTeleportation?: boolean;
  119408. /**
  119409. * Floor meshes that will be used for teleport
  119410. */
  119411. floorMeshes?: Array<AbstractMesh>;
  119412. /**
  119413. * If set to true, the first frame will not be used to reset position
  119414. * The first frame is mainly used when copying transformation from the old camera
  119415. * Mainly used in AR
  119416. */
  119417. ignoreNativeCameraTransformation?: boolean;
  119418. /**
  119419. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  119420. */
  119421. inputOptions?: IWebXRInputOptions;
  119422. /**
  119423. * optional configuration for the output canvas
  119424. */
  119425. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  119426. /**
  119427. * optional UI options. This can be used among other to change session mode and reference space type
  119428. */
  119429. uiOptions?: WebXREnterExitUIOptions;
  119430. /**
  119431. * When loading teleportation and pointer select, use stable versions instead of latest.
  119432. */
  119433. useStablePlugins?: boolean;
  119434. }
  119435. /**
  119436. * Default experience which provides a similar setup to the previous webVRExperience
  119437. */
  119438. export class WebXRDefaultExperience {
  119439. /**
  119440. * Base experience
  119441. */
  119442. baseExperience: WebXRExperienceHelper;
  119443. /**
  119444. * Enables ui for entering/exiting xr
  119445. */
  119446. enterExitUI: WebXREnterExitUI;
  119447. /**
  119448. * Input experience extension
  119449. */
  119450. input: WebXRInput;
  119451. /**
  119452. * Enables laser pointer and selection
  119453. */
  119454. pointerSelection: WebXRControllerPointerSelection;
  119455. /**
  119456. * Default target xr should render to
  119457. */
  119458. renderTarget: WebXRRenderTarget;
  119459. /**
  119460. * Enables teleportation
  119461. */
  119462. teleportation: WebXRMotionControllerTeleportation;
  119463. private constructor();
  119464. /**
  119465. * Creates the default xr experience
  119466. * @param scene scene
  119467. * @param options options for basic configuration
  119468. * @returns resulting WebXRDefaultExperience
  119469. */
  119470. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119471. /**
  119472. * DIsposes of the experience helper
  119473. */
  119474. dispose(): void;
  119475. }
  119476. }
  119477. declare module BABYLON {
  119478. /**
  119479. * Options to modify the vr teleportation behavior.
  119480. */
  119481. export interface VRTeleportationOptions {
  119482. /**
  119483. * The name of the mesh which should be used as the teleportation floor. (default: null)
  119484. */
  119485. floorMeshName?: string;
  119486. /**
  119487. * A list of meshes to be used as the teleportation floor. (default: empty)
  119488. */
  119489. floorMeshes?: Mesh[];
  119490. /**
  119491. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  119492. */
  119493. teleportationMode?: number;
  119494. /**
  119495. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  119496. */
  119497. teleportationTime?: number;
  119498. /**
  119499. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  119500. */
  119501. teleportationSpeed?: number;
  119502. /**
  119503. * The easing function used in the animation or null for Linear. (default CircleEase)
  119504. */
  119505. easingFunction?: EasingFunction;
  119506. }
  119507. /**
  119508. * Options to modify the vr experience helper's behavior.
  119509. */
  119510. export interface VRExperienceHelperOptions extends WebVROptions {
  119511. /**
  119512. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  119513. */
  119514. createDeviceOrientationCamera?: boolean;
  119515. /**
  119516. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  119517. */
  119518. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  119519. /**
  119520. * Uses the main button on the controller to toggle the laser casted. (default: true)
  119521. */
  119522. laserToggle?: boolean;
  119523. /**
  119524. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  119525. */
  119526. floorMeshes?: Mesh[];
  119527. /**
  119528. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  119529. */
  119530. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  119531. /**
  119532. * Defines if WebXR should be used instead of WebVR (if available)
  119533. */
  119534. useXR?: boolean;
  119535. }
  119536. /**
  119537. * Event containing information after VR has been entered
  119538. */
  119539. export class OnAfterEnteringVRObservableEvent {
  119540. /**
  119541. * If entering vr was successful
  119542. */
  119543. success: boolean;
  119544. }
  119545. /**
  119546. * Helps to quickly add VR support to an existing scene.
  119547. * See http://doc.babylonjs.com/how_to/webvr_helper
  119548. */
  119549. export class VRExperienceHelper {
  119550. /** Options to modify the vr experience helper's behavior. */
  119551. webVROptions: VRExperienceHelperOptions;
  119552. private _scene;
  119553. private _position;
  119554. private _btnVR;
  119555. private _btnVRDisplayed;
  119556. private _webVRsupported;
  119557. private _webVRready;
  119558. private _webVRrequesting;
  119559. private _webVRpresenting;
  119560. private _hasEnteredVR;
  119561. private _fullscreenVRpresenting;
  119562. private _inputElement;
  119563. private _webVRCamera;
  119564. private _vrDeviceOrientationCamera;
  119565. private _deviceOrientationCamera;
  119566. private _existingCamera;
  119567. private _onKeyDown;
  119568. private _onVrDisplayPresentChange;
  119569. private _onVRDisplayChanged;
  119570. private _onVRRequestPresentStart;
  119571. private _onVRRequestPresentComplete;
  119572. /**
  119573. * 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)
  119574. */
  119575. enableGazeEvenWhenNoPointerLock: boolean;
  119576. /**
  119577. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  119578. */
  119579. exitVROnDoubleTap: boolean;
  119580. /**
  119581. * Observable raised right before entering VR.
  119582. */
  119583. onEnteringVRObservable: Observable<VRExperienceHelper>;
  119584. /**
  119585. * Observable raised when entering VR has completed.
  119586. */
  119587. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  119588. /**
  119589. * Observable raised when exiting VR.
  119590. */
  119591. onExitingVRObservable: Observable<VRExperienceHelper>;
  119592. /**
  119593. * Observable raised when controller mesh is loaded.
  119594. */
  119595. onControllerMeshLoadedObservable: Observable<WebVRController>;
  119596. /** Return this.onEnteringVRObservable
  119597. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  119598. */
  119599. get onEnteringVR(): Observable<VRExperienceHelper>;
  119600. /** Return this.onExitingVRObservable
  119601. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  119602. */
  119603. get onExitingVR(): Observable<VRExperienceHelper>;
  119604. /** Return this.onControllerMeshLoadedObservable
  119605. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  119606. */
  119607. get onControllerMeshLoaded(): Observable<WebVRController>;
  119608. private _rayLength;
  119609. private _useCustomVRButton;
  119610. private _teleportationRequested;
  119611. private _teleportActive;
  119612. private _floorMeshName;
  119613. private _floorMeshesCollection;
  119614. private _teleportationMode;
  119615. private _teleportationTime;
  119616. private _teleportationSpeed;
  119617. private _teleportationEasing;
  119618. private _rotationAllowed;
  119619. private _teleportBackwardsVector;
  119620. private _teleportationTarget;
  119621. private _isDefaultTeleportationTarget;
  119622. private _postProcessMove;
  119623. private _teleportationFillColor;
  119624. private _teleportationBorderColor;
  119625. private _rotationAngle;
  119626. private _haloCenter;
  119627. private _cameraGazer;
  119628. private _padSensibilityUp;
  119629. private _padSensibilityDown;
  119630. private _leftController;
  119631. private _rightController;
  119632. private _gazeColor;
  119633. private _laserColor;
  119634. private _pickedLaserColor;
  119635. private _pickedGazeColor;
  119636. /**
  119637. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  119638. */
  119639. onNewMeshSelected: Observable<AbstractMesh>;
  119640. /**
  119641. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  119642. * This observable will provide the mesh and the controller used to select the mesh
  119643. */
  119644. onMeshSelectedWithController: Observable<{
  119645. mesh: AbstractMesh;
  119646. controller: WebVRController;
  119647. }>;
  119648. /**
  119649. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  119650. */
  119651. onNewMeshPicked: Observable<PickingInfo>;
  119652. private _circleEase;
  119653. /**
  119654. * Observable raised before camera teleportation
  119655. */
  119656. onBeforeCameraTeleport: Observable<Vector3>;
  119657. /**
  119658. * Observable raised after camera teleportation
  119659. */
  119660. onAfterCameraTeleport: Observable<Vector3>;
  119661. /**
  119662. * Observable raised when current selected mesh gets unselected
  119663. */
  119664. onSelectedMeshUnselected: Observable<AbstractMesh>;
  119665. private _raySelectionPredicate;
  119666. /**
  119667. * To be optionaly changed by user to define custom ray selection
  119668. */
  119669. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119670. /**
  119671. * To be optionaly changed by user to define custom selection logic (after ray selection)
  119672. */
  119673. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119674. /**
  119675. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  119676. */
  119677. teleportationEnabled: boolean;
  119678. private _defaultHeight;
  119679. private _teleportationInitialized;
  119680. private _interactionsEnabled;
  119681. private _interactionsRequested;
  119682. private _displayGaze;
  119683. private _displayLaserPointer;
  119684. /**
  119685. * The mesh used to display where the user is going to teleport.
  119686. */
  119687. get teleportationTarget(): Mesh;
  119688. /**
  119689. * Sets the mesh to be used to display where the user is going to teleport.
  119690. */
  119691. set teleportationTarget(value: Mesh);
  119692. /**
  119693. * 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
  119694. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  119695. * See http://doc.babylonjs.com/resources/baking_transformations
  119696. */
  119697. get gazeTrackerMesh(): Mesh;
  119698. set gazeTrackerMesh(value: Mesh);
  119699. /**
  119700. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  119701. */
  119702. updateGazeTrackerScale: boolean;
  119703. /**
  119704. * If the gaze trackers color should be updated when selecting meshes
  119705. */
  119706. updateGazeTrackerColor: boolean;
  119707. /**
  119708. * If the controller laser color should be updated when selecting meshes
  119709. */
  119710. updateControllerLaserColor: boolean;
  119711. /**
  119712. * The gaze tracking mesh corresponding to the left controller
  119713. */
  119714. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  119715. /**
  119716. * The gaze tracking mesh corresponding to the right controller
  119717. */
  119718. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  119719. /**
  119720. * If the ray of the gaze should be displayed.
  119721. */
  119722. get displayGaze(): boolean;
  119723. /**
  119724. * Sets if the ray of the gaze should be displayed.
  119725. */
  119726. set displayGaze(value: boolean);
  119727. /**
  119728. * If the ray of the LaserPointer should be displayed.
  119729. */
  119730. get displayLaserPointer(): boolean;
  119731. /**
  119732. * Sets if the ray of the LaserPointer should be displayed.
  119733. */
  119734. set displayLaserPointer(value: boolean);
  119735. /**
  119736. * The deviceOrientationCamera used as the camera when not in VR.
  119737. */
  119738. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  119739. /**
  119740. * Based on the current WebVR support, returns the current VR camera used.
  119741. */
  119742. get currentVRCamera(): Nullable<Camera>;
  119743. /**
  119744. * The webVRCamera which is used when in VR.
  119745. */
  119746. get webVRCamera(): WebVRFreeCamera;
  119747. /**
  119748. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119749. */
  119750. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  119751. /**
  119752. * The html button that is used to trigger entering into VR.
  119753. */
  119754. get vrButton(): Nullable<HTMLButtonElement>;
  119755. private get _teleportationRequestInitiated();
  119756. /**
  119757. * Defines whether or not Pointer lock should be requested when switching to
  119758. * full screen.
  119759. */
  119760. requestPointerLockOnFullScreen: boolean;
  119761. /**
  119762. * If asking to force XR, this will be populated with the default xr experience
  119763. */
  119764. xr: WebXRDefaultExperience;
  119765. /**
  119766. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  119767. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  119768. */
  119769. xrTestDone: boolean;
  119770. /**
  119771. * Instantiates a VRExperienceHelper.
  119772. * Helps to quickly add VR support to an existing scene.
  119773. * @param scene The scene the VRExperienceHelper belongs to.
  119774. * @param webVROptions Options to modify the vr experience helper's behavior.
  119775. */
  119776. constructor(scene: Scene,
  119777. /** Options to modify the vr experience helper's behavior. */
  119778. webVROptions?: VRExperienceHelperOptions);
  119779. private completeVRInit;
  119780. private _onDefaultMeshLoaded;
  119781. private _onResize;
  119782. private _onFullscreenChange;
  119783. /**
  119784. * Gets a value indicating if we are currently in VR mode.
  119785. */
  119786. get isInVRMode(): boolean;
  119787. private onVrDisplayPresentChange;
  119788. private onVRDisplayChanged;
  119789. private moveButtonToBottomRight;
  119790. private displayVRButton;
  119791. private updateButtonVisibility;
  119792. private _cachedAngularSensibility;
  119793. /**
  119794. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  119795. * Otherwise, will use the fullscreen API.
  119796. */
  119797. enterVR(): void;
  119798. /**
  119799. * Attempt to exit VR, or fullscreen.
  119800. */
  119801. exitVR(): void;
  119802. /**
  119803. * The position of the vr experience helper.
  119804. */
  119805. get position(): Vector3;
  119806. /**
  119807. * Sets the position of the vr experience helper.
  119808. */
  119809. set position(value: Vector3);
  119810. /**
  119811. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  119812. */
  119813. enableInteractions(): void;
  119814. private get _noControllerIsActive();
  119815. private beforeRender;
  119816. private _isTeleportationFloor;
  119817. /**
  119818. * Adds a floor mesh to be used for teleportation.
  119819. * @param floorMesh the mesh to be used for teleportation.
  119820. */
  119821. addFloorMesh(floorMesh: Mesh): void;
  119822. /**
  119823. * Removes a floor mesh from being used for teleportation.
  119824. * @param floorMesh the mesh to be removed.
  119825. */
  119826. removeFloorMesh(floorMesh: Mesh): void;
  119827. /**
  119828. * Enables interactions and teleportation using the VR controllers and gaze.
  119829. * @param vrTeleportationOptions options to modify teleportation behavior.
  119830. */
  119831. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  119832. private _onNewGamepadConnected;
  119833. private _tryEnableInteractionOnController;
  119834. private _onNewGamepadDisconnected;
  119835. private _enableInteractionOnController;
  119836. private _checkTeleportWithRay;
  119837. private _checkRotate;
  119838. private _checkTeleportBackwards;
  119839. private _enableTeleportationOnController;
  119840. private _createTeleportationCircles;
  119841. private _displayTeleportationTarget;
  119842. private _hideTeleportationTarget;
  119843. private _rotateCamera;
  119844. private _moveTeleportationSelectorTo;
  119845. private _workingVector;
  119846. private _workingQuaternion;
  119847. private _workingMatrix;
  119848. /**
  119849. * Time Constant Teleportation Mode
  119850. */
  119851. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  119852. /**
  119853. * Speed Constant Teleportation Mode
  119854. */
  119855. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  119856. /**
  119857. * Teleports the users feet to the desired location
  119858. * @param location The location where the user's feet should be placed
  119859. */
  119860. teleportCamera(location: Vector3): void;
  119861. private _convertNormalToDirectionOfRay;
  119862. private _castRayAndSelectObject;
  119863. private _notifySelectedMeshUnselected;
  119864. /**
  119865. * Permanently set new colors for the laser pointer
  119866. * @param color the new laser color
  119867. * @param pickedColor the new laser color when picked mesh detected
  119868. */
  119869. setLaserColor(color: Color3, pickedColor?: Color3): void;
  119870. /**
  119871. * Set lighting enabled / disabled on the laser pointer of both controllers
  119872. * @param enabled should the lighting be enabled on the laser pointer
  119873. */
  119874. setLaserLightingState(enabled?: boolean): void;
  119875. /**
  119876. * Permanently set new colors for the gaze pointer
  119877. * @param color the new gaze color
  119878. * @param pickedColor the new gaze color when picked mesh detected
  119879. */
  119880. setGazeColor(color: Color3, pickedColor?: Color3): void;
  119881. /**
  119882. * Sets the color of the laser ray from the vr controllers.
  119883. * @param color new color for the ray.
  119884. */
  119885. changeLaserColor(color: Color3): void;
  119886. /**
  119887. * Sets the color of the ray from the vr headsets gaze.
  119888. * @param color new color for the ray.
  119889. */
  119890. changeGazeColor(color: Color3): void;
  119891. /**
  119892. * Exits VR and disposes of the vr experience helper
  119893. */
  119894. dispose(): void;
  119895. /**
  119896. * Gets the name of the VRExperienceHelper class
  119897. * @returns "VRExperienceHelper"
  119898. */
  119899. getClassName(): string;
  119900. }
  119901. }
  119902. declare module BABYLON {
  119903. /**
  119904. * Contains an array of blocks representing the octree
  119905. */
  119906. export interface IOctreeContainer<T> {
  119907. /**
  119908. * Blocks within the octree
  119909. */
  119910. blocks: Array<OctreeBlock<T>>;
  119911. }
  119912. /**
  119913. * Class used to store a cell in an octree
  119914. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  119915. */
  119916. export class OctreeBlock<T> {
  119917. /**
  119918. * Gets the content of the current block
  119919. */
  119920. entries: T[];
  119921. /**
  119922. * Gets the list of block children
  119923. */
  119924. blocks: Array<OctreeBlock<T>>;
  119925. private _depth;
  119926. private _maxDepth;
  119927. private _capacity;
  119928. private _minPoint;
  119929. private _maxPoint;
  119930. private _boundingVectors;
  119931. private _creationFunc;
  119932. /**
  119933. * Creates a new block
  119934. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  119935. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  119936. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119937. * @param depth defines the current depth of this block in the octree
  119938. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  119939. * @param creationFunc defines a callback to call when an element is added to the block
  119940. */
  119941. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  119942. /**
  119943. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  119944. */
  119945. get capacity(): number;
  119946. /**
  119947. * Gets the minimum vector (in world space) of the block's bounding box
  119948. */
  119949. get minPoint(): Vector3;
  119950. /**
  119951. * Gets the maximum vector (in world space) of the block's bounding box
  119952. */
  119953. get maxPoint(): Vector3;
  119954. /**
  119955. * Add a new element to this block
  119956. * @param entry defines the element to add
  119957. */
  119958. addEntry(entry: T): void;
  119959. /**
  119960. * Remove an element from this block
  119961. * @param entry defines the element to remove
  119962. */
  119963. removeEntry(entry: T): void;
  119964. /**
  119965. * Add an array of elements to this block
  119966. * @param entries defines the array of elements to add
  119967. */
  119968. addEntries(entries: T[]): void;
  119969. /**
  119970. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  119971. * @param frustumPlanes defines the frustum planes to test
  119972. * @param selection defines the array to store current content if selection is positive
  119973. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119974. */
  119975. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119976. /**
  119977. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  119978. * @param sphereCenter defines the bounding sphere center
  119979. * @param sphereRadius defines the bounding sphere radius
  119980. * @param selection defines the array to store current content if selection is positive
  119981. * @param allowDuplicate defines if the selection array can contains duplicated entries
  119982. */
  119983. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  119984. /**
  119985. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  119986. * @param ray defines the ray to test with
  119987. * @param selection defines the array to store current content if selection is positive
  119988. */
  119989. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  119990. /**
  119991. * Subdivide the content into child blocks (this block will then be empty)
  119992. */
  119993. createInnerBlocks(): void;
  119994. /**
  119995. * @hidden
  119996. */
  119997. 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;
  119998. }
  119999. }
  120000. declare module BABYLON {
  120001. /**
  120002. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  120003. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120004. */
  120005. export class Octree<T> {
  120006. /** 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.) */
  120007. maxDepth: number;
  120008. /**
  120009. * Blocks within the octree containing objects
  120010. */
  120011. blocks: Array<OctreeBlock<T>>;
  120012. /**
  120013. * Content stored in the octree
  120014. */
  120015. dynamicContent: T[];
  120016. private _maxBlockCapacity;
  120017. private _selectionContent;
  120018. private _creationFunc;
  120019. /**
  120020. * Creates a octree
  120021. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120022. * @param creationFunc function to be used to instatiate the octree
  120023. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  120024. * @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.)
  120025. */
  120026. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  120027. /** 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.) */
  120028. maxDepth?: number);
  120029. /**
  120030. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  120031. * @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);
  120032. * @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);
  120033. * @param entries meshes to be added to the octree blocks
  120034. */
  120035. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  120036. /**
  120037. * Adds a mesh to the octree
  120038. * @param entry Mesh to add to the octree
  120039. */
  120040. addMesh(entry: T): void;
  120041. /**
  120042. * Remove an element from the octree
  120043. * @param entry defines the element to remove
  120044. */
  120045. removeMesh(entry: T): void;
  120046. /**
  120047. * Selects an array of meshes within the frustum
  120048. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  120049. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  120050. * @returns array of meshes within the frustum
  120051. */
  120052. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  120053. /**
  120054. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  120055. * @param sphereCenter defines the bounding sphere center
  120056. * @param sphereRadius defines the bounding sphere radius
  120057. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120058. * @returns an array of objects that intersect the sphere
  120059. */
  120060. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  120061. /**
  120062. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  120063. * @param ray defines the ray to test with
  120064. * @returns array of intersected objects
  120065. */
  120066. intersectsRay(ray: Ray): SmartArray<T>;
  120067. /**
  120068. * Adds a mesh into the octree block if it intersects the block
  120069. */
  120070. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  120071. /**
  120072. * Adds a submesh into the octree block if it intersects the block
  120073. */
  120074. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  120075. }
  120076. }
  120077. declare module BABYLON {
  120078. interface Scene {
  120079. /**
  120080. * @hidden
  120081. * Backing Filed
  120082. */
  120083. _selectionOctree: Octree<AbstractMesh>;
  120084. /**
  120085. * Gets the octree used to boost mesh selection (picking)
  120086. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120087. */
  120088. selectionOctree: Octree<AbstractMesh>;
  120089. /**
  120090. * Creates or updates the octree used to boost selection (picking)
  120091. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120092. * @param maxCapacity defines the maximum capacity per leaf
  120093. * @param maxDepth defines the maximum depth of the octree
  120094. * @returns an octree of AbstractMesh
  120095. */
  120096. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  120097. }
  120098. interface AbstractMesh {
  120099. /**
  120100. * @hidden
  120101. * Backing Field
  120102. */
  120103. _submeshesOctree: Octree<SubMesh>;
  120104. /**
  120105. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  120106. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  120107. * @param maxCapacity defines the maximum size of each block (64 by default)
  120108. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  120109. * @returns the new octree
  120110. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  120111. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120112. */
  120113. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  120114. }
  120115. /**
  120116. * Defines the octree scene component responsible to manage any octrees
  120117. * in a given scene.
  120118. */
  120119. export class OctreeSceneComponent {
  120120. /**
  120121. * The component name help to identify the component in the list of scene components.
  120122. */
  120123. readonly name: string;
  120124. /**
  120125. * The scene the component belongs to.
  120126. */
  120127. scene: Scene;
  120128. /**
  120129. * Indicates if the meshes have been checked to make sure they are isEnabled()
  120130. */
  120131. readonly checksIsEnabled: boolean;
  120132. /**
  120133. * Creates a new instance of the component for the given scene
  120134. * @param scene Defines the scene to register the component in
  120135. */
  120136. constructor(scene: Scene);
  120137. /**
  120138. * Registers the component in a given scene
  120139. */
  120140. register(): void;
  120141. /**
  120142. * Return the list of active meshes
  120143. * @returns the list of active meshes
  120144. */
  120145. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120146. /**
  120147. * Return the list of active sub meshes
  120148. * @param mesh The mesh to get the candidates sub meshes from
  120149. * @returns the list of active sub meshes
  120150. */
  120151. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120152. private _tempRay;
  120153. /**
  120154. * Return the list of sub meshes intersecting with a given local ray
  120155. * @param mesh defines the mesh to find the submesh for
  120156. * @param localRay defines the ray in local space
  120157. * @returns the list of intersecting sub meshes
  120158. */
  120159. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  120160. /**
  120161. * Return the list of sub meshes colliding with a collider
  120162. * @param mesh defines the mesh to find the submesh for
  120163. * @param collider defines the collider to evaluate the collision against
  120164. * @returns the list of colliding sub meshes
  120165. */
  120166. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  120167. /**
  120168. * Rebuilds the elements related to this component in case of
  120169. * context lost for instance.
  120170. */
  120171. rebuild(): void;
  120172. /**
  120173. * Disposes the component and the associated ressources.
  120174. */
  120175. dispose(): void;
  120176. }
  120177. }
  120178. declare module BABYLON {
  120179. /**
  120180. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  120181. */
  120182. export class Gizmo implements IDisposable {
  120183. /** The utility layer the gizmo will be added to */
  120184. gizmoLayer: UtilityLayerRenderer;
  120185. /**
  120186. * The root mesh of the gizmo
  120187. */
  120188. _rootMesh: Mesh;
  120189. private _attachedMesh;
  120190. /**
  120191. * Ratio for the scale of the gizmo (Default: 1)
  120192. */
  120193. scaleRatio: number;
  120194. /**
  120195. * If a custom mesh has been set (Default: false)
  120196. */
  120197. protected _customMeshSet: boolean;
  120198. /**
  120199. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  120200. * * When set, interactions will be enabled
  120201. */
  120202. get attachedMesh(): Nullable<AbstractMesh>;
  120203. set attachedMesh(value: Nullable<AbstractMesh>);
  120204. /**
  120205. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  120206. * @param mesh The mesh to replace the default mesh of the gizmo
  120207. */
  120208. setCustomMesh(mesh: Mesh): void;
  120209. /**
  120210. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  120211. */
  120212. updateGizmoRotationToMatchAttachedMesh: boolean;
  120213. /**
  120214. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  120215. */
  120216. updateGizmoPositionToMatchAttachedMesh: boolean;
  120217. /**
  120218. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  120219. */
  120220. updateScale: boolean;
  120221. protected _interactionsEnabled: boolean;
  120222. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120223. private _beforeRenderObserver;
  120224. private _tempVector;
  120225. /**
  120226. * Creates a gizmo
  120227. * @param gizmoLayer The utility layer the gizmo will be added to
  120228. */
  120229. constructor(
  120230. /** The utility layer the gizmo will be added to */
  120231. gizmoLayer?: UtilityLayerRenderer);
  120232. /**
  120233. * Updates the gizmo to match the attached mesh's position/rotation
  120234. */
  120235. protected _update(): void;
  120236. /**
  120237. * Disposes of the gizmo
  120238. */
  120239. dispose(): void;
  120240. }
  120241. }
  120242. declare module BABYLON {
  120243. /**
  120244. * Single plane drag gizmo
  120245. */
  120246. export class PlaneDragGizmo extends Gizmo {
  120247. /**
  120248. * Drag behavior responsible for the gizmos dragging interactions
  120249. */
  120250. dragBehavior: PointerDragBehavior;
  120251. private _pointerObserver;
  120252. /**
  120253. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120254. */
  120255. snapDistance: number;
  120256. /**
  120257. * Event that fires each time the gizmo snaps to a new location.
  120258. * * snapDistance is the the change in distance
  120259. */
  120260. onSnapObservable: Observable<{
  120261. snapDistance: number;
  120262. }>;
  120263. private _plane;
  120264. private _coloredMaterial;
  120265. private _hoverMaterial;
  120266. private _isEnabled;
  120267. private _parent;
  120268. /** @hidden */
  120269. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  120270. /** @hidden */
  120271. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120272. /**
  120273. * Creates a PlaneDragGizmo
  120274. * @param gizmoLayer The utility layer the gizmo will be added to
  120275. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  120276. * @param color The color of the gizmo
  120277. */
  120278. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120279. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120280. /**
  120281. * If the gizmo is enabled
  120282. */
  120283. set isEnabled(value: boolean);
  120284. get isEnabled(): boolean;
  120285. /**
  120286. * Disposes of the gizmo
  120287. */
  120288. dispose(): void;
  120289. }
  120290. }
  120291. declare module BABYLON {
  120292. /**
  120293. * Gizmo that enables dragging a mesh along 3 axis
  120294. */
  120295. export class PositionGizmo extends Gizmo {
  120296. /**
  120297. * Internal gizmo used for interactions on the x axis
  120298. */
  120299. xGizmo: AxisDragGizmo;
  120300. /**
  120301. * Internal gizmo used for interactions on the y axis
  120302. */
  120303. yGizmo: AxisDragGizmo;
  120304. /**
  120305. * Internal gizmo used for interactions on the z axis
  120306. */
  120307. zGizmo: AxisDragGizmo;
  120308. /**
  120309. * Internal gizmo used for interactions on the yz plane
  120310. */
  120311. xPlaneGizmo: PlaneDragGizmo;
  120312. /**
  120313. * Internal gizmo used for interactions on the xz plane
  120314. */
  120315. yPlaneGizmo: PlaneDragGizmo;
  120316. /**
  120317. * Internal gizmo used for interactions on the xy plane
  120318. */
  120319. zPlaneGizmo: PlaneDragGizmo;
  120320. /**
  120321. * private variables
  120322. */
  120323. private _meshAttached;
  120324. private _updateGizmoRotationToMatchAttachedMesh;
  120325. private _snapDistance;
  120326. private _scaleRatio;
  120327. /** Fires an event when any of it's sub gizmos are dragged */
  120328. onDragStartObservable: Observable<unknown>;
  120329. /** Fires an event when any of it's sub gizmos are released from dragging */
  120330. onDragEndObservable: Observable<unknown>;
  120331. /**
  120332. * If set to true, planar drag is enabled
  120333. */
  120334. private _planarGizmoEnabled;
  120335. get attachedMesh(): Nullable<AbstractMesh>;
  120336. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120337. /**
  120338. * Creates a PositionGizmo
  120339. * @param gizmoLayer The utility layer the gizmo will be added to
  120340. */
  120341. constructor(gizmoLayer?: UtilityLayerRenderer);
  120342. /**
  120343. * If the planar drag gizmo is enabled
  120344. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  120345. */
  120346. set planarGizmoEnabled(value: boolean);
  120347. get planarGizmoEnabled(): boolean;
  120348. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120349. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120350. /**
  120351. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120352. */
  120353. set snapDistance(value: number);
  120354. get snapDistance(): number;
  120355. /**
  120356. * Ratio for the scale of the gizmo (Default: 1)
  120357. */
  120358. set scaleRatio(value: number);
  120359. get scaleRatio(): number;
  120360. /**
  120361. * Disposes of the gizmo
  120362. */
  120363. dispose(): void;
  120364. /**
  120365. * CustomMeshes are not supported by this gizmo
  120366. * @param mesh The mesh to replace the default mesh of the gizmo
  120367. */
  120368. setCustomMesh(mesh: Mesh): void;
  120369. }
  120370. }
  120371. declare module BABYLON {
  120372. /**
  120373. * Single axis drag gizmo
  120374. */
  120375. export class AxisDragGizmo extends Gizmo {
  120376. /**
  120377. * Drag behavior responsible for the gizmos dragging interactions
  120378. */
  120379. dragBehavior: PointerDragBehavior;
  120380. private _pointerObserver;
  120381. /**
  120382. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120383. */
  120384. snapDistance: number;
  120385. /**
  120386. * Event that fires each time the gizmo snaps to a new location.
  120387. * * snapDistance is the the change in distance
  120388. */
  120389. onSnapObservable: Observable<{
  120390. snapDistance: number;
  120391. }>;
  120392. private _isEnabled;
  120393. private _parent;
  120394. private _arrow;
  120395. private _coloredMaterial;
  120396. private _hoverMaterial;
  120397. /** @hidden */
  120398. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  120399. /** @hidden */
  120400. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120401. /**
  120402. * Creates an AxisDragGizmo
  120403. * @param gizmoLayer The utility layer the gizmo will be added to
  120404. * @param dragAxis The axis which the gizmo will be able to drag on
  120405. * @param color The color of the gizmo
  120406. */
  120407. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120408. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120409. /**
  120410. * If the gizmo is enabled
  120411. */
  120412. set isEnabled(value: boolean);
  120413. get isEnabled(): boolean;
  120414. /**
  120415. * Disposes of the gizmo
  120416. */
  120417. dispose(): void;
  120418. }
  120419. }
  120420. declare module BABYLON.Debug {
  120421. /**
  120422. * The Axes viewer will show 3 axes in a specific point in space
  120423. */
  120424. export class AxesViewer {
  120425. private _xAxis;
  120426. private _yAxis;
  120427. private _zAxis;
  120428. private _scaleLinesFactor;
  120429. private _instanced;
  120430. /**
  120431. * Gets the hosting scene
  120432. */
  120433. scene: Scene;
  120434. /**
  120435. * Gets or sets a number used to scale line length
  120436. */
  120437. scaleLines: number;
  120438. /** Gets the node hierarchy used to render x-axis */
  120439. get xAxis(): TransformNode;
  120440. /** Gets the node hierarchy used to render y-axis */
  120441. get yAxis(): TransformNode;
  120442. /** Gets the node hierarchy used to render z-axis */
  120443. get zAxis(): TransformNode;
  120444. /**
  120445. * Creates a new AxesViewer
  120446. * @param scene defines the hosting scene
  120447. * @param scaleLines defines a number used to scale line length (1 by default)
  120448. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  120449. * @param xAxis defines the node hierarchy used to render the x-axis
  120450. * @param yAxis defines the node hierarchy used to render the y-axis
  120451. * @param zAxis defines the node hierarchy used to render the z-axis
  120452. */
  120453. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  120454. /**
  120455. * Force the viewer to update
  120456. * @param position defines the position of the viewer
  120457. * @param xaxis defines the x axis of the viewer
  120458. * @param yaxis defines the y axis of the viewer
  120459. * @param zaxis defines the z axis of the viewer
  120460. */
  120461. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  120462. /**
  120463. * Creates an instance of this axes viewer.
  120464. * @returns a new axes viewer with instanced meshes
  120465. */
  120466. createInstance(): AxesViewer;
  120467. /** Releases resources */
  120468. dispose(): void;
  120469. private static _SetRenderingGroupId;
  120470. }
  120471. }
  120472. declare module BABYLON.Debug {
  120473. /**
  120474. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  120475. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  120476. */
  120477. export class BoneAxesViewer extends AxesViewer {
  120478. /**
  120479. * Gets or sets the target mesh where to display the axes viewer
  120480. */
  120481. mesh: Nullable<Mesh>;
  120482. /**
  120483. * Gets or sets the target bone where to display the axes viewer
  120484. */
  120485. bone: Nullable<Bone>;
  120486. /** Gets current position */
  120487. pos: Vector3;
  120488. /** Gets direction of X axis */
  120489. xaxis: Vector3;
  120490. /** Gets direction of Y axis */
  120491. yaxis: Vector3;
  120492. /** Gets direction of Z axis */
  120493. zaxis: Vector3;
  120494. /**
  120495. * Creates a new BoneAxesViewer
  120496. * @param scene defines the hosting scene
  120497. * @param bone defines the target bone
  120498. * @param mesh defines the target mesh
  120499. * @param scaleLines defines a scaling factor for line length (1 by default)
  120500. */
  120501. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  120502. /**
  120503. * Force the viewer to update
  120504. */
  120505. update(): void;
  120506. /** Releases resources */
  120507. dispose(): void;
  120508. }
  120509. }
  120510. declare module BABYLON {
  120511. /**
  120512. * Interface used to define scene explorer extensibility option
  120513. */
  120514. export interface IExplorerExtensibilityOption {
  120515. /**
  120516. * Define the option label
  120517. */
  120518. label: string;
  120519. /**
  120520. * Defines the action to execute on click
  120521. */
  120522. action: (entity: any) => void;
  120523. }
  120524. /**
  120525. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  120526. */
  120527. export interface IExplorerExtensibilityGroup {
  120528. /**
  120529. * Defines a predicate to test if a given type mut be extended
  120530. */
  120531. predicate: (entity: any) => boolean;
  120532. /**
  120533. * Gets the list of options added to a type
  120534. */
  120535. entries: IExplorerExtensibilityOption[];
  120536. }
  120537. /**
  120538. * Interface used to define the options to use to create the Inspector
  120539. */
  120540. export interface IInspectorOptions {
  120541. /**
  120542. * Display in overlay mode (default: false)
  120543. */
  120544. overlay?: boolean;
  120545. /**
  120546. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  120547. */
  120548. globalRoot?: HTMLElement;
  120549. /**
  120550. * Display the Scene explorer
  120551. */
  120552. showExplorer?: boolean;
  120553. /**
  120554. * Display the property inspector
  120555. */
  120556. showInspector?: boolean;
  120557. /**
  120558. * Display in embed mode (both panes on the right)
  120559. */
  120560. embedMode?: boolean;
  120561. /**
  120562. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  120563. */
  120564. handleResize?: boolean;
  120565. /**
  120566. * Allow the panes to popup (default: true)
  120567. */
  120568. enablePopup?: boolean;
  120569. /**
  120570. * Allow the panes to be closed by users (default: true)
  120571. */
  120572. enableClose?: boolean;
  120573. /**
  120574. * Optional list of extensibility entries
  120575. */
  120576. explorerExtensibility?: IExplorerExtensibilityGroup[];
  120577. /**
  120578. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  120579. */
  120580. inspectorURL?: string;
  120581. /**
  120582. * Optional initial tab (default to DebugLayerTab.Properties)
  120583. */
  120584. initialTab?: DebugLayerTab;
  120585. }
  120586. interface Scene {
  120587. /**
  120588. * @hidden
  120589. * Backing field
  120590. */
  120591. _debugLayer: DebugLayer;
  120592. /**
  120593. * Gets the debug layer (aka Inspector) associated with the scene
  120594. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120595. */
  120596. debugLayer: DebugLayer;
  120597. }
  120598. /**
  120599. * Enum of inspector action tab
  120600. */
  120601. export enum DebugLayerTab {
  120602. /**
  120603. * Properties tag (default)
  120604. */
  120605. Properties = 0,
  120606. /**
  120607. * Debug tab
  120608. */
  120609. Debug = 1,
  120610. /**
  120611. * Statistics tab
  120612. */
  120613. Statistics = 2,
  120614. /**
  120615. * Tools tab
  120616. */
  120617. Tools = 3,
  120618. /**
  120619. * Settings tab
  120620. */
  120621. Settings = 4
  120622. }
  120623. /**
  120624. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120625. * what is happening in your scene
  120626. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120627. */
  120628. export class DebugLayer {
  120629. /**
  120630. * Define the url to get the inspector script from.
  120631. * By default it uses the babylonjs CDN.
  120632. * @ignoreNaming
  120633. */
  120634. static InspectorURL: string;
  120635. private _scene;
  120636. private BJSINSPECTOR;
  120637. private _onPropertyChangedObservable?;
  120638. /**
  120639. * Observable triggered when a property is changed through the inspector.
  120640. */
  120641. get onPropertyChangedObservable(): any;
  120642. /**
  120643. * Instantiates a new debug layer.
  120644. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120645. * what is happening in your scene
  120646. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120647. * @param scene Defines the scene to inspect
  120648. */
  120649. constructor(scene: Scene);
  120650. /** Creates the inspector window. */
  120651. private _createInspector;
  120652. /**
  120653. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  120654. * @param entity defines the entity to select
  120655. * @param lineContainerTitle defines the specific block to highlight
  120656. */
  120657. select(entity: any, lineContainerTitle?: string): void;
  120658. /** Get the inspector from bundle or global */
  120659. private _getGlobalInspector;
  120660. /**
  120661. * Get if the inspector is visible or not.
  120662. * @returns true if visible otherwise, false
  120663. */
  120664. isVisible(): boolean;
  120665. /**
  120666. * Hide the inspector and close its window.
  120667. */
  120668. hide(): void;
  120669. /**
  120670. * Launch the debugLayer.
  120671. * @param config Define the configuration of the inspector
  120672. * @return a promise fulfilled when the debug layer is visible
  120673. */
  120674. show(config?: IInspectorOptions): Promise<DebugLayer>;
  120675. }
  120676. }
  120677. declare module BABYLON {
  120678. /**
  120679. * Class containing static functions to help procedurally build meshes
  120680. */
  120681. export class BoxBuilder {
  120682. /**
  120683. * Creates a box mesh
  120684. * * The parameter `size` sets the size (float) of each box side (default 1)
  120685. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120686. * * 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)
  120687. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120691. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120692. * @param name defines the name of the mesh
  120693. * @param options defines the options used to create the mesh
  120694. * @param scene defines the hosting scene
  120695. * @returns the box mesh
  120696. */
  120697. static CreateBox(name: string, options: {
  120698. size?: number;
  120699. width?: number;
  120700. height?: number;
  120701. depth?: number;
  120702. faceUV?: Vector4[];
  120703. faceColors?: Color4[];
  120704. sideOrientation?: number;
  120705. frontUVs?: Vector4;
  120706. backUVs?: Vector4;
  120707. wrap?: boolean;
  120708. topBaseAt?: number;
  120709. bottomBaseAt?: number;
  120710. updatable?: boolean;
  120711. }, scene?: Nullable<Scene>): Mesh;
  120712. }
  120713. }
  120714. declare module BABYLON.Debug {
  120715. /**
  120716. * Used to show the physics impostor around the specific mesh
  120717. */
  120718. export class PhysicsViewer {
  120719. /** @hidden */
  120720. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  120721. /** @hidden */
  120722. protected _meshes: Array<Nullable<AbstractMesh>>;
  120723. /** @hidden */
  120724. protected _scene: Nullable<Scene>;
  120725. /** @hidden */
  120726. protected _numMeshes: number;
  120727. /** @hidden */
  120728. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  120729. private _renderFunction;
  120730. private _utilityLayer;
  120731. private _debugBoxMesh;
  120732. private _debugSphereMesh;
  120733. private _debugCylinderMesh;
  120734. private _debugMaterial;
  120735. private _debugMeshMeshes;
  120736. /**
  120737. * Creates a new PhysicsViewer
  120738. * @param scene defines the hosting scene
  120739. */
  120740. constructor(scene: Scene);
  120741. /** @hidden */
  120742. protected _updateDebugMeshes(): void;
  120743. /**
  120744. * Renders a specified physic impostor
  120745. * @param impostor defines the impostor to render
  120746. * @param targetMesh defines the mesh represented by the impostor
  120747. * @returns the new debug mesh used to render the impostor
  120748. */
  120749. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  120750. /**
  120751. * Hides a specified physic impostor
  120752. * @param impostor defines the impostor to hide
  120753. */
  120754. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  120755. private _getDebugMaterial;
  120756. private _getDebugBoxMesh;
  120757. private _getDebugSphereMesh;
  120758. private _getDebugCylinderMesh;
  120759. private _getDebugMeshMesh;
  120760. private _getDebugMesh;
  120761. /** Releases all resources */
  120762. dispose(): void;
  120763. }
  120764. }
  120765. declare module BABYLON {
  120766. /**
  120767. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120768. * in order to better appreciate the issue one might have.
  120769. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120770. */
  120771. export class RayHelper {
  120772. /**
  120773. * Defines the ray we are currently tryin to visualize.
  120774. */
  120775. ray: Nullable<Ray>;
  120776. private _renderPoints;
  120777. private _renderLine;
  120778. private _renderFunction;
  120779. private _scene;
  120780. private _updateToMeshFunction;
  120781. private _attachedToMesh;
  120782. private _meshSpaceDirection;
  120783. private _meshSpaceOrigin;
  120784. /**
  120785. * Helper function to create a colored helper in a scene in one line.
  120786. * @param ray Defines the ray we are currently tryin to visualize
  120787. * @param scene Defines the scene the ray is used in
  120788. * @param color Defines the color we want to see the ray in
  120789. * @returns The newly created ray helper.
  120790. */
  120791. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  120792. /**
  120793. * Instantiate a new ray helper.
  120794. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120795. * in order to better appreciate the issue one might have.
  120796. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120797. * @param ray Defines the ray we are currently tryin to visualize
  120798. */
  120799. constructor(ray: Ray);
  120800. /**
  120801. * Shows the ray we are willing to debug.
  120802. * @param scene Defines the scene the ray needs to be rendered in
  120803. * @param color Defines the color the ray needs to be rendered in
  120804. */
  120805. show(scene: Scene, color?: Color3): void;
  120806. /**
  120807. * Hides the ray we are debugging.
  120808. */
  120809. hide(): void;
  120810. private _render;
  120811. /**
  120812. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  120813. * @param mesh Defines the mesh we want the helper attached to
  120814. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  120815. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  120816. * @param length Defines the length of the ray
  120817. */
  120818. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  120819. /**
  120820. * Detach the ray helper from the mesh it has previously been attached to.
  120821. */
  120822. detachFromMesh(): void;
  120823. private _updateToMesh;
  120824. /**
  120825. * Dispose the helper and release its associated resources.
  120826. */
  120827. dispose(): void;
  120828. }
  120829. }
  120830. declare module BABYLON.Debug {
  120831. /**
  120832. * Class used to render a debug view of a given skeleton
  120833. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  120834. */
  120835. export class SkeletonViewer {
  120836. /** defines the skeleton to render */
  120837. skeleton: Skeleton;
  120838. /** defines the mesh attached to the skeleton */
  120839. mesh: AbstractMesh;
  120840. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  120841. autoUpdateBonesMatrices: boolean;
  120842. /** defines the rendering group id to use with the viewer */
  120843. renderingGroupId: number;
  120844. /** Gets or sets the color used to render the skeleton */
  120845. color: Color3;
  120846. private _scene;
  120847. private _debugLines;
  120848. private _debugMesh;
  120849. private _isEnabled;
  120850. private _renderFunction;
  120851. private _utilityLayer;
  120852. /**
  120853. * Returns the mesh used to render the bones
  120854. */
  120855. get debugMesh(): Nullable<LinesMesh>;
  120856. /**
  120857. * Creates a new SkeletonViewer
  120858. * @param skeleton defines the skeleton to render
  120859. * @param mesh defines the mesh attached to the skeleton
  120860. * @param scene defines the hosting scene
  120861. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  120862. * @param renderingGroupId defines the rendering group id to use with the viewer
  120863. */
  120864. constructor(
  120865. /** defines the skeleton to render */
  120866. skeleton: Skeleton,
  120867. /** defines the mesh attached to the skeleton */
  120868. mesh: AbstractMesh, scene: Scene,
  120869. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  120870. autoUpdateBonesMatrices?: boolean,
  120871. /** defines the rendering group id to use with the viewer */
  120872. renderingGroupId?: number);
  120873. /** Gets or sets a boolean indicating if the viewer is enabled */
  120874. set isEnabled(value: boolean);
  120875. get isEnabled(): boolean;
  120876. private _getBonePosition;
  120877. private _getLinesForBonesWithLength;
  120878. private _getLinesForBonesNoLength;
  120879. /** Update the viewer to sync with current skeleton state */
  120880. update(): void;
  120881. /** Release associated resources */
  120882. dispose(): void;
  120883. }
  120884. }
  120885. declare module BABYLON {
  120886. /**
  120887. * Options to create the null engine
  120888. */
  120889. export class NullEngineOptions {
  120890. /**
  120891. * Render width (Default: 512)
  120892. */
  120893. renderWidth: number;
  120894. /**
  120895. * Render height (Default: 256)
  120896. */
  120897. renderHeight: number;
  120898. /**
  120899. * Texture size (Default: 512)
  120900. */
  120901. textureSize: number;
  120902. /**
  120903. * If delta time between frames should be constant
  120904. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120905. */
  120906. deterministicLockstep: boolean;
  120907. /**
  120908. * Maximum about of steps between frames (Default: 4)
  120909. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120910. */
  120911. lockstepMaxSteps: number;
  120912. }
  120913. /**
  120914. * The null engine class provides support for headless version of babylon.js.
  120915. * This can be used in server side scenario or for testing purposes
  120916. */
  120917. export class NullEngine extends Engine {
  120918. private _options;
  120919. /**
  120920. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  120921. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120922. * @returns true if engine is in deterministic lock step mode
  120923. */
  120924. isDeterministicLockStep(): boolean;
  120925. /**
  120926. * Gets the max steps when engine is running in deterministic lock step
  120927. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120928. * @returns the max steps
  120929. */
  120930. getLockstepMaxSteps(): number;
  120931. /**
  120932. * Gets the current hardware scaling level.
  120933. * By default the hardware scaling level is computed from the window device ratio.
  120934. * 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.
  120935. * @returns a number indicating the current hardware scaling level
  120936. */
  120937. getHardwareScalingLevel(): number;
  120938. constructor(options?: NullEngineOptions);
  120939. /**
  120940. * Creates a vertex buffer
  120941. * @param vertices the data for the vertex buffer
  120942. * @returns the new WebGL static buffer
  120943. */
  120944. createVertexBuffer(vertices: FloatArray): DataBuffer;
  120945. /**
  120946. * Creates a new index buffer
  120947. * @param indices defines the content of the index buffer
  120948. * @param updatable defines if the index buffer must be updatable
  120949. * @returns a new webGL buffer
  120950. */
  120951. createIndexBuffer(indices: IndicesArray): DataBuffer;
  120952. /**
  120953. * Clear the current render buffer or the current render target (if any is set up)
  120954. * @param color defines the color to use
  120955. * @param backBuffer defines if the back buffer must be cleared
  120956. * @param depth defines if the depth buffer must be cleared
  120957. * @param stencil defines if the stencil buffer must be cleared
  120958. */
  120959. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120960. /**
  120961. * Gets the current render width
  120962. * @param useScreen defines if screen size must be used (or the current render target if any)
  120963. * @returns a number defining the current render width
  120964. */
  120965. getRenderWidth(useScreen?: boolean): number;
  120966. /**
  120967. * Gets the current render height
  120968. * @param useScreen defines if screen size must be used (or the current render target if any)
  120969. * @returns a number defining the current render height
  120970. */
  120971. getRenderHeight(useScreen?: boolean): number;
  120972. /**
  120973. * Set the WebGL's viewport
  120974. * @param viewport defines the viewport element to be used
  120975. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120976. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120977. */
  120978. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120979. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  120980. /**
  120981. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120982. * @param pipelineContext defines the pipeline context to use
  120983. * @param uniformsNames defines the list of uniform names
  120984. * @returns an array of webGL uniform locations
  120985. */
  120986. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120987. /**
  120988. * Gets the lsit of active attributes for a given webGL program
  120989. * @param pipelineContext defines the pipeline context to use
  120990. * @param attributesNames defines the list of attribute names to get
  120991. * @returns an array of indices indicating the offset of each attribute
  120992. */
  120993. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120994. /**
  120995. * Binds an effect to the webGL context
  120996. * @param effect defines the effect to bind
  120997. */
  120998. bindSamplers(effect: Effect): void;
  120999. /**
  121000. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121001. * @param effect defines the effect to activate
  121002. */
  121003. enableEffect(effect: Effect): void;
  121004. /**
  121005. * Set various states to the webGL context
  121006. * @param culling defines backface culling state
  121007. * @param zOffset defines the value to apply to zOffset (0 by default)
  121008. * @param force defines if states must be applied even if cache is up to date
  121009. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121010. */
  121011. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121012. /**
  121013. * Set the value of an uniform to an array of int32
  121014. * @param uniform defines the webGL uniform location where to store the value
  121015. * @param array defines the array of int32 to store
  121016. */
  121017. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121018. /**
  121019. * Set the value of an uniform to an array of int32 (stored as vec2)
  121020. * @param uniform defines the webGL uniform location where to store the value
  121021. * @param array defines the array of int32 to store
  121022. */
  121023. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121024. /**
  121025. * Set the value of an uniform to an array of int32 (stored as vec3)
  121026. * @param uniform defines the webGL uniform location where to store the value
  121027. * @param array defines the array of int32 to store
  121028. */
  121029. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121030. /**
  121031. * Set the value of an uniform to an array of int32 (stored as vec4)
  121032. * @param uniform defines the webGL uniform location where to store the value
  121033. * @param array defines the array of int32 to store
  121034. */
  121035. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121036. /**
  121037. * Set the value of an uniform to an array of float32
  121038. * @param uniform defines the webGL uniform location where to store the value
  121039. * @param array defines the array of float32 to store
  121040. */
  121041. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121042. /**
  121043. * Set the value of an uniform to an array of float32 (stored as vec2)
  121044. * @param uniform defines the webGL uniform location where to store the value
  121045. * @param array defines the array of float32 to store
  121046. */
  121047. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121048. /**
  121049. * Set the value of an uniform to an array of float32 (stored as vec3)
  121050. * @param uniform defines the webGL uniform location where to store the value
  121051. * @param array defines the array of float32 to store
  121052. */
  121053. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121054. /**
  121055. * Set the value of an uniform to an array of float32 (stored as vec4)
  121056. * @param uniform defines the webGL uniform location where to store the value
  121057. * @param array defines the array of float32 to store
  121058. */
  121059. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121060. /**
  121061. * Set the value of an uniform to an array of number
  121062. * @param uniform defines the webGL uniform location where to store the value
  121063. * @param array defines the array of number to store
  121064. */
  121065. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121066. /**
  121067. * Set the value of an uniform to an array of number (stored as vec2)
  121068. * @param uniform defines the webGL uniform location where to store the value
  121069. * @param array defines the array of number to store
  121070. */
  121071. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121072. /**
  121073. * Set the value of an uniform to an array of number (stored as vec3)
  121074. * @param uniform defines the webGL uniform location where to store the value
  121075. * @param array defines the array of number to store
  121076. */
  121077. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121078. /**
  121079. * Set the value of an uniform to an array of number (stored as vec4)
  121080. * @param uniform defines the webGL uniform location where to store the value
  121081. * @param array defines the array of number to store
  121082. */
  121083. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121084. /**
  121085. * Set the value of an uniform to an array of float32 (stored as matrices)
  121086. * @param uniform defines the webGL uniform location where to store the value
  121087. * @param matrices defines the array of float32 to store
  121088. */
  121089. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121090. /**
  121091. * Set the value of an uniform to a matrix (3x3)
  121092. * @param uniform defines the webGL uniform location where to store the value
  121093. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121094. */
  121095. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121096. /**
  121097. * Set the value of an uniform to a matrix (2x2)
  121098. * @param uniform defines the webGL uniform location where to store the value
  121099. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121100. */
  121101. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121102. /**
  121103. * Set the value of an uniform to a number (float)
  121104. * @param uniform defines the webGL uniform location where to store the value
  121105. * @param value defines the float number to store
  121106. */
  121107. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121108. /**
  121109. * Set the value of an uniform to a vec2
  121110. * @param uniform defines the webGL uniform location where to store the value
  121111. * @param x defines the 1st component of the value
  121112. * @param y defines the 2nd component of the value
  121113. */
  121114. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121115. /**
  121116. * Set the value of an uniform to a vec3
  121117. * @param uniform defines the webGL uniform location where to store the value
  121118. * @param x defines the 1st component of the value
  121119. * @param y defines the 2nd component of the value
  121120. * @param z defines the 3rd component of the value
  121121. */
  121122. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121123. /**
  121124. * Set the value of an uniform to a boolean
  121125. * @param uniform defines the webGL uniform location where to store the value
  121126. * @param bool defines the boolean to store
  121127. */
  121128. setBool(uniform: WebGLUniformLocation, bool: number): void;
  121129. /**
  121130. * Set the value of an uniform to a vec4
  121131. * @param uniform defines the webGL uniform location where to store the value
  121132. * @param x defines the 1st component of the value
  121133. * @param y defines the 2nd component of the value
  121134. * @param z defines the 3rd component of the value
  121135. * @param w defines the 4th component of the value
  121136. */
  121137. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121138. /**
  121139. * Sets the current alpha mode
  121140. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  121141. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121142. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121143. */
  121144. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121145. /**
  121146. * Bind webGl buffers directly to the webGL context
  121147. * @param vertexBuffers defines the vertex buffer to bind
  121148. * @param indexBuffer defines the index buffer to bind
  121149. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121150. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121151. * @param effect defines the effect associated with the vertex buffer
  121152. */
  121153. bindBuffers(vertexBuffers: {
  121154. [key: string]: VertexBuffer;
  121155. }, indexBuffer: DataBuffer, effect: Effect): void;
  121156. /**
  121157. * Force the entire cache to be cleared
  121158. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121159. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121160. */
  121161. wipeCaches(bruteForce?: boolean): void;
  121162. /**
  121163. * Send a draw order
  121164. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121165. * @param indexStart defines the starting index
  121166. * @param indexCount defines the number of index to draw
  121167. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121168. */
  121169. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121170. /**
  121171. * Draw a list of indexed primitives
  121172. * @param fillMode defines the primitive to use
  121173. * @param indexStart defines the starting index
  121174. * @param indexCount defines the number of index to draw
  121175. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121176. */
  121177. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121178. /**
  121179. * Draw a list of unindexed primitives
  121180. * @param fillMode defines the primitive to use
  121181. * @param verticesStart defines the index of first vertex to draw
  121182. * @param verticesCount defines the count of vertices to draw
  121183. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121184. */
  121185. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121186. /** @hidden */
  121187. _createTexture(): WebGLTexture;
  121188. /** @hidden */
  121189. _releaseTexture(texture: InternalTexture): void;
  121190. /**
  121191. * Usually called from Texture.ts.
  121192. * Passed information to create a WebGLTexture
  121193. * @param urlArg defines a value which contains one of the following:
  121194. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121195. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121196. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121197. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121198. * @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)
  121199. * @param scene needed for loading to the correct scene
  121200. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121201. * @param onLoad optional callback to be called upon successful completion
  121202. * @param onError optional callback to be called upon failure
  121203. * @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
  121204. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121205. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121206. * @param forcedExtension defines the extension to use to pick the right loader
  121207. * @param mimeType defines an optional mime type
  121208. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121209. */
  121210. 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;
  121211. /**
  121212. * Creates a new render target texture
  121213. * @param size defines the size of the texture
  121214. * @param options defines the options used to create the texture
  121215. * @returns a new render target texture stored in an InternalTexture
  121216. */
  121217. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  121218. /**
  121219. * Update the sampling mode of a given texture
  121220. * @param samplingMode defines the required sampling mode
  121221. * @param texture defines the texture to update
  121222. */
  121223. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121224. /**
  121225. * Binds the frame buffer to the specified texture.
  121226. * @param texture The texture to render to or null for the default canvas
  121227. * @param faceIndex The face of the texture to render to in case of cube texture
  121228. * @param requiredWidth The width of the target to render to
  121229. * @param requiredHeight The height of the target to render to
  121230. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121231. * @param lodLevel defines le lod level to bind to the frame buffer
  121232. */
  121233. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121234. /**
  121235. * Unbind the current render target texture from the webGL context
  121236. * @param texture defines the render target texture to unbind
  121237. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121238. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121239. */
  121240. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121241. /**
  121242. * Creates a dynamic vertex buffer
  121243. * @param vertices the data for the dynamic vertex buffer
  121244. * @returns the new WebGL dynamic buffer
  121245. */
  121246. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  121247. /**
  121248. * Update the content of a dynamic texture
  121249. * @param texture defines the texture to update
  121250. * @param canvas defines the canvas containing the source
  121251. * @param invertY defines if data must be stored with Y axis inverted
  121252. * @param premulAlpha defines if alpha is stored as premultiplied
  121253. * @param format defines the format of the data
  121254. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  121255. */
  121256. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  121257. /**
  121258. * Gets a boolean indicating if all created effects are ready
  121259. * @returns true if all effects are ready
  121260. */
  121261. areAllEffectsReady(): boolean;
  121262. /**
  121263. * @hidden
  121264. * Get the current error code of the webGL context
  121265. * @returns the error code
  121266. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121267. */
  121268. getError(): number;
  121269. /** @hidden */
  121270. _getUnpackAlignement(): number;
  121271. /** @hidden */
  121272. _unpackFlipY(value: boolean): void;
  121273. /**
  121274. * Update a dynamic index buffer
  121275. * @param indexBuffer defines the target index buffer
  121276. * @param indices defines the data to update
  121277. * @param offset defines the offset in the target index buffer where update should start
  121278. */
  121279. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  121280. /**
  121281. * Updates a dynamic vertex buffer.
  121282. * @param vertexBuffer the vertex buffer to update
  121283. * @param vertices the data used to update the vertex buffer
  121284. * @param byteOffset the byte offset of the data (optional)
  121285. * @param byteLength the byte length of the data (optional)
  121286. */
  121287. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  121288. /** @hidden */
  121289. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  121290. /** @hidden */
  121291. _bindTexture(channel: number, texture: InternalTexture): void;
  121292. protected _deleteBuffer(buffer: WebGLBuffer): void;
  121293. /**
  121294. * 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
  121295. */
  121296. releaseEffects(): void;
  121297. displayLoadingUI(): void;
  121298. hideLoadingUI(): void;
  121299. /** @hidden */
  121300. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121301. /** @hidden */
  121302. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121303. /** @hidden */
  121304. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121305. /** @hidden */
  121306. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121307. }
  121308. }
  121309. declare module BABYLON {
  121310. /**
  121311. * @hidden
  121312. **/
  121313. export class _TimeToken {
  121314. _startTimeQuery: Nullable<WebGLQuery>;
  121315. _endTimeQuery: Nullable<WebGLQuery>;
  121316. _timeElapsedQuery: Nullable<WebGLQuery>;
  121317. _timeElapsedQueryEnded: boolean;
  121318. }
  121319. }
  121320. declare module BABYLON {
  121321. /** @hidden */
  121322. export class _OcclusionDataStorage {
  121323. /** @hidden */
  121324. occlusionInternalRetryCounter: number;
  121325. /** @hidden */
  121326. isOcclusionQueryInProgress: boolean;
  121327. /** @hidden */
  121328. isOccluded: boolean;
  121329. /** @hidden */
  121330. occlusionRetryCount: number;
  121331. /** @hidden */
  121332. occlusionType: number;
  121333. /** @hidden */
  121334. occlusionQueryAlgorithmType: number;
  121335. }
  121336. interface Engine {
  121337. /**
  121338. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  121339. * @return the new query
  121340. */
  121341. createQuery(): WebGLQuery;
  121342. /**
  121343. * Delete and release a webGL query
  121344. * @param query defines the query to delete
  121345. * @return the current engine
  121346. */
  121347. deleteQuery(query: WebGLQuery): Engine;
  121348. /**
  121349. * Check if a given query has resolved and got its value
  121350. * @param query defines the query to check
  121351. * @returns true if the query got its value
  121352. */
  121353. isQueryResultAvailable(query: WebGLQuery): boolean;
  121354. /**
  121355. * Gets the value of a given query
  121356. * @param query defines the query to check
  121357. * @returns the value of the query
  121358. */
  121359. getQueryResult(query: WebGLQuery): number;
  121360. /**
  121361. * Initiates an occlusion query
  121362. * @param algorithmType defines the algorithm to use
  121363. * @param query defines the query to use
  121364. * @returns the current engine
  121365. * @see http://doc.babylonjs.com/features/occlusionquery
  121366. */
  121367. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  121368. /**
  121369. * Ends an occlusion query
  121370. * @see http://doc.babylonjs.com/features/occlusionquery
  121371. * @param algorithmType defines the algorithm to use
  121372. * @returns the current engine
  121373. */
  121374. endOcclusionQuery(algorithmType: number): Engine;
  121375. /**
  121376. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  121377. * Please note that only one query can be issued at a time
  121378. * @returns a time token used to track the time span
  121379. */
  121380. startTimeQuery(): Nullable<_TimeToken>;
  121381. /**
  121382. * Ends a time query
  121383. * @param token defines the token used to measure the time span
  121384. * @returns the time spent (in ns)
  121385. */
  121386. endTimeQuery(token: _TimeToken): int;
  121387. /** @hidden */
  121388. _currentNonTimestampToken: Nullable<_TimeToken>;
  121389. /** @hidden */
  121390. _createTimeQuery(): WebGLQuery;
  121391. /** @hidden */
  121392. _deleteTimeQuery(query: WebGLQuery): void;
  121393. /** @hidden */
  121394. _getGlAlgorithmType(algorithmType: number): number;
  121395. /** @hidden */
  121396. _getTimeQueryResult(query: WebGLQuery): any;
  121397. /** @hidden */
  121398. _getTimeQueryAvailability(query: WebGLQuery): any;
  121399. }
  121400. interface AbstractMesh {
  121401. /**
  121402. * Backing filed
  121403. * @hidden
  121404. */
  121405. __occlusionDataStorage: _OcclusionDataStorage;
  121406. /**
  121407. * Access property
  121408. * @hidden
  121409. */
  121410. _occlusionDataStorage: _OcclusionDataStorage;
  121411. /**
  121412. * 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.
  121413. * The default value is -1 which means don't break the query and wait till the result
  121414. * @see http://doc.babylonjs.com/features/occlusionquery
  121415. */
  121416. occlusionRetryCount: number;
  121417. /**
  121418. * 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:
  121419. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  121420. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  121421. * * 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.
  121422. * @see http://doc.babylonjs.com/features/occlusionquery
  121423. */
  121424. occlusionType: number;
  121425. /**
  121426. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  121427. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  121428. * * 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.
  121429. * @see http://doc.babylonjs.com/features/occlusionquery
  121430. */
  121431. occlusionQueryAlgorithmType: number;
  121432. /**
  121433. * 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
  121434. * @see http://doc.babylonjs.com/features/occlusionquery
  121435. */
  121436. isOccluded: boolean;
  121437. /**
  121438. * Flag to check the progress status of the query
  121439. * @see http://doc.babylonjs.com/features/occlusionquery
  121440. */
  121441. isOcclusionQueryInProgress: boolean;
  121442. }
  121443. }
  121444. declare module BABYLON {
  121445. /** @hidden */
  121446. export var _forceTransformFeedbackToBundle: boolean;
  121447. interface Engine {
  121448. /**
  121449. * Creates a webGL transform feedback object
  121450. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  121451. * @returns the webGL transform feedback object
  121452. */
  121453. createTransformFeedback(): WebGLTransformFeedback;
  121454. /**
  121455. * Delete a webGL transform feedback object
  121456. * @param value defines the webGL transform feedback object to delete
  121457. */
  121458. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  121459. /**
  121460. * Bind a webGL transform feedback object to the webgl context
  121461. * @param value defines the webGL transform feedback object to bind
  121462. */
  121463. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  121464. /**
  121465. * Begins a transform feedback operation
  121466. * @param usePoints defines if points or triangles must be used
  121467. */
  121468. beginTransformFeedback(usePoints: boolean): void;
  121469. /**
  121470. * Ends a transform feedback operation
  121471. */
  121472. endTransformFeedback(): void;
  121473. /**
  121474. * Specify the varyings to use with transform feedback
  121475. * @param program defines the associated webGL program
  121476. * @param value defines the list of strings representing the varying names
  121477. */
  121478. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  121479. /**
  121480. * Bind a webGL buffer for a transform feedback operation
  121481. * @param value defines the webGL buffer to bind
  121482. */
  121483. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  121484. }
  121485. }
  121486. declare module BABYLON {
  121487. /**
  121488. * Creation options of the multi render target texture.
  121489. */
  121490. export interface IMultiRenderTargetOptions {
  121491. /**
  121492. * Define if the texture needs to create mip maps after render.
  121493. */
  121494. generateMipMaps?: boolean;
  121495. /**
  121496. * Define the types of all the draw buffers we want to create
  121497. */
  121498. types?: number[];
  121499. /**
  121500. * Define the sampling modes of all the draw buffers we want to create
  121501. */
  121502. samplingModes?: number[];
  121503. /**
  121504. * Define if a depth buffer is required
  121505. */
  121506. generateDepthBuffer?: boolean;
  121507. /**
  121508. * Define if a stencil buffer is required
  121509. */
  121510. generateStencilBuffer?: boolean;
  121511. /**
  121512. * Define if a depth texture is required instead of a depth buffer
  121513. */
  121514. generateDepthTexture?: boolean;
  121515. /**
  121516. * Define the number of desired draw buffers
  121517. */
  121518. textureCount?: number;
  121519. /**
  121520. * Define if aspect ratio should be adapted to the texture or stay the scene one
  121521. */
  121522. doNotChangeAspectRatio?: boolean;
  121523. /**
  121524. * Define the default type of the buffers we are creating
  121525. */
  121526. defaultType?: number;
  121527. }
  121528. /**
  121529. * A multi render target, like a render target provides the ability to render to a texture.
  121530. * Unlike the render target, it can render to several draw buffers in one draw.
  121531. * This is specially interesting in deferred rendering or for any effects requiring more than
  121532. * just one color from a single pass.
  121533. */
  121534. export class MultiRenderTarget extends RenderTargetTexture {
  121535. private _internalTextures;
  121536. private _textures;
  121537. private _multiRenderTargetOptions;
  121538. /**
  121539. * Get if draw buffers are currently supported by the used hardware and browser.
  121540. */
  121541. get isSupported(): boolean;
  121542. /**
  121543. * Get the list of textures generated by the multi render target.
  121544. */
  121545. get textures(): Texture[];
  121546. /**
  121547. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  121548. */
  121549. get depthTexture(): Texture;
  121550. /**
  121551. * Set the wrapping mode on U of all the textures we are rendering to.
  121552. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121553. */
  121554. set wrapU(wrap: number);
  121555. /**
  121556. * Set the wrapping mode on V of all the textures we are rendering to.
  121557. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121558. */
  121559. set wrapV(wrap: number);
  121560. /**
  121561. * Instantiate a new multi render target texture.
  121562. * A multi render target, like a render target provides the ability to render to a texture.
  121563. * Unlike the render target, it can render to several draw buffers in one draw.
  121564. * This is specially interesting in deferred rendering or for any effects requiring more than
  121565. * just one color from a single pass.
  121566. * @param name Define the name of the texture
  121567. * @param size Define the size of the buffers to render to
  121568. * @param count Define the number of target we are rendering into
  121569. * @param scene Define the scene the texture belongs to
  121570. * @param options Define the options used to create the multi render target
  121571. */
  121572. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  121573. /** @hidden */
  121574. _rebuild(): void;
  121575. private _createInternalTextures;
  121576. private _createTextures;
  121577. /**
  121578. * Define the number of samples used if MSAA is enabled.
  121579. */
  121580. get samples(): number;
  121581. set samples(value: number);
  121582. /**
  121583. * Resize all the textures in the multi render target.
  121584. * Be carrefull as it will recreate all the data in the new texture.
  121585. * @param size Define the new size
  121586. */
  121587. resize(size: any): void;
  121588. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  121589. /**
  121590. * Dispose the render targets and their associated resources
  121591. */
  121592. dispose(): void;
  121593. /**
  121594. * Release all the underlying texture used as draw buffers.
  121595. */
  121596. releaseInternalTextures(): void;
  121597. }
  121598. }
  121599. declare module BABYLON {
  121600. interface ThinEngine {
  121601. /**
  121602. * Unbind a list of render target textures from the webGL context
  121603. * This is used only when drawBuffer extension or webGL2 are active
  121604. * @param textures defines the render target textures to unbind
  121605. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121606. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121607. */
  121608. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  121609. /**
  121610. * Create a multi render target texture
  121611. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  121612. * @param size defines the size of the texture
  121613. * @param options defines the creation options
  121614. * @returns the cube texture as an InternalTexture
  121615. */
  121616. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  121617. /**
  121618. * Update the sample count for a given multiple render target texture
  121619. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121620. * @param textures defines the textures to update
  121621. * @param samples defines the sample count to set
  121622. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121623. */
  121624. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  121625. }
  121626. }
  121627. declare module BABYLON {
  121628. /**
  121629. * Class used to define an additional view for the engine
  121630. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121631. */
  121632. export class EngineView {
  121633. /** Defines the canvas where to render the view */
  121634. target: HTMLCanvasElement;
  121635. /** Defines an optional camera used to render the view (will use active camera else) */
  121636. camera?: Camera;
  121637. }
  121638. interface Engine {
  121639. /**
  121640. * Gets or sets the HTML element to use for attaching events
  121641. */
  121642. inputElement: Nullable<HTMLElement>;
  121643. /**
  121644. * Gets the current engine view
  121645. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121646. */
  121647. activeView: Nullable<EngineView>;
  121648. /** Gets or sets the list of views */
  121649. views: EngineView[];
  121650. /**
  121651. * Register a new child canvas
  121652. * @param canvas defines the canvas to register
  121653. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  121654. * @returns the associated view
  121655. */
  121656. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  121657. /**
  121658. * Remove a registered child canvas
  121659. * @param canvas defines the canvas to remove
  121660. * @returns the current engine
  121661. */
  121662. unRegisterView(canvas: HTMLCanvasElement): Engine;
  121663. }
  121664. }
  121665. declare module BABYLON {
  121666. interface Engine {
  121667. /** @hidden */
  121668. _excludedCompressedTextures: string[];
  121669. /** @hidden */
  121670. _textureFormatInUse: string;
  121671. /**
  121672. * Gets the list of texture formats supported
  121673. */
  121674. readonly texturesSupported: Array<string>;
  121675. /**
  121676. * Gets the texture format in use
  121677. */
  121678. readonly textureFormatInUse: Nullable<string>;
  121679. /**
  121680. * Set the compressed texture extensions or file names to skip.
  121681. *
  121682. * @param skippedFiles defines the list of those texture files you want to skip
  121683. * Example: [".dds", ".env", "myfile.png"]
  121684. */
  121685. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  121686. /**
  121687. * Set the compressed texture format to use, based on the formats you have, and the formats
  121688. * supported by the hardware / browser.
  121689. *
  121690. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  121691. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  121692. * to API arguments needed to compressed textures. This puts the burden on the container
  121693. * generator to house the arcane code for determining these for current & future formats.
  121694. *
  121695. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121696. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121697. *
  121698. * Note: The result of this call is not taken into account when a texture is base64.
  121699. *
  121700. * @param formatsAvailable defines the list of those format families you have created
  121701. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  121702. *
  121703. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  121704. * @returns The extension selected.
  121705. */
  121706. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  121707. }
  121708. }
  121709. declare module BABYLON {
  121710. /**
  121711. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  121712. */
  121713. export interface CubeMapInfo {
  121714. /**
  121715. * The pixel array for the front face.
  121716. * This is stored in format, left to right, up to down format.
  121717. */
  121718. front: Nullable<ArrayBufferView>;
  121719. /**
  121720. * The pixel array for the back face.
  121721. * This is stored in format, left to right, up to down format.
  121722. */
  121723. back: Nullable<ArrayBufferView>;
  121724. /**
  121725. * The pixel array for the left face.
  121726. * This is stored in format, left to right, up to down format.
  121727. */
  121728. left: Nullable<ArrayBufferView>;
  121729. /**
  121730. * The pixel array for the right face.
  121731. * This is stored in format, left to right, up to down format.
  121732. */
  121733. right: Nullable<ArrayBufferView>;
  121734. /**
  121735. * The pixel array for the up face.
  121736. * This is stored in format, left to right, up to down format.
  121737. */
  121738. up: Nullable<ArrayBufferView>;
  121739. /**
  121740. * The pixel array for the down face.
  121741. * This is stored in format, left to right, up to down format.
  121742. */
  121743. down: Nullable<ArrayBufferView>;
  121744. /**
  121745. * The size of the cubemap stored.
  121746. *
  121747. * Each faces will be size * size pixels.
  121748. */
  121749. size: number;
  121750. /**
  121751. * The format of the texture.
  121752. *
  121753. * RGBA, RGB.
  121754. */
  121755. format: number;
  121756. /**
  121757. * The type of the texture data.
  121758. *
  121759. * UNSIGNED_INT, FLOAT.
  121760. */
  121761. type: number;
  121762. /**
  121763. * Specifies whether the texture is in gamma space.
  121764. */
  121765. gammaSpace: boolean;
  121766. }
  121767. /**
  121768. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  121769. */
  121770. export class PanoramaToCubeMapTools {
  121771. private static FACE_FRONT;
  121772. private static FACE_BACK;
  121773. private static FACE_RIGHT;
  121774. private static FACE_LEFT;
  121775. private static FACE_DOWN;
  121776. private static FACE_UP;
  121777. /**
  121778. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  121779. *
  121780. * @param float32Array The source data.
  121781. * @param inputWidth The width of the input panorama.
  121782. * @param inputHeight The height of the input panorama.
  121783. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  121784. * @return The cubemap data
  121785. */
  121786. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  121787. private static CreateCubemapTexture;
  121788. private static CalcProjectionSpherical;
  121789. }
  121790. }
  121791. declare module BABYLON {
  121792. /**
  121793. * Helper class dealing with the extraction of spherical polynomial dataArray
  121794. * from a cube map.
  121795. */
  121796. export class CubeMapToSphericalPolynomialTools {
  121797. private static FileFaces;
  121798. /**
  121799. * Converts a texture to the according Spherical Polynomial data.
  121800. * This extracts the first 3 orders only as they are the only one used in the lighting.
  121801. *
  121802. * @param texture The texture to extract the information from.
  121803. * @return The Spherical Polynomial data.
  121804. */
  121805. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  121806. /**
  121807. * Converts a cubemap to the according Spherical Polynomial data.
  121808. * This extracts the first 3 orders only as they are the only one used in the lighting.
  121809. *
  121810. * @param cubeInfo The Cube map to extract the information from.
  121811. * @return The Spherical Polynomial data.
  121812. */
  121813. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  121814. }
  121815. }
  121816. declare module BABYLON {
  121817. interface BaseTexture {
  121818. /**
  121819. * Get the polynomial representation of the texture data.
  121820. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  121821. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  121822. */
  121823. sphericalPolynomial: Nullable<SphericalPolynomial>;
  121824. }
  121825. }
  121826. declare module BABYLON {
  121827. /** @hidden */
  121828. export var rgbdEncodePixelShader: {
  121829. name: string;
  121830. shader: string;
  121831. };
  121832. }
  121833. declare module BABYLON {
  121834. /** @hidden */
  121835. export var rgbdDecodePixelShader: {
  121836. name: string;
  121837. shader: string;
  121838. };
  121839. }
  121840. declare module BABYLON {
  121841. /**
  121842. * Raw texture data and descriptor sufficient for WebGL texture upload
  121843. */
  121844. export interface EnvironmentTextureInfo {
  121845. /**
  121846. * Version of the environment map
  121847. */
  121848. version: number;
  121849. /**
  121850. * Width of image
  121851. */
  121852. width: number;
  121853. /**
  121854. * Irradiance information stored in the file.
  121855. */
  121856. irradiance: any;
  121857. /**
  121858. * Specular information stored in the file.
  121859. */
  121860. specular: any;
  121861. }
  121862. /**
  121863. * Defines One Image in the file. It requires only the position in the file
  121864. * as well as the length.
  121865. */
  121866. interface BufferImageData {
  121867. /**
  121868. * Length of the image data.
  121869. */
  121870. length: number;
  121871. /**
  121872. * Position of the data from the null terminator delimiting the end of the JSON.
  121873. */
  121874. position: number;
  121875. }
  121876. /**
  121877. * Defines the specular data enclosed in the file.
  121878. * This corresponds to the version 1 of the data.
  121879. */
  121880. export interface EnvironmentTextureSpecularInfoV1 {
  121881. /**
  121882. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  121883. */
  121884. specularDataPosition?: number;
  121885. /**
  121886. * This contains all the images data needed to reconstruct the cubemap.
  121887. */
  121888. mipmaps: Array<BufferImageData>;
  121889. /**
  121890. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  121891. */
  121892. lodGenerationScale: number;
  121893. }
  121894. /**
  121895. * Sets of helpers addressing the serialization and deserialization of environment texture
  121896. * stored in a BabylonJS env file.
  121897. * Those files are usually stored as .env files.
  121898. */
  121899. export class EnvironmentTextureTools {
  121900. /**
  121901. * Magic number identifying the env file.
  121902. */
  121903. private static _MagicBytes;
  121904. /**
  121905. * Gets the environment info from an env file.
  121906. * @param data The array buffer containing the .env bytes.
  121907. * @returns the environment file info (the json header) if successfully parsed.
  121908. */
  121909. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  121910. /**
  121911. * Creates an environment texture from a loaded cube texture.
  121912. * @param texture defines the cube texture to convert in env file
  121913. * @return a promise containing the environment data if succesfull.
  121914. */
  121915. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  121916. /**
  121917. * Creates a JSON representation of the spherical data.
  121918. * @param texture defines the texture containing the polynomials
  121919. * @return the JSON representation of the spherical info
  121920. */
  121921. private static _CreateEnvTextureIrradiance;
  121922. /**
  121923. * Creates the ArrayBufferViews used for initializing environment texture image data.
  121924. * @param data the image data
  121925. * @param info parameters that determine what views will be created for accessing the underlying buffer
  121926. * @return the views described by info providing access to the underlying buffer
  121927. */
  121928. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  121929. /**
  121930. * Uploads the texture info contained in the env file to the GPU.
  121931. * @param texture defines the internal texture to upload to
  121932. * @param data defines the data to load
  121933. * @param info defines the texture info retrieved through the GetEnvInfo method
  121934. * @returns a promise
  121935. */
  121936. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  121937. private static _OnImageReadyAsync;
  121938. /**
  121939. * Uploads the levels of image data to the GPU.
  121940. * @param texture defines the internal texture to upload to
  121941. * @param imageData defines the array buffer views of image data [mipmap][face]
  121942. * @returns a promise
  121943. */
  121944. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  121945. /**
  121946. * Uploads spherical polynomials information to the texture.
  121947. * @param texture defines the texture we are trying to upload the information to
  121948. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  121949. */
  121950. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  121951. /** @hidden */
  121952. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121953. }
  121954. }
  121955. declare module BABYLON {
  121956. /**
  121957. * Contains position and normal vectors for a vertex
  121958. */
  121959. export class PositionNormalVertex {
  121960. /** the position of the vertex (defaut: 0,0,0) */
  121961. position: Vector3;
  121962. /** the normal of the vertex (defaut: 0,1,0) */
  121963. normal: Vector3;
  121964. /**
  121965. * Creates a PositionNormalVertex
  121966. * @param position the position of the vertex (defaut: 0,0,0)
  121967. * @param normal the normal of the vertex (defaut: 0,1,0)
  121968. */
  121969. constructor(
  121970. /** the position of the vertex (defaut: 0,0,0) */
  121971. position?: Vector3,
  121972. /** the normal of the vertex (defaut: 0,1,0) */
  121973. normal?: Vector3);
  121974. /**
  121975. * Clones the PositionNormalVertex
  121976. * @returns the cloned PositionNormalVertex
  121977. */
  121978. clone(): PositionNormalVertex;
  121979. }
  121980. /**
  121981. * Contains position, normal and uv vectors for a vertex
  121982. */
  121983. export class PositionNormalTextureVertex {
  121984. /** the position of the vertex (defaut: 0,0,0) */
  121985. position: Vector3;
  121986. /** the normal of the vertex (defaut: 0,1,0) */
  121987. normal: Vector3;
  121988. /** the uv of the vertex (default: 0,0) */
  121989. uv: Vector2;
  121990. /**
  121991. * Creates a PositionNormalTextureVertex
  121992. * @param position the position of the vertex (defaut: 0,0,0)
  121993. * @param normal the normal of the vertex (defaut: 0,1,0)
  121994. * @param uv the uv of the vertex (default: 0,0)
  121995. */
  121996. constructor(
  121997. /** the position of the vertex (defaut: 0,0,0) */
  121998. position?: Vector3,
  121999. /** the normal of the vertex (defaut: 0,1,0) */
  122000. normal?: Vector3,
  122001. /** the uv of the vertex (default: 0,0) */
  122002. uv?: Vector2);
  122003. /**
  122004. * Clones the PositionNormalTextureVertex
  122005. * @returns the cloned PositionNormalTextureVertex
  122006. */
  122007. clone(): PositionNormalTextureVertex;
  122008. }
  122009. }
  122010. declare module BABYLON {
  122011. /** @hidden */
  122012. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  122013. private _genericAttributeLocation;
  122014. private _varyingLocationCount;
  122015. private _varyingLocationMap;
  122016. private _replacements;
  122017. private _textureCount;
  122018. private _uniforms;
  122019. lineProcessor(line: string): string;
  122020. attributeProcessor(attribute: string): string;
  122021. varyingProcessor(varying: string, isFragment: boolean): string;
  122022. uniformProcessor(uniform: string): string;
  122023. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  122024. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  122025. }
  122026. }
  122027. declare module BABYLON {
  122028. /**
  122029. * Container for accessors for natively-stored mesh data buffers.
  122030. */
  122031. class NativeDataBuffer extends DataBuffer {
  122032. /**
  122033. * Accessor value used to identify/retrieve a natively-stored index buffer.
  122034. */
  122035. nativeIndexBuffer?: any;
  122036. /**
  122037. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  122038. */
  122039. nativeVertexBuffer?: any;
  122040. }
  122041. /** @hidden */
  122042. class NativeTexture extends InternalTexture {
  122043. getInternalTexture(): InternalTexture;
  122044. getViewCount(): number;
  122045. }
  122046. /** @hidden */
  122047. export class NativeEngine extends Engine {
  122048. private readonly _native;
  122049. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  122050. private readonly INVALID_HANDLE;
  122051. getHardwareScalingLevel(): number;
  122052. constructor();
  122053. /**
  122054. * Can be used to override the current requestAnimationFrame requester.
  122055. * @hidden
  122056. */
  122057. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  122058. /**
  122059. * Override default engine behavior.
  122060. * @param color
  122061. * @param backBuffer
  122062. * @param depth
  122063. * @param stencil
  122064. */
  122065. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  122066. /**
  122067. * Gets host document
  122068. * @returns the host document object
  122069. */
  122070. getHostDocument(): Nullable<Document>;
  122071. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122072. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  122073. createVertexBuffer(data: DataArray): NativeDataBuffer;
  122074. recordVertexArrayObject(vertexBuffers: {
  122075. [key: string]: VertexBuffer;
  122076. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  122077. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122078. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122079. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  122080. /**
  122081. * Draw a list of indexed primitives
  122082. * @param fillMode defines the primitive to use
  122083. * @param indexStart defines the starting index
  122084. * @param indexCount defines the number of index to draw
  122085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122086. */
  122087. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  122088. /**
  122089. * Draw a list of unindexed primitives
  122090. * @param fillMode defines the primitive to use
  122091. * @param verticesStart defines the index of first vertex to draw
  122092. * @param verticesCount defines the count of vertices to draw
  122093. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122094. */
  122095. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  122096. createPipelineContext(): IPipelineContext;
  122097. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  122098. /** @hidden */
  122099. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  122100. /** @hidden */
  122101. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  122102. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122103. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122104. protected _setProgram(program: WebGLProgram): void;
  122105. _releaseEffect(effect: Effect): void;
  122106. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122107. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  122108. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  122109. bindSamplers(effect: Effect): void;
  122110. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  122111. getRenderWidth(useScreen?: boolean): number;
  122112. getRenderHeight(useScreen?: boolean): number;
  122113. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  122114. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122115. /**
  122116. * Set the z offset to apply to current rendering
  122117. * @param value defines the offset to apply
  122118. */
  122119. setZOffset(value: number): void;
  122120. /**
  122121. * Gets the current value of the zOffset
  122122. * @returns the current zOffset state
  122123. */
  122124. getZOffset(): number;
  122125. /**
  122126. * Enable or disable depth buffering
  122127. * @param enable defines the state to set
  122128. */
  122129. setDepthBuffer(enable: boolean): void;
  122130. /**
  122131. * Gets a boolean indicating if depth writing is enabled
  122132. * @returns the current depth writing state
  122133. */
  122134. getDepthWrite(): boolean;
  122135. /**
  122136. * Enable or disable depth writing
  122137. * @param enable defines the state to set
  122138. */
  122139. setDepthWrite(enable: boolean): void;
  122140. /**
  122141. * Enable or disable color writing
  122142. * @param enable defines the state to set
  122143. */
  122144. setColorWrite(enable: boolean): void;
  122145. /**
  122146. * Gets a boolean indicating if color writing is enabled
  122147. * @returns the current color writing state
  122148. */
  122149. getColorWrite(): boolean;
  122150. /**
  122151. * Sets alpha constants used by some alpha blending modes
  122152. * @param r defines the red component
  122153. * @param g defines the green component
  122154. * @param b defines the blue component
  122155. * @param a defines the alpha component
  122156. */
  122157. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  122158. /**
  122159. * Sets the current alpha mode
  122160. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  122161. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  122162. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122163. */
  122164. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  122165. /**
  122166. * Gets the current alpha mode
  122167. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122168. * @returns the current alpha mode
  122169. */
  122170. getAlphaMode(): number;
  122171. setInt(uniform: WebGLUniformLocation, int: number): void;
  122172. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  122173. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  122174. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  122175. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  122176. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  122177. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  122178. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  122179. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  122180. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  122181. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  122182. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  122183. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  122184. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  122185. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122186. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122187. setFloat(uniform: WebGLUniformLocation, value: number): void;
  122188. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  122189. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  122190. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  122191. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  122192. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  122193. wipeCaches(bruteForce?: boolean): void;
  122194. _createTexture(): WebGLTexture;
  122195. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  122196. /**
  122197. * Usually called from Texture.ts.
  122198. * Passed information to create a WebGLTexture
  122199. * @param urlArg defines a value which contains one of the following:
  122200. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  122201. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  122202. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  122203. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  122204. * @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)
  122205. * @param scene needed for loading to the correct scene
  122206. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  122207. * @param onLoad optional callback to be called upon successful completion
  122208. * @param onError optional callback to be called upon failure
  122209. * @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
  122210. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  122211. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  122212. * @param forcedExtension defines the extension to use to pick the right loader
  122213. * @param mimeType defines an optional mime type
  122214. * @returns a InternalTexture for assignment back into BABYLON.Texture
  122215. */
  122216. 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;
  122217. /**
  122218. * Creates a cube texture
  122219. * @param rootUrl defines the url where the files to load is located
  122220. * @param scene defines the current scene
  122221. * @param files defines the list of files to load (1 per face)
  122222. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  122223. * @param onLoad defines an optional callback raised when the texture is loaded
  122224. * @param onError defines an optional callback raised if there is an issue to load the texture
  122225. * @param format defines the format of the data
  122226. * @param forcedExtension defines the extension to use to pick the right loader
  122227. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  122228. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122229. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122230. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  122231. * @returns the cube texture as an InternalTexture
  122232. */
  122233. 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;
  122234. private _getSamplingFilter;
  122235. private static _GetNativeTextureFormat;
  122236. createRenderTargetTexture(size: number | {
  122237. width: number;
  122238. height: number;
  122239. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  122240. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  122241. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  122242. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  122243. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  122244. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  122245. /**
  122246. * Updates a dynamic vertex buffer.
  122247. * @param vertexBuffer the vertex buffer to update
  122248. * @param data the data used to update the vertex buffer
  122249. * @param byteOffset the byte offset of the data (optional)
  122250. * @param byteLength the byte length of the data (optional)
  122251. */
  122252. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  122253. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  122254. private _updateAnisotropicLevel;
  122255. private _getAddressMode;
  122256. /** @hidden */
  122257. _bindTexture(channel: number, texture: InternalTexture): void;
  122258. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  122259. releaseEffects(): void;
  122260. /** @hidden */
  122261. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122262. /** @hidden */
  122263. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122264. /** @hidden */
  122265. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122266. /** @hidden */
  122267. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  122268. }
  122269. }
  122270. declare module BABYLON {
  122271. /**
  122272. * Gather the list of clipboard event types as constants.
  122273. */
  122274. export class ClipboardEventTypes {
  122275. /**
  122276. * The clipboard event is fired when a copy command is active (pressed).
  122277. */
  122278. static readonly COPY: number;
  122279. /**
  122280. * The clipboard event is fired when a cut command is active (pressed).
  122281. */
  122282. static readonly CUT: number;
  122283. /**
  122284. * The clipboard event is fired when a paste command is active (pressed).
  122285. */
  122286. static readonly PASTE: number;
  122287. }
  122288. /**
  122289. * This class is used to store clipboard related info for the onClipboardObservable event.
  122290. */
  122291. export class ClipboardInfo {
  122292. /**
  122293. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122294. */
  122295. type: number;
  122296. /**
  122297. * Defines the related dom event
  122298. */
  122299. event: ClipboardEvent;
  122300. /**
  122301. *Creates an instance of ClipboardInfo.
  122302. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  122303. * @param event Defines the related dom event
  122304. */
  122305. constructor(
  122306. /**
  122307. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122308. */
  122309. type: number,
  122310. /**
  122311. * Defines the related dom event
  122312. */
  122313. event: ClipboardEvent);
  122314. /**
  122315. * Get the clipboard event's type from the keycode.
  122316. * @param keyCode Defines the keyCode for the current keyboard event.
  122317. * @return {number}
  122318. */
  122319. static GetTypeFromCharacter(keyCode: number): number;
  122320. }
  122321. }
  122322. declare module BABYLON {
  122323. /**
  122324. * Google Daydream controller
  122325. */
  122326. export class DaydreamController extends WebVRController {
  122327. /**
  122328. * Base Url for the controller model.
  122329. */
  122330. static MODEL_BASE_URL: string;
  122331. /**
  122332. * File name for the controller model.
  122333. */
  122334. static MODEL_FILENAME: string;
  122335. /**
  122336. * Gamepad Id prefix used to identify Daydream Controller.
  122337. */
  122338. static readonly GAMEPAD_ID_PREFIX: string;
  122339. /**
  122340. * Creates a new DaydreamController from a gamepad
  122341. * @param vrGamepad the gamepad that the controller should be created from
  122342. */
  122343. constructor(vrGamepad: any);
  122344. /**
  122345. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122346. * @param scene scene in which to add meshes
  122347. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122348. */
  122349. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122350. /**
  122351. * Called once for each button that changed state since the last frame
  122352. * @param buttonIdx Which button index changed
  122353. * @param state New state of the button
  122354. * @param changes Which properties on the state changed since last frame
  122355. */
  122356. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122357. }
  122358. }
  122359. declare module BABYLON {
  122360. /**
  122361. * Gear VR Controller
  122362. */
  122363. export class GearVRController extends WebVRController {
  122364. /**
  122365. * Base Url for the controller model.
  122366. */
  122367. static MODEL_BASE_URL: string;
  122368. /**
  122369. * File name for the controller model.
  122370. */
  122371. static MODEL_FILENAME: string;
  122372. /**
  122373. * Gamepad Id prefix used to identify this controller.
  122374. */
  122375. static readonly GAMEPAD_ID_PREFIX: string;
  122376. private readonly _buttonIndexToObservableNameMap;
  122377. /**
  122378. * Creates a new GearVRController from a gamepad
  122379. * @param vrGamepad the gamepad that the controller should be created from
  122380. */
  122381. constructor(vrGamepad: any);
  122382. /**
  122383. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122384. * @param scene scene in which to add meshes
  122385. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122386. */
  122387. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122388. /**
  122389. * Called once for each button that changed state since the last frame
  122390. * @param buttonIdx Which button index changed
  122391. * @param state New state of the button
  122392. * @param changes Which properties on the state changed since last frame
  122393. */
  122394. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122395. }
  122396. }
  122397. declare module BABYLON {
  122398. /**
  122399. * Generic Controller
  122400. */
  122401. export class GenericController extends WebVRController {
  122402. /**
  122403. * Base Url for the controller model.
  122404. */
  122405. static readonly MODEL_BASE_URL: string;
  122406. /**
  122407. * File name for the controller model.
  122408. */
  122409. static readonly MODEL_FILENAME: string;
  122410. /**
  122411. * Creates a new GenericController from a gamepad
  122412. * @param vrGamepad the gamepad that the controller should be created from
  122413. */
  122414. constructor(vrGamepad: any);
  122415. /**
  122416. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122417. * @param scene scene in which to add meshes
  122418. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122419. */
  122420. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122421. /**
  122422. * Called once for each button that changed state since the last frame
  122423. * @param buttonIdx Which button index changed
  122424. * @param state New state of the button
  122425. * @param changes Which properties on the state changed since last frame
  122426. */
  122427. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122428. }
  122429. }
  122430. declare module BABYLON {
  122431. /**
  122432. * Oculus Touch Controller
  122433. */
  122434. export class OculusTouchController extends WebVRController {
  122435. /**
  122436. * Base Url for the controller model.
  122437. */
  122438. static MODEL_BASE_URL: string;
  122439. /**
  122440. * File name for the left controller model.
  122441. */
  122442. static MODEL_LEFT_FILENAME: string;
  122443. /**
  122444. * File name for the right controller model.
  122445. */
  122446. static MODEL_RIGHT_FILENAME: string;
  122447. /**
  122448. * Base Url for the Quest controller model.
  122449. */
  122450. static QUEST_MODEL_BASE_URL: string;
  122451. /**
  122452. * @hidden
  122453. * If the controllers are running on a device that needs the updated Quest controller models
  122454. */
  122455. static _IsQuest: boolean;
  122456. /**
  122457. * Fired when the secondary trigger on this controller is modified
  122458. */
  122459. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  122460. /**
  122461. * Fired when the thumb rest on this controller is modified
  122462. */
  122463. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  122464. /**
  122465. * Creates a new OculusTouchController from a gamepad
  122466. * @param vrGamepad the gamepad that the controller should be created from
  122467. */
  122468. constructor(vrGamepad: any);
  122469. /**
  122470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122471. * @param scene scene in which to add meshes
  122472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122473. */
  122474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122475. /**
  122476. * Fired when the A button on this controller is modified
  122477. */
  122478. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122479. /**
  122480. * Fired when the B button on this controller is modified
  122481. */
  122482. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122483. /**
  122484. * Fired when the X button on this controller is modified
  122485. */
  122486. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122487. /**
  122488. * Fired when the Y button on this controller is modified
  122489. */
  122490. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122491. /**
  122492. * Called once for each button that changed state since the last frame
  122493. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  122494. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  122495. * 2) secondary trigger (same)
  122496. * 3) A (right) X (left), touch, pressed = value
  122497. * 4) B / Y
  122498. * 5) thumb rest
  122499. * @param buttonIdx Which button index changed
  122500. * @param state New state of the button
  122501. * @param changes Which properties on the state changed since last frame
  122502. */
  122503. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122504. }
  122505. }
  122506. declare module BABYLON {
  122507. /**
  122508. * Vive Controller
  122509. */
  122510. export class ViveController extends WebVRController {
  122511. /**
  122512. * Base Url for the controller model.
  122513. */
  122514. static MODEL_BASE_URL: string;
  122515. /**
  122516. * File name for the controller model.
  122517. */
  122518. static MODEL_FILENAME: string;
  122519. /**
  122520. * Creates a new ViveController from a gamepad
  122521. * @param vrGamepad the gamepad that the controller should be created from
  122522. */
  122523. constructor(vrGamepad: any);
  122524. /**
  122525. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122526. * @param scene scene in which to add meshes
  122527. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122528. */
  122529. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122530. /**
  122531. * Fired when the left button on this controller is modified
  122532. */
  122533. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122534. /**
  122535. * Fired when the right button on this controller is modified
  122536. */
  122537. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122538. /**
  122539. * Fired when the menu button on this controller is modified
  122540. */
  122541. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122542. /**
  122543. * Called once for each button that changed state since the last frame
  122544. * Vive mapping:
  122545. * 0: touchpad
  122546. * 1: trigger
  122547. * 2: left AND right buttons
  122548. * 3: menu button
  122549. * @param buttonIdx Which button index changed
  122550. * @param state New state of the button
  122551. * @param changes Which properties on the state changed since last frame
  122552. */
  122553. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122554. }
  122555. }
  122556. declare module BABYLON {
  122557. /**
  122558. * Defines the WindowsMotionController object that the state of the windows motion controller
  122559. */
  122560. export class WindowsMotionController extends WebVRController {
  122561. /**
  122562. * The base url used to load the left and right controller models
  122563. */
  122564. static MODEL_BASE_URL: string;
  122565. /**
  122566. * The name of the left controller model file
  122567. */
  122568. static MODEL_LEFT_FILENAME: string;
  122569. /**
  122570. * The name of the right controller model file
  122571. */
  122572. static MODEL_RIGHT_FILENAME: string;
  122573. /**
  122574. * The controller name prefix for this controller type
  122575. */
  122576. static readonly GAMEPAD_ID_PREFIX: string;
  122577. /**
  122578. * The controller id pattern for this controller type
  122579. */
  122580. private static readonly GAMEPAD_ID_PATTERN;
  122581. private _loadedMeshInfo;
  122582. protected readonly _mapping: {
  122583. buttons: string[];
  122584. buttonMeshNames: {
  122585. 'trigger': string;
  122586. 'menu': string;
  122587. 'grip': string;
  122588. 'thumbstick': string;
  122589. 'trackpad': string;
  122590. };
  122591. buttonObservableNames: {
  122592. 'trigger': string;
  122593. 'menu': string;
  122594. 'grip': string;
  122595. 'thumbstick': string;
  122596. 'trackpad': string;
  122597. };
  122598. axisMeshNames: string[];
  122599. pointingPoseMeshName: string;
  122600. };
  122601. /**
  122602. * Fired when the trackpad on this controller is clicked
  122603. */
  122604. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122605. /**
  122606. * Fired when the trackpad on this controller is modified
  122607. */
  122608. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122609. /**
  122610. * The current x and y values of this controller's trackpad
  122611. */
  122612. trackpad: StickValues;
  122613. /**
  122614. * Creates a new WindowsMotionController from a gamepad
  122615. * @param vrGamepad the gamepad that the controller should be created from
  122616. */
  122617. constructor(vrGamepad: any);
  122618. /**
  122619. * Fired when the trigger on this controller is modified
  122620. */
  122621. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122622. /**
  122623. * Fired when the menu button on this controller is modified
  122624. */
  122625. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122626. /**
  122627. * Fired when the grip button on this controller is modified
  122628. */
  122629. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122630. /**
  122631. * Fired when the thumbstick button on this controller is modified
  122632. */
  122633. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122634. /**
  122635. * Fired when the touchpad button on this controller is modified
  122636. */
  122637. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122638. /**
  122639. * Fired when the touchpad values on this controller are modified
  122640. */
  122641. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  122642. protected _updateTrackpad(): void;
  122643. /**
  122644. * Called once per frame by the engine.
  122645. */
  122646. update(): void;
  122647. /**
  122648. * Called once for each button that changed state since the last frame
  122649. * @param buttonIdx Which button index changed
  122650. * @param state New state of the button
  122651. * @param changes Which properties on the state changed since last frame
  122652. */
  122653. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122654. /**
  122655. * Moves the buttons on the controller mesh based on their current state
  122656. * @param buttonName the name of the button to move
  122657. * @param buttonValue the value of the button which determines the buttons new position
  122658. */
  122659. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  122660. /**
  122661. * Moves the axis on the controller mesh based on its current state
  122662. * @param axis the index of the axis
  122663. * @param axisValue the value of the axis which determines the meshes new position
  122664. * @hidden
  122665. */
  122666. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  122667. /**
  122668. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122669. * @param scene scene in which to add meshes
  122670. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122671. */
  122672. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  122673. /**
  122674. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  122675. * can be transformed by button presses and axes values, based on this._mapping.
  122676. *
  122677. * @param scene scene in which the meshes exist
  122678. * @param meshes list of meshes that make up the controller model to process
  122679. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  122680. */
  122681. private processModel;
  122682. private createMeshInfo;
  122683. /**
  122684. * Gets the ray of the controller in the direction the controller is pointing
  122685. * @param length the length the resulting ray should be
  122686. * @returns a ray in the direction the controller is pointing
  122687. */
  122688. getForwardRay(length?: number): Ray;
  122689. /**
  122690. * Disposes of the controller
  122691. */
  122692. dispose(): void;
  122693. }
  122694. /**
  122695. * This class represents a new windows motion controller in XR.
  122696. */
  122697. export class XRWindowsMotionController extends WindowsMotionController {
  122698. /**
  122699. * Changing the original WIndowsMotionController mapping to fir the new mapping
  122700. */
  122701. protected readonly _mapping: {
  122702. buttons: string[];
  122703. buttonMeshNames: {
  122704. 'trigger': string;
  122705. 'menu': string;
  122706. 'grip': string;
  122707. 'thumbstick': string;
  122708. 'trackpad': string;
  122709. };
  122710. buttonObservableNames: {
  122711. 'trigger': string;
  122712. 'menu': string;
  122713. 'grip': string;
  122714. 'thumbstick': string;
  122715. 'trackpad': string;
  122716. };
  122717. axisMeshNames: string[];
  122718. pointingPoseMeshName: string;
  122719. };
  122720. /**
  122721. * Construct a new XR-Based windows motion controller
  122722. *
  122723. * @param gamepadInfo the gamepad object from the browser
  122724. */
  122725. constructor(gamepadInfo: any);
  122726. /**
  122727. * holds the thumbstick values (X,Y)
  122728. */
  122729. thumbstickValues: StickValues;
  122730. /**
  122731. * Fired when the thumbstick on this controller is clicked
  122732. */
  122733. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  122734. /**
  122735. * Fired when the thumbstick on this controller is modified
  122736. */
  122737. onThumbstickValuesChangedObservable: Observable<StickValues>;
  122738. /**
  122739. * Fired when the touchpad button on this controller is modified
  122740. */
  122741. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122742. /**
  122743. * Fired when the touchpad values on this controller are modified
  122744. */
  122745. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122746. /**
  122747. * Fired when the thumbstick button on this controller is modified
  122748. * here to prevent breaking changes
  122749. */
  122750. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122751. /**
  122752. * updating the thumbstick(!) and not the trackpad.
  122753. * This is named this way due to the difference between WebVR and XR and to avoid
  122754. * changing the parent class.
  122755. */
  122756. protected _updateTrackpad(): void;
  122757. /**
  122758. * Disposes the class with joy
  122759. */
  122760. dispose(): void;
  122761. }
  122762. }
  122763. declare module BABYLON {
  122764. /**
  122765. * Class containing static functions to help procedurally build meshes
  122766. */
  122767. export class PolyhedronBuilder {
  122768. /**
  122769. * Creates a polyhedron mesh
  122770. * * 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
  122771. * * The parameter `size` (positive float, default 1) sets the polygon size
  122772. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122773. * * 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`
  122774. * * 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
  122775. * * 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)`)
  122776. * * 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
  122777. * * 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
  122778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122779. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122781. * @param name defines the name of the mesh
  122782. * @param options defines the options used to create the mesh
  122783. * @param scene defines the hosting scene
  122784. * @returns the polyhedron mesh
  122785. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  122786. */
  122787. static CreatePolyhedron(name: string, options: {
  122788. type?: number;
  122789. size?: number;
  122790. sizeX?: number;
  122791. sizeY?: number;
  122792. sizeZ?: number;
  122793. custom?: any;
  122794. faceUV?: Vector4[];
  122795. faceColors?: Color4[];
  122796. flat?: boolean;
  122797. updatable?: boolean;
  122798. sideOrientation?: number;
  122799. frontUVs?: Vector4;
  122800. backUVs?: Vector4;
  122801. }, scene?: Nullable<Scene>): Mesh;
  122802. }
  122803. }
  122804. declare module BABYLON {
  122805. /**
  122806. * Gizmo that enables scaling a mesh along 3 axis
  122807. */
  122808. export class ScaleGizmo extends Gizmo {
  122809. /**
  122810. * Internal gizmo used for interactions on the x axis
  122811. */
  122812. xGizmo: AxisScaleGizmo;
  122813. /**
  122814. * Internal gizmo used for interactions on the y axis
  122815. */
  122816. yGizmo: AxisScaleGizmo;
  122817. /**
  122818. * Internal gizmo used for interactions on the z axis
  122819. */
  122820. zGizmo: AxisScaleGizmo;
  122821. /**
  122822. * Internal gizmo used to scale all axis equally
  122823. */
  122824. uniformScaleGizmo: AxisScaleGizmo;
  122825. private _meshAttached;
  122826. private _updateGizmoRotationToMatchAttachedMesh;
  122827. private _snapDistance;
  122828. private _scaleRatio;
  122829. private _uniformScalingMesh;
  122830. private _octahedron;
  122831. private _sensitivity;
  122832. /** Fires an event when any of it's sub gizmos are dragged */
  122833. onDragStartObservable: Observable<unknown>;
  122834. /** Fires an event when any of it's sub gizmos are released from dragging */
  122835. onDragEndObservable: Observable<unknown>;
  122836. get attachedMesh(): Nullable<AbstractMesh>;
  122837. set attachedMesh(mesh: Nullable<AbstractMesh>);
  122838. /**
  122839. * Creates a ScaleGizmo
  122840. * @param gizmoLayer The utility layer the gizmo will be added to
  122841. */
  122842. constructor(gizmoLayer?: UtilityLayerRenderer);
  122843. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  122844. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  122845. /**
  122846. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122847. */
  122848. set snapDistance(value: number);
  122849. get snapDistance(): number;
  122850. /**
  122851. * Ratio for the scale of the gizmo (Default: 1)
  122852. */
  122853. set scaleRatio(value: number);
  122854. get scaleRatio(): number;
  122855. /**
  122856. * Sensitivity factor for dragging (Default: 1)
  122857. */
  122858. set sensitivity(value: number);
  122859. get sensitivity(): number;
  122860. /**
  122861. * Disposes of the gizmo
  122862. */
  122863. dispose(): void;
  122864. }
  122865. }
  122866. declare module BABYLON {
  122867. /**
  122868. * Single axis scale gizmo
  122869. */
  122870. export class AxisScaleGizmo extends Gizmo {
  122871. /**
  122872. * Drag behavior responsible for the gizmos dragging interactions
  122873. */
  122874. dragBehavior: PointerDragBehavior;
  122875. private _pointerObserver;
  122876. /**
  122877. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  122878. */
  122879. snapDistance: number;
  122880. /**
  122881. * Event that fires each time the gizmo snaps to a new location.
  122882. * * snapDistance is the the change in distance
  122883. */
  122884. onSnapObservable: Observable<{
  122885. snapDistance: number;
  122886. }>;
  122887. /**
  122888. * If the scaling operation should be done on all axis (default: false)
  122889. */
  122890. uniformScaling: boolean;
  122891. /**
  122892. * Custom sensitivity value for the drag strength
  122893. */
  122894. sensitivity: number;
  122895. private _isEnabled;
  122896. private _parent;
  122897. private _arrow;
  122898. private _coloredMaterial;
  122899. private _hoverMaterial;
  122900. /**
  122901. * Creates an AxisScaleGizmo
  122902. * @param gizmoLayer The utility layer the gizmo will be added to
  122903. * @param dragAxis The axis which the gizmo will be able to scale on
  122904. * @param color The color of the gizmo
  122905. */
  122906. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  122907. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  122908. /**
  122909. * If the gizmo is enabled
  122910. */
  122911. set isEnabled(value: boolean);
  122912. get isEnabled(): boolean;
  122913. /**
  122914. * Disposes of the gizmo
  122915. */
  122916. dispose(): void;
  122917. /**
  122918. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  122919. * @param mesh The mesh to replace the default mesh of the gizmo
  122920. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  122921. */
  122922. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  122923. }
  122924. }
  122925. declare module BABYLON {
  122926. /**
  122927. * Bounding box gizmo
  122928. */
  122929. export class BoundingBoxGizmo extends Gizmo {
  122930. private _lineBoundingBox;
  122931. private _rotateSpheresParent;
  122932. private _scaleBoxesParent;
  122933. private _boundingDimensions;
  122934. private _renderObserver;
  122935. private _pointerObserver;
  122936. private _scaleDragSpeed;
  122937. private _tmpQuaternion;
  122938. private _tmpVector;
  122939. private _tmpRotationMatrix;
  122940. /**
  122941. * 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)
  122942. */
  122943. ignoreChildren: boolean;
  122944. /**
  122945. * 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)
  122946. */
  122947. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  122948. /**
  122949. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  122950. */
  122951. rotationSphereSize: number;
  122952. /**
  122953. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  122954. */
  122955. scaleBoxSize: number;
  122956. /**
  122957. * 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)
  122958. */
  122959. fixedDragMeshScreenSize: boolean;
  122960. /**
  122961. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  122962. */
  122963. fixedDragMeshScreenSizeDistanceFactor: number;
  122964. /**
  122965. * Fired when a rotation sphere or scale box is dragged
  122966. */
  122967. onDragStartObservable: Observable<{}>;
  122968. /**
  122969. * Fired when a scale box is dragged
  122970. */
  122971. onScaleBoxDragObservable: Observable<{}>;
  122972. /**
  122973. * Fired when a scale box drag is ended
  122974. */
  122975. onScaleBoxDragEndObservable: Observable<{}>;
  122976. /**
  122977. * Fired when a rotation sphere is dragged
  122978. */
  122979. onRotationSphereDragObservable: Observable<{}>;
  122980. /**
  122981. * Fired when a rotation sphere drag is ended
  122982. */
  122983. onRotationSphereDragEndObservable: Observable<{}>;
  122984. /**
  122985. * 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)
  122986. */
  122987. scalePivot: Nullable<Vector3>;
  122988. /**
  122989. * Mesh used as a pivot to rotate the attached mesh
  122990. */
  122991. private _anchorMesh;
  122992. private _existingMeshScale;
  122993. private _dragMesh;
  122994. private pointerDragBehavior;
  122995. private coloredMaterial;
  122996. private hoverColoredMaterial;
  122997. /**
  122998. * Sets the color of the bounding box gizmo
  122999. * @param color the color to set
  123000. */
  123001. setColor(color: Color3): void;
  123002. /**
  123003. * Creates an BoundingBoxGizmo
  123004. * @param gizmoLayer The utility layer the gizmo will be added to
  123005. * @param color The color of the gizmo
  123006. */
  123007. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  123008. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123009. private _selectNode;
  123010. /**
  123011. * Updates the bounding box information for the Gizmo
  123012. */
  123013. updateBoundingBox(): void;
  123014. private _updateRotationSpheres;
  123015. private _updateScaleBoxes;
  123016. /**
  123017. * Enables rotation on the specified axis and disables rotation on the others
  123018. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  123019. */
  123020. setEnabledRotationAxis(axis: string): void;
  123021. /**
  123022. * Enables/disables scaling
  123023. * @param enable if scaling should be enabled
  123024. * @param homogeneousScaling defines if scaling should only be homogeneous
  123025. */
  123026. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  123027. private _updateDummy;
  123028. /**
  123029. * Enables a pointer drag behavior on the bounding box of the gizmo
  123030. */
  123031. enableDragBehavior(): void;
  123032. /**
  123033. * Disposes of the gizmo
  123034. */
  123035. dispose(): void;
  123036. /**
  123037. * 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)
  123038. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  123039. * @returns the bounding box mesh with the passed in mesh as a child
  123040. */
  123041. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  123042. /**
  123043. * CustomMeshes are not supported by this gizmo
  123044. * @param mesh The mesh to replace the default mesh of the gizmo
  123045. */
  123046. setCustomMesh(mesh: Mesh): void;
  123047. }
  123048. }
  123049. declare module BABYLON {
  123050. /**
  123051. * Single plane rotation gizmo
  123052. */
  123053. export class PlaneRotationGizmo extends Gizmo {
  123054. /**
  123055. * Drag behavior responsible for the gizmos dragging interactions
  123056. */
  123057. dragBehavior: PointerDragBehavior;
  123058. private _pointerObserver;
  123059. /**
  123060. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  123061. */
  123062. snapDistance: number;
  123063. /**
  123064. * Event that fires each time the gizmo snaps to a new location.
  123065. * * snapDistance is the the change in distance
  123066. */
  123067. onSnapObservable: Observable<{
  123068. snapDistance: number;
  123069. }>;
  123070. private _isEnabled;
  123071. private _parent;
  123072. /**
  123073. * Creates a PlaneRotationGizmo
  123074. * @param gizmoLayer The utility layer the gizmo will be added to
  123075. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  123076. * @param color The color of the gizmo
  123077. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123078. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123079. */
  123080. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  123081. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123082. /**
  123083. * If the gizmo is enabled
  123084. */
  123085. set isEnabled(value: boolean);
  123086. get isEnabled(): boolean;
  123087. /**
  123088. * Disposes of the gizmo
  123089. */
  123090. dispose(): void;
  123091. }
  123092. }
  123093. declare module BABYLON {
  123094. /**
  123095. * Gizmo that enables rotating a mesh along 3 axis
  123096. */
  123097. export class RotationGizmo extends Gizmo {
  123098. /**
  123099. * Internal gizmo used for interactions on the x axis
  123100. */
  123101. xGizmo: PlaneRotationGizmo;
  123102. /**
  123103. * Internal gizmo used for interactions on the y axis
  123104. */
  123105. yGizmo: PlaneRotationGizmo;
  123106. /**
  123107. * Internal gizmo used for interactions on the z axis
  123108. */
  123109. zGizmo: PlaneRotationGizmo;
  123110. /** Fires an event when any of it's sub gizmos are dragged */
  123111. onDragStartObservable: Observable<unknown>;
  123112. /** Fires an event when any of it's sub gizmos are released from dragging */
  123113. onDragEndObservable: Observable<unknown>;
  123114. private _meshAttached;
  123115. get attachedMesh(): Nullable<AbstractMesh>;
  123116. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123117. /**
  123118. * Creates a RotationGizmo
  123119. * @param gizmoLayer The utility layer the gizmo will be added to
  123120. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123121. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123122. */
  123123. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  123124. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123125. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123126. /**
  123127. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123128. */
  123129. set snapDistance(value: number);
  123130. get snapDistance(): number;
  123131. /**
  123132. * Ratio for the scale of the gizmo (Default: 1)
  123133. */
  123134. set scaleRatio(value: number);
  123135. get scaleRatio(): number;
  123136. /**
  123137. * Disposes of the gizmo
  123138. */
  123139. dispose(): void;
  123140. /**
  123141. * CustomMeshes are not supported by this gizmo
  123142. * @param mesh The mesh to replace the default mesh of the gizmo
  123143. */
  123144. setCustomMesh(mesh: Mesh): void;
  123145. }
  123146. }
  123147. declare module BABYLON {
  123148. /**
  123149. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  123150. */
  123151. export class GizmoManager implements IDisposable {
  123152. private scene;
  123153. /**
  123154. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  123155. */
  123156. gizmos: {
  123157. positionGizmo: Nullable<PositionGizmo>;
  123158. rotationGizmo: Nullable<RotationGizmo>;
  123159. scaleGizmo: Nullable<ScaleGizmo>;
  123160. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  123161. };
  123162. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  123163. clearGizmoOnEmptyPointerEvent: boolean;
  123164. /** Fires an event when the manager is attached to a mesh */
  123165. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  123166. private _gizmosEnabled;
  123167. private _pointerObserver;
  123168. private _attachedMesh;
  123169. private _boundingBoxColor;
  123170. private _defaultUtilityLayer;
  123171. private _defaultKeepDepthUtilityLayer;
  123172. /**
  123173. * When bounding box gizmo is enabled, this can be used to track drag/end events
  123174. */
  123175. boundingBoxDragBehavior: SixDofDragBehavior;
  123176. /**
  123177. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  123178. */
  123179. attachableMeshes: Nullable<Array<AbstractMesh>>;
  123180. /**
  123181. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  123182. */
  123183. usePointerToAttachGizmos: boolean;
  123184. /**
  123185. * Utility layer that the bounding box gizmo belongs to
  123186. */
  123187. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  123188. /**
  123189. * Utility layer that all gizmos besides bounding box belong to
  123190. */
  123191. get utilityLayer(): UtilityLayerRenderer;
  123192. /**
  123193. * Instatiates a gizmo manager
  123194. * @param scene the scene to overlay the gizmos on top of
  123195. */
  123196. constructor(scene: Scene);
  123197. /**
  123198. * Attaches a set of gizmos to the specified mesh
  123199. * @param mesh The mesh the gizmo's should be attached to
  123200. */
  123201. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  123202. /**
  123203. * If the position gizmo is enabled
  123204. */
  123205. set positionGizmoEnabled(value: boolean);
  123206. get positionGizmoEnabled(): boolean;
  123207. /**
  123208. * If the rotation gizmo is enabled
  123209. */
  123210. set rotationGizmoEnabled(value: boolean);
  123211. get rotationGizmoEnabled(): boolean;
  123212. /**
  123213. * If the scale gizmo is enabled
  123214. */
  123215. set scaleGizmoEnabled(value: boolean);
  123216. get scaleGizmoEnabled(): boolean;
  123217. /**
  123218. * If the boundingBox gizmo is enabled
  123219. */
  123220. set boundingBoxGizmoEnabled(value: boolean);
  123221. get boundingBoxGizmoEnabled(): boolean;
  123222. /**
  123223. * Disposes of the gizmo manager
  123224. */
  123225. dispose(): void;
  123226. }
  123227. }
  123228. declare module BABYLON {
  123229. /**
  123230. * A directional light is defined by a direction (what a surprise!).
  123231. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  123232. * 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.
  123233. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123234. */
  123235. export class DirectionalLight extends ShadowLight {
  123236. private _shadowFrustumSize;
  123237. /**
  123238. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  123239. */
  123240. get shadowFrustumSize(): number;
  123241. /**
  123242. * Specifies a fix frustum size for the shadow generation.
  123243. */
  123244. set shadowFrustumSize(value: number);
  123245. private _shadowOrthoScale;
  123246. /**
  123247. * Gets the shadow projection scale against the optimal computed one.
  123248. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123249. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123250. */
  123251. get shadowOrthoScale(): number;
  123252. /**
  123253. * Sets the shadow projection scale against the optimal computed one.
  123254. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123255. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123256. */
  123257. set shadowOrthoScale(value: number);
  123258. /**
  123259. * Automatically compute the projection matrix to best fit (including all the casters)
  123260. * on each frame.
  123261. */
  123262. autoUpdateExtends: boolean;
  123263. /**
  123264. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  123265. * on each frame. autoUpdateExtends must be set to true for this to work
  123266. */
  123267. autoCalcShadowZBounds: boolean;
  123268. private _orthoLeft;
  123269. private _orthoRight;
  123270. private _orthoTop;
  123271. private _orthoBottom;
  123272. /**
  123273. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  123274. * The directional light is emitted from everywhere in the given direction.
  123275. * It can cast shadows.
  123276. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123277. * @param name The friendly name of the light
  123278. * @param direction The direction of the light
  123279. * @param scene The scene the light belongs to
  123280. */
  123281. constructor(name: string, direction: Vector3, scene: Scene);
  123282. /**
  123283. * Returns the string "DirectionalLight".
  123284. * @return The class name
  123285. */
  123286. getClassName(): string;
  123287. /**
  123288. * Returns the integer 1.
  123289. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123290. */
  123291. getTypeID(): number;
  123292. /**
  123293. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  123294. * Returns the DirectionalLight Shadow projection matrix.
  123295. */
  123296. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123297. /**
  123298. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  123299. * Returns the DirectionalLight Shadow projection matrix.
  123300. */
  123301. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  123302. /**
  123303. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  123304. * Returns the DirectionalLight Shadow projection matrix.
  123305. */
  123306. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123307. protected _buildUniformLayout(): void;
  123308. /**
  123309. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  123310. * @param effect The effect to update
  123311. * @param lightIndex The index of the light in the effect to update
  123312. * @returns The directional light
  123313. */
  123314. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  123315. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  123316. /**
  123317. * Gets the minZ used for shadow according to both the scene and the light.
  123318. *
  123319. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123320. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123321. * @param activeCamera The camera we are returning the min for
  123322. * @returns the depth min z
  123323. */
  123324. getDepthMinZ(activeCamera: Camera): number;
  123325. /**
  123326. * Gets the maxZ used for shadow according to both the scene and the light.
  123327. *
  123328. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123329. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123330. * @param activeCamera The camera we are returning the max for
  123331. * @returns the depth max z
  123332. */
  123333. getDepthMaxZ(activeCamera: Camera): number;
  123334. /**
  123335. * Prepares the list of defines specific to the light type.
  123336. * @param defines the list of defines
  123337. * @param lightIndex defines the index of the light for the effect
  123338. */
  123339. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123340. }
  123341. }
  123342. declare module BABYLON {
  123343. /**
  123344. * Class containing static functions to help procedurally build meshes
  123345. */
  123346. export class HemisphereBuilder {
  123347. /**
  123348. * Creates a hemisphere mesh
  123349. * @param name defines the name of the mesh
  123350. * @param options defines the options used to create the mesh
  123351. * @param scene defines the hosting scene
  123352. * @returns the hemisphere mesh
  123353. */
  123354. static CreateHemisphere(name: string, options: {
  123355. segments?: number;
  123356. diameter?: number;
  123357. sideOrientation?: number;
  123358. }, scene: any): Mesh;
  123359. }
  123360. }
  123361. declare module BABYLON {
  123362. /**
  123363. * A spot light is defined by a position, a direction, an angle, and an exponent.
  123364. * These values define a cone of light starting from the position, emitting toward the direction.
  123365. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  123366. * and the exponent defines the speed of the decay of the light with distance (reach).
  123367. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123368. */
  123369. export class SpotLight extends ShadowLight {
  123370. private _angle;
  123371. private _innerAngle;
  123372. private _cosHalfAngle;
  123373. private _lightAngleScale;
  123374. private _lightAngleOffset;
  123375. /**
  123376. * Gets the cone angle of the spot light in Radians.
  123377. */
  123378. get angle(): number;
  123379. /**
  123380. * Sets the cone angle of the spot light in Radians.
  123381. */
  123382. set angle(value: number);
  123383. /**
  123384. * Only used in gltf falloff mode, this defines the angle where
  123385. * the directional falloff will start before cutting at angle which could be seen
  123386. * as outer angle.
  123387. */
  123388. get innerAngle(): number;
  123389. /**
  123390. * Only used in gltf falloff mode, this defines the angle where
  123391. * the directional falloff will start before cutting at angle which could be seen
  123392. * as outer angle.
  123393. */
  123394. set innerAngle(value: number);
  123395. private _shadowAngleScale;
  123396. /**
  123397. * Allows scaling the angle of the light for shadow generation only.
  123398. */
  123399. get shadowAngleScale(): number;
  123400. /**
  123401. * Allows scaling the angle of the light for shadow generation only.
  123402. */
  123403. set shadowAngleScale(value: number);
  123404. /**
  123405. * The light decay speed with the distance from the emission spot.
  123406. */
  123407. exponent: number;
  123408. private _projectionTextureMatrix;
  123409. /**
  123410. * Allows reading the projecton texture
  123411. */
  123412. get projectionTextureMatrix(): Matrix;
  123413. protected _projectionTextureLightNear: number;
  123414. /**
  123415. * Gets the near clip of the Spotlight for texture projection.
  123416. */
  123417. get projectionTextureLightNear(): number;
  123418. /**
  123419. * Sets the near clip of the Spotlight for texture projection.
  123420. */
  123421. set projectionTextureLightNear(value: number);
  123422. protected _projectionTextureLightFar: number;
  123423. /**
  123424. * Gets the far clip of the Spotlight for texture projection.
  123425. */
  123426. get projectionTextureLightFar(): number;
  123427. /**
  123428. * Sets the far clip of the Spotlight for texture projection.
  123429. */
  123430. set projectionTextureLightFar(value: number);
  123431. protected _projectionTextureUpDirection: Vector3;
  123432. /**
  123433. * Gets the Up vector of the Spotlight for texture projection.
  123434. */
  123435. get projectionTextureUpDirection(): Vector3;
  123436. /**
  123437. * Sets the Up vector of the Spotlight for texture projection.
  123438. */
  123439. set projectionTextureUpDirection(value: Vector3);
  123440. private _projectionTexture;
  123441. /**
  123442. * Gets the projection texture of the light.
  123443. */
  123444. get projectionTexture(): Nullable<BaseTexture>;
  123445. /**
  123446. * Sets the projection texture of the light.
  123447. */
  123448. set projectionTexture(value: Nullable<BaseTexture>);
  123449. private _projectionTextureViewLightDirty;
  123450. private _projectionTextureProjectionLightDirty;
  123451. private _projectionTextureDirty;
  123452. private _projectionTextureViewTargetVector;
  123453. private _projectionTextureViewLightMatrix;
  123454. private _projectionTextureProjectionLightMatrix;
  123455. private _projectionTextureScalingMatrix;
  123456. /**
  123457. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  123458. * It can cast shadows.
  123459. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123460. * @param name The light friendly name
  123461. * @param position The position of the spot light in the scene
  123462. * @param direction The direction of the light in the scene
  123463. * @param angle The cone angle of the light in Radians
  123464. * @param exponent The light decay speed with the distance from the emission spot
  123465. * @param scene The scene the lights belongs to
  123466. */
  123467. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  123468. /**
  123469. * Returns the string "SpotLight".
  123470. * @returns the class name
  123471. */
  123472. getClassName(): string;
  123473. /**
  123474. * Returns the integer 2.
  123475. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123476. */
  123477. getTypeID(): number;
  123478. /**
  123479. * Overrides the direction setter to recompute the projection texture view light Matrix.
  123480. */
  123481. protected _setDirection(value: Vector3): void;
  123482. /**
  123483. * Overrides the position setter to recompute the projection texture view light Matrix.
  123484. */
  123485. protected _setPosition(value: Vector3): void;
  123486. /**
  123487. * 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.
  123488. * Returns the SpotLight.
  123489. */
  123490. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123491. protected _computeProjectionTextureViewLightMatrix(): void;
  123492. protected _computeProjectionTextureProjectionLightMatrix(): void;
  123493. /**
  123494. * Main function for light texture projection matrix computing.
  123495. */
  123496. protected _computeProjectionTextureMatrix(): void;
  123497. protected _buildUniformLayout(): void;
  123498. private _computeAngleValues;
  123499. /**
  123500. * Sets the passed Effect "effect" with the Light textures.
  123501. * @param effect The effect to update
  123502. * @param lightIndex The index of the light in the effect to update
  123503. * @returns The light
  123504. */
  123505. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  123506. /**
  123507. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  123508. * @param effect The effect to update
  123509. * @param lightIndex The index of the light in the effect to update
  123510. * @returns The spot light
  123511. */
  123512. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  123513. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123514. /**
  123515. * Disposes the light and the associated resources.
  123516. */
  123517. dispose(): void;
  123518. /**
  123519. * Prepares the list of defines specific to the light type.
  123520. * @param defines the list of defines
  123521. * @param lightIndex defines the index of the light for the effect
  123522. */
  123523. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123524. }
  123525. }
  123526. declare module BABYLON {
  123527. /**
  123528. * Gizmo that enables viewing a light
  123529. */
  123530. export class LightGizmo extends Gizmo {
  123531. private _lightMesh;
  123532. private _material;
  123533. private _cachedPosition;
  123534. private _cachedForward;
  123535. private _attachedMeshParent;
  123536. /**
  123537. * Creates a LightGizmo
  123538. * @param gizmoLayer The utility layer the gizmo will be added to
  123539. */
  123540. constructor(gizmoLayer?: UtilityLayerRenderer);
  123541. private _light;
  123542. /**
  123543. * The light that the gizmo is attached to
  123544. */
  123545. set light(light: Nullable<Light>);
  123546. get light(): Nullable<Light>;
  123547. /**
  123548. * Gets the material used to render the light gizmo
  123549. */
  123550. get material(): StandardMaterial;
  123551. /**
  123552. * @hidden
  123553. * Updates the gizmo to match the attached mesh's position/rotation
  123554. */
  123555. protected _update(): void;
  123556. private static _Scale;
  123557. /**
  123558. * Creates the lines for a light mesh
  123559. */
  123560. private static _CreateLightLines;
  123561. /**
  123562. * Disposes of the light gizmo
  123563. */
  123564. dispose(): void;
  123565. private static _CreateHemisphericLightMesh;
  123566. private static _CreatePointLightMesh;
  123567. private static _CreateSpotLightMesh;
  123568. private static _CreateDirectionalLightMesh;
  123569. }
  123570. }
  123571. declare module BABYLON {
  123572. /** @hidden */
  123573. export var backgroundFragmentDeclaration: {
  123574. name: string;
  123575. shader: string;
  123576. };
  123577. }
  123578. declare module BABYLON {
  123579. /** @hidden */
  123580. export var backgroundUboDeclaration: {
  123581. name: string;
  123582. shader: string;
  123583. };
  123584. }
  123585. declare module BABYLON {
  123586. /** @hidden */
  123587. export var backgroundPixelShader: {
  123588. name: string;
  123589. shader: string;
  123590. };
  123591. }
  123592. declare module BABYLON {
  123593. /** @hidden */
  123594. export var backgroundVertexDeclaration: {
  123595. name: string;
  123596. shader: string;
  123597. };
  123598. }
  123599. declare module BABYLON {
  123600. /** @hidden */
  123601. export var backgroundVertexShader: {
  123602. name: string;
  123603. shader: string;
  123604. };
  123605. }
  123606. declare module BABYLON {
  123607. /**
  123608. * Background material used to create an efficient environement around your scene.
  123609. */
  123610. export class BackgroundMaterial extends PushMaterial {
  123611. /**
  123612. * Standard reflectance value at parallel view angle.
  123613. */
  123614. static StandardReflectance0: number;
  123615. /**
  123616. * Standard reflectance value at grazing angle.
  123617. */
  123618. static StandardReflectance90: number;
  123619. protected _primaryColor: Color3;
  123620. /**
  123621. * Key light Color (multiply against the environement texture)
  123622. */
  123623. primaryColor: Color3;
  123624. protected __perceptualColor: Nullable<Color3>;
  123625. /**
  123626. * Experimental Internal Use Only.
  123627. *
  123628. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  123629. * This acts as a helper to set the primary color to a more "human friendly" value.
  123630. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  123631. * output color as close as possible from the chosen value.
  123632. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  123633. * part of lighting setup.)
  123634. */
  123635. get _perceptualColor(): Nullable<Color3>;
  123636. set _perceptualColor(value: Nullable<Color3>);
  123637. protected _primaryColorShadowLevel: float;
  123638. /**
  123639. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  123640. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  123641. */
  123642. get primaryColorShadowLevel(): float;
  123643. set primaryColorShadowLevel(value: float);
  123644. protected _primaryColorHighlightLevel: float;
  123645. /**
  123646. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  123647. * The primary color is used at the level chosen to define what the white area would look.
  123648. */
  123649. get primaryColorHighlightLevel(): float;
  123650. set primaryColorHighlightLevel(value: float);
  123651. protected _reflectionTexture: Nullable<BaseTexture>;
  123652. /**
  123653. * Reflection Texture used in the material.
  123654. * Should be author in a specific way for the best result (refer to the documentation).
  123655. */
  123656. reflectionTexture: Nullable<BaseTexture>;
  123657. protected _reflectionBlur: float;
  123658. /**
  123659. * Reflection Texture level of blur.
  123660. *
  123661. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  123662. * texture twice.
  123663. */
  123664. reflectionBlur: float;
  123665. protected _diffuseTexture: Nullable<BaseTexture>;
  123666. /**
  123667. * Diffuse Texture used in the material.
  123668. * Should be author in a specific way for the best result (refer to the documentation).
  123669. */
  123670. diffuseTexture: Nullable<BaseTexture>;
  123671. protected _shadowLights: Nullable<IShadowLight[]>;
  123672. /**
  123673. * Specify the list of lights casting shadow on the material.
  123674. * All scene shadow lights will be included if null.
  123675. */
  123676. shadowLights: Nullable<IShadowLight[]>;
  123677. protected _shadowLevel: float;
  123678. /**
  123679. * Helps adjusting the shadow to a softer level if required.
  123680. * 0 means black shadows and 1 means no shadows.
  123681. */
  123682. shadowLevel: float;
  123683. protected _sceneCenter: Vector3;
  123684. /**
  123685. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  123686. * It is usually zero but might be interesting to modify according to your setup.
  123687. */
  123688. sceneCenter: Vector3;
  123689. protected _opacityFresnel: boolean;
  123690. /**
  123691. * This helps specifying that the material is falling off to the sky box at grazing angle.
  123692. * This helps ensuring a nice transition when the camera goes under the ground.
  123693. */
  123694. opacityFresnel: boolean;
  123695. protected _reflectionFresnel: boolean;
  123696. /**
  123697. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  123698. * This helps adding a mirror texture on the ground.
  123699. */
  123700. reflectionFresnel: boolean;
  123701. protected _reflectionFalloffDistance: number;
  123702. /**
  123703. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  123704. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  123705. */
  123706. reflectionFalloffDistance: number;
  123707. protected _reflectionAmount: number;
  123708. /**
  123709. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  123710. */
  123711. reflectionAmount: number;
  123712. protected _reflectionReflectance0: number;
  123713. /**
  123714. * This specifies the weight of the reflection at grazing angle.
  123715. */
  123716. reflectionReflectance0: number;
  123717. protected _reflectionReflectance90: number;
  123718. /**
  123719. * This specifies the weight of the reflection at a perpendicular point of view.
  123720. */
  123721. reflectionReflectance90: number;
  123722. /**
  123723. * Sets the reflection reflectance fresnel values according to the default standard
  123724. * empirically know to work well :-)
  123725. */
  123726. set reflectionStandardFresnelWeight(value: number);
  123727. protected _useRGBColor: boolean;
  123728. /**
  123729. * Helps to directly use the maps channels instead of their level.
  123730. */
  123731. useRGBColor: boolean;
  123732. protected _enableNoise: boolean;
  123733. /**
  123734. * This helps reducing the banding effect that could occur on the background.
  123735. */
  123736. enableNoise: boolean;
  123737. /**
  123738. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123739. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  123740. * Recommended to be keep at 1.0 except for special cases.
  123741. */
  123742. get fovMultiplier(): number;
  123743. set fovMultiplier(value: number);
  123744. private _fovMultiplier;
  123745. /**
  123746. * Enable the FOV adjustment feature controlled by fovMultiplier.
  123747. */
  123748. useEquirectangularFOV: boolean;
  123749. private _maxSimultaneousLights;
  123750. /**
  123751. * Number of Simultaneous lights allowed on the material.
  123752. */
  123753. maxSimultaneousLights: int;
  123754. /**
  123755. * Default configuration related to image processing available in the Background Material.
  123756. */
  123757. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123758. /**
  123759. * Keep track of the image processing observer to allow dispose and replace.
  123760. */
  123761. private _imageProcessingObserver;
  123762. /**
  123763. * Attaches a new image processing configuration to the PBR Material.
  123764. * @param configuration (if null the scene configuration will be use)
  123765. */
  123766. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123767. /**
  123768. * Gets the image processing configuration used either in this material.
  123769. */
  123770. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  123771. /**
  123772. * Sets the Default image processing configuration used either in the this material.
  123773. *
  123774. * If sets to null, the scene one is in use.
  123775. */
  123776. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  123777. /**
  123778. * Gets wether the color curves effect is enabled.
  123779. */
  123780. get cameraColorCurvesEnabled(): boolean;
  123781. /**
  123782. * Sets wether the color curves effect is enabled.
  123783. */
  123784. set cameraColorCurvesEnabled(value: boolean);
  123785. /**
  123786. * Gets wether the color grading effect is enabled.
  123787. */
  123788. get cameraColorGradingEnabled(): boolean;
  123789. /**
  123790. * Gets wether the color grading effect is enabled.
  123791. */
  123792. set cameraColorGradingEnabled(value: boolean);
  123793. /**
  123794. * Gets wether tonemapping is enabled or not.
  123795. */
  123796. get cameraToneMappingEnabled(): boolean;
  123797. /**
  123798. * Sets wether tonemapping is enabled or not
  123799. */
  123800. set cameraToneMappingEnabled(value: boolean);
  123801. /**
  123802. * The camera exposure used on this material.
  123803. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  123804. * This corresponds to a photographic exposure.
  123805. */
  123806. get cameraExposure(): float;
  123807. /**
  123808. * The camera exposure used on this material.
  123809. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  123810. * This corresponds to a photographic exposure.
  123811. */
  123812. set cameraExposure(value: float);
  123813. /**
  123814. * Gets The camera contrast used on this material.
  123815. */
  123816. get cameraContrast(): float;
  123817. /**
  123818. * Sets The camera contrast used on this material.
  123819. */
  123820. set cameraContrast(value: float);
  123821. /**
  123822. * Gets the Color Grading 2D Lookup Texture.
  123823. */
  123824. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  123825. /**
  123826. * Sets the Color Grading 2D Lookup Texture.
  123827. */
  123828. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  123829. /**
  123830. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  123831. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  123832. * 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;
  123833. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  123834. */
  123835. get cameraColorCurves(): Nullable<ColorCurves>;
  123836. /**
  123837. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  123838. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  123839. * 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;
  123840. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  123841. */
  123842. set cameraColorCurves(value: Nullable<ColorCurves>);
  123843. /**
  123844. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  123845. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  123846. */
  123847. switchToBGR: boolean;
  123848. private _renderTargets;
  123849. private _reflectionControls;
  123850. private _white;
  123851. private _primaryShadowColor;
  123852. private _primaryHighlightColor;
  123853. /**
  123854. * Instantiates a Background Material in the given scene
  123855. * @param name The friendly name of the material
  123856. * @param scene The scene to add the material to
  123857. */
  123858. constructor(name: string, scene: Scene);
  123859. /**
  123860. * Gets a boolean indicating that current material needs to register RTT
  123861. */
  123862. get hasRenderTargetTextures(): boolean;
  123863. /**
  123864. * The entire material has been created in order to prevent overdraw.
  123865. * @returns false
  123866. */
  123867. needAlphaTesting(): boolean;
  123868. /**
  123869. * The entire material has been created in order to prevent overdraw.
  123870. * @returns true if blending is enable
  123871. */
  123872. needAlphaBlending(): boolean;
  123873. /**
  123874. * Checks wether the material is ready to be rendered for a given mesh.
  123875. * @param mesh The mesh to render
  123876. * @param subMesh The submesh to check against
  123877. * @param useInstances Specify wether or not the material is used with instances
  123878. * @returns true if all the dependencies are ready (Textures, Effects...)
  123879. */
  123880. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123881. /**
  123882. * Compute the primary color according to the chosen perceptual color.
  123883. */
  123884. private _computePrimaryColorFromPerceptualColor;
  123885. /**
  123886. * Compute the highlights and shadow colors according to their chosen levels.
  123887. */
  123888. private _computePrimaryColors;
  123889. /**
  123890. * Build the uniform buffer used in the material.
  123891. */
  123892. buildUniformLayout(): void;
  123893. /**
  123894. * Unbind the material.
  123895. */
  123896. unbind(): void;
  123897. /**
  123898. * Bind only the world matrix to the material.
  123899. * @param world The world matrix to bind.
  123900. */
  123901. bindOnlyWorldMatrix(world: Matrix): void;
  123902. /**
  123903. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  123904. * @param world The world matrix to bind.
  123905. * @param subMesh The submesh to bind for.
  123906. */
  123907. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123908. /**
  123909. * Checks to see if a texture is used in the material.
  123910. * @param texture - Base texture to use.
  123911. * @returns - Boolean specifying if a texture is used in the material.
  123912. */
  123913. hasTexture(texture: BaseTexture): boolean;
  123914. /**
  123915. * Dispose the material.
  123916. * @param forceDisposeEffect Force disposal of the associated effect.
  123917. * @param forceDisposeTextures Force disposal of the associated textures.
  123918. */
  123919. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  123920. /**
  123921. * Clones the material.
  123922. * @param name The cloned name.
  123923. * @returns The cloned material.
  123924. */
  123925. clone(name: string): BackgroundMaterial;
  123926. /**
  123927. * Serializes the current material to its JSON representation.
  123928. * @returns The JSON representation.
  123929. */
  123930. serialize(): any;
  123931. /**
  123932. * Gets the class name of the material
  123933. * @returns "BackgroundMaterial"
  123934. */
  123935. getClassName(): string;
  123936. /**
  123937. * Parse a JSON input to create back a background material.
  123938. * @param source The JSON data to parse
  123939. * @param scene The scene to create the parsed material in
  123940. * @param rootUrl The root url of the assets the material depends upon
  123941. * @returns the instantiated BackgroundMaterial.
  123942. */
  123943. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  123944. }
  123945. }
  123946. declare module BABYLON {
  123947. /**
  123948. * Represents the different options available during the creation of
  123949. * a Environment helper.
  123950. *
  123951. * This can control the default ground, skybox and image processing setup of your scene.
  123952. */
  123953. export interface IEnvironmentHelperOptions {
  123954. /**
  123955. * Specifies whether or not to create a ground.
  123956. * True by default.
  123957. */
  123958. createGround: boolean;
  123959. /**
  123960. * Specifies the ground size.
  123961. * 15 by default.
  123962. */
  123963. groundSize: number;
  123964. /**
  123965. * The texture used on the ground for the main color.
  123966. * Comes from the BabylonJS CDN by default.
  123967. *
  123968. * Remarks: Can be either a texture or a url.
  123969. */
  123970. groundTexture: string | BaseTexture;
  123971. /**
  123972. * The color mixed in the ground texture by default.
  123973. * BabylonJS clearColor by default.
  123974. */
  123975. groundColor: Color3;
  123976. /**
  123977. * Specifies the ground opacity.
  123978. * 1 by default.
  123979. */
  123980. groundOpacity: number;
  123981. /**
  123982. * Enables the ground to receive shadows.
  123983. * True by default.
  123984. */
  123985. enableGroundShadow: boolean;
  123986. /**
  123987. * Helps preventing the shadow to be fully black on the ground.
  123988. * 0.5 by default.
  123989. */
  123990. groundShadowLevel: number;
  123991. /**
  123992. * Creates a mirror texture attach to the ground.
  123993. * false by default.
  123994. */
  123995. enableGroundMirror: boolean;
  123996. /**
  123997. * Specifies the ground mirror size ratio.
  123998. * 0.3 by default as the default kernel is 64.
  123999. */
  124000. groundMirrorSizeRatio: number;
  124001. /**
  124002. * Specifies the ground mirror blur kernel size.
  124003. * 64 by default.
  124004. */
  124005. groundMirrorBlurKernel: number;
  124006. /**
  124007. * Specifies the ground mirror visibility amount.
  124008. * 1 by default
  124009. */
  124010. groundMirrorAmount: number;
  124011. /**
  124012. * Specifies the ground mirror reflectance weight.
  124013. * This uses the standard weight of the background material to setup the fresnel effect
  124014. * of the mirror.
  124015. * 1 by default.
  124016. */
  124017. groundMirrorFresnelWeight: number;
  124018. /**
  124019. * Specifies the ground mirror Falloff distance.
  124020. * This can helps reducing the size of the reflection.
  124021. * 0 by Default.
  124022. */
  124023. groundMirrorFallOffDistance: number;
  124024. /**
  124025. * Specifies the ground mirror texture type.
  124026. * Unsigned Int by Default.
  124027. */
  124028. groundMirrorTextureType: number;
  124029. /**
  124030. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  124031. * the shown objects.
  124032. */
  124033. groundYBias: number;
  124034. /**
  124035. * Specifies whether or not to create a skybox.
  124036. * True by default.
  124037. */
  124038. createSkybox: boolean;
  124039. /**
  124040. * Specifies the skybox size.
  124041. * 20 by default.
  124042. */
  124043. skyboxSize: number;
  124044. /**
  124045. * The texture used on the skybox for the main color.
  124046. * Comes from the BabylonJS CDN by default.
  124047. *
  124048. * Remarks: Can be either a texture or a url.
  124049. */
  124050. skyboxTexture: string | BaseTexture;
  124051. /**
  124052. * The color mixed in the skybox texture by default.
  124053. * BabylonJS clearColor by default.
  124054. */
  124055. skyboxColor: Color3;
  124056. /**
  124057. * The background rotation around the Y axis of the scene.
  124058. * This helps aligning the key lights of your scene with the background.
  124059. * 0 by default.
  124060. */
  124061. backgroundYRotation: number;
  124062. /**
  124063. * Compute automatically the size of the elements to best fit with the scene.
  124064. */
  124065. sizeAuto: boolean;
  124066. /**
  124067. * Default position of the rootMesh if autoSize is not true.
  124068. */
  124069. rootPosition: Vector3;
  124070. /**
  124071. * Sets up the image processing in the scene.
  124072. * true by default.
  124073. */
  124074. setupImageProcessing: boolean;
  124075. /**
  124076. * The texture used as your environment texture in the scene.
  124077. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  124078. *
  124079. * Remarks: Can be either a texture or a url.
  124080. */
  124081. environmentTexture: string | BaseTexture;
  124082. /**
  124083. * The value of the exposure to apply to the scene.
  124084. * 0.6 by default if setupImageProcessing is true.
  124085. */
  124086. cameraExposure: number;
  124087. /**
  124088. * The value of the contrast to apply to the scene.
  124089. * 1.6 by default if setupImageProcessing is true.
  124090. */
  124091. cameraContrast: number;
  124092. /**
  124093. * Specifies whether or not tonemapping should be enabled in the scene.
  124094. * true by default if setupImageProcessing is true.
  124095. */
  124096. toneMappingEnabled: boolean;
  124097. }
  124098. /**
  124099. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  124100. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  124101. * It also helps with the default setup of your imageProcessing configuration.
  124102. */
  124103. export class EnvironmentHelper {
  124104. /**
  124105. * Default ground texture URL.
  124106. */
  124107. private static _groundTextureCDNUrl;
  124108. /**
  124109. * Default skybox texture URL.
  124110. */
  124111. private static _skyboxTextureCDNUrl;
  124112. /**
  124113. * Default environment texture URL.
  124114. */
  124115. private static _environmentTextureCDNUrl;
  124116. /**
  124117. * Creates the default options for the helper.
  124118. */
  124119. private static _getDefaultOptions;
  124120. private _rootMesh;
  124121. /**
  124122. * Gets the root mesh created by the helper.
  124123. */
  124124. get rootMesh(): Mesh;
  124125. private _skybox;
  124126. /**
  124127. * Gets the skybox created by the helper.
  124128. */
  124129. get skybox(): Nullable<Mesh>;
  124130. private _skyboxTexture;
  124131. /**
  124132. * Gets the skybox texture created by the helper.
  124133. */
  124134. get skyboxTexture(): Nullable<BaseTexture>;
  124135. private _skyboxMaterial;
  124136. /**
  124137. * Gets the skybox material created by the helper.
  124138. */
  124139. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  124140. private _ground;
  124141. /**
  124142. * Gets the ground mesh created by the helper.
  124143. */
  124144. get ground(): Nullable<Mesh>;
  124145. private _groundTexture;
  124146. /**
  124147. * Gets the ground texture created by the helper.
  124148. */
  124149. get groundTexture(): Nullable<BaseTexture>;
  124150. private _groundMirror;
  124151. /**
  124152. * Gets the ground mirror created by the helper.
  124153. */
  124154. get groundMirror(): Nullable<MirrorTexture>;
  124155. /**
  124156. * Gets the ground mirror render list to helps pushing the meshes
  124157. * you wish in the ground reflection.
  124158. */
  124159. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  124160. private _groundMaterial;
  124161. /**
  124162. * Gets the ground material created by the helper.
  124163. */
  124164. get groundMaterial(): Nullable<BackgroundMaterial>;
  124165. /**
  124166. * Stores the creation options.
  124167. */
  124168. private readonly _scene;
  124169. private _options;
  124170. /**
  124171. * This observable will be notified with any error during the creation of the environment,
  124172. * mainly texture creation errors.
  124173. */
  124174. onErrorObservable: Observable<{
  124175. message?: string;
  124176. exception?: any;
  124177. }>;
  124178. /**
  124179. * constructor
  124180. * @param options Defines the options we want to customize the helper
  124181. * @param scene The scene to add the material to
  124182. */
  124183. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  124184. /**
  124185. * Updates the background according to the new options
  124186. * @param options
  124187. */
  124188. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  124189. /**
  124190. * Sets the primary color of all the available elements.
  124191. * @param color the main color to affect to the ground and the background
  124192. */
  124193. setMainColor(color: Color3): void;
  124194. /**
  124195. * Setup the image processing according to the specified options.
  124196. */
  124197. private _setupImageProcessing;
  124198. /**
  124199. * Setup the environment texture according to the specified options.
  124200. */
  124201. private _setupEnvironmentTexture;
  124202. /**
  124203. * Setup the background according to the specified options.
  124204. */
  124205. private _setupBackground;
  124206. /**
  124207. * Get the scene sizes according to the setup.
  124208. */
  124209. private _getSceneSize;
  124210. /**
  124211. * Setup the ground according to the specified options.
  124212. */
  124213. private _setupGround;
  124214. /**
  124215. * Setup the ground material according to the specified options.
  124216. */
  124217. private _setupGroundMaterial;
  124218. /**
  124219. * Setup the ground diffuse texture according to the specified options.
  124220. */
  124221. private _setupGroundDiffuseTexture;
  124222. /**
  124223. * Setup the ground mirror texture according to the specified options.
  124224. */
  124225. private _setupGroundMirrorTexture;
  124226. /**
  124227. * Setup the ground to receive the mirror texture.
  124228. */
  124229. private _setupMirrorInGroundMaterial;
  124230. /**
  124231. * Setup the skybox according to the specified options.
  124232. */
  124233. private _setupSkybox;
  124234. /**
  124235. * Setup the skybox material according to the specified options.
  124236. */
  124237. private _setupSkyboxMaterial;
  124238. /**
  124239. * Setup the skybox reflection texture according to the specified options.
  124240. */
  124241. private _setupSkyboxReflectionTexture;
  124242. private _errorHandler;
  124243. /**
  124244. * Dispose all the elements created by the Helper.
  124245. */
  124246. dispose(): void;
  124247. }
  124248. }
  124249. declare module BABYLON {
  124250. /**
  124251. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  124252. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  124253. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  124254. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124255. */
  124256. export class PhotoDome extends TransformNode {
  124257. /**
  124258. * Define the image as a Monoscopic panoramic 360 image.
  124259. */
  124260. static readonly MODE_MONOSCOPIC: number;
  124261. /**
  124262. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124263. */
  124264. static readonly MODE_TOPBOTTOM: number;
  124265. /**
  124266. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124267. */
  124268. static readonly MODE_SIDEBYSIDE: number;
  124269. private _useDirectMapping;
  124270. /**
  124271. * The texture being displayed on the sphere
  124272. */
  124273. protected _photoTexture: Texture;
  124274. /**
  124275. * Gets or sets the texture being displayed on the sphere
  124276. */
  124277. get photoTexture(): Texture;
  124278. set photoTexture(value: Texture);
  124279. /**
  124280. * Observable raised when an error occured while loading the 360 image
  124281. */
  124282. onLoadErrorObservable: Observable<string>;
  124283. /**
  124284. * The skybox material
  124285. */
  124286. protected _material: BackgroundMaterial;
  124287. /**
  124288. * The surface used for the skybox
  124289. */
  124290. protected _mesh: Mesh;
  124291. /**
  124292. * Gets the mesh used for the skybox.
  124293. */
  124294. get mesh(): Mesh;
  124295. /**
  124296. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124297. * Also see the options.resolution property.
  124298. */
  124299. get fovMultiplier(): number;
  124300. set fovMultiplier(value: number);
  124301. private _imageMode;
  124302. /**
  124303. * Gets or set the current video mode for the video. It can be:
  124304. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  124305. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124306. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124307. */
  124308. get imageMode(): number;
  124309. set imageMode(value: number);
  124310. /**
  124311. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  124312. * @param name Element's name, child elements will append suffixes for their own names.
  124313. * @param urlsOfPhoto defines the url of the photo to display
  124314. * @param options defines an object containing optional or exposed sub element properties
  124315. * @param onError defines a callback called when an error occured while loading the texture
  124316. */
  124317. constructor(name: string, urlOfPhoto: string, options: {
  124318. resolution?: number;
  124319. size?: number;
  124320. useDirectMapping?: boolean;
  124321. faceForward?: boolean;
  124322. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  124323. private _onBeforeCameraRenderObserver;
  124324. private _changeImageMode;
  124325. /**
  124326. * Releases resources associated with this node.
  124327. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  124328. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  124329. */
  124330. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124331. }
  124332. }
  124333. declare module BABYLON {
  124334. /**
  124335. * Class used to host RGBD texture specific utilities
  124336. */
  124337. export class RGBDTextureTools {
  124338. /**
  124339. * Expand the RGBD Texture from RGBD to Half Float if possible.
  124340. * @param texture the texture to expand.
  124341. */
  124342. static ExpandRGBDTexture(texture: Texture): void;
  124343. }
  124344. }
  124345. declare module BABYLON {
  124346. /**
  124347. * Class used to host texture specific utilities
  124348. */
  124349. export class BRDFTextureTools {
  124350. /**
  124351. * Prevents texture cache collision
  124352. */
  124353. private static _instanceNumber;
  124354. /**
  124355. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  124356. * @param scene defines the hosting scene
  124357. * @returns the environment BRDF texture
  124358. */
  124359. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  124360. private static _environmentBRDFBase64Texture;
  124361. }
  124362. }
  124363. declare module BABYLON {
  124364. /**
  124365. * @hidden
  124366. */
  124367. export interface IMaterialClearCoatDefines {
  124368. CLEARCOAT: boolean;
  124369. CLEARCOAT_DEFAULTIOR: boolean;
  124370. CLEARCOAT_TEXTURE: boolean;
  124371. CLEARCOAT_TEXTUREDIRECTUV: number;
  124372. CLEARCOAT_BUMP: boolean;
  124373. CLEARCOAT_BUMPDIRECTUV: number;
  124374. CLEARCOAT_TINT: boolean;
  124375. CLEARCOAT_TINT_TEXTURE: boolean;
  124376. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124377. /** @hidden */
  124378. _areTexturesDirty: boolean;
  124379. }
  124380. /**
  124381. * Define the code related to the clear coat parameters of the pbr material.
  124382. */
  124383. export class PBRClearCoatConfiguration {
  124384. /**
  124385. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124386. * The default fits with a polyurethane material.
  124387. */
  124388. private static readonly _DefaultIndexOfRefraction;
  124389. private _isEnabled;
  124390. /**
  124391. * Defines if the clear coat is enabled in the material.
  124392. */
  124393. isEnabled: boolean;
  124394. /**
  124395. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  124396. */
  124397. intensity: number;
  124398. /**
  124399. * Defines the clear coat layer roughness.
  124400. */
  124401. roughness: number;
  124402. private _indexOfRefraction;
  124403. /**
  124404. * Defines the index of refraction of the clear coat.
  124405. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124406. * The default fits with a polyurethane material.
  124407. * Changing the default value is more performance intensive.
  124408. */
  124409. indexOfRefraction: number;
  124410. private _texture;
  124411. /**
  124412. * Stores the clear coat values in a texture.
  124413. */
  124414. texture: Nullable<BaseTexture>;
  124415. private _bumpTexture;
  124416. /**
  124417. * Define the clear coat specific bump texture.
  124418. */
  124419. bumpTexture: Nullable<BaseTexture>;
  124420. private _isTintEnabled;
  124421. /**
  124422. * Defines if the clear coat tint is enabled in the material.
  124423. */
  124424. isTintEnabled: boolean;
  124425. /**
  124426. * Defines the clear coat tint of the material.
  124427. * This is only use if tint is enabled
  124428. */
  124429. tintColor: Color3;
  124430. /**
  124431. * Defines the distance at which the tint color should be found in the
  124432. * clear coat media.
  124433. * This is only use if tint is enabled
  124434. */
  124435. tintColorAtDistance: number;
  124436. /**
  124437. * Defines the clear coat layer thickness.
  124438. * This is only use if tint is enabled
  124439. */
  124440. tintThickness: number;
  124441. private _tintTexture;
  124442. /**
  124443. * Stores the clear tint values in a texture.
  124444. * rgb is tint
  124445. * a is a thickness factor
  124446. */
  124447. tintTexture: Nullable<BaseTexture>;
  124448. /** @hidden */
  124449. private _internalMarkAllSubMeshesAsTexturesDirty;
  124450. /** @hidden */
  124451. _markAllSubMeshesAsTexturesDirty(): void;
  124452. /**
  124453. * Instantiate a new istance of clear coat configuration.
  124454. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124455. */
  124456. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124457. /**
  124458. * Gets wehter the submesh is ready to be used or not.
  124459. * @param defines the list of "defines" to update.
  124460. * @param scene defines the scene the material belongs to.
  124461. * @param engine defines the engine the material belongs to.
  124462. * @param disableBumpMap defines wether the material disables bump or not.
  124463. * @returns - boolean indicating that the submesh is ready or not.
  124464. */
  124465. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  124466. /**
  124467. * Checks to see if a texture is used in the material.
  124468. * @param defines the list of "defines" to update.
  124469. * @param scene defines the scene to the material belongs to.
  124470. */
  124471. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  124472. /**
  124473. * Binds the material data.
  124474. * @param uniformBuffer defines the Uniform buffer to fill in.
  124475. * @param scene defines the scene the material belongs to.
  124476. * @param engine defines the engine the material belongs to.
  124477. * @param disableBumpMap defines wether the material disables bump or not.
  124478. * @param isFrozen defines wether the material is frozen or not.
  124479. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124480. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124481. */
  124482. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  124483. /**
  124484. * Checks to see if a texture is used in the material.
  124485. * @param texture - Base texture to use.
  124486. * @returns - Boolean specifying if a texture is used in the material.
  124487. */
  124488. hasTexture(texture: BaseTexture): boolean;
  124489. /**
  124490. * Returns an array of the actively used textures.
  124491. * @param activeTextures Array of BaseTextures
  124492. */
  124493. getActiveTextures(activeTextures: BaseTexture[]): void;
  124494. /**
  124495. * Returns the animatable textures.
  124496. * @param animatables Array of animatable textures.
  124497. */
  124498. getAnimatables(animatables: IAnimatable[]): void;
  124499. /**
  124500. * Disposes the resources of the material.
  124501. * @param forceDisposeTextures - Forces the disposal of all textures.
  124502. */
  124503. dispose(forceDisposeTextures?: boolean): void;
  124504. /**
  124505. * Get the current class name of the texture useful for serialization or dynamic coding.
  124506. * @returns "PBRClearCoatConfiguration"
  124507. */
  124508. getClassName(): string;
  124509. /**
  124510. * Add fallbacks to the effect fallbacks list.
  124511. * @param defines defines the Base texture to use.
  124512. * @param fallbacks defines the current fallback list.
  124513. * @param currentRank defines the current fallback rank.
  124514. * @returns the new fallback rank.
  124515. */
  124516. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124517. /**
  124518. * Add the required uniforms to the current list.
  124519. * @param uniforms defines the current uniform list.
  124520. */
  124521. static AddUniforms(uniforms: string[]): void;
  124522. /**
  124523. * Add the required samplers to the current list.
  124524. * @param samplers defines the current sampler list.
  124525. */
  124526. static AddSamplers(samplers: string[]): void;
  124527. /**
  124528. * Add the required uniforms to the current buffer.
  124529. * @param uniformBuffer defines the current uniform buffer.
  124530. */
  124531. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124532. /**
  124533. * Makes a duplicate of the current configuration into another one.
  124534. * @param clearCoatConfiguration define the config where to copy the info
  124535. */
  124536. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  124537. /**
  124538. * Serializes this clear coat configuration.
  124539. * @returns - An object with the serialized config.
  124540. */
  124541. serialize(): any;
  124542. /**
  124543. * Parses a anisotropy Configuration from a serialized object.
  124544. * @param source - Serialized object.
  124545. * @param scene Defines the scene we are parsing for
  124546. * @param rootUrl Defines the rootUrl to load from
  124547. */
  124548. parse(source: any, scene: Scene, rootUrl: string): void;
  124549. }
  124550. }
  124551. declare module BABYLON {
  124552. /**
  124553. * @hidden
  124554. */
  124555. export interface IMaterialAnisotropicDefines {
  124556. ANISOTROPIC: boolean;
  124557. ANISOTROPIC_TEXTURE: boolean;
  124558. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124559. MAINUV1: boolean;
  124560. _areTexturesDirty: boolean;
  124561. _needUVs: boolean;
  124562. }
  124563. /**
  124564. * Define the code related to the anisotropic parameters of the pbr material.
  124565. */
  124566. export class PBRAnisotropicConfiguration {
  124567. private _isEnabled;
  124568. /**
  124569. * Defines if the anisotropy is enabled in the material.
  124570. */
  124571. isEnabled: boolean;
  124572. /**
  124573. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  124574. */
  124575. intensity: number;
  124576. /**
  124577. * Defines if the effect is along the tangents, bitangents or in between.
  124578. * By default, the effect is "strectching" the highlights along the tangents.
  124579. */
  124580. direction: Vector2;
  124581. private _texture;
  124582. /**
  124583. * Stores the anisotropy values in a texture.
  124584. * rg is direction (like normal from -1 to 1)
  124585. * b is a intensity
  124586. */
  124587. texture: Nullable<BaseTexture>;
  124588. /** @hidden */
  124589. private _internalMarkAllSubMeshesAsTexturesDirty;
  124590. /** @hidden */
  124591. _markAllSubMeshesAsTexturesDirty(): void;
  124592. /**
  124593. * Instantiate a new istance of anisotropy configuration.
  124594. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124595. */
  124596. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124597. /**
  124598. * Specifies that the submesh is ready to be used.
  124599. * @param defines the list of "defines" to update.
  124600. * @param scene defines the scene the material belongs to.
  124601. * @returns - boolean indicating that the submesh is ready or not.
  124602. */
  124603. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  124604. /**
  124605. * Checks to see if a texture is used in the material.
  124606. * @param defines the list of "defines" to update.
  124607. * @param mesh the mesh we are preparing the defines for.
  124608. * @param scene defines the scene the material belongs to.
  124609. */
  124610. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  124611. /**
  124612. * Binds the material data.
  124613. * @param uniformBuffer defines the Uniform buffer to fill in.
  124614. * @param scene defines the scene the material belongs to.
  124615. * @param isFrozen defines wether the material is frozen or not.
  124616. */
  124617. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124618. /**
  124619. * Checks to see if a texture is used in the material.
  124620. * @param texture - Base texture to use.
  124621. * @returns - Boolean specifying if a texture is used in the material.
  124622. */
  124623. hasTexture(texture: BaseTexture): boolean;
  124624. /**
  124625. * Returns an array of the actively used textures.
  124626. * @param activeTextures Array of BaseTextures
  124627. */
  124628. getActiveTextures(activeTextures: BaseTexture[]): void;
  124629. /**
  124630. * Returns the animatable textures.
  124631. * @param animatables Array of animatable textures.
  124632. */
  124633. getAnimatables(animatables: IAnimatable[]): void;
  124634. /**
  124635. * Disposes the resources of the material.
  124636. * @param forceDisposeTextures - Forces the disposal of all textures.
  124637. */
  124638. dispose(forceDisposeTextures?: boolean): void;
  124639. /**
  124640. * Get the current class name of the texture useful for serialization or dynamic coding.
  124641. * @returns "PBRAnisotropicConfiguration"
  124642. */
  124643. getClassName(): string;
  124644. /**
  124645. * Add fallbacks to the effect fallbacks list.
  124646. * @param defines defines the Base texture to use.
  124647. * @param fallbacks defines the current fallback list.
  124648. * @param currentRank defines the current fallback rank.
  124649. * @returns the new fallback rank.
  124650. */
  124651. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124652. /**
  124653. * Add the required uniforms to the current list.
  124654. * @param uniforms defines the current uniform list.
  124655. */
  124656. static AddUniforms(uniforms: string[]): void;
  124657. /**
  124658. * Add the required uniforms to the current buffer.
  124659. * @param uniformBuffer defines the current uniform buffer.
  124660. */
  124661. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124662. /**
  124663. * Add the required samplers to the current list.
  124664. * @param samplers defines the current sampler list.
  124665. */
  124666. static AddSamplers(samplers: string[]): void;
  124667. /**
  124668. * Makes a duplicate of the current configuration into another one.
  124669. * @param anisotropicConfiguration define the config where to copy the info
  124670. */
  124671. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  124672. /**
  124673. * Serializes this anisotropy configuration.
  124674. * @returns - An object with the serialized config.
  124675. */
  124676. serialize(): any;
  124677. /**
  124678. * Parses a anisotropy Configuration from a serialized object.
  124679. * @param source - Serialized object.
  124680. * @param scene Defines the scene we are parsing for
  124681. * @param rootUrl Defines the rootUrl to load from
  124682. */
  124683. parse(source: any, scene: Scene, rootUrl: string): void;
  124684. }
  124685. }
  124686. declare module BABYLON {
  124687. /**
  124688. * @hidden
  124689. */
  124690. export interface IMaterialBRDFDefines {
  124691. BRDF_V_HEIGHT_CORRELATED: boolean;
  124692. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124693. SPHERICAL_HARMONICS: boolean;
  124694. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124695. /** @hidden */
  124696. _areMiscDirty: boolean;
  124697. }
  124698. /**
  124699. * Define the code related to the BRDF parameters of the pbr material.
  124700. */
  124701. export class PBRBRDFConfiguration {
  124702. /**
  124703. * Default value used for the energy conservation.
  124704. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124705. */
  124706. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  124707. /**
  124708. * Default value used for the Smith Visibility Height Correlated mode.
  124709. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124710. */
  124711. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  124712. /**
  124713. * Default value used for the IBL diffuse part.
  124714. * This can help switching back to the polynomials mode globally which is a tiny bit
  124715. * less GPU intensive at the drawback of a lower quality.
  124716. */
  124717. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  124718. /**
  124719. * Default value used for activating energy conservation for the specular workflow.
  124720. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124721. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124722. */
  124723. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  124724. private _useEnergyConservation;
  124725. /**
  124726. * Defines if the material uses energy conservation.
  124727. */
  124728. useEnergyConservation: boolean;
  124729. private _useSmithVisibilityHeightCorrelated;
  124730. /**
  124731. * LEGACY Mode set to false
  124732. * Defines if the material uses height smith correlated visibility term.
  124733. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  124734. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  124735. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  124736. * Not relying on height correlated will also disable energy conservation.
  124737. */
  124738. useSmithVisibilityHeightCorrelated: boolean;
  124739. private _useSphericalHarmonics;
  124740. /**
  124741. * LEGACY Mode set to false
  124742. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  124743. * diffuse part of the IBL.
  124744. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  124745. * to the ground truth.
  124746. */
  124747. useSphericalHarmonics: boolean;
  124748. private _useSpecularGlossinessInputEnergyConservation;
  124749. /**
  124750. * Defines if the material uses energy conservation, when the specular workflow is active.
  124751. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124752. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124753. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  124754. */
  124755. useSpecularGlossinessInputEnergyConservation: boolean;
  124756. /** @hidden */
  124757. private _internalMarkAllSubMeshesAsMiscDirty;
  124758. /** @hidden */
  124759. _markAllSubMeshesAsMiscDirty(): void;
  124760. /**
  124761. * Instantiate a new istance of clear coat configuration.
  124762. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  124763. */
  124764. constructor(markAllSubMeshesAsMiscDirty: () => void);
  124765. /**
  124766. * Checks to see if a texture is used in the material.
  124767. * @param defines the list of "defines" to update.
  124768. */
  124769. prepareDefines(defines: IMaterialBRDFDefines): void;
  124770. /**
  124771. * Get the current class name of the texture useful for serialization or dynamic coding.
  124772. * @returns "PBRClearCoatConfiguration"
  124773. */
  124774. getClassName(): string;
  124775. /**
  124776. * Makes a duplicate of the current configuration into another one.
  124777. * @param brdfConfiguration define the config where to copy the info
  124778. */
  124779. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  124780. /**
  124781. * Serializes this BRDF configuration.
  124782. * @returns - An object with the serialized config.
  124783. */
  124784. serialize(): any;
  124785. /**
  124786. * Parses a anisotropy Configuration from a serialized object.
  124787. * @param source - Serialized object.
  124788. * @param scene Defines the scene we are parsing for
  124789. * @param rootUrl Defines the rootUrl to load from
  124790. */
  124791. parse(source: any, scene: Scene, rootUrl: string): void;
  124792. }
  124793. }
  124794. declare module BABYLON {
  124795. /**
  124796. * @hidden
  124797. */
  124798. export interface IMaterialSheenDefines {
  124799. SHEEN: boolean;
  124800. SHEEN_TEXTURE: boolean;
  124801. SHEEN_TEXTUREDIRECTUV: number;
  124802. SHEEN_LINKWITHALBEDO: boolean;
  124803. SHEEN_ROUGHNESS: boolean;
  124804. SHEEN_ALBEDOSCALING: boolean;
  124805. /** @hidden */
  124806. _areTexturesDirty: boolean;
  124807. }
  124808. /**
  124809. * Define the code related to the Sheen parameters of the pbr material.
  124810. */
  124811. export class PBRSheenConfiguration {
  124812. private _isEnabled;
  124813. /**
  124814. * Defines if the material uses sheen.
  124815. */
  124816. isEnabled: boolean;
  124817. private _linkSheenWithAlbedo;
  124818. /**
  124819. * Defines if the sheen is linked to the sheen color.
  124820. */
  124821. linkSheenWithAlbedo: boolean;
  124822. /**
  124823. * Defines the sheen intensity.
  124824. */
  124825. intensity: number;
  124826. /**
  124827. * Defines the sheen color.
  124828. */
  124829. color: Color3;
  124830. private _texture;
  124831. /**
  124832. * Stores the sheen tint values in a texture.
  124833. * rgb is tint
  124834. * a is a intensity
  124835. */
  124836. texture: Nullable<BaseTexture>;
  124837. private _roughness;
  124838. /**
  124839. * Defines the sheen roughness.
  124840. * It is not taken into account if linkSheenWithAlbedo is true.
  124841. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  124842. */
  124843. roughness: Nullable<number>;
  124844. private _albedoScaling;
  124845. /**
  124846. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  124847. * It allows the strength of the sheen effect to not depend on the base color of the material,
  124848. * making it easier to setup and tweak the effect
  124849. */
  124850. albedoScaling: boolean;
  124851. /** @hidden */
  124852. private _internalMarkAllSubMeshesAsTexturesDirty;
  124853. /** @hidden */
  124854. _markAllSubMeshesAsTexturesDirty(): void;
  124855. /**
  124856. * Instantiate a new istance of clear coat configuration.
  124857. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124858. */
  124859. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124860. /**
  124861. * Specifies that the submesh is ready to be used.
  124862. * @param defines the list of "defines" to update.
  124863. * @param scene defines the scene the material belongs to.
  124864. * @returns - boolean indicating that the submesh is ready or not.
  124865. */
  124866. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  124867. /**
  124868. * Checks to see if a texture is used in the material.
  124869. * @param defines the list of "defines" to update.
  124870. * @param scene defines the scene the material belongs to.
  124871. */
  124872. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  124873. /**
  124874. * Binds the material data.
  124875. * @param uniformBuffer defines the Uniform buffer to fill in.
  124876. * @param scene defines the scene the material belongs to.
  124877. * @param isFrozen defines wether the material is frozen or not.
  124878. */
  124879. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124880. /**
  124881. * Checks to see if a texture is used in the material.
  124882. * @param texture - Base texture to use.
  124883. * @returns - Boolean specifying if a texture is used in the material.
  124884. */
  124885. hasTexture(texture: BaseTexture): boolean;
  124886. /**
  124887. * Returns an array of the actively used textures.
  124888. * @param activeTextures Array of BaseTextures
  124889. */
  124890. getActiveTextures(activeTextures: BaseTexture[]): void;
  124891. /**
  124892. * Returns the animatable textures.
  124893. * @param animatables Array of animatable textures.
  124894. */
  124895. getAnimatables(animatables: IAnimatable[]): void;
  124896. /**
  124897. * Disposes the resources of the material.
  124898. * @param forceDisposeTextures - Forces the disposal of all textures.
  124899. */
  124900. dispose(forceDisposeTextures?: boolean): void;
  124901. /**
  124902. * Get the current class name of the texture useful for serialization or dynamic coding.
  124903. * @returns "PBRSheenConfiguration"
  124904. */
  124905. getClassName(): string;
  124906. /**
  124907. * Add fallbacks to the effect fallbacks list.
  124908. * @param defines defines the Base texture to use.
  124909. * @param fallbacks defines the current fallback list.
  124910. * @param currentRank defines the current fallback rank.
  124911. * @returns the new fallback rank.
  124912. */
  124913. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124914. /**
  124915. * Add the required uniforms to the current list.
  124916. * @param uniforms defines the current uniform list.
  124917. */
  124918. static AddUniforms(uniforms: string[]): void;
  124919. /**
  124920. * Add the required uniforms to the current buffer.
  124921. * @param uniformBuffer defines the current uniform buffer.
  124922. */
  124923. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124924. /**
  124925. * Add the required samplers to the current list.
  124926. * @param samplers defines the current sampler list.
  124927. */
  124928. static AddSamplers(samplers: string[]): void;
  124929. /**
  124930. * Makes a duplicate of the current configuration into another one.
  124931. * @param sheenConfiguration define the config where to copy the info
  124932. */
  124933. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  124934. /**
  124935. * Serializes this BRDF configuration.
  124936. * @returns - An object with the serialized config.
  124937. */
  124938. serialize(): any;
  124939. /**
  124940. * Parses a anisotropy Configuration from a serialized object.
  124941. * @param source - Serialized object.
  124942. * @param scene Defines the scene we are parsing for
  124943. * @param rootUrl Defines the rootUrl to load from
  124944. */
  124945. parse(source: any, scene: Scene, rootUrl: string): void;
  124946. }
  124947. }
  124948. declare module BABYLON {
  124949. /**
  124950. * @hidden
  124951. */
  124952. export interface IMaterialSubSurfaceDefines {
  124953. SUBSURFACE: boolean;
  124954. SS_REFRACTION: boolean;
  124955. SS_TRANSLUCENCY: boolean;
  124956. SS_SCATERRING: boolean;
  124957. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124958. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124959. SS_REFRACTIONMAP_3D: boolean;
  124960. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124961. SS_LODINREFRACTIONALPHA: boolean;
  124962. SS_GAMMAREFRACTION: boolean;
  124963. SS_RGBDREFRACTION: boolean;
  124964. SS_LINEARSPECULARREFRACTION: boolean;
  124965. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124966. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124967. /** @hidden */
  124968. _areTexturesDirty: boolean;
  124969. }
  124970. /**
  124971. * Define the code related to the sub surface parameters of the pbr material.
  124972. */
  124973. export class PBRSubSurfaceConfiguration {
  124974. private _isRefractionEnabled;
  124975. /**
  124976. * Defines if the refraction is enabled in the material.
  124977. */
  124978. isRefractionEnabled: boolean;
  124979. private _isTranslucencyEnabled;
  124980. /**
  124981. * Defines if the translucency is enabled in the material.
  124982. */
  124983. isTranslucencyEnabled: boolean;
  124984. private _isScatteringEnabled;
  124985. /**
  124986. * Defines the refraction intensity of the material.
  124987. * The refraction when enabled replaces the Diffuse part of the material.
  124988. * The intensity helps transitionning between diffuse and refraction.
  124989. */
  124990. refractionIntensity: number;
  124991. /**
  124992. * Defines the translucency intensity of the material.
  124993. * When translucency has been enabled, this defines how much of the "translucency"
  124994. * is addded to the diffuse part of the material.
  124995. */
  124996. translucencyIntensity: number;
  124997. /**
  124998. * Defines the scattering intensity of the material.
  124999. * When scattering has been enabled, this defines how much of the "scattered light"
  125000. * is addded to the diffuse part of the material.
  125001. */
  125002. scatteringIntensity: number;
  125003. private _thicknessTexture;
  125004. /**
  125005. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  125006. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  125007. * 0 would mean minimumThickness
  125008. * 1 would mean maximumThickness
  125009. * The other channels might be use as a mask to vary the different effects intensity.
  125010. */
  125011. thicknessTexture: Nullable<BaseTexture>;
  125012. private _refractionTexture;
  125013. /**
  125014. * Defines the texture to use for refraction.
  125015. */
  125016. refractionTexture: Nullable<BaseTexture>;
  125017. private _indexOfRefraction;
  125018. /**
  125019. * Defines the index of refraction used in the material.
  125020. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  125021. */
  125022. indexOfRefraction: number;
  125023. private _invertRefractionY;
  125024. /**
  125025. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125026. */
  125027. invertRefractionY: boolean;
  125028. private _linkRefractionWithTransparency;
  125029. /**
  125030. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125031. * Materials half opaque for instance using refraction could benefit from this control.
  125032. */
  125033. linkRefractionWithTransparency: boolean;
  125034. /**
  125035. * Defines the minimum thickness stored in the thickness map.
  125036. * If no thickness map is defined, this value will be used to simulate thickness.
  125037. */
  125038. minimumThickness: number;
  125039. /**
  125040. * Defines the maximum thickness stored in the thickness map.
  125041. */
  125042. maximumThickness: number;
  125043. /**
  125044. * Defines the volume tint of the material.
  125045. * This is used for both translucency and scattering.
  125046. */
  125047. tintColor: Color3;
  125048. /**
  125049. * Defines the distance at which the tint color should be found in the media.
  125050. * This is used for refraction only.
  125051. */
  125052. tintColorAtDistance: number;
  125053. /**
  125054. * Defines how far each channel transmit through the media.
  125055. * It is defined as a color to simplify it selection.
  125056. */
  125057. diffusionDistance: Color3;
  125058. private _useMaskFromThicknessTexture;
  125059. /**
  125060. * Stores the intensity of the different subsurface effects in the thickness texture.
  125061. * * the green channel is the translucency intensity.
  125062. * * the blue channel is the scattering intensity.
  125063. * * the alpha channel is the refraction intensity.
  125064. */
  125065. useMaskFromThicknessTexture: boolean;
  125066. /** @hidden */
  125067. private _internalMarkAllSubMeshesAsTexturesDirty;
  125068. /** @hidden */
  125069. _markAllSubMeshesAsTexturesDirty(): void;
  125070. /**
  125071. * Instantiate a new istance of sub surface configuration.
  125072. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125073. */
  125074. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125075. /**
  125076. * Gets wehter the submesh is ready to be used or not.
  125077. * @param defines the list of "defines" to update.
  125078. * @param scene defines the scene the material belongs to.
  125079. * @returns - boolean indicating that the submesh is ready or not.
  125080. */
  125081. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  125082. /**
  125083. * Checks to see if a texture is used in the material.
  125084. * @param defines the list of "defines" to update.
  125085. * @param scene defines the scene to the material belongs to.
  125086. */
  125087. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  125088. /**
  125089. * Binds the material data.
  125090. * @param uniformBuffer defines the Uniform buffer to fill in.
  125091. * @param scene defines the scene the material belongs to.
  125092. * @param engine defines the engine the material belongs to.
  125093. * @param isFrozen defines wether the material is frozen or not.
  125094. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  125095. */
  125096. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  125097. /**
  125098. * Unbinds the material from the mesh.
  125099. * @param activeEffect defines the effect that should be unbound from.
  125100. * @returns true if unbound, otherwise false
  125101. */
  125102. unbind(activeEffect: Effect): boolean;
  125103. /**
  125104. * Returns the texture used for refraction or null if none is used.
  125105. * @param scene defines the scene the material belongs to.
  125106. * @returns - Refraction texture if present. If no refraction texture and refraction
  125107. * is linked with transparency, returns environment texture. Otherwise, returns null.
  125108. */
  125109. private _getRefractionTexture;
  125110. /**
  125111. * Returns true if alpha blending should be disabled.
  125112. */
  125113. get disableAlphaBlending(): boolean;
  125114. /**
  125115. * Fills the list of render target textures.
  125116. * @param renderTargets the list of render targets to update
  125117. */
  125118. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  125119. /**
  125120. * Checks to see if a texture is used in the material.
  125121. * @param texture - Base texture to use.
  125122. * @returns - Boolean specifying if a texture is used in the material.
  125123. */
  125124. hasTexture(texture: BaseTexture): boolean;
  125125. /**
  125126. * Gets a boolean indicating that current material needs to register RTT
  125127. * @returns true if this uses a render target otherwise false.
  125128. */
  125129. hasRenderTargetTextures(): boolean;
  125130. /**
  125131. * Returns an array of the actively used textures.
  125132. * @param activeTextures Array of BaseTextures
  125133. */
  125134. getActiveTextures(activeTextures: BaseTexture[]): void;
  125135. /**
  125136. * Returns the animatable textures.
  125137. * @param animatables Array of animatable textures.
  125138. */
  125139. getAnimatables(animatables: IAnimatable[]): void;
  125140. /**
  125141. * Disposes the resources of the material.
  125142. * @param forceDisposeTextures - Forces the disposal of all textures.
  125143. */
  125144. dispose(forceDisposeTextures?: boolean): void;
  125145. /**
  125146. * Get the current class name of the texture useful for serialization or dynamic coding.
  125147. * @returns "PBRSubSurfaceConfiguration"
  125148. */
  125149. getClassName(): string;
  125150. /**
  125151. * Add fallbacks to the effect fallbacks list.
  125152. * @param defines defines the Base texture to use.
  125153. * @param fallbacks defines the current fallback list.
  125154. * @param currentRank defines the current fallback rank.
  125155. * @returns the new fallback rank.
  125156. */
  125157. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125158. /**
  125159. * Add the required uniforms to the current list.
  125160. * @param uniforms defines the current uniform list.
  125161. */
  125162. static AddUniforms(uniforms: string[]): void;
  125163. /**
  125164. * Add the required samplers to the current list.
  125165. * @param samplers defines the current sampler list.
  125166. */
  125167. static AddSamplers(samplers: string[]): void;
  125168. /**
  125169. * Add the required uniforms to the current buffer.
  125170. * @param uniformBuffer defines the current uniform buffer.
  125171. */
  125172. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125173. /**
  125174. * Makes a duplicate of the current configuration into another one.
  125175. * @param configuration define the config where to copy the info
  125176. */
  125177. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  125178. /**
  125179. * Serializes this Sub Surface configuration.
  125180. * @returns - An object with the serialized config.
  125181. */
  125182. serialize(): any;
  125183. /**
  125184. * Parses a anisotropy Configuration from a serialized object.
  125185. * @param source - Serialized object.
  125186. * @param scene Defines the scene we are parsing for
  125187. * @param rootUrl Defines the rootUrl to load from
  125188. */
  125189. parse(source: any, scene: Scene, rootUrl: string): void;
  125190. }
  125191. }
  125192. declare module BABYLON {
  125193. /** @hidden */
  125194. export var pbrFragmentDeclaration: {
  125195. name: string;
  125196. shader: string;
  125197. };
  125198. }
  125199. declare module BABYLON {
  125200. /** @hidden */
  125201. export var pbrUboDeclaration: {
  125202. name: string;
  125203. shader: string;
  125204. };
  125205. }
  125206. declare module BABYLON {
  125207. /** @hidden */
  125208. export var pbrFragmentExtraDeclaration: {
  125209. name: string;
  125210. shader: string;
  125211. };
  125212. }
  125213. declare module BABYLON {
  125214. /** @hidden */
  125215. export var pbrFragmentSamplersDeclaration: {
  125216. name: string;
  125217. shader: string;
  125218. };
  125219. }
  125220. declare module BABYLON {
  125221. /** @hidden */
  125222. export var pbrHelperFunctions: {
  125223. name: string;
  125224. shader: string;
  125225. };
  125226. }
  125227. declare module BABYLON {
  125228. /** @hidden */
  125229. export var harmonicsFunctions: {
  125230. name: string;
  125231. shader: string;
  125232. };
  125233. }
  125234. declare module BABYLON {
  125235. /** @hidden */
  125236. export var pbrDirectLightingSetupFunctions: {
  125237. name: string;
  125238. shader: string;
  125239. };
  125240. }
  125241. declare module BABYLON {
  125242. /** @hidden */
  125243. export var pbrDirectLightingFalloffFunctions: {
  125244. name: string;
  125245. shader: string;
  125246. };
  125247. }
  125248. declare module BABYLON {
  125249. /** @hidden */
  125250. export var pbrBRDFFunctions: {
  125251. name: string;
  125252. shader: string;
  125253. };
  125254. }
  125255. declare module BABYLON {
  125256. /** @hidden */
  125257. export var pbrDirectLightingFunctions: {
  125258. name: string;
  125259. shader: string;
  125260. };
  125261. }
  125262. declare module BABYLON {
  125263. /** @hidden */
  125264. export var pbrIBLFunctions: {
  125265. name: string;
  125266. shader: string;
  125267. };
  125268. }
  125269. declare module BABYLON {
  125270. /** @hidden */
  125271. export var pbrDebug: {
  125272. name: string;
  125273. shader: string;
  125274. };
  125275. }
  125276. declare module BABYLON {
  125277. /** @hidden */
  125278. export var pbrPixelShader: {
  125279. name: string;
  125280. shader: string;
  125281. };
  125282. }
  125283. declare module BABYLON {
  125284. /** @hidden */
  125285. export var pbrVertexDeclaration: {
  125286. name: string;
  125287. shader: string;
  125288. };
  125289. }
  125290. declare module BABYLON {
  125291. /** @hidden */
  125292. export var pbrVertexShader: {
  125293. name: string;
  125294. shader: string;
  125295. };
  125296. }
  125297. declare module BABYLON {
  125298. /**
  125299. * Manages the defines for the PBR Material.
  125300. * @hidden
  125301. */
  125302. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  125303. PBR: boolean;
  125304. MAINUV1: boolean;
  125305. MAINUV2: boolean;
  125306. UV1: boolean;
  125307. UV2: boolean;
  125308. ALBEDO: boolean;
  125309. GAMMAALBEDO: boolean;
  125310. ALBEDODIRECTUV: number;
  125311. VERTEXCOLOR: boolean;
  125312. AMBIENT: boolean;
  125313. AMBIENTDIRECTUV: number;
  125314. AMBIENTINGRAYSCALE: boolean;
  125315. OPACITY: boolean;
  125316. VERTEXALPHA: boolean;
  125317. OPACITYDIRECTUV: number;
  125318. OPACITYRGB: boolean;
  125319. ALPHATEST: boolean;
  125320. DEPTHPREPASS: boolean;
  125321. ALPHABLEND: boolean;
  125322. ALPHAFROMALBEDO: boolean;
  125323. ALPHATESTVALUE: string;
  125324. SPECULAROVERALPHA: boolean;
  125325. RADIANCEOVERALPHA: boolean;
  125326. ALPHAFRESNEL: boolean;
  125327. LINEARALPHAFRESNEL: boolean;
  125328. PREMULTIPLYALPHA: boolean;
  125329. EMISSIVE: boolean;
  125330. EMISSIVEDIRECTUV: number;
  125331. REFLECTIVITY: boolean;
  125332. REFLECTIVITYDIRECTUV: number;
  125333. SPECULARTERM: boolean;
  125334. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  125335. MICROSURFACEAUTOMATIC: boolean;
  125336. LODBASEDMICROSFURACE: boolean;
  125337. MICROSURFACEMAP: boolean;
  125338. MICROSURFACEMAPDIRECTUV: number;
  125339. METALLICWORKFLOW: boolean;
  125340. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  125341. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  125342. METALLNESSSTOREINMETALMAPBLUE: boolean;
  125343. AOSTOREINMETALMAPRED: boolean;
  125344. METALLICF0FACTORFROMMETALLICMAP: boolean;
  125345. ENVIRONMENTBRDF: boolean;
  125346. ENVIRONMENTBRDF_RGBD: boolean;
  125347. NORMAL: boolean;
  125348. TANGENT: boolean;
  125349. BUMP: boolean;
  125350. BUMPDIRECTUV: number;
  125351. OBJECTSPACE_NORMALMAP: boolean;
  125352. PARALLAX: boolean;
  125353. PARALLAXOCCLUSION: boolean;
  125354. NORMALXYSCALE: boolean;
  125355. LIGHTMAP: boolean;
  125356. LIGHTMAPDIRECTUV: number;
  125357. USELIGHTMAPASSHADOWMAP: boolean;
  125358. GAMMALIGHTMAP: boolean;
  125359. RGBDLIGHTMAP: boolean;
  125360. REFLECTION: boolean;
  125361. REFLECTIONMAP_3D: boolean;
  125362. REFLECTIONMAP_SPHERICAL: boolean;
  125363. REFLECTIONMAP_PLANAR: boolean;
  125364. REFLECTIONMAP_CUBIC: boolean;
  125365. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  125366. REFLECTIONMAP_PROJECTION: boolean;
  125367. REFLECTIONMAP_SKYBOX: boolean;
  125368. REFLECTIONMAP_EXPLICIT: boolean;
  125369. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  125370. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  125371. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  125372. INVERTCUBICMAP: boolean;
  125373. USESPHERICALFROMREFLECTIONMAP: boolean;
  125374. USEIRRADIANCEMAP: boolean;
  125375. SPHERICAL_HARMONICS: boolean;
  125376. USESPHERICALINVERTEX: boolean;
  125377. REFLECTIONMAP_OPPOSITEZ: boolean;
  125378. LODINREFLECTIONALPHA: boolean;
  125379. GAMMAREFLECTION: boolean;
  125380. RGBDREFLECTION: boolean;
  125381. LINEARSPECULARREFLECTION: boolean;
  125382. RADIANCEOCCLUSION: boolean;
  125383. HORIZONOCCLUSION: boolean;
  125384. INSTANCES: boolean;
  125385. NUM_BONE_INFLUENCERS: number;
  125386. BonesPerMesh: number;
  125387. BONETEXTURE: boolean;
  125388. NONUNIFORMSCALING: boolean;
  125389. MORPHTARGETS: boolean;
  125390. MORPHTARGETS_NORMAL: boolean;
  125391. MORPHTARGETS_TANGENT: boolean;
  125392. MORPHTARGETS_UV: boolean;
  125393. NUM_MORPH_INFLUENCERS: number;
  125394. IMAGEPROCESSING: boolean;
  125395. VIGNETTE: boolean;
  125396. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125397. VIGNETTEBLENDMODEOPAQUE: boolean;
  125398. TONEMAPPING: boolean;
  125399. TONEMAPPING_ACES: boolean;
  125400. CONTRAST: boolean;
  125401. COLORCURVES: boolean;
  125402. COLORGRADING: boolean;
  125403. COLORGRADING3D: boolean;
  125404. SAMPLER3DGREENDEPTH: boolean;
  125405. SAMPLER3DBGRMAP: boolean;
  125406. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125407. EXPOSURE: boolean;
  125408. MULTIVIEW: boolean;
  125409. USEPHYSICALLIGHTFALLOFF: boolean;
  125410. USEGLTFLIGHTFALLOFF: boolean;
  125411. TWOSIDEDLIGHTING: boolean;
  125412. SHADOWFLOAT: boolean;
  125413. CLIPPLANE: boolean;
  125414. CLIPPLANE2: boolean;
  125415. CLIPPLANE3: boolean;
  125416. CLIPPLANE4: boolean;
  125417. CLIPPLANE5: boolean;
  125418. CLIPPLANE6: boolean;
  125419. POINTSIZE: boolean;
  125420. FOG: boolean;
  125421. LOGARITHMICDEPTH: boolean;
  125422. FORCENORMALFORWARD: boolean;
  125423. SPECULARAA: boolean;
  125424. CLEARCOAT: boolean;
  125425. CLEARCOAT_DEFAULTIOR: boolean;
  125426. CLEARCOAT_TEXTURE: boolean;
  125427. CLEARCOAT_TEXTUREDIRECTUV: number;
  125428. CLEARCOAT_BUMP: boolean;
  125429. CLEARCOAT_BUMPDIRECTUV: number;
  125430. CLEARCOAT_TINT: boolean;
  125431. CLEARCOAT_TINT_TEXTURE: boolean;
  125432. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  125433. ANISOTROPIC: boolean;
  125434. ANISOTROPIC_TEXTURE: boolean;
  125435. ANISOTROPIC_TEXTUREDIRECTUV: number;
  125436. BRDF_V_HEIGHT_CORRELATED: boolean;
  125437. MS_BRDF_ENERGY_CONSERVATION: boolean;
  125438. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  125439. SHEEN: boolean;
  125440. SHEEN_TEXTURE: boolean;
  125441. SHEEN_TEXTUREDIRECTUV: number;
  125442. SHEEN_LINKWITHALBEDO: boolean;
  125443. SHEEN_ROUGHNESS: boolean;
  125444. SHEEN_ALBEDOSCALING: boolean;
  125445. SUBSURFACE: boolean;
  125446. SS_REFRACTION: boolean;
  125447. SS_TRANSLUCENCY: boolean;
  125448. SS_SCATERRING: boolean;
  125449. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125450. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125451. SS_REFRACTIONMAP_3D: boolean;
  125452. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125453. SS_LODINREFRACTIONALPHA: boolean;
  125454. SS_GAMMAREFRACTION: boolean;
  125455. SS_RGBDREFRACTION: boolean;
  125456. SS_LINEARSPECULARREFRACTION: boolean;
  125457. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125458. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125459. UNLIT: boolean;
  125460. DEBUGMODE: number;
  125461. /**
  125462. * Initializes the PBR Material defines.
  125463. */
  125464. constructor();
  125465. /**
  125466. * Resets the PBR Material defines.
  125467. */
  125468. reset(): void;
  125469. }
  125470. /**
  125471. * The Physically based material base class of BJS.
  125472. *
  125473. * This offers the main features of a standard PBR material.
  125474. * For more information, please refer to the documentation :
  125475. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125476. */
  125477. export abstract class PBRBaseMaterial extends PushMaterial {
  125478. /**
  125479. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125480. */
  125481. static readonly PBRMATERIAL_OPAQUE: number;
  125482. /**
  125483. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125484. */
  125485. static readonly PBRMATERIAL_ALPHATEST: number;
  125486. /**
  125487. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125488. */
  125489. static readonly PBRMATERIAL_ALPHABLEND: number;
  125490. /**
  125491. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125492. * They are also discarded below the alpha cutoff threshold to improve performances.
  125493. */
  125494. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125495. /**
  125496. * Defines the default value of how much AO map is occluding the analytical lights
  125497. * (point spot...).
  125498. */
  125499. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125500. /**
  125501. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  125502. */
  125503. static readonly LIGHTFALLOFF_PHYSICAL: number;
  125504. /**
  125505. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  125506. * to enhance interoperability with other engines.
  125507. */
  125508. static readonly LIGHTFALLOFF_GLTF: number;
  125509. /**
  125510. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  125511. * to enhance interoperability with other materials.
  125512. */
  125513. static readonly LIGHTFALLOFF_STANDARD: number;
  125514. /**
  125515. * Intensity of the direct lights e.g. the four lights available in your scene.
  125516. * This impacts both the direct diffuse and specular highlights.
  125517. */
  125518. protected _directIntensity: number;
  125519. /**
  125520. * Intensity of the emissive part of the material.
  125521. * This helps controlling the emissive effect without modifying the emissive color.
  125522. */
  125523. protected _emissiveIntensity: number;
  125524. /**
  125525. * Intensity of the environment e.g. how much the environment will light the object
  125526. * either through harmonics for rough material or through the refelction for shiny ones.
  125527. */
  125528. protected _environmentIntensity: number;
  125529. /**
  125530. * This is a special control allowing the reduction of the specular highlights coming from the
  125531. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125532. */
  125533. protected _specularIntensity: number;
  125534. /**
  125535. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  125536. */
  125537. private _lightingInfos;
  125538. /**
  125539. * Debug Control allowing disabling the bump map on this material.
  125540. */
  125541. protected _disableBumpMap: boolean;
  125542. /**
  125543. * AKA Diffuse Texture in standard nomenclature.
  125544. */
  125545. protected _albedoTexture: Nullable<BaseTexture>;
  125546. /**
  125547. * AKA Occlusion Texture in other nomenclature.
  125548. */
  125549. protected _ambientTexture: Nullable<BaseTexture>;
  125550. /**
  125551. * AKA Occlusion Texture Intensity in other nomenclature.
  125552. */
  125553. protected _ambientTextureStrength: number;
  125554. /**
  125555. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125556. * 1 means it completely occludes it
  125557. * 0 mean it has no impact
  125558. */
  125559. protected _ambientTextureImpactOnAnalyticalLights: number;
  125560. /**
  125561. * Stores the alpha values in a texture.
  125562. */
  125563. protected _opacityTexture: Nullable<BaseTexture>;
  125564. /**
  125565. * Stores the reflection values in a texture.
  125566. */
  125567. protected _reflectionTexture: Nullable<BaseTexture>;
  125568. /**
  125569. * Stores the emissive values in a texture.
  125570. */
  125571. protected _emissiveTexture: Nullable<BaseTexture>;
  125572. /**
  125573. * AKA Specular texture in other nomenclature.
  125574. */
  125575. protected _reflectivityTexture: Nullable<BaseTexture>;
  125576. /**
  125577. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125578. */
  125579. protected _metallicTexture: Nullable<BaseTexture>;
  125580. /**
  125581. * Specifies the metallic scalar of the metallic/roughness workflow.
  125582. * Can also be used to scale the metalness values of the metallic texture.
  125583. */
  125584. protected _metallic: Nullable<number>;
  125585. /**
  125586. * Specifies the roughness scalar of the metallic/roughness workflow.
  125587. * Can also be used to scale the roughness values of the metallic texture.
  125588. */
  125589. protected _roughness: Nullable<number>;
  125590. /**
  125591. * Specifies the an F0 factor to help configuring the material F0.
  125592. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125593. * to 0.5 the previously hard coded value stays the same.
  125594. * Can also be used to scale the F0 values of the metallic texture.
  125595. */
  125596. protected _metallicF0Factor: number;
  125597. /**
  125598. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125599. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125600. * your expectation as it multiplies with the texture data.
  125601. */
  125602. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  125603. /**
  125604. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125605. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125606. */
  125607. protected _microSurfaceTexture: Nullable<BaseTexture>;
  125608. /**
  125609. * Stores surface normal data used to displace a mesh in a texture.
  125610. */
  125611. protected _bumpTexture: Nullable<BaseTexture>;
  125612. /**
  125613. * Stores the pre-calculated light information of a mesh in a texture.
  125614. */
  125615. protected _lightmapTexture: Nullable<BaseTexture>;
  125616. /**
  125617. * The color of a material in ambient lighting.
  125618. */
  125619. protected _ambientColor: Color3;
  125620. /**
  125621. * AKA Diffuse Color in other nomenclature.
  125622. */
  125623. protected _albedoColor: Color3;
  125624. /**
  125625. * AKA Specular Color in other nomenclature.
  125626. */
  125627. protected _reflectivityColor: Color3;
  125628. /**
  125629. * The color applied when light is reflected from a material.
  125630. */
  125631. protected _reflectionColor: Color3;
  125632. /**
  125633. * The color applied when light is emitted from a material.
  125634. */
  125635. protected _emissiveColor: Color3;
  125636. /**
  125637. * AKA Glossiness in other nomenclature.
  125638. */
  125639. protected _microSurface: number;
  125640. /**
  125641. * Specifies that the material will use the light map as a show map.
  125642. */
  125643. protected _useLightmapAsShadowmap: boolean;
  125644. /**
  125645. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125646. * makes the reflect vector face the model (under horizon).
  125647. */
  125648. protected _useHorizonOcclusion: boolean;
  125649. /**
  125650. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125651. * too much the area relying on ambient texture to define their ambient occlusion.
  125652. */
  125653. protected _useRadianceOcclusion: boolean;
  125654. /**
  125655. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  125656. */
  125657. protected _useAlphaFromAlbedoTexture: boolean;
  125658. /**
  125659. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  125660. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  125661. */
  125662. protected _useSpecularOverAlpha: boolean;
  125663. /**
  125664. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  125665. */
  125666. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  125667. /**
  125668. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  125669. */
  125670. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  125671. /**
  125672. * Specifies if the metallic texture contains the roughness information in its green channel.
  125673. */
  125674. protected _useRoughnessFromMetallicTextureGreen: boolean;
  125675. /**
  125676. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125677. */
  125678. protected _useMetallnessFromMetallicTextureBlue: boolean;
  125679. /**
  125680. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125681. */
  125682. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  125683. /**
  125684. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125685. */
  125686. protected _useAmbientInGrayScale: boolean;
  125687. /**
  125688. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125689. * The material will try to infer what glossiness each pixel should be.
  125690. */
  125691. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  125692. /**
  125693. * Defines the falloff type used in this material.
  125694. * It by default is Physical.
  125695. */
  125696. protected _lightFalloff: number;
  125697. /**
  125698. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125699. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125700. */
  125701. protected _useRadianceOverAlpha: boolean;
  125702. /**
  125703. * Allows using an object space normal map (instead of tangent space).
  125704. */
  125705. protected _useObjectSpaceNormalMap: boolean;
  125706. /**
  125707. * Allows using the bump map in parallax mode.
  125708. */
  125709. protected _useParallax: boolean;
  125710. /**
  125711. * Allows using the bump map in parallax occlusion mode.
  125712. */
  125713. protected _useParallaxOcclusion: boolean;
  125714. /**
  125715. * Controls the scale bias of the parallax mode.
  125716. */
  125717. protected _parallaxScaleBias: number;
  125718. /**
  125719. * If sets to true, disables all the lights affecting the material.
  125720. */
  125721. protected _disableLighting: boolean;
  125722. /**
  125723. * Number of Simultaneous lights allowed on the material.
  125724. */
  125725. protected _maxSimultaneousLights: number;
  125726. /**
  125727. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  125728. */
  125729. protected _invertNormalMapX: boolean;
  125730. /**
  125731. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  125732. */
  125733. protected _invertNormalMapY: boolean;
  125734. /**
  125735. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125736. */
  125737. protected _twoSidedLighting: boolean;
  125738. /**
  125739. * Defines the alpha limits in alpha test mode.
  125740. */
  125741. protected _alphaCutOff: number;
  125742. /**
  125743. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  125744. */
  125745. protected _forceAlphaTest: boolean;
  125746. /**
  125747. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125748. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125749. */
  125750. protected _useAlphaFresnel: boolean;
  125751. /**
  125752. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125753. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125754. */
  125755. protected _useLinearAlphaFresnel: boolean;
  125756. /**
  125757. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  125758. * from cos thetav and roughness:
  125759. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  125760. */
  125761. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  125762. /**
  125763. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125764. */
  125765. protected _forceIrradianceInFragment: boolean;
  125766. /**
  125767. * Force normal to face away from face.
  125768. */
  125769. protected _forceNormalForward: boolean;
  125770. /**
  125771. * Enables specular anti aliasing in the PBR shader.
  125772. * It will both interacts on the Geometry for analytical and IBL lighting.
  125773. * It also prefilter the roughness map based on the bump values.
  125774. */
  125775. protected _enableSpecularAntiAliasing: boolean;
  125776. /**
  125777. * Default configuration related to image processing available in the PBR Material.
  125778. */
  125779. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  125780. /**
  125781. * Keep track of the image processing observer to allow dispose and replace.
  125782. */
  125783. private _imageProcessingObserver;
  125784. /**
  125785. * Attaches a new image processing configuration to the PBR Material.
  125786. * @param configuration
  125787. */
  125788. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  125789. /**
  125790. * Stores the available render targets.
  125791. */
  125792. private _renderTargets;
  125793. /**
  125794. * Sets the global ambient color for the material used in lighting calculations.
  125795. */
  125796. private _globalAmbientColor;
  125797. /**
  125798. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  125799. */
  125800. private _useLogarithmicDepth;
  125801. /**
  125802. * If set to true, no lighting calculations will be applied.
  125803. */
  125804. private _unlit;
  125805. private _debugMode;
  125806. /**
  125807. * @hidden
  125808. * This is reserved for the inspector.
  125809. * Defines the material debug mode.
  125810. * It helps seeing only some components of the material while troubleshooting.
  125811. */
  125812. debugMode: number;
  125813. /**
  125814. * @hidden
  125815. * This is reserved for the inspector.
  125816. * Specify from where on screen the debug mode should start.
  125817. * The value goes from -1 (full screen) to 1 (not visible)
  125818. * It helps with side by side comparison against the final render
  125819. * This defaults to -1
  125820. */
  125821. private debugLimit;
  125822. /**
  125823. * @hidden
  125824. * This is reserved for the inspector.
  125825. * As the default viewing range might not be enough (if the ambient is really small for instance)
  125826. * You can use the factor to better multiply the final value.
  125827. */
  125828. private debugFactor;
  125829. /**
  125830. * Defines the clear coat layer parameters for the material.
  125831. */
  125832. readonly clearCoat: PBRClearCoatConfiguration;
  125833. /**
  125834. * Defines the anisotropic parameters for the material.
  125835. */
  125836. readonly anisotropy: PBRAnisotropicConfiguration;
  125837. /**
  125838. * Defines the BRDF parameters for the material.
  125839. */
  125840. readonly brdf: PBRBRDFConfiguration;
  125841. /**
  125842. * Defines the Sheen parameters for the material.
  125843. */
  125844. readonly sheen: PBRSheenConfiguration;
  125845. /**
  125846. * Defines the SubSurface parameters for the material.
  125847. */
  125848. readonly subSurface: PBRSubSurfaceConfiguration;
  125849. /**
  125850. * Custom callback helping to override the default shader used in the material.
  125851. */
  125852. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  125853. protected _rebuildInParallel: boolean;
  125854. /**
  125855. * Instantiates a new PBRMaterial instance.
  125856. *
  125857. * @param name The material name
  125858. * @param scene The scene the material will be use in.
  125859. */
  125860. constructor(name: string, scene: Scene);
  125861. /**
  125862. * Gets a boolean indicating that current material needs to register RTT
  125863. */
  125864. get hasRenderTargetTextures(): boolean;
  125865. /**
  125866. * Gets the name of the material class.
  125867. */
  125868. getClassName(): string;
  125869. /**
  125870. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  125871. */
  125872. get useLogarithmicDepth(): boolean;
  125873. /**
  125874. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  125875. */
  125876. set useLogarithmicDepth(value: boolean);
  125877. /**
  125878. * Returns true if alpha blending should be disabled.
  125879. */
  125880. protected get _disableAlphaBlending(): boolean;
  125881. /**
  125882. * Specifies whether or not this material should be rendered in alpha blend mode.
  125883. */
  125884. needAlphaBlending(): boolean;
  125885. /**
  125886. * Specifies whether or not this material should be rendered in alpha test mode.
  125887. */
  125888. needAlphaTesting(): boolean;
  125889. /**
  125890. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  125891. */
  125892. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  125893. /**
  125894. * Gets the texture used for the alpha test.
  125895. */
  125896. getAlphaTestTexture(): Nullable<BaseTexture>;
  125897. /**
  125898. * Specifies that the submesh is ready to be used.
  125899. * @param mesh - BJS mesh.
  125900. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  125901. * @param useInstances - Specifies that instances should be used.
  125902. * @returns - boolean indicating that the submesh is ready or not.
  125903. */
  125904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  125905. /**
  125906. * Specifies if the material uses metallic roughness workflow.
  125907. * @returns boolean specifiying if the material uses metallic roughness workflow.
  125908. */
  125909. isMetallicWorkflow(): boolean;
  125910. private _prepareEffect;
  125911. private _prepareDefines;
  125912. /**
  125913. * Force shader compilation
  125914. */
  125915. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  125916. /**
  125917. * Initializes the uniform buffer layout for the shader.
  125918. */
  125919. buildUniformLayout(): void;
  125920. /**
  125921. * Unbinds the material from the mesh
  125922. */
  125923. unbind(): void;
  125924. /**
  125925. * Binds the submesh data.
  125926. * @param world - The world matrix.
  125927. * @param mesh - The BJS mesh.
  125928. * @param subMesh - A submesh of the BJS mesh.
  125929. */
  125930. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  125931. /**
  125932. * Returns the animatable textures.
  125933. * @returns - Array of animatable textures.
  125934. */
  125935. getAnimatables(): IAnimatable[];
  125936. /**
  125937. * Returns the texture used for reflections.
  125938. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  125939. */
  125940. private _getReflectionTexture;
  125941. /**
  125942. * Returns an array of the actively used textures.
  125943. * @returns - Array of BaseTextures
  125944. */
  125945. getActiveTextures(): BaseTexture[];
  125946. /**
  125947. * Checks to see if a texture is used in the material.
  125948. * @param texture - Base texture to use.
  125949. * @returns - Boolean specifying if a texture is used in the material.
  125950. */
  125951. hasTexture(texture: BaseTexture): boolean;
  125952. /**
  125953. * Disposes the resources of the material.
  125954. * @param forceDisposeEffect - Forces the disposal of effects.
  125955. * @param forceDisposeTextures - Forces the disposal of all textures.
  125956. */
  125957. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  125958. }
  125959. }
  125960. declare module BABYLON {
  125961. /**
  125962. * The Physically based material of BJS.
  125963. *
  125964. * This offers the main features of a standard PBR material.
  125965. * For more information, please refer to the documentation :
  125966. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125967. */
  125968. export class PBRMaterial extends PBRBaseMaterial {
  125969. /**
  125970. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125971. */
  125972. static readonly PBRMATERIAL_OPAQUE: number;
  125973. /**
  125974. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125975. */
  125976. static readonly PBRMATERIAL_ALPHATEST: number;
  125977. /**
  125978. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125979. */
  125980. static readonly PBRMATERIAL_ALPHABLEND: number;
  125981. /**
  125982. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125983. * They are also discarded below the alpha cutoff threshold to improve performances.
  125984. */
  125985. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125986. /**
  125987. * Defines the default value of how much AO map is occluding the analytical lights
  125988. * (point spot...).
  125989. */
  125990. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125991. /**
  125992. * Intensity of the direct lights e.g. the four lights available in your scene.
  125993. * This impacts both the direct diffuse and specular highlights.
  125994. */
  125995. directIntensity: number;
  125996. /**
  125997. * Intensity of the emissive part of the material.
  125998. * This helps controlling the emissive effect without modifying the emissive color.
  125999. */
  126000. emissiveIntensity: number;
  126001. /**
  126002. * Intensity of the environment e.g. how much the environment will light the object
  126003. * either through harmonics for rough material or through the refelction for shiny ones.
  126004. */
  126005. environmentIntensity: number;
  126006. /**
  126007. * This is a special control allowing the reduction of the specular highlights coming from the
  126008. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  126009. */
  126010. specularIntensity: number;
  126011. /**
  126012. * Debug Control allowing disabling the bump map on this material.
  126013. */
  126014. disableBumpMap: boolean;
  126015. /**
  126016. * AKA Diffuse Texture in standard nomenclature.
  126017. */
  126018. albedoTexture: BaseTexture;
  126019. /**
  126020. * AKA Occlusion Texture in other nomenclature.
  126021. */
  126022. ambientTexture: BaseTexture;
  126023. /**
  126024. * AKA Occlusion Texture Intensity in other nomenclature.
  126025. */
  126026. ambientTextureStrength: number;
  126027. /**
  126028. * Defines how much the AO map is occluding the analytical lights (point spot...).
  126029. * 1 means it completely occludes it
  126030. * 0 mean it has no impact
  126031. */
  126032. ambientTextureImpactOnAnalyticalLights: number;
  126033. /**
  126034. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  126035. */
  126036. opacityTexture: BaseTexture;
  126037. /**
  126038. * Stores the reflection values in a texture.
  126039. */
  126040. reflectionTexture: Nullable<BaseTexture>;
  126041. /**
  126042. * Stores the emissive values in a texture.
  126043. */
  126044. emissiveTexture: BaseTexture;
  126045. /**
  126046. * AKA Specular texture in other nomenclature.
  126047. */
  126048. reflectivityTexture: BaseTexture;
  126049. /**
  126050. * Used to switch from specular/glossiness to metallic/roughness workflow.
  126051. */
  126052. metallicTexture: BaseTexture;
  126053. /**
  126054. * Specifies the metallic scalar of the metallic/roughness workflow.
  126055. * Can also be used to scale the metalness values of the metallic texture.
  126056. */
  126057. metallic: Nullable<number>;
  126058. /**
  126059. * Specifies the roughness scalar of the metallic/roughness workflow.
  126060. * Can also be used to scale the roughness values of the metallic texture.
  126061. */
  126062. roughness: Nullable<number>;
  126063. /**
  126064. * Specifies the an F0 factor to help configuring the material F0.
  126065. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  126066. * to 0.5 the previously hard coded value stays the same.
  126067. * Can also be used to scale the F0 values of the metallic texture.
  126068. */
  126069. metallicF0Factor: number;
  126070. /**
  126071. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  126072. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  126073. * your expectation as it multiplies with the texture data.
  126074. */
  126075. useMetallicF0FactorFromMetallicTexture: boolean;
  126076. /**
  126077. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  126078. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  126079. */
  126080. microSurfaceTexture: BaseTexture;
  126081. /**
  126082. * Stores surface normal data used to displace a mesh in a texture.
  126083. */
  126084. bumpTexture: BaseTexture;
  126085. /**
  126086. * Stores the pre-calculated light information of a mesh in a texture.
  126087. */
  126088. lightmapTexture: BaseTexture;
  126089. /**
  126090. * Stores the refracted light information in a texture.
  126091. */
  126092. get refractionTexture(): Nullable<BaseTexture>;
  126093. set refractionTexture(value: Nullable<BaseTexture>);
  126094. /**
  126095. * The color of a material in ambient lighting.
  126096. */
  126097. ambientColor: Color3;
  126098. /**
  126099. * AKA Diffuse Color in other nomenclature.
  126100. */
  126101. albedoColor: Color3;
  126102. /**
  126103. * AKA Specular Color in other nomenclature.
  126104. */
  126105. reflectivityColor: Color3;
  126106. /**
  126107. * The color reflected from the material.
  126108. */
  126109. reflectionColor: Color3;
  126110. /**
  126111. * The color emitted from the material.
  126112. */
  126113. emissiveColor: Color3;
  126114. /**
  126115. * AKA Glossiness in other nomenclature.
  126116. */
  126117. microSurface: number;
  126118. /**
  126119. * source material index of refraction (IOR)' / 'destination material IOR.
  126120. */
  126121. get indexOfRefraction(): number;
  126122. set indexOfRefraction(value: number);
  126123. /**
  126124. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  126125. */
  126126. get invertRefractionY(): boolean;
  126127. set invertRefractionY(value: boolean);
  126128. /**
  126129. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  126130. * Materials half opaque for instance using refraction could benefit from this control.
  126131. */
  126132. get linkRefractionWithTransparency(): boolean;
  126133. set linkRefractionWithTransparency(value: boolean);
  126134. /**
  126135. * If true, the light map contains occlusion information instead of lighting info.
  126136. */
  126137. useLightmapAsShadowmap: boolean;
  126138. /**
  126139. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126140. */
  126141. useAlphaFromAlbedoTexture: boolean;
  126142. /**
  126143. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126144. */
  126145. forceAlphaTest: boolean;
  126146. /**
  126147. * Defines the alpha limits in alpha test mode.
  126148. */
  126149. alphaCutOff: number;
  126150. /**
  126151. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  126152. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126153. */
  126154. useSpecularOverAlpha: boolean;
  126155. /**
  126156. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126157. */
  126158. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126159. /**
  126160. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126161. */
  126162. useRoughnessFromMetallicTextureAlpha: boolean;
  126163. /**
  126164. * Specifies if the metallic texture contains the roughness information in its green channel.
  126165. */
  126166. useRoughnessFromMetallicTextureGreen: boolean;
  126167. /**
  126168. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126169. */
  126170. useMetallnessFromMetallicTextureBlue: boolean;
  126171. /**
  126172. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126173. */
  126174. useAmbientOcclusionFromMetallicTextureRed: boolean;
  126175. /**
  126176. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126177. */
  126178. useAmbientInGrayScale: boolean;
  126179. /**
  126180. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126181. * The material will try to infer what glossiness each pixel should be.
  126182. */
  126183. useAutoMicroSurfaceFromReflectivityMap: boolean;
  126184. /**
  126185. * BJS is using an harcoded light falloff based on a manually sets up range.
  126186. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126187. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126188. */
  126189. get usePhysicalLightFalloff(): boolean;
  126190. /**
  126191. * BJS is using an harcoded light falloff based on a manually sets up range.
  126192. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126193. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126194. */
  126195. set usePhysicalLightFalloff(value: boolean);
  126196. /**
  126197. * In order to support the falloff compatibility with gltf, a special mode has been added
  126198. * to reproduce the gltf light falloff.
  126199. */
  126200. get useGLTFLightFalloff(): boolean;
  126201. /**
  126202. * In order to support the falloff compatibility with gltf, a special mode has been added
  126203. * to reproduce the gltf light falloff.
  126204. */
  126205. set useGLTFLightFalloff(value: boolean);
  126206. /**
  126207. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126208. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126209. */
  126210. useRadianceOverAlpha: boolean;
  126211. /**
  126212. * Allows using an object space normal map (instead of tangent space).
  126213. */
  126214. useObjectSpaceNormalMap: boolean;
  126215. /**
  126216. * Allows using the bump map in parallax mode.
  126217. */
  126218. useParallax: boolean;
  126219. /**
  126220. * Allows using the bump map in parallax occlusion mode.
  126221. */
  126222. useParallaxOcclusion: boolean;
  126223. /**
  126224. * Controls the scale bias of the parallax mode.
  126225. */
  126226. parallaxScaleBias: number;
  126227. /**
  126228. * If sets to true, disables all the lights affecting the material.
  126229. */
  126230. disableLighting: boolean;
  126231. /**
  126232. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126233. */
  126234. forceIrradianceInFragment: boolean;
  126235. /**
  126236. * Number of Simultaneous lights allowed on the material.
  126237. */
  126238. maxSimultaneousLights: number;
  126239. /**
  126240. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126241. */
  126242. invertNormalMapX: boolean;
  126243. /**
  126244. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126245. */
  126246. invertNormalMapY: boolean;
  126247. /**
  126248. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126249. */
  126250. twoSidedLighting: boolean;
  126251. /**
  126252. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126253. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126254. */
  126255. useAlphaFresnel: boolean;
  126256. /**
  126257. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126258. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126259. */
  126260. useLinearAlphaFresnel: boolean;
  126261. /**
  126262. * Let user defines the brdf lookup texture used for IBL.
  126263. * A default 8bit version is embedded but you could point at :
  126264. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  126265. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  126266. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  126267. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  126268. */
  126269. environmentBRDFTexture: Nullable<BaseTexture>;
  126270. /**
  126271. * Force normal to face away from face.
  126272. */
  126273. forceNormalForward: boolean;
  126274. /**
  126275. * Enables specular anti aliasing in the PBR shader.
  126276. * It will both interacts on the Geometry for analytical and IBL lighting.
  126277. * It also prefilter the roughness map based on the bump values.
  126278. */
  126279. enableSpecularAntiAliasing: boolean;
  126280. /**
  126281. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126282. * makes the reflect vector face the model (under horizon).
  126283. */
  126284. useHorizonOcclusion: boolean;
  126285. /**
  126286. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126287. * too much the area relying on ambient texture to define their ambient occlusion.
  126288. */
  126289. useRadianceOcclusion: boolean;
  126290. /**
  126291. * If set to true, no lighting calculations will be applied.
  126292. */
  126293. unlit: boolean;
  126294. /**
  126295. * Gets the image processing configuration used either in this material.
  126296. */
  126297. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126298. /**
  126299. * Sets the Default image processing configuration used either in the this material.
  126300. *
  126301. * If sets to null, the scene one is in use.
  126302. */
  126303. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126304. /**
  126305. * Gets wether the color curves effect is enabled.
  126306. */
  126307. get cameraColorCurvesEnabled(): boolean;
  126308. /**
  126309. * Sets wether the color curves effect is enabled.
  126310. */
  126311. set cameraColorCurvesEnabled(value: boolean);
  126312. /**
  126313. * Gets wether the color grading effect is enabled.
  126314. */
  126315. get cameraColorGradingEnabled(): boolean;
  126316. /**
  126317. * Gets wether the color grading effect is enabled.
  126318. */
  126319. set cameraColorGradingEnabled(value: boolean);
  126320. /**
  126321. * Gets wether tonemapping is enabled or not.
  126322. */
  126323. get cameraToneMappingEnabled(): boolean;
  126324. /**
  126325. * Sets wether tonemapping is enabled or not
  126326. */
  126327. set cameraToneMappingEnabled(value: boolean);
  126328. /**
  126329. * The camera exposure used on this material.
  126330. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126331. * This corresponds to a photographic exposure.
  126332. */
  126333. get cameraExposure(): number;
  126334. /**
  126335. * The camera exposure used on this material.
  126336. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126337. * This corresponds to a photographic exposure.
  126338. */
  126339. set cameraExposure(value: number);
  126340. /**
  126341. * Gets The camera contrast used on this material.
  126342. */
  126343. get cameraContrast(): number;
  126344. /**
  126345. * Sets The camera contrast used on this material.
  126346. */
  126347. set cameraContrast(value: number);
  126348. /**
  126349. * Gets the Color Grading 2D Lookup Texture.
  126350. */
  126351. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126352. /**
  126353. * Sets the Color Grading 2D Lookup Texture.
  126354. */
  126355. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126356. /**
  126357. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126358. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126359. * 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;
  126360. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126361. */
  126362. get cameraColorCurves(): Nullable<ColorCurves>;
  126363. /**
  126364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126366. * 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;
  126367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126368. */
  126369. set cameraColorCurves(value: Nullable<ColorCurves>);
  126370. /**
  126371. * Instantiates a new PBRMaterial instance.
  126372. *
  126373. * @param name The material name
  126374. * @param scene The scene the material will be use in.
  126375. */
  126376. constructor(name: string, scene: Scene);
  126377. /**
  126378. * Returns the name of this material class.
  126379. */
  126380. getClassName(): string;
  126381. /**
  126382. * Makes a duplicate of the current material.
  126383. * @param name - name to use for the new material.
  126384. */
  126385. clone(name: string): PBRMaterial;
  126386. /**
  126387. * Serializes this PBR Material.
  126388. * @returns - An object with the serialized material.
  126389. */
  126390. serialize(): any;
  126391. /**
  126392. * Parses a PBR Material from a serialized object.
  126393. * @param source - Serialized object.
  126394. * @param scene - BJS scene instance.
  126395. * @param rootUrl - url for the scene object
  126396. * @returns - PBRMaterial
  126397. */
  126398. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  126399. }
  126400. }
  126401. declare module BABYLON {
  126402. /**
  126403. * Direct draw surface info
  126404. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  126405. */
  126406. export interface DDSInfo {
  126407. /**
  126408. * Width of the texture
  126409. */
  126410. width: number;
  126411. /**
  126412. * Width of the texture
  126413. */
  126414. height: number;
  126415. /**
  126416. * Number of Mipmaps for the texture
  126417. * @see https://en.wikipedia.org/wiki/Mipmap
  126418. */
  126419. mipmapCount: number;
  126420. /**
  126421. * If the textures format is a known fourCC format
  126422. * @see https://www.fourcc.org/
  126423. */
  126424. isFourCC: boolean;
  126425. /**
  126426. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  126427. */
  126428. isRGB: boolean;
  126429. /**
  126430. * If the texture is a lumincance format
  126431. */
  126432. isLuminance: boolean;
  126433. /**
  126434. * If this is a cube texture
  126435. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  126436. */
  126437. isCube: boolean;
  126438. /**
  126439. * If the texture is a compressed format eg. FOURCC_DXT1
  126440. */
  126441. isCompressed: boolean;
  126442. /**
  126443. * The dxgiFormat of the texture
  126444. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  126445. */
  126446. dxgiFormat: number;
  126447. /**
  126448. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  126449. */
  126450. textureType: number;
  126451. /**
  126452. * Sphericle polynomial created for the dds texture
  126453. */
  126454. sphericalPolynomial?: SphericalPolynomial;
  126455. }
  126456. /**
  126457. * Class used to provide DDS decompression tools
  126458. */
  126459. export class DDSTools {
  126460. /**
  126461. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  126462. */
  126463. static StoreLODInAlphaChannel: boolean;
  126464. /**
  126465. * Gets DDS information from an array buffer
  126466. * @param data defines the array buffer view to read data from
  126467. * @returns the DDS information
  126468. */
  126469. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  126470. private static _FloatView;
  126471. private static _Int32View;
  126472. private static _ToHalfFloat;
  126473. private static _FromHalfFloat;
  126474. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  126475. private static _GetHalfFloatRGBAArrayBuffer;
  126476. private static _GetFloatRGBAArrayBuffer;
  126477. private static _GetFloatAsUIntRGBAArrayBuffer;
  126478. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  126479. private static _GetRGBAArrayBuffer;
  126480. private static _ExtractLongWordOrder;
  126481. private static _GetRGBArrayBuffer;
  126482. private static _GetLuminanceArrayBuffer;
  126483. /**
  126484. * Uploads DDS Levels to a Babylon Texture
  126485. * @hidden
  126486. */
  126487. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  126488. }
  126489. interface ThinEngine {
  126490. /**
  126491. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  126492. * @param rootUrl defines the url where the file to load is located
  126493. * @param scene defines the current scene
  126494. * @param lodScale defines scale to apply to the mip map selection
  126495. * @param lodOffset defines offset to apply to the mip map selection
  126496. * @param onLoad defines an optional callback raised when the texture is loaded
  126497. * @param onError defines an optional callback raised if there is an issue to load the texture
  126498. * @param format defines the format of the data
  126499. * @param forcedExtension defines the extension to use to pick the right loader
  126500. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  126501. * @returns the cube texture as an InternalTexture
  126502. */
  126503. 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;
  126504. }
  126505. }
  126506. declare module BABYLON {
  126507. /**
  126508. * Implementation of the DDS Texture Loader.
  126509. * @hidden
  126510. */
  126511. export class _DDSTextureLoader implements IInternalTextureLoader {
  126512. /**
  126513. * Defines wether the loader supports cascade loading the different faces.
  126514. */
  126515. readonly supportCascades: boolean;
  126516. /**
  126517. * This returns if the loader support the current file information.
  126518. * @param extension defines the file extension of the file being loaded
  126519. * @returns true if the loader can load the specified file
  126520. */
  126521. canLoad(extension: string): boolean;
  126522. /**
  126523. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126524. * @param data contains the texture data
  126525. * @param texture defines the BabylonJS internal texture
  126526. * @param createPolynomials will be true if polynomials have been requested
  126527. * @param onLoad defines the callback to trigger once the texture is ready
  126528. * @param onError defines the callback to trigger in case of error
  126529. */
  126530. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126531. /**
  126532. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126533. * @param data contains the texture data
  126534. * @param texture defines the BabylonJS internal texture
  126535. * @param callback defines the method to call once ready to upload
  126536. */
  126537. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126538. }
  126539. }
  126540. declare module BABYLON {
  126541. /**
  126542. * Implementation of the ENV Texture Loader.
  126543. * @hidden
  126544. */
  126545. export class _ENVTextureLoader implements IInternalTextureLoader {
  126546. /**
  126547. * Defines wether the loader supports cascade loading the different faces.
  126548. */
  126549. readonly supportCascades: boolean;
  126550. /**
  126551. * This returns if the loader support the current file information.
  126552. * @param extension defines the file extension of the file being loaded
  126553. * @returns true if the loader can load the specified file
  126554. */
  126555. canLoad(extension: string): boolean;
  126556. /**
  126557. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126558. * @param data contains the texture data
  126559. * @param texture defines the BabylonJS internal texture
  126560. * @param createPolynomials will be true if polynomials have been requested
  126561. * @param onLoad defines the callback to trigger once the texture is ready
  126562. * @param onError defines the callback to trigger in case of error
  126563. */
  126564. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126565. /**
  126566. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126567. * @param data contains the texture data
  126568. * @param texture defines the BabylonJS internal texture
  126569. * @param callback defines the method to call once ready to upload
  126570. */
  126571. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126572. }
  126573. }
  126574. declare module BABYLON {
  126575. /**
  126576. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  126577. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  126578. */
  126579. export class KhronosTextureContainer {
  126580. /** contents of the KTX container file */
  126581. data: ArrayBufferView;
  126582. private static HEADER_LEN;
  126583. private static COMPRESSED_2D;
  126584. private static COMPRESSED_3D;
  126585. private static TEX_2D;
  126586. private static TEX_3D;
  126587. /**
  126588. * Gets the openGL type
  126589. */
  126590. glType: number;
  126591. /**
  126592. * Gets the openGL type size
  126593. */
  126594. glTypeSize: number;
  126595. /**
  126596. * Gets the openGL format
  126597. */
  126598. glFormat: number;
  126599. /**
  126600. * Gets the openGL internal format
  126601. */
  126602. glInternalFormat: number;
  126603. /**
  126604. * Gets the base internal format
  126605. */
  126606. glBaseInternalFormat: number;
  126607. /**
  126608. * Gets image width in pixel
  126609. */
  126610. pixelWidth: number;
  126611. /**
  126612. * Gets image height in pixel
  126613. */
  126614. pixelHeight: number;
  126615. /**
  126616. * Gets image depth in pixels
  126617. */
  126618. pixelDepth: number;
  126619. /**
  126620. * Gets the number of array elements
  126621. */
  126622. numberOfArrayElements: number;
  126623. /**
  126624. * Gets the number of faces
  126625. */
  126626. numberOfFaces: number;
  126627. /**
  126628. * Gets the number of mipmap levels
  126629. */
  126630. numberOfMipmapLevels: number;
  126631. /**
  126632. * Gets the bytes of key value data
  126633. */
  126634. bytesOfKeyValueData: number;
  126635. /**
  126636. * Gets the load type
  126637. */
  126638. loadType: number;
  126639. /**
  126640. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  126641. */
  126642. isInvalid: boolean;
  126643. /**
  126644. * Creates a new KhronosTextureContainer
  126645. * @param data contents of the KTX container file
  126646. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  126647. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  126648. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  126649. */
  126650. constructor(
  126651. /** contents of the KTX container file */
  126652. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  126653. /**
  126654. * Uploads KTX content to a Babylon Texture.
  126655. * It is assumed that the texture has already been created & is currently bound
  126656. * @hidden
  126657. */
  126658. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  126659. private _upload2DCompressedLevels;
  126660. /**
  126661. * Checks if the given data starts with a KTX file identifier.
  126662. * @param data the data to check
  126663. * @returns true if the data is a KTX file or false otherwise
  126664. */
  126665. static IsValid(data: ArrayBufferView): boolean;
  126666. }
  126667. }
  126668. declare module BABYLON {
  126669. /**
  126670. * Class for loading KTX2 files
  126671. * !!! Experimental Extension Subject to Changes !!!
  126672. * @hidden
  126673. */
  126674. export class KhronosTextureContainer2 {
  126675. private static _ModulePromise;
  126676. private static _TranscodeFormat;
  126677. constructor(engine: ThinEngine);
  126678. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  126679. private _determineTranscodeFormat;
  126680. /**
  126681. * Checks if the given data starts with a KTX2 file identifier.
  126682. * @param data the data to check
  126683. * @returns true if the data is a KTX2 file or false otherwise
  126684. */
  126685. static IsValid(data: ArrayBufferView): boolean;
  126686. }
  126687. }
  126688. declare module BABYLON {
  126689. /**
  126690. * Implementation of the KTX Texture Loader.
  126691. * @hidden
  126692. */
  126693. export class _KTXTextureLoader implements IInternalTextureLoader {
  126694. /**
  126695. * Defines wether the loader supports cascade loading the different faces.
  126696. */
  126697. readonly supportCascades: boolean;
  126698. /**
  126699. * This returns if the loader support the current file information.
  126700. * @param extension defines the file extension of the file being loaded
  126701. * @returns true if the loader can load the specified file
  126702. */
  126703. canLoad(extension: string): boolean;
  126704. /**
  126705. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126706. * @param data contains the texture data
  126707. * @param texture defines the BabylonJS internal texture
  126708. * @param createPolynomials will be true if polynomials have been requested
  126709. * @param onLoad defines the callback to trigger once the texture is ready
  126710. * @param onError defines the callback to trigger in case of error
  126711. */
  126712. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126713. /**
  126714. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126715. * @param data contains the texture data
  126716. * @param texture defines the BabylonJS internal texture
  126717. * @param callback defines the method to call once ready to upload
  126718. */
  126719. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  126720. }
  126721. }
  126722. declare module BABYLON {
  126723. /** @hidden */
  126724. export var _forceSceneHelpersToBundle: boolean;
  126725. interface Scene {
  126726. /**
  126727. * Creates a default light for the scene.
  126728. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  126729. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  126730. */
  126731. createDefaultLight(replace?: boolean): void;
  126732. /**
  126733. * Creates a default camera for the scene.
  126734. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  126735. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  126736. * @param replace has default false, when true replaces the active camera in the scene
  126737. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  126738. */
  126739. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  126740. /**
  126741. * Creates a default camera and a default light.
  126742. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  126743. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  126744. * @param replace has the default false, when true replaces the active camera/light in the scene
  126745. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  126746. */
  126747. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  126748. /**
  126749. * Creates a new sky box
  126750. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  126751. * @param environmentTexture defines the texture to use as environment texture
  126752. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  126753. * @param scale defines the overall scale of the skybox
  126754. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  126755. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  126756. * @returns a new mesh holding the sky box
  126757. */
  126758. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  126759. /**
  126760. * Creates a new environment
  126761. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  126762. * @param options defines the options you can use to configure the environment
  126763. * @returns the new EnvironmentHelper
  126764. */
  126765. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  126766. /**
  126767. * Creates a new VREXperienceHelper
  126768. * @see http://doc.babylonjs.com/how_to/webvr_helper
  126769. * @param webVROptions defines the options used to create the new VREXperienceHelper
  126770. * @returns a new VREXperienceHelper
  126771. */
  126772. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  126773. /**
  126774. * Creates a new WebXRDefaultExperience
  126775. * @see http://doc.babylonjs.com/how_to/webxr
  126776. * @param options experience options
  126777. * @returns a promise for a new WebXRDefaultExperience
  126778. */
  126779. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126780. }
  126781. }
  126782. declare module BABYLON {
  126783. /**
  126784. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  126785. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  126786. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  126787. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  126788. */
  126789. export class VideoDome extends TransformNode {
  126790. /**
  126791. * Define the video source as a Monoscopic panoramic 360 video.
  126792. */
  126793. static readonly MODE_MONOSCOPIC: number;
  126794. /**
  126795. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  126796. */
  126797. static readonly MODE_TOPBOTTOM: number;
  126798. /**
  126799. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  126800. */
  126801. static readonly MODE_SIDEBYSIDE: number;
  126802. private _halfDome;
  126803. private _useDirectMapping;
  126804. /**
  126805. * The video texture being displayed on the sphere
  126806. */
  126807. protected _videoTexture: VideoTexture;
  126808. /**
  126809. * Gets the video texture being displayed on the sphere
  126810. */
  126811. get videoTexture(): VideoTexture;
  126812. /**
  126813. * The skybox material
  126814. */
  126815. protected _material: BackgroundMaterial;
  126816. /**
  126817. * The surface used for the skybox
  126818. */
  126819. protected _mesh: Mesh;
  126820. /**
  126821. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  126822. */
  126823. private _halfDomeMask;
  126824. /**
  126825. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  126826. * Also see the options.resolution property.
  126827. */
  126828. get fovMultiplier(): number;
  126829. set fovMultiplier(value: number);
  126830. private _videoMode;
  126831. /**
  126832. * Gets or set the current video mode for the video. It can be:
  126833. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  126834. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  126835. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  126836. */
  126837. get videoMode(): number;
  126838. set videoMode(value: number);
  126839. /**
  126840. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  126841. *
  126842. */
  126843. get halfDome(): boolean;
  126844. /**
  126845. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  126846. */
  126847. set halfDome(enabled: boolean);
  126848. /**
  126849. * Oberserver used in Stereoscopic VR Mode.
  126850. */
  126851. private _onBeforeCameraRenderObserver;
  126852. /**
  126853. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  126854. * @param name Element's name, child elements will append suffixes for their own names.
  126855. * @param urlsOrVideo defines the url(s) or the video element to use
  126856. * @param options An object containing optional or exposed sub element properties
  126857. */
  126858. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  126859. resolution?: number;
  126860. clickToPlay?: boolean;
  126861. autoPlay?: boolean;
  126862. loop?: boolean;
  126863. size?: number;
  126864. poster?: string;
  126865. faceForward?: boolean;
  126866. useDirectMapping?: boolean;
  126867. halfDomeMode?: boolean;
  126868. }, scene: Scene);
  126869. private _changeVideoMode;
  126870. /**
  126871. * Releases resources associated with this node.
  126872. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  126873. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  126874. */
  126875. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  126876. }
  126877. }
  126878. declare module BABYLON {
  126879. /**
  126880. * This class can be used to get instrumentation data from a Babylon engine
  126881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126882. */
  126883. export class EngineInstrumentation implements IDisposable {
  126884. /**
  126885. * Define the instrumented engine.
  126886. */
  126887. engine: Engine;
  126888. private _captureGPUFrameTime;
  126889. private _gpuFrameTimeToken;
  126890. private _gpuFrameTime;
  126891. private _captureShaderCompilationTime;
  126892. private _shaderCompilationTime;
  126893. private _onBeginFrameObserver;
  126894. private _onEndFrameObserver;
  126895. private _onBeforeShaderCompilationObserver;
  126896. private _onAfterShaderCompilationObserver;
  126897. /**
  126898. * Gets the perf counter used for GPU frame time
  126899. */
  126900. get gpuFrameTimeCounter(): PerfCounter;
  126901. /**
  126902. * Gets the GPU frame time capture status
  126903. */
  126904. get captureGPUFrameTime(): boolean;
  126905. /**
  126906. * Enable or disable the GPU frame time capture
  126907. */
  126908. set captureGPUFrameTime(value: boolean);
  126909. /**
  126910. * Gets the perf counter used for shader compilation time
  126911. */
  126912. get shaderCompilationTimeCounter(): PerfCounter;
  126913. /**
  126914. * Gets the shader compilation time capture status
  126915. */
  126916. get captureShaderCompilationTime(): boolean;
  126917. /**
  126918. * Enable or disable the shader compilation time capture
  126919. */
  126920. set captureShaderCompilationTime(value: boolean);
  126921. /**
  126922. * Instantiates a new engine instrumentation.
  126923. * This class can be used to get instrumentation data from a Babylon engine
  126924. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  126925. * @param engine Defines the engine to instrument
  126926. */
  126927. constructor(
  126928. /**
  126929. * Define the instrumented engine.
  126930. */
  126931. engine: Engine);
  126932. /**
  126933. * Dispose and release associated resources.
  126934. */
  126935. dispose(): void;
  126936. }
  126937. }
  126938. declare module BABYLON {
  126939. /**
  126940. * This class can be used to get instrumentation data from a Babylon engine
  126941. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  126942. */
  126943. export class SceneInstrumentation implements IDisposable {
  126944. /**
  126945. * Defines the scene to instrument
  126946. */
  126947. scene: Scene;
  126948. private _captureActiveMeshesEvaluationTime;
  126949. private _activeMeshesEvaluationTime;
  126950. private _captureRenderTargetsRenderTime;
  126951. private _renderTargetsRenderTime;
  126952. private _captureFrameTime;
  126953. private _frameTime;
  126954. private _captureRenderTime;
  126955. private _renderTime;
  126956. private _captureInterFrameTime;
  126957. private _interFrameTime;
  126958. private _captureParticlesRenderTime;
  126959. private _particlesRenderTime;
  126960. private _captureSpritesRenderTime;
  126961. private _spritesRenderTime;
  126962. private _capturePhysicsTime;
  126963. private _physicsTime;
  126964. private _captureAnimationsTime;
  126965. private _animationsTime;
  126966. private _captureCameraRenderTime;
  126967. private _cameraRenderTime;
  126968. private _onBeforeActiveMeshesEvaluationObserver;
  126969. private _onAfterActiveMeshesEvaluationObserver;
  126970. private _onBeforeRenderTargetsRenderObserver;
  126971. private _onAfterRenderTargetsRenderObserver;
  126972. private _onAfterRenderObserver;
  126973. private _onBeforeDrawPhaseObserver;
  126974. private _onAfterDrawPhaseObserver;
  126975. private _onBeforeAnimationsObserver;
  126976. private _onBeforeParticlesRenderingObserver;
  126977. private _onAfterParticlesRenderingObserver;
  126978. private _onBeforeSpritesRenderingObserver;
  126979. private _onAfterSpritesRenderingObserver;
  126980. private _onBeforePhysicsObserver;
  126981. private _onAfterPhysicsObserver;
  126982. private _onAfterAnimationsObserver;
  126983. private _onBeforeCameraRenderObserver;
  126984. private _onAfterCameraRenderObserver;
  126985. /**
  126986. * Gets the perf counter used for active meshes evaluation time
  126987. */
  126988. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  126989. /**
  126990. * Gets the active meshes evaluation time capture status
  126991. */
  126992. get captureActiveMeshesEvaluationTime(): boolean;
  126993. /**
  126994. * Enable or disable the active meshes evaluation time capture
  126995. */
  126996. set captureActiveMeshesEvaluationTime(value: boolean);
  126997. /**
  126998. * Gets the perf counter used for render targets render time
  126999. */
  127000. get renderTargetsRenderTimeCounter(): PerfCounter;
  127001. /**
  127002. * Gets the render targets render time capture status
  127003. */
  127004. get captureRenderTargetsRenderTime(): boolean;
  127005. /**
  127006. * Enable or disable the render targets render time capture
  127007. */
  127008. set captureRenderTargetsRenderTime(value: boolean);
  127009. /**
  127010. * Gets the perf counter used for particles render time
  127011. */
  127012. get particlesRenderTimeCounter(): PerfCounter;
  127013. /**
  127014. * Gets the particles render time capture status
  127015. */
  127016. get captureParticlesRenderTime(): boolean;
  127017. /**
  127018. * Enable or disable the particles render time capture
  127019. */
  127020. set captureParticlesRenderTime(value: boolean);
  127021. /**
  127022. * Gets the perf counter used for sprites render time
  127023. */
  127024. get spritesRenderTimeCounter(): PerfCounter;
  127025. /**
  127026. * Gets the sprites render time capture status
  127027. */
  127028. get captureSpritesRenderTime(): boolean;
  127029. /**
  127030. * Enable or disable the sprites render time capture
  127031. */
  127032. set captureSpritesRenderTime(value: boolean);
  127033. /**
  127034. * Gets the perf counter used for physics time
  127035. */
  127036. get physicsTimeCounter(): PerfCounter;
  127037. /**
  127038. * Gets the physics time capture status
  127039. */
  127040. get capturePhysicsTime(): boolean;
  127041. /**
  127042. * Enable or disable the physics time capture
  127043. */
  127044. set capturePhysicsTime(value: boolean);
  127045. /**
  127046. * Gets the perf counter used for animations time
  127047. */
  127048. get animationsTimeCounter(): PerfCounter;
  127049. /**
  127050. * Gets the animations time capture status
  127051. */
  127052. get captureAnimationsTime(): boolean;
  127053. /**
  127054. * Enable or disable the animations time capture
  127055. */
  127056. set captureAnimationsTime(value: boolean);
  127057. /**
  127058. * Gets the perf counter used for frame time capture
  127059. */
  127060. get frameTimeCounter(): PerfCounter;
  127061. /**
  127062. * Gets the frame time capture status
  127063. */
  127064. get captureFrameTime(): boolean;
  127065. /**
  127066. * Enable or disable the frame time capture
  127067. */
  127068. set captureFrameTime(value: boolean);
  127069. /**
  127070. * Gets the perf counter used for inter-frames time capture
  127071. */
  127072. get interFrameTimeCounter(): PerfCounter;
  127073. /**
  127074. * Gets the inter-frames time capture status
  127075. */
  127076. get captureInterFrameTime(): boolean;
  127077. /**
  127078. * Enable or disable the inter-frames time capture
  127079. */
  127080. set captureInterFrameTime(value: boolean);
  127081. /**
  127082. * Gets the perf counter used for render time capture
  127083. */
  127084. get renderTimeCounter(): PerfCounter;
  127085. /**
  127086. * Gets the render time capture status
  127087. */
  127088. get captureRenderTime(): boolean;
  127089. /**
  127090. * Enable or disable the render time capture
  127091. */
  127092. set captureRenderTime(value: boolean);
  127093. /**
  127094. * Gets the perf counter used for camera render time capture
  127095. */
  127096. get cameraRenderTimeCounter(): PerfCounter;
  127097. /**
  127098. * Gets the camera render time capture status
  127099. */
  127100. get captureCameraRenderTime(): boolean;
  127101. /**
  127102. * Enable or disable the camera render time capture
  127103. */
  127104. set captureCameraRenderTime(value: boolean);
  127105. /**
  127106. * Gets the perf counter used for draw calls
  127107. */
  127108. get drawCallsCounter(): PerfCounter;
  127109. /**
  127110. * Instantiates a new scene instrumentation.
  127111. * This class can be used to get instrumentation data from a Babylon engine
  127112. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127113. * @param scene Defines the scene to instrument
  127114. */
  127115. constructor(
  127116. /**
  127117. * Defines the scene to instrument
  127118. */
  127119. scene: Scene);
  127120. /**
  127121. * Dispose and release associated resources.
  127122. */
  127123. dispose(): void;
  127124. }
  127125. }
  127126. declare module BABYLON {
  127127. /** @hidden */
  127128. export var glowMapGenerationPixelShader: {
  127129. name: string;
  127130. shader: string;
  127131. };
  127132. }
  127133. declare module BABYLON {
  127134. /** @hidden */
  127135. export var glowMapGenerationVertexShader: {
  127136. name: string;
  127137. shader: string;
  127138. };
  127139. }
  127140. declare module BABYLON {
  127141. /**
  127142. * Effect layer options. This helps customizing the behaviour
  127143. * of the effect layer.
  127144. */
  127145. export interface IEffectLayerOptions {
  127146. /**
  127147. * Multiplication factor apply to the canvas size to compute the render target size
  127148. * used to generated the objects (the smaller the faster).
  127149. */
  127150. mainTextureRatio: number;
  127151. /**
  127152. * Enforces a fixed size texture to ensure effect stability across devices.
  127153. */
  127154. mainTextureFixedSize?: number;
  127155. /**
  127156. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  127157. */
  127158. alphaBlendingMode: number;
  127159. /**
  127160. * The camera attached to the layer.
  127161. */
  127162. camera: Nullable<Camera>;
  127163. /**
  127164. * The rendering group to draw the layer in.
  127165. */
  127166. renderingGroupId: number;
  127167. }
  127168. /**
  127169. * The effect layer Helps adding post process effect blended with the main pass.
  127170. *
  127171. * This can be for instance use to generate glow or higlight effects on the scene.
  127172. *
  127173. * The effect layer class can not be used directly and is intented to inherited from to be
  127174. * customized per effects.
  127175. */
  127176. export abstract class EffectLayer {
  127177. private _vertexBuffers;
  127178. private _indexBuffer;
  127179. private _cachedDefines;
  127180. private _effectLayerMapGenerationEffect;
  127181. private _effectLayerOptions;
  127182. private _mergeEffect;
  127183. protected _scene: Scene;
  127184. protected _engine: Engine;
  127185. protected _maxSize: number;
  127186. protected _mainTextureDesiredSize: ISize;
  127187. protected _mainTexture: RenderTargetTexture;
  127188. protected _shouldRender: boolean;
  127189. protected _postProcesses: PostProcess[];
  127190. protected _textures: BaseTexture[];
  127191. protected _emissiveTextureAndColor: {
  127192. texture: Nullable<BaseTexture>;
  127193. color: Color4;
  127194. };
  127195. /**
  127196. * The name of the layer
  127197. */
  127198. name: string;
  127199. /**
  127200. * The clear color of the texture used to generate the glow map.
  127201. */
  127202. neutralColor: Color4;
  127203. /**
  127204. * Specifies whether the highlight layer is enabled or not.
  127205. */
  127206. isEnabled: boolean;
  127207. /**
  127208. * Gets the camera attached to the layer.
  127209. */
  127210. get camera(): Nullable<Camera>;
  127211. /**
  127212. * Gets the rendering group id the layer should render in.
  127213. */
  127214. get renderingGroupId(): number;
  127215. set renderingGroupId(renderingGroupId: number);
  127216. /**
  127217. * An event triggered when the effect layer has been disposed.
  127218. */
  127219. onDisposeObservable: Observable<EffectLayer>;
  127220. /**
  127221. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  127222. */
  127223. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  127224. /**
  127225. * An event triggered when the generated texture is being merged in the scene.
  127226. */
  127227. onBeforeComposeObservable: Observable<EffectLayer>;
  127228. /**
  127229. * An event triggered when the mesh is rendered into the effect render target.
  127230. */
  127231. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  127232. /**
  127233. * An event triggered after the mesh has been rendered into the effect render target.
  127234. */
  127235. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  127236. /**
  127237. * An event triggered when the generated texture has been merged in the scene.
  127238. */
  127239. onAfterComposeObservable: Observable<EffectLayer>;
  127240. /**
  127241. * An event triggered when the efffect layer changes its size.
  127242. */
  127243. onSizeChangedObservable: Observable<EffectLayer>;
  127244. /** @hidden */
  127245. static _SceneComponentInitialization: (scene: Scene) => void;
  127246. /**
  127247. * Instantiates a new effect Layer and references it in the scene.
  127248. * @param name The name of the layer
  127249. * @param scene The scene to use the layer in
  127250. */
  127251. constructor(
  127252. /** The Friendly of the effect in the scene */
  127253. name: string, scene: Scene);
  127254. /**
  127255. * Get the effect name of the layer.
  127256. * @return The effect name
  127257. */
  127258. abstract getEffectName(): string;
  127259. /**
  127260. * Checks for the readiness of the element composing the layer.
  127261. * @param subMesh the mesh to check for
  127262. * @param useInstances specify whether or not to use instances to render the mesh
  127263. * @return true if ready otherwise, false
  127264. */
  127265. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127266. /**
  127267. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127268. * @returns true if the effect requires stencil during the main canvas render pass.
  127269. */
  127270. abstract needStencil(): boolean;
  127271. /**
  127272. * Create the merge effect. This is the shader use to blit the information back
  127273. * to the main canvas at the end of the scene rendering.
  127274. * @returns The effect containing the shader used to merge the effect on the main canvas
  127275. */
  127276. protected abstract _createMergeEffect(): Effect;
  127277. /**
  127278. * Creates the render target textures and post processes used in the effect layer.
  127279. */
  127280. protected abstract _createTextureAndPostProcesses(): void;
  127281. /**
  127282. * Implementation specific of rendering the generating effect on the main canvas.
  127283. * @param effect The effect used to render through
  127284. */
  127285. protected abstract _internalRender(effect: Effect): void;
  127286. /**
  127287. * Sets the required values for both the emissive texture and and the main color.
  127288. */
  127289. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127290. /**
  127291. * Free any resources and references associated to a mesh.
  127292. * Internal use
  127293. * @param mesh The mesh to free.
  127294. */
  127295. abstract _disposeMesh(mesh: Mesh): void;
  127296. /**
  127297. * Serializes this layer (Glow or Highlight for example)
  127298. * @returns a serialized layer object
  127299. */
  127300. abstract serialize?(): any;
  127301. /**
  127302. * Initializes the effect layer with the required options.
  127303. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  127304. */
  127305. protected _init(options: Partial<IEffectLayerOptions>): void;
  127306. /**
  127307. * Generates the index buffer of the full screen quad blending to the main canvas.
  127308. */
  127309. private _generateIndexBuffer;
  127310. /**
  127311. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  127312. */
  127313. private _generateVertexBuffer;
  127314. /**
  127315. * Sets the main texture desired size which is the closest power of two
  127316. * of the engine canvas size.
  127317. */
  127318. private _setMainTextureSize;
  127319. /**
  127320. * Creates the main texture for the effect layer.
  127321. */
  127322. protected _createMainTexture(): void;
  127323. /**
  127324. * Adds specific effects defines.
  127325. * @param defines The defines to add specifics to.
  127326. */
  127327. protected _addCustomEffectDefines(defines: string[]): void;
  127328. /**
  127329. * Checks for the readiness of the element composing the layer.
  127330. * @param subMesh the mesh to check for
  127331. * @param useInstances specify whether or not to use instances to render the mesh
  127332. * @param emissiveTexture the associated emissive texture used to generate the glow
  127333. * @return true if ready otherwise, false
  127334. */
  127335. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  127336. /**
  127337. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  127338. */
  127339. render(): void;
  127340. /**
  127341. * Determine if a given mesh will be used in the current effect.
  127342. * @param mesh mesh to test
  127343. * @returns true if the mesh will be used
  127344. */
  127345. hasMesh(mesh: AbstractMesh): boolean;
  127346. /**
  127347. * Returns true if the layer contains information to display, otherwise false.
  127348. * @returns true if the glow layer should be rendered
  127349. */
  127350. shouldRender(): boolean;
  127351. /**
  127352. * Returns true if the mesh should render, otherwise false.
  127353. * @param mesh The mesh to render
  127354. * @returns true if it should render otherwise false
  127355. */
  127356. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  127357. /**
  127358. * Returns true if the mesh can be rendered, otherwise false.
  127359. * @param mesh The mesh to render
  127360. * @param material The material used on the mesh
  127361. * @returns true if it can be rendered otherwise false
  127362. */
  127363. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127364. /**
  127365. * Returns true if the mesh should render, otherwise false.
  127366. * @param mesh The mesh to render
  127367. * @returns true if it should render otherwise false
  127368. */
  127369. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  127370. /**
  127371. * Renders the submesh passed in parameter to the generation map.
  127372. */
  127373. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  127374. /**
  127375. * Defines whether the current material of the mesh should be use to render the effect.
  127376. * @param mesh defines the current mesh to render
  127377. */
  127378. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  127379. /**
  127380. * Rebuild the required buffers.
  127381. * @hidden Internal use only.
  127382. */
  127383. _rebuild(): void;
  127384. /**
  127385. * Dispose only the render target textures and post process.
  127386. */
  127387. private _disposeTextureAndPostProcesses;
  127388. /**
  127389. * Dispose the highlight layer and free resources.
  127390. */
  127391. dispose(): void;
  127392. /**
  127393. * Gets the class name of the effect layer
  127394. * @returns the string with the class name of the effect layer
  127395. */
  127396. getClassName(): string;
  127397. /**
  127398. * Creates an effect layer from parsed effect layer data
  127399. * @param parsedEffectLayer defines effect layer data
  127400. * @param scene defines the current scene
  127401. * @param rootUrl defines the root URL containing the effect layer information
  127402. * @returns a parsed effect Layer
  127403. */
  127404. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  127405. }
  127406. }
  127407. declare module BABYLON {
  127408. interface AbstractScene {
  127409. /**
  127410. * The list of effect layers (highlights/glow) added to the scene
  127411. * @see http://doc.babylonjs.com/how_to/highlight_layer
  127412. * @see http://doc.babylonjs.com/how_to/glow_layer
  127413. */
  127414. effectLayers: Array<EffectLayer>;
  127415. /**
  127416. * Removes the given effect layer from this scene.
  127417. * @param toRemove defines the effect layer to remove
  127418. * @returns the index of the removed effect layer
  127419. */
  127420. removeEffectLayer(toRemove: EffectLayer): number;
  127421. /**
  127422. * Adds the given effect layer to this scene
  127423. * @param newEffectLayer defines the effect layer to add
  127424. */
  127425. addEffectLayer(newEffectLayer: EffectLayer): void;
  127426. }
  127427. /**
  127428. * Defines the layer scene component responsible to manage any effect layers
  127429. * in a given scene.
  127430. */
  127431. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  127432. /**
  127433. * The component name helpfull to identify the component in the list of scene components.
  127434. */
  127435. readonly name: string;
  127436. /**
  127437. * The scene the component belongs to.
  127438. */
  127439. scene: Scene;
  127440. private _engine;
  127441. private _renderEffects;
  127442. private _needStencil;
  127443. private _previousStencilState;
  127444. /**
  127445. * Creates a new instance of the component for the given scene
  127446. * @param scene Defines the scene to register the component in
  127447. */
  127448. constructor(scene: Scene);
  127449. /**
  127450. * Registers the component in a given scene
  127451. */
  127452. register(): void;
  127453. /**
  127454. * Rebuilds the elements related to this component in case of
  127455. * context lost for instance.
  127456. */
  127457. rebuild(): void;
  127458. /**
  127459. * Serializes the component data to the specified json object
  127460. * @param serializationObject The object to serialize to
  127461. */
  127462. serialize(serializationObject: any): void;
  127463. /**
  127464. * Adds all the elements from the container to the scene
  127465. * @param container the container holding the elements
  127466. */
  127467. addFromContainer(container: AbstractScene): void;
  127468. /**
  127469. * Removes all the elements in the container from the scene
  127470. * @param container contains the elements to remove
  127471. * @param dispose if the removed element should be disposed (default: false)
  127472. */
  127473. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127474. /**
  127475. * Disposes the component and the associated ressources.
  127476. */
  127477. dispose(): void;
  127478. private _isReadyForMesh;
  127479. private _renderMainTexture;
  127480. private _setStencil;
  127481. private _setStencilBack;
  127482. private _draw;
  127483. private _drawCamera;
  127484. private _drawRenderingGroup;
  127485. }
  127486. }
  127487. declare module BABYLON {
  127488. /** @hidden */
  127489. export var glowMapMergePixelShader: {
  127490. name: string;
  127491. shader: string;
  127492. };
  127493. }
  127494. declare module BABYLON {
  127495. /** @hidden */
  127496. export var glowMapMergeVertexShader: {
  127497. name: string;
  127498. shader: string;
  127499. };
  127500. }
  127501. declare module BABYLON {
  127502. interface AbstractScene {
  127503. /**
  127504. * Return a the first highlight layer of the scene with a given name.
  127505. * @param name The name of the highlight layer to look for.
  127506. * @return The highlight layer if found otherwise null.
  127507. */
  127508. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  127509. }
  127510. /**
  127511. * Glow layer options. This helps customizing the behaviour
  127512. * of the glow layer.
  127513. */
  127514. export interface IGlowLayerOptions {
  127515. /**
  127516. * Multiplication factor apply to the canvas size to compute the render target size
  127517. * used to generated the glowing objects (the smaller the faster).
  127518. */
  127519. mainTextureRatio: number;
  127520. /**
  127521. * Enforces a fixed size texture to ensure resize independant blur.
  127522. */
  127523. mainTextureFixedSize?: number;
  127524. /**
  127525. * How big is the kernel of the blur texture.
  127526. */
  127527. blurKernelSize: number;
  127528. /**
  127529. * The camera attached to the layer.
  127530. */
  127531. camera: Nullable<Camera>;
  127532. /**
  127533. * Enable MSAA by chosing the number of samples.
  127534. */
  127535. mainTextureSamples?: number;
  127536. /**
  127537. * The rendering group to draw the layer in.
  127538. */
  127539. renderingGroupId: number;
  127540. }
  127541. /**
  127542. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  127543. *
  127544. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  127545. *
  127546. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  127547. */
  127548. export class GlowLayer extends EffectLayer {
  127549. /**
  127550. * Effect Name of the layer.
  127551. */
  127552. static readonly EffectName: string;
  127553. /**
  127554. * The default blur kernel size used for the glow.
  127555. */
  127556. static DefaultBlurKernelSize: number;
  127557. /**
  127558. * The default texture size ratio used for the glow.
  127559. */
  127560. static DefaultTextureRatio: number;
  127561. /**
  127562. * Sets the kernel size of the blur.
  127563. */
  127564. set blurKernelSize(value: number);
  127565. /**
  127566. * Gets the kernel size of the blur.
  127567. */
  127568. get blurKernelSize(): number;
  127569. /**
  127570. * Sets the glow intensity.
  127571. */
  127572. set intensity(value: number);
  127573. /**
  127574. * Gets the glow intensity.
  127575. */
  127576. get intensity(): number;
  127577. private _options;
  127578. private _intensity;
  127579. private _horizontalBlurPostprocess1;
  127580. private _verticalBlurPostprocess1;
  127581. private _horizontalBlurPostprocess2;
  127582. private _verticalBlurPostprocess2;
  127583. private _blurTexture1;
  127584. private _blurTexture2;
  127585. private _postProcesses1;
  127586. private _postProcesses2;
  127587. private _includedOnlyMeshes;
  127588. private _excludedMeshes;
  127589. private _meshesUsingTheirOwnMaterials;
  127590. /**
  127591. * Callback used to let the user override the color selection on a per mesh basis
  127592. */
  127593. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  127594. /**
  127595. * Callback used to let the user override the texture selection on a per mesh basis
  127596. */
  127597. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  127598. /**
  127599. * Instantiates a new glow Layer and references it to the scene.
  127600. * @param name The name of the layer
  127601. * @param scene The scene to use the layer in
  127602. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  127603. */
  127604. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  127605. /**
  127606. * Get the effect name of the layer.
  127607. * @return The effect name
  127608. */
  127609. getEffectName(): string;
  127610. /**
  127611. * Create the merge effect. This is the shader use to blit the information back
  127612. * to the main canvas at the end of the scene rendering.
  127613. */
  127614. protected _createMergeEffect(): Effect;
  127615. /**
  127616. * Creates the render target textures and post processes used in the glow layer.
  127617. */
  127618. protected _createTextureAndPostProcesses(): void;
  127619. /**
  127620. * Checks for the readiness of the element composing the layer.
  127621. * @param subMesh the mesh to check for
  127622. * @param useInstances specify wether or not to use instances to render the mesh
  127623. * @param emissiveTexture the associated emissive texture used to generate the glow
  127624. * @return true if ready otherwise, false
  127625. */
  127626. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127627. /**
  127628. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127629. */
  127630. needStencil(): boolean;
  127631. /**
  127632. * Returns true if the mesh can be rendered, otherwise false.
  127633. * @param mesh The mesh to render
  127634. * @param material The material used on the mesh
  127635. * @returns true if it can be rendered otherwise false
  127636. */
  127637. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127638. /**
  127639. * Implementation specific of rendering the generating effect on the main canvas.
  127640. * @param effect The effect used to render through
  127641. */
  127642. protected _internalRender(effect: Effect): void;
  127643. /**
  127644. * Sets the required values for both the emissive texture and and the main color.
  127645. */
  127646. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127647. /**
  127648. * Returns true if the mesh should render, otherwise false.
  127649. * @param mesh The mesh to render
  127650. * @returns true if it should render otherwise false
  127651. */
  127652. protected _shouldRenderMesh(mesh: Mesh): boolean;
  127653. /**
  127654. * Adds specific effects defines.
  127655. * @param defines The defines to add specifics to.
  127656. */
  127657. protected _addCustomEffectDefines(defines: string[]): void;
  127658. /**
  127659. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  127660. * @param mesh The mesh to exclude from the glow layer
  127661. */
  127662. addExcludedMesh(mesh: Mesh): void;
  127663. /**
  127664. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  127665. * @param mesh The mesh to remove
  127666. */
  127667. removeExcludedMesh(mesh: Mesh): void;
  127668. /**
  127669. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  127670. * @param mesh The mesh to include in the glow layer
  127671. */
  127672. addIncludedOnlyMesh(mesh: Mesh): void;
  127673. /**
  127674. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  127675. * @param mesh The mesh to remove
  127676. */
  127677. removeIncludedOnlyMesh(mesh: Mesh): void;
  127678. /**
  127679. * Determine if a given mesh will be used in the glow layer
  127680. * @param mesh The mesh to test
  127681. * @returns true if the mesh will be highlighted by the current glow layer
  127682. */
  127683. hasMesh(mesh: AbstractMesh): boolean;
  127684. /**
  127685. * Defines whether the current material of the mesh should be use to render the effect.
  127686. * @param mesh defines the current mesh to render
  127687. */
  127688. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  127689. /**
  127690. * Add a mesh to be rendered through its own material and not with emissive only.
  127691. * @param mesh The mesh for which we need to use its material
  127692. */
  127693. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  127694. /**
  127695. * Remove a mesh from being rendered through its own material and not with emissive only.
  127696. * @param mesh The mesh for which we need to not use its material
  127697. */
  127698. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  127699. /**
  127700. * Free any resources and references associated to a mesh.
  127701. * Internal use
  127702. * @param mesh The mesh to free.
  127703. * @hidden
  127704. */
  127705. _disposeMesh(mesh: Mesh): void;
  127706. /**
  127707. * Gets the class name of the effect layer
  127708. * @returns the string with the class name of the effect layer
  127709. */
  127710. getClassName(): string;
  127711. /**
  127712. * Serializes this glow layer
  127713. * @returns a serialized glow layer object
  127714. */
  127715. serialize(): any;
  127716. /**
  127717. * Creates a Glow Layer from parsed glow layer data
  127718. * @param parsedGlowLayer defines glow layer data
  127719. * @param scene defines the current scene
  127720. * @param rootUrl defines the root URL containing the glow layer information
  127721. * @returns a parsed Glow Layer
  127722. */
  127723. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  127724. }
  127725. }
  127726. declare module BABYLON {
  127727. /** @hidden */
  127728. export var glowBlurPostProcessPixelShader: {
  127729. name: string;
  127730. shader: string;
  127731. };
  127732. }
  127733. declare module BABYLON {
  127734. interface AbstractScene {
  127735. /**
  127736. * Return a the first highlight layer of the scene with a given name.
  127737. * @param name The name of the highlight layer to look for.
  127738. * @return The highlight layer if found otherwise null.
  127739. */
  127740. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  127741. }
  127742. /**
  127743. * Highlight layer options. This helps customizing the behaviour
  127744. * of the highlight layer.
  127745. */
  127746. export interface IHighlightLayerOptions {
  127747. /**
  127748. * Multiplication factor apply to the canvas size to compute the render target size
  127749. * used to generated the glowing objects (the smaller the faster).
  127750. */
  127751. mainTextureRatio: number;
  127752. /**
  127753. * Enforces a fixed size texture to ensure resize independant blur.
  127754. */
  127755. mainTextureFixedSize?: number;
  127756. /**
  127757. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  127758. * of the picture to blur (the smaller the faster).
  127759. */
  127760. blurTextureSizeRatio: number;
  127761. /**
  127762. * How big in texel of the blur texture is the vertical blur.
  127763. */
  127764. blurVerticalSize: number;
  127765. /**
  127766. * How big in texel of the blur texture is the horizontal blur.
  127767. */
  127768. blurHorizontalSize: number;
  127769. /**
  127770. * Alpha blending mode used to apply the blur. Default is combine.
  127771. */
  127772. alphaBlendingMode: number;
  127773. /**
  127774. * The camera attached to the layer.
  127775. */
  127776. camera: Nullable<Camera>;
  127777. /**
  127778. * Should we display highlight as a solid stroke?
  127779. */
  127780. isStroke?: boolean;
  127781. /**
  127782. * The rendering group to draw the layer in.
  127783. */
  127784. renderingGroupId: number;
  127785. }
  127786. /**
  127787. * The highlight layer Helps adding a glow effect around a mesh.
  127788. *
  127789. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  127790. * glowy meshes to your scene.
  127791. *
  127792. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  127793. */
  127794. export class HighlightLayer extends EffectLayer {
  127795. name: string;
  127796. /**
  127797. * Effect Name of the highlight layer.
  127798. */
  127799. static readonly EffectName: string;
  127800. /**
  127801. * The neutral color used during the preparation of the glow effect.
  127802. * This is black by default as the blend operation is a blend operation.
  127803. */
  127804. static NeutralColor: Color4;
  127805. /**
  127806. * Stencil value used for glowing meshes.
  127807. */
  127808. static GlowingMeshStencilReference: number;
  127809. /**
  127810. * Stencil value used for the other meshes in the scene.
  127811. */
  127812. static NormalMeshStencilReference: number;
  127813. /**
  127814. * Specifies whether or not the inner glow is ACTIVE in the layer.
  127815. */
  127816. innerGlow: boolean;
  127817. /**
  127818. * Specifies whether or not the outer glow is ACTIVE in the layer.
  127819. */
  127820. outerGlow: boolean;
  127821. /**
  127822. * Specifies the horizontal size of the blur.
  127823. */
  127824. set blurHorizontalSize(value: number);
  127825. /**
  127826. * Specifies the vertical size of the blur.
  127827. */
  127828. set blurVerticalSize(value: number);
  127829. /**
  127830. * Gets the horizontal size of the blur.
  127831. */
  127832. get blurHorizontalSize(): number;
  127833. /**
  127834. * Gets the vertical size of the blur.
  127835. */
  127836. get blurVerticalSize(): number;
  127837. /**
  127838. * An event triggered when the highlight layer is being blurred.
  127839. */
  127840. onBeforeBlurObservable: Observable<HighlightLayer>;
  127841. /**
  127842. * An event triggered when the highlight layer has been blurred.
  127843. */
  127844. onAfterBlurObservable: Observable<HighlightLayer>;
  127845. private _instanceGlowingMeshStencilReference;
  127846. private _options;
  127847. private _downSamplePostprocess;
  127848. private _horizontalBlurPostprocess;
  127849. private _verticalBlurPostprocess;
  127850. private _blurTexture;
  127851. private _meshes;
  127852. private _excludedMeshes;
  127853. /**
  127854. * Instantiates a new highlight Layer and references it to the scene..
  127855. * @param name The name of the layer
  127856. * @param scene The scene to use the layer in
  127857. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  127858. */
  127859. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  127860. /**
  127861. * Get the effect name of the layer.
  127862. * @return The effect name
  127863. */
  127864. getEffectName(): string;
  127865. /**
  127866. * Create the merge effect. This is the shader use to blit the information back
  127867. * to the main canvas at the end of the scene rendering.
  127868. */
  127869. protected _createMergeEffect(): Effect;
  127870. /**
  127871. * Creates the render target textures and post processes used in the highlight layer.
  127872. */
  127873. protected _createTextureAndPostProcesses(): void;
  127874. /**
  127875. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  127876. */
  127877. needStencil(): boolean;
  127878. /**
  127879. * Checks for the readiness of the element composing the layer.
  127880. * @param subMesh the mesh to check for
  127881. * @param useInstances specify wether or not to use instances to render the mesh
  127882. * @param emissiveTexture the associated emissive texture used to generate the glow
  127883. * @return true if ready otherwise, false
  127884. */
  127885. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127886. /**
  127887. * Implementation specific of rendering the generating effect on the main canvas.
  127888. * @param effect The effect used to render through
  127889. */
  127890. protected _internalRender(effect: Effect): void;
  127891. /**
  127892. * Returns true if the layer contains information to display, otherwise false.
  127893. */
  127894. shouldRender(): boolean;
  127895. /**
  127896. * Returns true if the mesh should render, otherwise false.
  127897. * @param mesh The mesh to render
  127898. * @returns true if it should render otherwise false
  127899. */
  127900. protected _shouldRenderMesh(mesh: Mesh): boolean;
  127901. /**
  127902. * Sets the required values for both the emissive texture and and the main color.
  127903. */
  127904. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127905. /**
  127906. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  127907. * @param mesh The mesh to exclude from the highlight layer
  127908. */
  127909. addExcludedMesh(mesh: Mesh): void;
  127910. /**
  127911. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  127912. * @param mesh The mesh to highlight
  127913. */
  127914. removeExcludedMesh(mesh: Mesh): void;
  127915. /**
  127916. * Determine if a given mesh will be highlighted by the current HighlightLayer
  127917. * @param mesh mesh to test
  127918. * @returns true if the mesh will be highlighted by the current HighlightLayer
  127919. */
  127920. hasMesh(mesh: AbstractMesh): boolean;
  127921. /**
  127922. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  127923. * @param mesh The mesh to highlight
  127924. * @param color The color of the highlight
  127925. * @param glowEmissiveOnly Extract the glow from the emissive texture
  127926. */
  127927. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  127928. /**
  127929. * Remove a mesh from the highlight layer in order to make it stop glowing.
  127930. * @param mesh The mesh to highlight
  127931. */
  127932. removeMesh(mesh: Mesh): void;
  127933. /**
  127934. * Remove all the meshes currently referenced in the highlight layer
  127935. */
  127936. removeAllMeshes(): void;
  127937. /**
  127938. * Force the stencil to the normal expected value for none glowing parts
  127939. */
  127940. private _defaultStencilReference;
  127941. /**
  127942. * Free any resources and references associated to a mesh.
  127943. * Internal use
  127944. * @param mesh The mesh to free.
  127945. * @hidden
  127946. */
  127947. _disposeMesh(mesh: Mesh): void;
  127948. /**
  127949. * Dispose the highlight layer and free resources.
  127950. */
  127951. dispose(): void;
  127952. /**
  127953. * Gets the class name of the effect layer
  127954. * @returns the string with the class name of the effect layer
  127955. */
  127956. getClassName(): string;
  127957. /**
  127958. * Serializes this Highlight layer
  127959. * @returns a serialized Highlight layer object
  127960. */
  127961. serialize(): any;
  127962. /**
  127963. * Creates a Highlight layer from parsed Highlight layer data
  127964. * @param parsedHightlightLayer defines the Highlight layer data
  127965. * @param scene defines the current scene
  127966. * @param rootUrl defines the root URL containing the Highlight layer information
  127967. * @returns a parsed Highlight layer
  127968. */
  127969. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  127970. }
  127971. }
  127972. declare module BABYLON {
  127973. interface AbstractScene {
  127974. /**
  127975. * The list of layers (background and foreground) of the scene
  127976. */
  127977. layers: Array<Layer>;
  127978. }
  127979. /**
  127980. * Defines the layer scene component responsible to manage any layers
  127981. * in a given scene.
  127982. */
  127983. export class LayerSceneComponent implements ISceneComponent {
  127984. /**
  127985. * The component name helpfull to identify the component in the list of scene components.
  127986. */
  127987. readonly name: string;
  127988. /**
  127989. * The scene the component belongs to.
  127990. */
  127991. scene: Scene;
  127992. private _engine;
  127993. /**
  127994. * Creates a new instance of the component for the given scene
  127995. * @param scene Defines the scene to register the component in
  127996. */
  127997. constructor(scene: Scene);
  127998. /**
  127999. * Registers the component in a given scene
  128000. */
  128001. register(): void;
  128002. /**
  128003. * Rebuilds the elements related to this component in case of
  128004. * context lost for instance.
  128005. */
  128006. rebuild(): void;
  128007. /**
  128008. * Disposes the component and the associated ressources.
  128009. */
  128010. dispose(): void;
  128011. private _draw;
  128012. private _drawCameraPredicate;
  128013. private _drawCameraBackground;
  128014. private _drawCameraForeground;
  128015. private _drawRenderTargetPredicate;
  128016. private _drawRenderTargetBackground;
  128017. private _drawRenderTargetForeground;
  128018. /**
  128019. * Adds all the elements from the container to the scene
  128020. * @param container the container holding the elements
  128021. */
  128022. addFromContainer(container: AbstractScene): void;
  128023. /**
  128024. * Removes all the elements in the container from the scene
  128025. * @param container contains the elements to remove
  128026. * @param dispose if the removed element should be disposed (default: false)
  128027. */
  128028. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128029. }
  128030. }
  128031. declare module BABYLON {
  128032. /** @hidden */
  128033. export var layerPixelShader: {
  128034. name: string;
  128035. shader: string;
  128036. };
  128037. }
  128038. declare module BABYLON {
  128039. /** @hidden */
  128040. export var layerVertexShader: {
  128041. name: string;
  128042. shader: string;
  128043. };
  128044. }
  128045. declare module BABYLON {
  128046. /**
  128047. * This represents a full screen 2d layer.
  128048. * This can be useful to display a picture in the background of your scene for instance.
  128049. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128050. */
  128051. export class Layer {
  128052. /**
  128053. * Define the name of the layer.
  128054. */
  128055. name: string;
  128056. /**
  128057. * Define the texture the layer should display.
  128058. */
  128059. texture: Nullable<Texture>;
  128060. /**
  128061. * Is the layer in background or foreground.
  128062. */
  128063. isBackground: boolean;
  128064. /**
  128065. * Define the color of the layer (instead of texture).
  128066. */
  128067. color: Color4;
  128068. /**
  128069. * Define the scale of the layer in order to zoom in out of the texture.
  128070. */
  128071. scale: Vector2;
  128072. /**
  128073. * Define an offset for the layer in order to shift the texture.
  128074. */
  128075. offset: Vector2;
  128076. /**
  128077. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  128078. */
  128079. alphaBlendingMode: number;
  128080. /**
  128081. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  128082. * Alpha test will not mix with the background color in case of transparency.
  128083. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  128084. */
  128085. alphaTest: boolean;
  128086. /**
  128087. * Define a mask to restrict the layer to only some of the scene cameras.
  128088. */
  128089. layerMask: number;
  128090. /**
  128091. * Define the list of render target the layer is visible into.
  128092. */
  128093. renderTargetTextures: RenderTargetTexture[];
  128094. /**
  128095. * Define if the layer is only used in renderTarget or if it also
  128096. * renders in the main frame buffer of the canvas.
  128097. */
  128098. renderOnlyInRenderTargetTextures: boolean;
  128099. private _scene;
  128100. private _vertexBuffers;
  128101. private _indexBuffer;
  128102. private _effect;
  128103. private _previousDefines;
  128104. /**
  128105. * An event triggered when the layer is disposed.
  128106. */
  128107. onDisposeObservable: Observable<Layer>;
  128108. private _onDisposeObserver;
  128109. /**
  128110. * Back compatibility with callback before the onDisposeObservable existed.
  128111. * The set callback will be triggered when the layer has been disposed.
  128112. */
  128113. set onDispose(callback: () => void);
  128114. /**
  128115. * An event triggered before rendering the scene
  128116. */
  128117. onBeforeRenderObservable: Observable<Layer>;
  128118. private _onBeforeRenderObserver;
  128119. /**
  128120. * Back compatibility with callback before the onBeforeRenderObservable existed.
  128121. * The set callback will be triggered just before rendering the layer.
  128122. */
  128123. set onBeforeRender(callback: () => void);
  128124. /**
  128125. * An event triggered after rendering the scene
  128126. */
  128127. onAfterRenderObservable: Observable<Layer>;
  128128. private _onAfterRenderObserver;
  128129. /**
  128130. * Back compatibility with callback before the onAfterRenderObservable existed.
  128131. * The set callback will be triggered just after rendering the layer.
  128132. */
  128133. set onAfterRender(callback: () => void);
  128134. /**
  128135. * Instantiates a new layer.
  128136. * This represents a full screen 2d layer.
  128137. * This can be useful to display a picture in the background of your scene for instance.
  128138. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128139. * @param name Define the name of the layer in the scene
  128140. * @param imgUrl Define the url of the texture to display in the layer
  128141. * @param scene Define the scene the layer belongs to
  128142. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  128143. * @param color Defines a color for the layer
  128144. */
  128145. constructor(
  128146. /**
  128147. * Define the name of the layer.
  128148. */
  128149. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  128150. private _createIndexBuffer;
  128151. /** @hidden */
  128152. _rebuild(): void;
  128153. /**
  128154. * Renders the layer in the scene.
  128155. */
  128156. render(): void;
  128157. /**
  128158. * Disposes and releases the associated ressources.
  128159. */
  128160. dispose(): void;
  128161. }
  128162. }
  128163. declare module BABYLON {
  128164. /** @hidden */
  128165. export var lensFlarePixelShader: {
  128166. name: string;
  128167. shader: string;
  128168. };
  128169. }
  128170. declare module BABYLON {
  128171. /** @hidden */
  128172. export var lensFlareVertexShader: {
  128173. name: string;
  128174. shader: string;
  128175. };
  128176. }
  128177. declare module BABYLON {
  128178. /**
  128179. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128180. * It is usually composed of several `lensFlare`.
  128181. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128182. */
  128183. export class LensFlareSystem {
  128184. /**
  128185. * Define the name of the lens flare system
  128186. */
  128187. name: string;
  128188. /**
  128189. * List of lens flares used in this system.
  128190. */
  128191. lensFlares: LensFlare[];
  128192. /**
  128193. * Define a limit from the border the lens flare can be visible.
  128194. */
  128195. borderLimit: number;
  128196. /**
  128197. * Define a viewport border we do not want to see the lens flare in.
  128198. */
  128199. viewportBorder: number;
  128200. /**
  128201. * Define a predicate which could limit the list of meshes able to occlude the effect.
  128202. */
  128203. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128204. /**
  128205. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  128206. */
  128207. layerMask: number;
  128208. /**
  128209. * Define the id of the lens flare system in the scene.
  128210. * (equal to name by default)
  128211. */
  128212. id: string;
  128213. private _scene;
  128214. private _emitter;
  128215. private _vertexBuffers;
  128216. private _indexBuffer;
  128217. private _effect;
  128218. private _positionX;
  128219. private _positionY;
  128220. private _isEnabled;
  128221. /** @hidden */
  128222. static _SceneComponentInitialization: (scene: Scene) => void;
  128223. /**
  128224. * Instantiates a lens flare system.
  128225. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128226. * It is usually composed of several `lensFlare`.
  128227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128228. * @param name Define the name of the lens flare system in the scene
  128229. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  128230. * @param scene Define the scene the lens flare system belongs to
  128231. */
  128232. constructor(
  128233. /**
  128234. * Define the name of the lens flare system
  128235. */
  128236. name: string, emitter: any, scene: Scene);
  128237. /**
  128238. * Define if the lens flare system is enabled.
  128239. */
  128240. get isEnabled(): boolean;
  128241. set isEnabled(value: boolean);
  128242. /**
  128243. * Get the scene the effects belongs to.
  128244. * @returns the scene holding the lens flare system
  128245. */
  128246. getScene(): Scene;
  128247. /**
  128248. * Get the emitter of the lens flare system.
  128249. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128250. * @returns the emitter of the lens flare system
  128251. */
  128252. getEmitter(): any;
  128253. /**
  128254. * Set the emitter of the lens flare system.
  128255. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128256. * @param newEmitter Define the new emitter of the system
  128257. */
  128258. setEmitter(newEmitter: any): void;
  128259. /**
  128260. * Get the lens flare system emitter position.
  128261. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  128262. * @returns the position
  128263. */
  128264. getEmitterPosition(): Vector3;
  128265. /**
  128266. * @hidden
  128267. */
  128268. computeEffectivePosition(globalViewport: Viewport): boolean;
  128269. /** @hidden */
  128270. _isVisible(): boolean;
  128271. /**
  128272. * @hidden
  128273. */
  128274. render(): boolean;
  128275. /**
  128276. * Dispose and release the lens flare with its associated resources.
  128277. */
  128278. dispose(): void;
  128279. /**
  128280. * Parse a lens flare system from a JSON repressentation
  128281. * @param parsedLensFlareSystem Define the JSON to parse
  128282. * @param scene Define the scene the parsed system should be instantiated in
  128283. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  128284. * @returns the parsed system
  128285. */
  128286. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  128287. /**
  128288. * Serialize the current Lens Flare System into a JSON representation.
  128289. * @returns the serialized JSON
  128290. */
  128291. serialize(): any;
  128292. }
  128293. }
  128294. declare module BABYLON {
  128295. /**
  128296. * This represents one of the lens effect in a `lensFlareSystem`.
  128297. * It controls one of the indiviual texture used in the effect.
  128298. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128299. */
  128300. export class LensFlare {
  128301. /**
  128302. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128303. */
  128304. size: number;
  128305. /**
  128306. * 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.
  128307. */
  128308. position: number;
  128309. /**
  128310. * Define the lens color.
  128311. */
  128312. color: Color3;
  128313. /**
  128314. * Define the lens texture.
  128315. */
  128316. texture: Nullable<Texture>;
  128317. /**
  128318. * Define the alpha mode to render this particular lens.
  128319. */
  128320. alphaMode: number;
  128321. private _system;
  128322. /**
  128323. * Creates a new Lens Flare.
  128324. * This represents one of the lens effect in a `lensFlareSystem`.
  128325. * It controls one of the indiviual texture used in the effect.
  128326. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128327. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  128328. * @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.
  128329. * @param color Define the lens color
  128330. * @param imgUrl Define the lens texture url
  128331. * @param system Define the `lensFlareSystem` this flare is part of
  128332. * @returns The newly created Lens Flare
  128333. */
  128334. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  128335. /**
  128336. * Instantiates a new Lens Flare.
  128337. * This represents one of the lens effect in a `lensFlareSystem`.
  128338. * It controls one of the indiviual texture used in the effect.
  128339. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128340. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  128341. * @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.
  128342. * @param color Define the lens color
  128343. * @param imgUrl Define the lens texture url
  128344. * @param system Define the `lensFlareSystem` this flare is part of
  128345. */
  128346. constructor(
  128347. /**
  128348. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128349. */
  128350. size: number,
  128351. /**
  128352. * 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.
  128353. */
  128354. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  128355. /**
  128356. * Dispose and release the lens flare with its associated resources.
  128357. */
  128358. dispose(): void;
  128359. }
  128360. }
  128361. declare module BABYLON {
  128362. interface AbstractScene {
  128363. /**
  128364. * The list of lens flare system added to the scene
  128365. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128366. */
  128367. lensFlareSystems: Array<LensFlareSystem>;
  128368. /**
  128369. * Removes the given lens flare system from this scene.
  128370. * @param toRemove The lens flare system to remove
  128371. * @returns The index of the removed lens flare system
  128372. */
  128373. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  128374. /**
  128375. * Adds the given lens flare system to this scene
  128376. * @param newLensFlareSystem The lens flare system to add
  128377. */
  128378. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  128379. /**
  128380. * Gets a lens flare system using its name
  128381. * @param name defines the name to look for
  128382. * @returns the lens flare system or null if not found
  128383. */
  128384. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  128385. /**
  128386. * Gets a lens flare system using its id
  128387. * @param id defines the id to look for
  128388. * @returns the lens flare system or null if not found
  128389. */
  128390. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  128391. }
  128392. /**
  128393. * Defines the lens flare scene component responsible to manage any lens flares
  128394. * in a given scene.
  128395. */
  128396. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  128397. /**
  128398. * The component name helpfull to identify the component in the list of scene components.
  128399. */
  128400. readonly name: string;
  128401. /**
  128402. * The scene the component belongs to.
  128403. */
  128404. scene: Scene;
  128405. /**
  128406. * Creates a new instance of the component for the given scene
  128407. * @param scene Defines the scene to register the component in
  128408. */
  128409. constructor(scene: Scene);
  128410. /**
  128411. * Registers the component in a given scene
  128412. */
  128413. register(): void;
  128414. /**
  128415. * Rebuilds the elements related to this component in case of
  128416. * context lost for instance.
  128417. */
  128418. rebuild(): void;
  128419. /**
  128420. * Adds all the elements from the container to the scene
  128421. * @param container the container holding the elements
  128422. */
  128423. addFromContainer(container: AbstractScene): void;
  128424. /**
  128425. * Removes all the elements in the container from the scene
  128426. * @param container contains the elements to remove
  128427. * @param dispose if the removed element should be disposed (default: false)
  128428. */
  128429. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128430. /**
  128431. * Serializes the component data to the specified json object
  128432. * @param serializationObject The object to serialize to
  128433. */
  128434. serialize(serializationObject: any): void;
  128435. /**
  128436. * Disposes the component and the associated ressources.
  128437. */
  128438. dispose(): void;
  128439. private _draw;
  128440. }
  128441. }
  128442. declare module BABYLON {
  128443. /** @hidden */
  128444. export var depthPixelShader: {
  128445. name: string;
  128446. shader: string;
  128447. };
  128448. }
  128449. declare module BABYLON {
  128450. /** @hidden */
  128451. export var depthVertexShader: {
  128452. name: string;
  128453. shader: string;
  128454. };
  128455. }
  128456. declare module BABYLON {
  128457. /**
  128458. * This represents a depth renderer in Babylon.
  128459. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128460. */
  128461. export class DepthRenderer {
  128462. private _scene;
  128463. private _depthMap;
  128464. private _effect;
  128465. private readonly _storeNonLinearDepth;
  128466. private readonly _clearColor;
  128467. /** Get if the depth renderer is using packed depth or not */
  128468. readonly isPacked: boolean;
  128469. private _cachedDefines;
  128470. private _camera;
  128471. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  128472. enabled: boolean;
  128473. /**
  128474. * Specifiess that the depth renderer will only be used within
  128475. * the camera it is created for.
  128476. * This can help forcing its rendering during the camera processing.
  128477. */
  128478. useOnlyInActiveCamera: boolean;
  128479. /** @hidden */
  128480. static _SceneComponentInitialization: (scene: Scene) => void;
  128481. /**
  128482. * Instantiates a depth renderer
  128483. * @param scene The scene the renderer belongs to
  128484. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128485. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128486. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128487. */
  128488. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128489. /**
  128490. * Creates the depth rendering effect and checks if the effect is ready.
  128491. * @param subMesh The submesh to be used to render the depth map of
  128492. * @param useInstances If multiple world instances should be used
  128493. * @returns if the depth renderer is ready to render the depth map
  128494. */
  128495. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128496. /**
  128497. * Gets the texture which the depth map will be written to.
  128498. * @returns The depth map texture
  128499. */
  128500. getDepthMap(): RenderTargetTexture;
  128501. /**
  128502. * Disposes of the depth renderer.
  128503. */
  128504. dispose(): void;
  128505. }
  128506. }
  128507. declare module BABYLON {
  128508. /** @hidden */
  128509. export var minmaxReduxPixelShader: {
  128510. name: string;
  128511. shader: string;
  128512. };
  128513. }
  128514. declare module BABYLON {
  128515. /**
  128516. * This class computes a min/max reduction from a texture: it means it computes the minimum
  128517. * and maximum values from all values of the texture.
  128518. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  128519. * The source values are read from the red channel of the texture.
  128520. */
  128521. export class MinMaxReducer {
  128522. /**
  128523. * Observable triggered when the computation has been performed
  128524. */
  128525. onAfterReductionPerformed: Observable<{
  128526. min: number;
  128527. max: number;
  128528. }>;
  128529. protected _camera: Camera;
  128530. protected _sourceTexture: Nullable<RenderTargetTexture>;
  128531. protected _reductionSteps: Nullable<Array<PostProcess>>;
  128532. protected _postProcessManager: PostProcessManager;
  128533. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  128534. protected _forceFullscreenViewport: boolean;
  128535. /**
  128536. * Creates a min/max reducer
  128537. * @param camera The camera to use for the post processes
  128538. */
  128539. constructor(camera: Camera);
  128540. /**
  128541. * Gets the texture used to read the values from.
  128542. */
  128543. get sourceTexture(): Nullable<RenderTargetTexture>;
  128544. /**
  128545. * Sets the source texture to read the values from.
  128546. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  128547. * because in such textures '1' value must not be taken into account to compute the maximum
  128548. * as this value is used to clear the texture.
  128549. * Note that the computation is not activated by calling this function, you must call activate() for that!
  128550. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  128551. * @param depthRedux Indicates if the texture is a depth texture or not
  128552. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  128553. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128554. */
  128555. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128556. /**
  128557. * Defines the refresh rate of the computation.
  128558. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128559. */
  128560. get refreshRate(): number;
  128561. set refreshRate(value: number);
  128562. protected _activated: boolean;
  128563. /**
  128564. * Gets the activation status of the reducer
  128565. */
  128566. get activated(): boolean;
  128567. /**
  128568. * Activates the reduction computation.
  128569. * When activated, the observers registered in onAfterReductionPerformed are
  128570. * called after the compuation is performed
  128571. */
  128572. activate(): void;
  128573. /**
  128574. * Deactivates the reduction computation.
  128575. */
  128576. deactivate(): void;
  128577. /**
  128578. * Disposes the min/max reducer
  128579. * @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.
  128580. */
  128581. dispose(disposeAll?: boolean): void;
  128582. }
  128583. }
  128584. declare module BABYLON {
  128585. /**
  128586. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  128587. */
  128588. export class DepthReducer extends MinMaxReducer {
  128589. private _depthRenderer;
  128590. private _depthRendererId;
  128591. /**
  128592. * Gets the depth renderer used for the computation.
  128593. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  128594. */
  128595. get depthRenderer(): Nullable<DepthRenderer>;
  128596. /**
  128597. * Creates a depth reducer
  128598. * @param camera The camera used to render the depth texture
  128599. */
  128600. constructor(camera: Camera);
  128601. /**
  128602. * Sets the depth renderer to use to generate the depth map
  128603. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  128604. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  128605. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128606. */
  128607. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  128608. /** @hidden */
  128609. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128610. /**
  128611. * Activates the reduction computation.
  128612. * When activated, the observers registered in onAfterReductionPerformed are
  128613. * called after the compuation is performed
  128614. */
  128615. activate(): void;
  128616. /**
  128617. * Deactivates the reduction computation.
  128618. */
  128619. deactivate(): void;
  128620. /**
  128621. * Disposes the depth reducer
  128622. * @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.
  128623. */
  128624. dispose(disposeAll?: boolean): void;
  128625. }
  128626. }
  128627. declare module BABYLON {
  128628. /**
  128629. * A CSM implementation allowing casting shadows on large scenes.
  128630. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  128631. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  128632. */
  128633. export class CascadedShadowGenerator extends ShadowGenerator {
  128634. private static readonly frustumCornersNDCSpace;
  128635. /**
  128636. * Name of the CSM class
  128637. */
  128638. static CLASSNAME: string;
  128639. /**
  128640. * Defines the default number of cascades used by the CSM.
  128641. */
  128642. static readonly DEFAULT_CASCADES_COUNT: number;
  128643. /**
  128644. * Defines the minimum number of cascades used by the CSM.
  128645. */
  128646. static readonly MIN_CASCADES_COUNT: number;
  128647. /**
  128648. * Defines the maximum number of cascades used by the CSM.
  128649. */
  128650. static readonly MAX_CASCADES_COUNT: number;
  128651. protected _validateFilter(filter: number): number;
  128652. /**
  128653. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  128654. */
  128655. penumbraDarkness: number;
  128656. private _numCascades;
  128657. /**
  128658. * Gets or set the number of cascades used by the CSM.
  128659. */
  128660. get numCascades(): number;
  128661. set numCascades(value: number);
  128662. /**
  128663. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  128664. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  128665. */
  128666. stabilizeCascades: boolean;
  128667. private _freezeShadowCastersBoundingInfo;
  128668. private _freezeShadowCastersBoundingInfoObservable;
  128669. /**
  128670. * Enables or disables the shadow casters bounding info computation.
  128671. * If your shadow casters don't move, you can disable this feature.
  128672. * If it is enabled, the bounding box computation is done every frame.
  128673. */
  128674. get freezeShadowCastersBoundingInfo(): boolean;
  128675. set freezeShadowCastersBoundingInfo(freeze: boolean);
  128676. private _scbiMin;
  128677. private _scbiMax;
  128678. protected _computeShadowCastersBoundingInfo(): void;
  128679. protected _shadowCastersBoundingInfo: BoundingInfo;
  128680. /**
  128681. * Gets or sets the shadow casters bounding info.
  128682. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  128683. * so that the system won't overwrite the bounds you provide
  128684. */
  128685. get shadowCastersBoundingInfo(): BoundingInfo;
  128686. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  128687. protected _breaksAreDirty: boolean;
  128688. protected _minDistance: number;
  128689. protected _maxDistance: number;
  128690. /**
  128691. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  128692. *
  128693. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  128694. * If you don't know these values, simply leave them to their defaults and don't call this function.
  128695. * @param min minimal distance for the breaks (default to 0.)
  128696. * @param max maximal distance for the breaks (default to 1.)
  128697. */
  128698. setMinMaxDistance(min: number, max: number): void;
  128699. /** Gets the minimal distance used in the cascade break computation */
  128700. get minDistance(): number;
  128701. /** Gets the maximal distance used in the cascade break computation */
  128702. get maxDistance(): number;
  128703. /**
  128704. * Gets the class name of that object
  128705. * @returns "CascadedShadowGenerator"
  128706. */
  128707. getClassName(): string;
  128708. private _cascadeMinExtents;
  128709. private _cascadeMaxExtents;
  128710. /**
  128711. * Gets a cascade minimum extents
  128712. * @param cascadeIndex index of the cascade
  128713. * @returns the minimum cascade extents
  128714. */
  128715. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  128716. /**
  128717. * Gets a cascade maximum extents
  128718. * @param cascadeIndex index of the cascade
  128719. * @returns the maximum cascade extents
  128720. */
  128721. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  128722. private _cascades;
  128723. private _currentLayer;
  128724. private _viewSpaceFrustumsZ;
  128725. private _viewMatrices;
  128726. private _projectionMatrices;
  128727. private _transformMatrices;
  128728. private _transformMatricesAsArray;
  128729. private _frustumLengths;
  128730. private _lightSizeUVCorrection;
  128731. private _depthCorrection;
  128732. private _frustumCornersWorldSpace;
  128733. private _frustumCenter;
  128734. private _shadowCameraPos;
  128735. private _shadowMaxZ;
  128736. /**
  128737. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  128738. * It defaults to camera.maxZ
  128739. */
  128740. get shadowMaxZ(): number;
  128741. /**
  128742. * Sets the shadow max z distance.
  128743. */
  128744. set shadowMaxZ(value: number);
  128745. protected _debug: boolean;
  128746. /**
  128747. * Gets or sets the debug flag.
  128748. * When enabled, the cascades are materialized by different colors on the screen.
  128749. */
  128750. get debug(): boolean;
  128751. set debug(dbg: boolean);
  128752. private _depthClamp;
  128753. /**
  128754. * Gets or sets the depth clamping value.
  128755. *
  128756. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  128757. * to account for the shadow casters far away.
  128758. *
  128759. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  128760. */
  128761. get depthClamp(): boolean;
  128762. set depthClamp(value: boolean);
  128763. private _cascadeBlendPercentage;
  128764. /**
  128765. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  128766. * It defaults to 0.1 (10% blending).
  128767. */
  128768. get cascadeBlendPercentage(): number;
  128769. set cascadeBlendPercentage(value: number);
  128770. private _lambda;
  128771. /**
  128772. * Gets or set the lambda parameter.
  128773. * This parameter is used to split the camera frustum and create the cascades.
  128774. * 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.
  128775. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  128776. */
  128777. get lambda(): number;
  128778. set lambda(value: number);
  128779. /**
  128780. * Gets the view matrix corresponding to a given cascade
  128781. * @param cascadeNum cascade to retrieve the view matrix from
  128782. * @returns the cascade view matrix
  128783. */
  128784. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  128785. /**
  128786. * Gets the projection matrix corresponding to a given cascade
  128787. * @param cascadeNum cascade to retrieve the projection matrix from
  128788. * @returns the cascade projection matrix
  128789. */
  128790. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  128791. /**
  128792. * Gets the transformation matrix corresponding to a given cascade
  128793. * @param cascadeNum cascade to retrieve the transformation matrix from
  128794. * @returns the cascade transformation matrix
  128795. */
  128796. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  128797. private _depthRenderer;
  128798. /**
  128799. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  128800. *
  128801. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  128802. *
  128803. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  128804. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  128805. * @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
  128806. */
  128807. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  128808. private _depthReducer;
  128809. private _autoCalcDepthBounds;
  128810. /**
  128811. * Gets or sets the autoCalcDepthBounds property.
  128812. *
  128813. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  128814. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  128815. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  128816. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  128817. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  128818. */
  128819. get autoCalcDepthBounds(): boolean;
  128820. set autoCalcDepthBounds(value: boolean);
  128821. /**
  128822. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  128823. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128824. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  128825. * for setting the refresh rate on the renderer yourself!
  128826. */
  128827. get autoCalcDepthBoundsRefreshRate(): number;
  128828. set autoCalcDepthBoundsRefreshRate(value: number);
  128829. /**
  128830. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  128831. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  128832. * you change the camera near/far planes!
  128833. */
  128834. splitFrustum(): void;
  128835. private _splitFrustum;
  128836. private _computeMatrices;
  128837. private _computeFrustumInWorldSpace;
  128838. private _computeCascadeFrustum;
  128839. /**
  128840. * Support test.
  128841. */
  128842. static get IsSupported(): boolean;
  128843. /** @hidden */
  128844. static _SceneComponentInitialization: (scene: Scene) => void;
  128845. /**
  128846. * Creates a Cascaded Shadow Generator object.
  128847. * A ShadowGenerator is the required tool to use the shadows.
  128848. * Each directional light casting shadows needs to use its own ShadowGenerator.
  128849. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  128850. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  128851. * @param light The directional light object generating the shadows.
  128852. * @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.
  128853. */
  128854. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  128855. protected _initializeGenerator(): void;
  128856. protected _createTargetRenderTexture(): void;
  128857. protected _initializeShadowMap(): void;
  128858. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  128859. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  128860. /**
  128861. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  128862. * @param defines Defines of the material we want to update
  128863. * @param lightIndex Index of the light in the enabled light list of the material
  128864. */
  128865. prepareDefines(defines: any, lightIndex: number): void;
  128866. /**
  128867. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  128868. * defined in the generator but impacting the effect).
  128869. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  128870. * @param effect The effect we are binfing the information for
  128871. */
  128872. bindShadowLight(lightIndex: string, effect: Effect): void;
  128873. /**
  128874. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  128875. * (eq to view projection * shadow projection matrices)
  128876. * @returns The transform matrix used to create the shadow map
  128877. */
  128878. getTransformMatrix(): Matrix;
  128879. /**
  128880. * Disposes the ShadowGenerator.
  128881. * Returns nothing.
  128882. */
  128883. dispose(): void;
  128884. /**
  128885. * Serializes the shadow generator setup to a json object.
  128886. * @returns The serialized JSON object
  128887. */
  128888. serialize(): any;
  128889. /**
  128890. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  128891. * @param parsedShadowGenerator The JSON object to parse
  128892. * @param scene The scene to create the shadow map for
  128893. * @returns The parsed shadow generator
  128894. */
  128895. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  128896. }
  128897. }
  128898. declare module BABYLON {
  128899. /**
  128900. * Defines the shadow generator component responsible to manage any shadow generators
  128901. * in a given scene.
  128902. */
  128903. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  128904. /**
  128905. * The component name helpfull to identify the component in the list of scene components.
  128906. */
  128907. readonly name: string;
  128908. /**
  128909. * The scene the component belongs to.
  128910. */
  128911. scene: Scene;
  128912. /**
  128913. * Creates a new instance of the component for the given scene
  128914. * @param scene Defines the scene to register the component in
  128915. */
  128916. constructor(scene: Scene);
  128917. /**
  128918. * Registers the component in a given scene
  128919. */
  128920. register(): void;
  128921. /**
  128922. * Rebuilds the elements related to this component in case of
  128923. * context lost for instance.
  128924. */
  128925. rebuild(): void;
  128926. /**
  128927. * Serializes the component data to the specified json object
  128928. * @param serializationObject The object to serialize to
  128929. */
  128930. serialize(serializationObject: any): void;
  128931. /**
  128932. * Adds all the elements from the container to the scene
  128933. * @param container the container holding the elements
  128934. */
  128935. addFromContainer(container: AbstractScene): void;
  128936. /**
  128937. * Removes all the elements in the container from the scene
  128938. * @param container contains the elements to remove
  128939. * @param dispose if the removed element should be disposed (default: false)
  128940. */
  128941. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128942. /**
  128943. * Rebuilds the elements related to this component in case of
  128944. * context lost for instance.
  128945. */
  128946. dispose(): void;
  128947. private _gatherRenderTargets;
  128948. }
  128949. }
  128950. declare module BABYLON {
  128951. /**
  128952. * A point light is a light defined by an unique point in world space.
  128953. * The light is emitted in every direction from this point.
  128954. * A good example of a point light is a standard light bulb.
  128955. * Documentation: https://doc.babylonjs.com/babylon101/lights
  128956. */
  128957. export class PointLight extends ShadowLight {
  128958. private _shadowAngle;
  128959. /**
  128960. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128961. * This specifies what angle the shadow will use to be created.
  128962. *
  128963. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128964. */
  128965. get shadowAngle(): number;
  128966. /**
  128967. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128968. * This specifies what angle the shadow will use to be created.
  128969. *
  128970. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  128971. */
  128972. set shadowAngle(value: number);
  128973. /**
  128974. * Gets the direction if it has been set.
  128975. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128976. */
  128977. get direction(): Vector3;
  128978. /**
  128979. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  128980. */
  128981. set direction(value: Vector3);
  128982. /**
  128983. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  128984. * A PointLight emits the light in every direction.
  128985. * It can cast shadows.
  128986. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  128987. * ```javascript
  128988. * var pointLight = new PointLight("pl", camera.position, scene);
  128989. * ```
  128990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  128991. * @param name The light friendly name
  128992. * @param position The position of the point light in the scene
  128993. * @param scene The scene the lights belongs to
  128994. */
  128995. constructor(name: string, position: Vector3, scene: Scene);
  128996. /**
  128997. * Returns the string "PointLight"
  128998. * @returns the class name
  128999. */
  129000. getClassName(): string;
  129001. /**
  129002. * Returns the integer 0.
  129003. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129004. */
  129005. getTypeID(): number;
  129006. /**
  129007. * Specifies wether or not the shadowmap should be a cube texture.
  129008. * @returns true if the shadowmap needs to be a cube texture.
  129009. */
  129010. needCube(): boolean;
  129011. /**
  129012. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  129013. * @param faceIndex The index of the face we are computed the direction to generate shadow
  129014. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  129015. */
  129016. getShadowDirection(faceIndex?: number): Vector3;
  129017. /**
  129018. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  129019. * - fov = PI / 2
  129020. * - aspect ratio : 1.0
  129021. * - z-near and far equal to the active camera minZ and maxZ.
  129022. * Returns the PointLight.
  129023. */
  129024. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129025. protected _buildUniformLayout(): void;
  129026. /**
  129027. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  129028. * @param effect The effect to update
  129029. * @param lightIndex The index of the light in the effect to update
  129030. * @returns The point light
  129031. */
  129032. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  129033. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129034. /**
  129035. * Prepares the list of defines specific to the light type.
  129036. * @param defines the list of defines
  129037. * @param lightIndex defines the index of the light for the effect
  129038. */
  129039. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129040. }
  129041. }
  129042. declare module BABYLON {
  129043. /**
  129044. * Header information of HDR texture files.
  129045. */
  129046. export interface HDRInfo {
  129047. /**
  129048. * The height of the texture in pixels.
  129049. */
  129050. height: number;
  129051. /**
  129052. * The width of the texture in pixels.
  129053. */
  129054. width: number;
  129055. /**
  129056. * The index of the beginning of the data in the binary file.
  129057. */
  129058. dataPosition: number;
  129059. }
  129060. /**
  129061. * This groups tools to convert HDR texture to native colors array.
  129062. */
  129063. export class HDRTools {
  129064. private static Ldexp;
  129065. private static Rgbe2float;
  129066. private static readStringLine;
  129067. /**
  129068. * Reads header information from an RGBE texture stored in a native array.
  129069. * More information on this format are available here:
  129070. * https://en.wikipedia.org/wiki/RGBE_image_format
  129071. *
  129072. * @param uint8array The binary file stored in native array.
  129073. * @return The header information.
  129074. */
  129075. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  129076. /**
  129077. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  129078. * This RGBE texture needs to store the information as a panorama.
  129079. *
  129080. * More information on this format are available here:
  129081. * https://en.wikipedia.org/wiki/RGBE_image_format
  129082. *
  129083. * @param buffer The binary file stored in an array buffer.
  129084. * @param size The expected size of the extracted cubemap.
  129085. * @return The Cube Map information.
  129086. */
  129087. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  129088. /**
  129089. * Returns the pixels data extracted from an RGBE texture.
  129090. * This pixels will be stored left to right up to down in the R G B order in one array.
  129091. *
  129092. * More information on this format are available here:
  129093. * https://en.wikipedia.org/wiki/RGBE_image_format
  129094. *
  129095. * @param uint8array The binary file stored in an array buffer.
  129096. * @param hdrInfo The header information of the file.
  129097. * @return The pixels data in RGB right to left up to down order.
  129098. */
  129099. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  129100. private static RGBE_ReadPixels_RLE;
  129101. }
  129102. }
  129103. declare module BABYLON {
  129104. /**
  129105. * This represents a texture coming from an HDR input.
  129106. *
  129107. * The only supported format is currently panorama picture stored in RGBE format.
  129108. * Example of such files can be found on HDRLib: http://hdrlib.com/
  129109. */
  129110. export class HDRCubeTexture extends BaseTexture {
  129111. private static _facesMapping;
  129112. private _generateHarmonics;
  129113. private _noMipmap;
  129114. private _textureMatrix;
  129115. private _size;
  129116. private _onLoad;
  129117. private _onError;
  129118. /**
  129119. * The texture URL.
  129120. */
  129121. url: string;
  129122. /**
  129123. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  129124. */
  129125. coordinatesMode: number;
  129126. protected _isBlocking: boolean;
  129127. /**
  129128. * Sets wether or not the texture is blocking during loading.
  129129. */
  129130. set isBlocking(value: boolean);
  129131. /**
  129132. * Gets wether or not the texture is blocking during loading.
  129133. */
  129134. get isBlocking(): boolean;
  129135. protected _rotationY: number;
  129136. /**
  129137. * Sets texture matrix rotation angle around Y axis in radians.
  129138. */
  129139. set rotationY(value: number);
  129140. /**
  129141. * Gets texture matrix rotation angle around Y axis radians.
  129142. */
  129143. get rotationY(): number;
  129144. /**
  129145. * Gets or sets the center of the bounding box associated with the cube texture
  129146. * It must define where the camera used to render the texture was set
  129147. */
  129148. boundingBoxPosition: Vector3;
  129149. private _boundingBoxSize;
  129150. /**
  129151. * Gets or sets the size of the bounding box associated with the cube texture
  129152. * When defined, the cubemap will switch to local mode
  129153. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  129154. * @example https://www.babylonjs-playground.com/#RNASML
  129155. */
  129156. set boundingBoxSize(value: Vector3);
  129157. get boundingBoxSize(): Vector3;
  129158. /**
  129159. * Instantiates an HDRTexture from the following parameters.
  129160. *
  129161. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  129162. * @param scene The scene the texture will be used in
  129163. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129164. * @param noMipmap Forces to not generate the mipmap if true
  129165. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  129166. * @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)
  129167. * @param reserved Reserved flag for internal use.
  129168. */
  129169. 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>);
  129170. /**
  129171. * Get the current class name of the texture useful for serialization or dynamic coding.
  129172. * @returns "HDRCubeTexture"
  129173. */
  129174. getClassName(): string;
  129175. /**
  129176. * Occurs when the file is raw .hdr file.
  129177. */
  129178. private loadTexture;
  129179. clone(): HDRCubeTexture;
  129180. delayLoad(): void;
  129181. /**
  129182. * Get the texture reflection matrix used to rotate/transform the reflection.
  129183. * @returns the reflection matrix
  129184. */
  129185. getReflectionTextureMatrix(): Matrix;
  129186. /**
  129187. * Set the texture reflection matrix used to rotate/transform the reflection.
  129188. * @param value Define the reflection matrix to set
  129189. */
  129190. setReflectionTextureMatrix(value: Matrix): void;
  129191. /**
  129192. * Parses a JSON representation of an HDR Texture in order to create the texture
  129193. * @param parsedTexture Define the JSON representation
  129194. * @param scene Define the scene the texture should be created in
  129195. * @param rootUrl Define the root url in case we need to load relative dependencies
  129196. * @returns the newly created texture after parsing
  129197. */
  129198. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  129199. serialize(): any;
  129200. }
  129201. }
  129202. declare module BABYLON {
  129203. /**
  129204. * Class used to control physics engine
  129205. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129206. */
  129207. export class PhysicsEngine implements IPhysicsEngine {
  129208. private _physicsPlugin;
  129209. /**
  129210. * Global value used to control the smallest number supported by the simulation
  129211. */
  129212. static Epsilon: number;
  129213. private _impostors;
  129214. private _joints;
  129215. private _subTimeStep;
  129216. /**
  129217. * Gets the gravity vector used by the simulation
  129218. */
  129219. gravity: Vector3;
  129220. /**
  129221. * Factory used to create the default physics plugin.
  129222. * @returns The default physics plugin
  129223. */
  129224. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  129225. /**
  129226. * Creates a new Physics Engine
  129227. * @param gravity defines the gravity vector used by the simulation
  129228. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  129229. */
  129230. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  129231. /**
  129232. * Sets the gravity vector used by the simulation
  129233. * @param gravity defines the gravity vector to use
  129234. */
  129235. setGravity(gravity: Vector3): void;
  129236. /**
  129237. * Set the time step of the physics engine.
  129238. * Default is 1/60.
  129239. * To slow it down, enter 1/600 for example.
  129240. * To speed it up, 1/30
  129241. * @param newTimeStep defines the new timestep to apply to this world.
  129242. */
  129243. setTimeStep(newTimeStep?: number): void;
  129244. /**
  129245. * Get the time step of the physics engine.
  129246. * @returns the current time step
  129247. */
  129248. getTimeStep(): number;
  129249. /**
  129250. * Set the sub time step of the physics engine.
  129251. * Default is 0 meaning there is no sub steps
  129252. * To increase physics resolution precision, set a small value (like 1 ms)
  129253. * @param subTimeStep defines the new sub timestep used for physics resolution.
  129254. */
  129255. setSubTimeStep(subTimeStep?: number): void;
  129256. /**
  129257. * Get the sub time step of the physics engine.
  129258. * @returns the current sub time step
  129259. */
  129260. getSubTimeStep(): number;
  129261. /**
  129262. * Release all resources
  129263. */
  129264. dispose(): void;
  129265. /**
  129266. * Gets the name of the current physics plugin
  129267. * @returns the name of the plugin
  129268. */
  129269. getPhysicsPluginName(): string;
  129270. /**
  129271. * Adding a new impostor for the impostor tracking.
  129272. * This will be done by the impostor itself.
  129273. * @param impostor the impostor to add
  129274. */
  129275. addImpostor(impostor: PhysicsImpostor): void;
  129276. /**
  129277. * Remove an impostor from the engine.
  129278. * This impostor and its mesh will not longer be updated by the physics engine.
  129279. * @param impostor the impostor to remove
  129280. */
  129281. removeImpostor(impostor: PhysicsImpostor): void;
  129282. /**
  129283. * Add a joint to the physics engine
  129284. * @param mainImpostor defines the main impostor to which the joint is added.
  129285. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  129286. * @param joint defines the joint that will connect both impostors.
  129287. */
  129288. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129289. /**
  129290. * Removes a joint from the simulation
  129291. * @param mainImpostor defines the impostor used with the joint
  129292. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  129293. * @param joint defines the joint to remove
  129294. */
  129295. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129296. /**
  129297. * Called by the scene. No need to call it.
  129298. * @param delta defines the timespam between frames
  129299. */
  129300. _step(delta: number): void;
  129301. /**
  129302. * Gets the current plugin used to run the simulation
  129303. * @returns current plugin
  129304. */
  129305. getPhysicsPlugin(): IPhysicsEnginePlugin;
  129306. /**
  129307. * Gets the list of physic impostors
  129308. * @returns an array of PhysicsImpostor
  129309. */
  129310. getImpostors(): Array<PhysicsImpostor>;
  129311. /**
  129312. * Gets the impostor for a physics enabled object
  129313. * @param object defines the object impersonated by the impostor
  129314. * @returns the PhysicsImpostor or null if not found
  129315. */
  129316. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  129317. /**
  129318. * Gets the impostor for a physics body object
  129319. * @param body defines physics body used by the impostor
  129320. * @returns the PhysicsImpostor or null if not found
  129321. */
  129322. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  129323. /**
  129324. * Does a raycast in the physics world
  129325. * @param from when should the ray start?
  129326. * @param to when should the ray end?
  129327. * @returns PhysicsRaycastResult
  129328. */
  129329. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129330. }
  129331. }
  129332. declare module BABYLON {
  129333. /** @hidden */
  129334. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  129335. private _useDeltaForWorldStep;
  129336. world: any;
  129337. name: string;
  129338. private _physicsMaterials;
  129339. private _fixedTimeStep;
  129340. private _cannonRaycastResult;
  129341. private _raycastResult;
  129342. private _physicsBodysToRemoveAfterStep;
  129343. BJSCANNON: any;
  129344. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  129345. setGravity(gravity: Vector3): void;
  129346. setTimeStep(timeStep: number): void;
  129347. getTimeStep(): number;
  129348. executeStep(delta: number): void;
  129349. private _removeMarkedPhysicsBodiesFromWorld;
  129350. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129351. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129352. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129353. private _processChildMeshes;
  129354. removePhysicsBody(impostor: PhysicsImpostor): void;
  129355. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129356. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129357. private _addMaterial;
  129358. private _checkWithEpsilon;
  129359. private _createShape;
  129360. private _createHeightmap;
  129361. private _minus90X;
  129362. private _plus90X;
  129363. private _tmpPosition;
  129364. private _tmpDeltaPosition;
  129365. private _tmpUnityRotation;
  129366. private _updatePhysicsBodyTransformation;
  129367. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129368. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129369. isSupported(): boolean;
  129370. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129371. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129372. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129373. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129374. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129375. getBodyMass(impostor: PhysicsImpostor): number;
  129376. getBodyFriction(impostor: PhysicsImpostor): number;
  129377. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129378. getBodyRestitution(impostor: PhysicsImpostor): number;
  129379. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129380. sleepBody(impostor: PhysicsImpostor): void;
  129381. wakeUpBody(impostor: PhysicsImpostor): void;
  129382. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  129383. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129384. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129385. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129386. getRadius(impostor: PhysicsImpostor): number;
  129387. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129388. dispose(): void;
  129389. private _extendNamespace;
  129390. /**
  129391. * Does a raycast in the physics world
  129392. * @param from when should the ray start?
  129393. * @param to when should the ray end?
  129394. * @returns PhysicsRaycastResult
  129395. */
  129396. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129397. }
  129398. }
  129399. declare module BABYLON {
  129400. /** @hidden */
  129401. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  129402. world: any;
  129403. name: string;
  129404. BJSOIMO: any;
  129405. private _raycastResult;
  129406. constructor(iterations?: number, oimoInjection?: any);
  129407. setGravity(gravity: Vector3): void;
  129408. setTimeStep(timeStep: number): void;
  129409. getTimeStep(): number;
  129410. private _tmpImpostorsArray;
  129411. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  129412. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129413. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129414. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129415. private _tmpPositionVector;
  129416. removePhysicsBody(impostor: PhysicsImpostor): void;
  129417. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129418. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129419. isSupported(): boolean;
  129420. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129421. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129422. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129423. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129424. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129425. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129426. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129427. getBodyMass(impostor: PhysicsImpostor): number;
  129428. getBodyFriction(impostor: PhysicsImpostor): number;
  129429. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129430. getBodyRestitution(impostor: PhysicsImpostor): number;
  129431. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129432. sleepBody(impostor: PhysicsImpostor): void;
  129433. wakeUpBody(impostor: PhysicsImpostor): void;
  129434. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129435. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  129436. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  129437. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129438. getRadius(impostor: PhysicsImpostor): number;
  129439. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129440. dispose(): void;
  129441. /**
  129442. * Does a raycast in the physics world
  129443. * @param from when should the ray start?
  129444. * @param to when should the ray end?
  129445. * @returns PhysicsRaycastResult
  129446. */
  129447. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129448. }
  129449. }
  129450. declare module BABYLON {
  129451. /**
  129452. * Class containing static functions to help procedurally build meshes
  129453. */
  129454. export class RibbonBuilder {
  129455. /**
  129456. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129457. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129458. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129459. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129460. * * 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
  129461. * * 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
  129462. * * 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
  129463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129465. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129466. * * 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
  129467. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129468. * * 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
  129469. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129471. * @param name defines the name of the mesh
  129472. * @param options defines the options used to create the mesh
  129473. * @param scene defines the hosting scene
  129474. * @returns the ribbon mesh
  129475. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129476. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129477. */
  129478. static CreateRibbon(name: string, options: {
  129479. pathArray: Vector3[][];
  129480. closeArray?: boolean;
  129481. closePath?: boolean;
  129482. offset?: number;
  129483. updatable?: boolean;
  129484. sideOrientation?: number;
  129485. frontUVs?: Vector4;
  129486. backUVs?: Vector4;
  129487. instance?: Mesh;
  129488. invertUV?: boolean;
  129489. uvs?: Vector2[];
  129490. colors?: Color4[];
  129491. }, scene?: Nullable<Scene>): Mesh;
  129492. }
  129493. }
  129494. declare module BABYLON {
  129495. /**
  129496. * Class containing static functions to help procedurally build meshes
  129497. */
  129498. export class ShapeBuilder {
  129499. /**
  129500. * 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.
  129501. * * 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.
  129502. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129503. * * 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.
  129504. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129505. * * 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
  129506. * * 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
  129507. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129510. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129512. * @param name defines the name of the mesh
  129513. * @param options defines the options used to create the mesh
  129514. * @param scene defines the hosting scene
  129515. * @returns the extruded shape mesh
  129516. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129518. */
  129519. static ExtrudeShape(name: string, options: {
  129520. shape: Vector3[];
  129521. path: Vector3[];
  129522. scale?: number;
  129523. rotation?: number;
  129524. cap?: number;
  129525. updatable?: boolean;
  129526. sideOrientation?: number;
  129527. frontUVs?: Vector4;
  129528. backUVs?: Vector4;
  129529. instance?: Mesh;
  129530. invertUV?: boolean;
  129531. }, scene?: Nullable<Scene>): Mesh;
  129532. /**
  129533. * Creates an custom extruded shape mesh.
  129534. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129535. * * 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.
  129536. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129537. * * 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
  129538. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129539. * * 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
  129540. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129541. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129542. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129543. * * 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
  129544. * * 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
  129545. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129550. * @param name defines the name of the mesh
  129551. * @param options defines the options used to create the mesh
  129552. * @param scene defines the hosting scene
  129553. * @returns the custom extruded shape mesh
  129554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129557. */
  129558. static ExtrudeShapeCustom(name: string, options: {
  129559. shape: Vector3[];
  129560. path: Vector3[];
  129561. scaleFunction?: any;
  129562. rotationFunction?: any;
  129563. ribbonCloseArray?: boolean;
  129564. ribbonClosePath?: boolean;
  129565. cap?: number;
  129566. updatable?: boolean;
  129567. sideOrientation?: number;
  129568. frontUVs?: Vector4;
  129569. backUVs?: Vector4;
  129570. instance?: Mesh;
  129571. invertUV?: boolean;
  129572. }, scene?: Nullable<Scene>): Mesh;
  129573. private static _ExtrudeShapeGeneric;
  129574. }
  129575. }
  129576. declare module BABYLON {
  129577. /**
  129578. * AmmoJS Physics plugin
  129579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  129580. * @see https://github.com/kripken/ammo.js/
  129581. */
  129582. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  129583. private _useDeltaForWorldStep;
  129584. /**
  129585. * Reference to the Ammo library
  129586. */
  129587. bjsAMMO: any;
  129588. /**
  129589. * Created ammoJS world which physics bodies are added to
  129590. */
  129591. world: any;
  129592. /**
  129593. * Name of the plugin
  129594. */
  129595. name: string;
  129596. private _timeStep;
  129597. private _fixedTimeStep;
  129598. private _maxSteps;
  129599. private _tmpQuaternion;
  129600. private _tmpAmmoTransform;
  129601. private _tmpAmmoQuaternion;
  129602. private _tmpAmmoConcreteContactResultCallback;
  129603. private _collisionConfiguration;
  129604. private _dispatcher;
  129605. private _overlappingPairCache;
  129606. private _solver;
  129607. private _softBodySolver;
  129608. private _tmpAmmoVectorA;
  129609. private _tmpAmmoVectorB;
  129610. private _tmpAmmoVectorC;
  129611. private _tmpAmmoVectorD;
  129612. private _tmpContactCallbackResult;
  129613. private _tmpAmmoVectorRCA;
  129614. private _tmpAmmoVectorRCB;
  129615. private _raycastResult;
  129616. private static readonly DISABLE_COLLISION_FLAG;
  129617. private static readonly KINEMATIC_FLAG;
  129618. private static readonly DISABLE_DEACTIVATION_FLAG;
  129619. /**
  129620. * Initializes the ammoJS plugin
  129621. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  129622. * @param ammoInjection can be used to inject your own ammo reference
  129623. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  129624. */
  129625. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  129626. /**
  129627. * Sets the gravity of the physics world (m/(s^2))
  129628. * @param gravity Gravity to set
  129629. */
  129630. setGravity(gravity: Vector3): void;
  129631. /**
  129632. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  129633. * @param timeStep timestep to use in seconds
  129634. */
  129635. setTimeStep(timeStep: number): void;
  129636. /**
  129637. * 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)
  129638. * @param fixedTimeStep fixedTimeStep to use in seconds
  129639. */
  129640. setFixedTimeStep(fixedTimeStep: number): void;
  129641. /**
  129642. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  129643. * @param maxSteps the maximum number of steps by the physics engine per frame
  129644. */
  129645. setMaxSteps(maxSteps: number): void;
  129646. /**
  129647. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  129648. * @returns the current timestep in seconds
  129649. */
  129650. getTimeStep(): number;
  129651. /**
  129652. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  129653. */
  129654. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  129655. private _isImpostorInContact;
  129656. private _isImpostorPairInContact;
  129657. private _stepSimulation;
  129658. /**
  129659. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  129660. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  129661. * After the step the babylon meshes are set to the position of the physics imposters
  129662. * @param delta amount of time to step forward
  129663. * @param impostors array of imposters to update before/after the step
  129664. */
  129665. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  129666. /**
  129667. * Update babylon mesh to match physics world object
  129668. * @param impostor imposter to match
  129669. */
  129670. private _afterSoftStep;
  129671. /**
  129672. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  129673. * @param impostor imposter to match
  129674. */
  129675. private _ropeStep;
  129676. /**
  129677. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  129678. * @param impostor imposter to match
  129679. */
  129680. private _softbodyOrClothStep;
  129681. private _tmpVector;
  129682. private _tmpMatrix;
  129683. /**
  129684. * Applies an impulse on the imposter
  129685. * @param impostor imposter to apply impulse to
  129686. * @param force amount of force to be applied to the imposter
  129687. * @param contactPoint the location to apply the impulse on the imposter
  129688. */
  129689. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129690. /**
  129691. * Applies a force on the imposter
  129692. * @param impostor imposter to apply force
  129693. * @param force amount of force to be applied to the imposter
  129694. * @param contactPoint the location to apply the force on the imposter
  129695. */
  129696. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129697. /**
  129698. * Creates a physics body using the plugin
  129699. * @param impostor the imposter to create the physics body on
  129700. */
  129701. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129702. /**
  129703. * Removes the physics body from the imposter and disposes of the body's memory
  129704. * @param impostor imposter to remove the physics body from
  129705. */
  129706. removePhysicsBody(impostor: PhysicsImpostor): void;
  129707. /**
  129708. * Generates a joint
  129709. * @param impostorJoint the imposter joint to create the joint with
  129710. */
  129711. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129712. /**
  129713. * Removes a joint
  129714. * @param impostorJoint the imposter joint to remove the joint from
  129715. */
  129716. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129717. private _addMeshVerts;
  129718. /**
  129719. * Initialise the soft body vertices to match its object's (mesh) vertices
  129720. * Softbody vertices (nodes) are in world space and to match this
  129721. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  129722. * @param impostor to create the softbody for
  129723. */
  129724. private _softVertexData;
  129725. /**
  129726. * Create an impostor's soft body
  129727. * @param impostor to create the softbody for
  129728. */
  129729. private _createSoftbody;
  129730. /**
  129731. * Create cloth for an impostor
  129732. * @param impostor to create the softbody for
  129733. */
  129734. private _createCloth;
  129735. /**
  129736. * Create rope for an impostor
  129737. * @param impostor to create the softbody for
  129738. */
  129739. private _createRope;
  129740. /**
  129741. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  129742. * @param impostor to create the custom physics shape for
  129743. */
  129744. private _createCustom;
  129745. private _addHullVerts;
  129746. private _createShape;
  129747. /**
  129748. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  129749. * @param impostor imposter containing the physics body and babylon object
  129750. */
  129751. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129752. /**
  129753. * Sets the babylon object's position/rotation from the physics body's position/rotation
  129754. * @param impostor imposter containing the physics body and babylon object
  129755. * @param newPosition new position
  129756. * @param newRotation new rotation
  129757. */
  129758. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129759. /**
  129760. * If this plugin is supported
  129761. * @returns true if its supported
  129762. */
  129763. isSupported(): boolean;
  129764. /**
  129765. * Sets the linear velocity of the physics body
  129766. * @param impostor imposter to set the velocity on
  129767. * @param velocity velocity to set
  129768. */
  129769. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129770. /**
  129771. * Sets the angular velocity of the physics body
  129772. * @param impostor imposter to set the velocity on
  129773. * @param velocity velocity to set
  129774. */
  129775. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129776. /**
  129777. * gets the linear velocity
  129778. * @param impostor imposter to get linear velocity from
  129779. * @returns linear velocity
  129780. */
  129781. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129782. /**
  129783. * gets the angular velocity
  129784. * @param impostor imposter to get angular velocity from
  129785. * @returns angular velocity
  129786. */
  129787. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129788. /**
  129789. * Sets the mass of physics body
  129790. * @param impostor imposter to set the mass on
  129791. * @param mass mass to set
  129792. */
  129793. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129794. /**
  129795. * Gets the mass of the physics body
  129796. * @param impostor imposter to get the mass from
  129797. * @returns mass
  129798. */
  129799. getBodyMass(impostor: PhysicsImpostor): number;
  129800. /**
  129801. * Gets friction of the impostor
  129802. * @param impostor impostor to get friction from
  129803. * @returns friction value
  129804. */
  129805. getBodyFriction(impostor: PhysicsImpostor): number;
  129806. /**
  129807. * Sets friction of the impostor
  129808. * @param impostor impostor to set friction on
  129809. * @param friction friction value
  129810. */
  129811. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129812. /**
  129813. * Gets restitution of the impostor
  129814. * @param impostor impostor to get restitution from
  129815. * @returns restitution value
  129816. */
  129817. getBodyRestitution(impostor: PhysicsImpostor): number;
  129818. /**
  129819. * Sets resitution of the impostor
  129820. * @param impostor impostor to set resitution on
  129821. * @param restitution resitution value
  129822. */
  129823. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129824. /**
  129825. * Gets pressure inside the impostor
  129826. * @param impostor impostor to get pressure from
  129827. * @returns pressure value
  129828. */
  129829. getBodyPressure(impostor: PhysicsImpostor): number;
  129830. /**
  129831. * Sets pressure inside a soft body impostor
  129832. * Cloth and rope must remain 0 pressure
  129833. * @param impostor impostor to set pressure on
  129834. * @param pressure pressure value
  129835. */
  129836. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  129837. /**
  129838. * Gets stiffness of the impostor
  129839. * @param impostor impostor to get stiffness from
  129840. * @returns pressure value
  129841. */
  129842. getBodyStiffness(impostor: PhysicsImpostor): number;
  129843. /**
  129844. * Sets stiffness of the impostor
  129845. * @param impostor impostor to set stiffness on
  129846. * @param stiffness stiffness value from 0 to 1
  129847. */
  129848. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  129849. /**
  129850. * Gets velocityIterations of the impostor
  129851. * @param impostor impostor to get velocity iterations from
  129852. * @returns velocityIterations value
  129853. */
  129854. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  129855. /**
  129856. * Sets velocityIterations of the impostor
  129857. * @param impostor impostor to set velocity iterations on
  129858. * @param velocityIterations velocityIterations value
  129859. */
  129860. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  129861. /**
  129862. * Gets positionIterations of the impostor
  129863. * @param impostor impostor to get position iterations from
  129864. * @returns positionIterations value
  129865. */
  129866. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  129867. /**
  129868. * Sets positionIterations of the impostor
  129869. * @param impostor impostor to set position on
  129870. * @param positionIterations positionIterations value
  129871. */
  129872. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  129873. /**
  129874. * Append an anchor to a cloth object
  129875. * @param impostor is the cloth impostor to add anchor to
  129876. * @param otherImpostor is the rigid impostor to anchor to
  129877. * @param width ratio across width from 0 to 1
  129878. * @param height ratio up height from 0 to 1
  129879. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  129880. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  129881. */
  129882. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  129883. /**
  129884. * Append an hook to a rope object
  129885. * @param impostor is the rope impostor to add hook to
  129886. * @param otherImpostor is the rigid impostor to hook to
  129887. * @param length ratio along the rope from 0 to 1
  129888. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  129889. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  129890. */
  129891. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  129892. /**
  129893. * Sleeps the physics body and stops it from being active
  129894. * @param impostor impostor to sleep
  129895. */
  129896. sleepBody(impostor: PhysicsImpostor): void;
  129897. /**
  129898. * Activates the physics body
  129899. * @param impostor impostor to activate
  129900. */
  129901. wakeUpBody(impostor: PhysicsImpostor): void;
  129902. /**
  129903. * Updates the distance parameters of the joint
  129904. * @param joint joint to update
  129905. * @param maxDistance maximum distance of the joint
  129906. * @param minDistance minimum distance of the joint
  129907. */
  129908. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129909. /**
  129910. * Sets a motor on the joint
  129911. * @param joint joint to set motor on
  129912. * @param speed speed of the motor
  129913. * @param maxForce maximum force of the motor
  129914. * @param motorIndex index of the motor
  129915. */
  129916. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129917. /**
  129918. * Sets the motors limit
  129919. * @param joint joint to set limit on
  129920. * @param upperLimit upper limit
  129921. * @param lowerLimit lower limit
  129922. */
  129923. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129924. /**
  129925. * Syncs the position and rotation of a mesh with the impostor
  129926. * @param mesh mesh to sync
  129927. * @param impostor impostor to update the mesh with
  129928. */
  129929. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129930. /**
  129931. * Gets the radius of the impostor
  129932. * @param impostor impostor to get radius from
  129933. * @returns the radius
  129934. */
  129935. getRadius(impostor: PhysicsImpostor): number;
  129936. /**
  129937. * Gets the box size of the impostor
  129938. * @param impostor impostor to get box size from
  129939. * @param result the resulting box size
  129940. */
  129941. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129942. /**
  129943. * Disposes of the impostor
  129944. */
  129945. dispose(): void;
  129946. /**
  129947. * Does a raycast in the physics world
  129948. * @param from when should the ray start?
  129949. * @param to when should the ray end?
  129950. * @returns PhysicsRaycastResult
  129951. */
  129952. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129953. }
  129954. }
  129955. declare module BABYLON {
  129956. interface AbstractScene {
  129957. /**
  129958. * The list of reflection probes added to the scene
  129959. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129960. */
  129961. reflectionProbes: Array<ReflectionProbe>;
  129962. /**
  129963. * Removes the given reflection probe from this scene.
  129964. * @param toRemove The reflection probe to remove
  129965. * @returns The index of the removed reflection probe
  129966. */
  129967. removeReflectionProbe(toRemove: ReflectionProbe): number;
  129968. /**
  129969. * Adds the given reflection probe to this scene.
  129970. * @param newReflectionProbe The reflection probe to add
  129971. */
  129972. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  129973. }
  129974. /**
  129975. * Class used to generate realtime reflection / refraction cube textures
  129976. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  129977. */
  129978. export class ReflectionProbe {
  129979. /** defines the name of the probe */
  129980. name: string;
  129981. private _scene;
  129982. private _renderTargetTexture;
  129983. private _projectionMatrix;
  129984. private _viewMatrix;
  129985. private _target;
  129986. private _add;
  129987. private _attachedMesh;
  129988. private _invertYAxis;
  129989. /** Gets or sets probe position (center of the cube map) */
  129990. position: Vector3;
  129991. /**
  129992. * Creates a new reflection probe
  129993. * @param name defines the name of the probe
  129994. * @param size defines the texture resolution (for each face)
  129995. * @param scene defines the hosting scene
  129996. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  129997. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  129998. */
  129999. constructor(
  130000. /** defines the name of the probe */
  130001. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  130002. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  130003. get samples(): number;
  130004. set samples(value: number);
  130005. /** Gets or sets the refresh rate to use (on every frame by default) */
  130006. get refreshRate(): number;
  130007. set refreshRate(value: number);
  130008. /**
  130009. * Gets the hosting scene
  130010. * @returns a Scene
  130011. */
  130012. getScene(): Scene;
  130013. /** Gets the internal CubeTexture used to render to */
  130014. get cubeTexture(): RenderTargetTexture;
  130015. /** Gets the list of meshes to render */
  130016. get renderList(): Nullable<AbstractMesh[]>;
  130017. /**
  130018. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  130019. * @param mesh defines the mesh to attach to
  130020. */
  130021. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130022. /**
  130023. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  130024. * @param renderingGroupId The rendering group id corresponding to its index
  130025. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  130026. */
  130027. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  130028. /**
  130029. * Clean all associated resources
  130030. */
  130031. dispose(): void;
  130032. /**
  130033. * Converts the reflection probe information to a readable string for debug purpose.
  130034. * @param fullDetails Supports for multiple levels of logging within scene loading
  130035. * @returns the human readable reflection probe info
  130036. */
  130037. toString(fullDetails?: boolean): string;
  130038. /**
  130039. * Get the class name of the relfection probe.
  130040. * @returns "ReflectionProbe"
  130041. */
  130042. getClassName(): string;
  130043. /**
  130044. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  130045. * @returns The JSON representation of the texture
  130046. */
  130047. serialize(): any;
  130048. /**
  130049. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  130050. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  130051. * @param scene Define the scene the parsed reflection probe should be instantiated in
  130052. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  130053. * @returns The parsed reflection probe if successful
  130054. */
  130055. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  130056. }
  130057. }
  130058. declare module BABYLON {
  130059. /** @hidden */
  130060. export var _BabylonLoaderRegistered: boolean;
  130061. /**
  130062. * Helps setting up some configuration for the babylon file loader.
  130063. */
  130064. export class BabylonFileLoaderConfiguration {
  130065. /**
  130066. * The loader does not allow injecting custom physix engine into the plugins.
  130067. * Unfortunately in ES6, we need to manually inject them into the plugin.
  130068. * So you could set this variable to your engine import to make it work.
  130069. */
  130070. static LoaderInjectedPhysicsEngine: any;
  130071. }
  130072. }
  130073. declare module BABYLON {
  130074. /**
  130075. * The Physically based simple base material of BJS.
  130076. *
  130077. * This enables better naming and convention enforcements on top of the pbrMaterial.
  130078. * It is used as the base class for both the specGloss and metalRough conventions.
  130079. */
  130080. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  130081. /**
  130082. * Number of Simultaneous lights allowed on the material.
  130083. */
  130084. maxSimultaneousLights: number;
  130085. /**
  130086. * If sets to true, disables all the lights affecting the material.
  130087. */
  130088. disableLighting: boolean;
  130089. /**
  130090. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  130091. */
  130092. environmentTexture: BaseTexture;
  130093. /**
  130094. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  130095. */
  130096. invertNormalMapX: boolean;
  130097. /**
  130098. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  130099. */
  130100. invertNormalMapY: boolean;
  130101. /**
  130102. * Normal map used in the model.
  130103. */
  130104. normalTexture: BaseTexture;
  130105. /**
  130106. * Emissivie color used to self-illuminate the model.
  130107. */
  130108. emissiveColor: Color3;
  130109. /**
  130110. * Emissivie texture used to self-illuminate the model.
  130111. */
  130112. emissiveTexture: BaseTexture;
  130113. /**
  130114. * Occlusion Channel Strenght.
  130115. */
  130116. occlusionStrength: number;
  130117. /**
  130118. * Occlusion Texture of the material (adding extra occlusion effects).
  130119. */
  130120. occlusionTexture: BaseTexture;
  130121. /**
  130122. * Defines the alpha limits in alpha test mode.
  130123. */
  130124. alphaCutOff: number;
  130125. /**
  130126. * Gets the current double sided mode.
  130127. */
  130128. get doubleSided(): boolean;
  130129. /**
  130130. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  130131. */
  130132. set doubleSided(value: boolean);
  130133. /**
  130134. * Stores the pre-calculated light information of a mesh in a texture.
  130135. */
  130136. lightmapTexture: BaseTexture;
  130137. /**
  130138. * If true, the light map contains occlusion information instead of lighting info.
  130139. */
  130140. useLightmapAsShadowmap: boolean;
  130141. /**
  130142. * Instantiates a new PBRMaterial instance.
  130143. *
  130144. * @param name The material name
  130145. * @param scene The scene the material will be use in.
  130146. */
  130147. constructor(name: string, scene: Scene);
  130148. getClassName(): string;
  130149. }
  130150. }
  130151. declare module BABYLON {
  130152. /**
  130153. * The PBR material of BJS following the metal roughness convention.
  130154. *
  130155. * This fits to the PBR convention in the GLTF definition:
  130156. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  130157. */
  130158. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  130159. /**
  130160. * The base color has two different interpretations depending on the value of metalness.
  130161. * When the material is a metal, the base color is the specific measured reflectance value
  130162. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  130163. * of the material.
  130164. */
  130165. baseColor: Color3;
  130166. /**
  130167. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  130168. * well as opacity information in the alpha channel.
  130169. */
  130170. baseTexture: BaseTexture;
  130171. /**
  130172. * Specifies the metallic scalar value of the material.
  130173. * Can also be used to scale the metalness values of the metallic texture.
  130174. */
  130175. metallic: number;
  130176. /**
  130177. * Specifies the roughness scalar value of the material.
  130178. * Can also be used to scale the roughness values of the metallic texture.
  130179. */
  130180. roughness: number;
  130181. /**
  130182. * Texture containing both the metallic value in the B channel and the
  130183. * roughness value in the G channel to keep better precision.
  130184. */
  130185. metallicRoughnessTexture: BaseTexture;
  130186. /**
  130187. * Instantiates a new PBRMetalRoughnessMaterial instance.
  130188. *
  130189. * @param name The material name
  130190. * @param scene The scene the material will be use in.
  130191. */
  130192. constructor(name: string, scene: Scene);
  130193. /**
  130194. * Return the currrent class name of the material.
  130195. */
  130196. getClassName(): string;
  130197. /**
  130198. * Makes a duplicate of the current material.
  130199. * @param name - name to use for the new material.
  130200. */
  130201. clone(name: string): PBRMetallicRoughnessMaterial;
  130202. /**
  130203. * Serialize the material to a parsable JSON object.
  130204. */
  130205. serialize(): any;
  130206. /**
  130207. * Parses a JSON object correponding to the serialize function.
  130208. */
  130209. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  130210. }
  130211. }
  130212. declare module BABYLON {
  130213. /**
  130214. * The PBR material of BJS following the specular glossiness convention.
  130215. *
  130216. * This fits to the PBR convention in the GLTF definition:
  130217. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  130218. */
  130219. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  130220. /**
  130221. * Specifies the diffuse color of the material.
  130222. */
  130223. diffuseColor: Color3;
  130224. /**
  130225. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  130226. * channel.
  130227. */
  130228. diffuseTexture: BaseTexture;
  130229. /**
  130230. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  130231. */
  130232. specularColor: Color3;
  130233. /**
  130234. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  130235. */
  130236. glossiness: number;
  130237. /**
  130238. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  130239. */
  130240. specularGlossinessTexture: BaseTexture;
  130241. /**
  130242. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  130243. *
  130244. * @param name The material name
  130245. * @param scene The scene the material will be use in.
  130246. */
  130247. constructor(name: string, scene: Scene);
  130248. /**
  130249. * Return the currrent class name of the material.
  130250. */
  130251. getClassName(): string;
  130252. /**
  130253. * Makes a duplicate of the current material.
  130254. * @param name - name to use for the new material.
  130255. */
  130256. clone(name: string): PBRSpecularGlossinessMaterial;
  130257. /**
  130258. * Serialize the material to a parsable JSON object.
  130259. */
  130260. serialize(): any;
  130261. /**
  130262. * Parses a JSON object correponding to the serialize function.
  130263. */
  130264. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  130265. }
  130266. }
  130267. declare module BABYLON {
  130268. /**
  130269. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  130270. * It can help converting any input color in a desired output one. This can then be used to create effects
  130271. * from sepia, black and white to sixties or futuristic rendering...
  130272. *
  130273. * The only supported format is currently 3dl.
  130274. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  130275. */
  130276. export class ColorGradingTexture extends BaseTexture {
  130277. /**
  130278. * The current texture matrix. (will always be identity in color grading texture)
  130279. */
  130280. private _textureMatrix;
  130281. /**
  130282. * The texture URL.
  130283. */
  130284. url: string;
  130285. /**
  130286. * Empty line regex stored for GC.
  130287. */
  130288. private static _noneEmptyLineRegex;
  130289. private _engine;
  130290. /**
  130291. * Instantiates a ColorGradingTexture from the following parameters.
  130292. *
  130293. * @param url The location of the color gradind data (currently only supporting 3dl)
  130294. * @param scene The scene the texture will be used in
  130295. */
  130296. constructor(url: string, scene: Scene);
  130297. /**
  130298. * Returns the texture matrix used in most of the material.
  130299. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  130300. */
  130301. getTextureMatrix(): Matrix;
  130302. /**
  130303. * Occurs when the file being loaded is a .3dl LUT file.
  130304. */
  130305. private load3dlTexture;
  130306. /**
  130307. * Starts the loading process of the texture.
  130308. */
  130309. private loadTexture;
  130310. /**
  130311. * Clones the color gradind texture.
  130312. */
  130313. clone(): ColorGradingTexture;
  130314. /**
  130315. * Called during delayed load for textures.
  130316. */
  130317. delayLoad(): void;
  130318. /**
  130319. * Parses a color grading texture serialized by Babylon.
  130320. * @param parsedTexture The texture information being parsedTexture
  130321. * @param scene The scene to load the texture in
  130322. * @param rootUrl The root url of the data assets to load
  130323. * @return A color gradind texture
  130324. */
  130325. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  130326. /**
  130327. * Serializes the LUT texture to json format.
  130328. */
  130329. serialize(): any;
  130330. }
  130331. }
  130332. declare module BABYLON {
  130333. /**
  130334. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  130335. */
  130336. export class EquiRectangularCubeTexture extends BaseTexture {
  130337. /** The six faces of the cube. */
  130338. private static _FacesMapping;
  130339. private _noMipmap;
  130340. private _onLoad;
  130341. private _onError;
  130342. /** The size of the cubemap. */
  130343. private _size;
  130344. /** The buffer of the image. */
  130345. private _buffer;
  130346. /** The width of the input image. */
  130347. private _width;
  130348. /** The height of the input image. */
  130349. private _height;
  130350. /** The URL to the image. */
  130351. url: string;
  130352. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  130353. coordinatesMode: number;
  130354. /**
  130355. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  130356. * @param url The location of the image
  130357. * @param scene The scene the texture will be used in
  130358. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  130359. * @param noMipmap Forces to not generate the mipmap if true
  130360. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130361. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130362. * @param onLoad — defines a callback called when texture is loaded
  130363. * @param onError — defines a callback called if there is an error
  130364. */
  130365. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  130366. /**
  130367. * Load the image data, by putting the image on a canvas and extracting its buffer.
  130368. */
  130369. private loadImage;
  130370. /**
  130371. * Convert the image buffer into a cubemap and create a CubeTexture.
  130372. */
  130373. private loadTexture;
  130374. /**
  130375. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  130376. * @param buffer The ArrayBuffer that should be converted.
  130377. * @returns The buffer as Float32Array.
  130378. */
  130379. private getFloat32ArrayFromArrayBuffer;
  130380. /**
  130381. * Get the current class name of the texture useful for serialization or dynamic coding.
  130382. * @returns "EquiRectangularCubeTexture"
  130383. */
  130384. getClassName(): string;
  130385. /**
  130386. * Create a clone of the current EquiRectangularCubeTexture and return it.
  130387. * @returns A clone of the current EquiRectangularCubeTexture.
  130388. */
  130389. clone(): EquiRectangularCubeTexture;
  130390. }
  130391. }
  130392. declare module BABYLON {
  130393. /**
  130394. * Based on jsTGALoader - Javascript loader for TGA file
  130395. * By Vincent Thibault
  130396. * @see http://blog.robrowser.com/javascript-tga-loader.html
  130397. */
  130398. export class TGATools {
  130399. private static _TYPE_INDEXED;
  130400. private static _TYPE_RGB;
  130401. private static _TYPE_GREY;
  130402. private static _TYPE_RLE_INDEXED;
  130403. private static _TYPE_RLE_RGB;
  130404. private static _TYPE_RLE_GREY;
  130405. private static _ORIGIN_MASK;
  130406. private static _ORIGIN_SHIFT;
  130407. private static _ORIGIN_BL;
  130408. private static _ORIGIN_BR;
  130409. private static _ORIGIN_UL;
  130410. private static _ORIGIN_UR;
  130411. /**
  130412. * Gets the header of a TGA file
  130413. * @param data defines the TGA data
  130414. * @returns the header
  130415. */
  130416. static GetTGAHeader(data: Uint8Array): any;
  130417. /**
  130418. * Uploads TGA content to a Babylon Texture
  130419. * @hidden
  130420. */
  130421. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  130422. /** @hidden */
  130423. 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;
  130424. /** @hidden */
  130425. 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;
  130426. /** @hidden */
  130427. 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;
  130428. /** @hidden */
  130429. 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;
  130430. /** @hidden */
  130431. 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;
  130432. /** @hidden */
  130433. 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;
  130434. }
  130435. }
  130436. declare module BABYLON {
  130437. /**
  130438. * Implementation of the TGA Texture Loader.
  130439. * @hidden
  130440. */
  130441. export class _TGATextureLoader implements IInternalTextureLoader {
  130442. /**
  130443. * Defines wether the loader supports cascade loading the different faces.
  130444. */
  130445. readonly supportCascades: boolean;
  130446. /**
  130447. * This returns if the loader support the current file information.
  130448. * @param extension defines the file extension of the file being loaded
  130449. * @returns true if the loader can load the specified file
  130450. */
  130451. canLoad(extension: string): boolean;
  130452. /**
  130453. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130454. * @param data contains the texture data
  130455. * @param texture defines the BabylonJS internal texture
  130456. * @param createPolynomials will be true if polynomials have been requested
  130457. * @param onLoad defines the callback to trigger once the texture is ready
  130458. * @param onError defines the callback to trigger in case of error
  130459. */
  130460. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130461. /**
  130462. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130463. * @param data contains the texture data
  130464. * @param texture defines the BabylonJS internal texture
  130465. * @param callback defines the method to call once ready to upload
  130466. */
  130467. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130468. }
  130469. }
  130470. declare module BABYLON {
  130471. /**
  130472. * Info about the .basis files
  130473. */
  130474. class BasisFileInfo {
  130475. /**
  130476. * If the file has alpha
  130477. */
  130478. hasAlpha: boolean;
  130479. /**
  130480. * Info about each image of the basis file
  130481. */
  130482. images: Array<{
  130483. levels: Array<{
  130484. width: number;
  130485. height: number;
  130486. transcodedPixels: ArrayBufferView;
  130487. }>;
  130488. }>;
  130489. }
  130490. /**
  130491. * Result of transcoding a basis file
  130492. */
  130493. class TranscodeResult {
  130494. /**
  130495. * Info about the .basis file
  130496. */
  130497. fileInfo: BasisFileInfo;
  130498. /**
  130499. * Format to use when loading the file
  130500. */
  130501. format: number;
  130502. }
  130503. /**
  130504. * Configuration options for the Basis transcoder
  130505. */
  130506. export class BasisTranscodeConfiguration {
  130507. /**
  130508. * Supported compression formats used to determine the supported output format of the transcoder
  130509. */
  130510. supportedCompressionFormats?: {
  130511. /**
  130512. * etc1 compression format
  130513. */
  130514. etc1?: boolean;
  130515. /**
  130516. * s3tc compression format
  130517. */
  130518. s3tc?: boolean;
  130519. /**
  130520. * pvrtc compression format
  130521. */
  130522. pvrtc?: boolean;
  130523. /**
  130524. * etc2 compression format
  130525. */
  130526. etc2?: boolean;
  130527. };
  130528. /**
  130529. * If mipmap levels should be loaded for transcoded images (Default: true)
  130530. */
  130531. loadMipmapLevels?: boolean;
  130532. /**
  130533. * Index of a single image to load (Default: all images)
  130534. */
  130535. loadSingleImage?: number;
  130536. }
  130537. /**
  130538. * Used to load .Basis files
  130539. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  130540. */
  130541. export class BasisTools {
  130542. private static _IgnoreSupportedFormats;
  130543. /**
  130544. * URL to use when loading the basis transcoder
  130545. */
  130546. static JSModuleURL: string;
  130547. /**
  130548. * URL to use when loading the wasm module for the transcoder
  130549. */
  130550. static WasmModuleURL: string;
  130551. /**
  130552. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  130553. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  130554. * @returns internal format corresponding to the Basis format
  130555. */
  130556. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  130557. private static _WorkerPromise;
  130558. private static _Worker;
  130559. private static _actionId;
  130560. private static _CreateWorkerAsync;
  130561. /**
  130562. * Transcodes a loaded image file to compressed pixel data
  130563. * @param data image data to transcode
  130564. * @param config configuration options for the transcoding
  130565. * @returns a promise resulting in the transcoded image
  130566. */
  130567. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  130568. /**
  130569. * Loads a texture from the transcode result
  130570. * @param texture texture load to
  130571. * @param transcodeResult the result of transcoding the basis file to load from
  130572. */
  130573. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  130574. }
  130575. }
  130576. declare module BABYLON {
  130577. /**
  130578. * Loader for .basis file format
  130579. */
  130580. export class _BasisTextureLoader implements IInternalTextureLoader {
  130581. /**
  130582. * Defines whether the loader supports cascade loading the different faces.
  130583. */
  130584. readonly supportCascades: boolean;
  130585. /**
  130586. * This returns if the loader support the current file information.
  130587. * @param extension defines the file extension of the file being loaded
  130588. * @returns true if the loader can load the specified file
  130589. */
  130590. canLoad(extension: string): boolean;
  130591. /**
  130592. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130593. * @param data contains the texture data
  130594. * @param texture defines the BabylonJS internal texture
  130595. * @param createPolynomials will be true if polynomials have been requested
  130596. * @param onLoad defines the callback to trigger once the texture is ready
  130597. * @param onError defines the callback to trigger in case of error
  130598. */
  130599. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130600. /**
  130601. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130602. * @param data contains the texture data
  130603. * @param texture defines the BabylonJS internal texture
  130604. * @param callback defines the method to call once ready to upload
  130605. */
  130606. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130607. }
  130608. }
  130609. declare module BABYLON {
  130610. /**
  130611. * 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.
  130612. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130613. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130614. */
  130615. export class CustomProceduralTexture extends ProceduralTexture {
  130616. private _animate;
  130617. private _time;
  130618. private _config;
  130619. private _texturePath;
  130620. /**
  130621. * Instantiates a new Custom Procedural Texture.
  130622. * 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.
  130623. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130624. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130625. * @param name Define the name of the texture
  130626. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  130627. * @param size Define the size of the texture to create
  130628. * @param scene Define the scene the texture belongs to
  130629. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  130630. * @param generateMipMaps Define if the texture should creates mip maps or not
  130631. */
  130632. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  130633. private _loadJson;
  130634. /**
  130635. * Is the texture ready to be used ? (rendered at least once)
  130636. * @returns true if ready, otherwise, false.
  130637. */
  130638. isReady(): boolean;
  130639. /**
  130640. * Render the texture to its associated render target.
  130641. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  130642. */
  130643. render(useCameraPostProcess?: boolean): void;
  130644. /**
  130645. * Update the list of dependant textures samplers in the shader.
  130646. */
  130647. updateTextures(): void;
  130648. /**
  130649. * Update the uniform values of the procedural texture in the shader.
  130650. */
  130651. updateShaderUniforms(): void;
  130652. /**
  130653. * Define if the texture animates or not.
  130654. */
  130655. get animate(): boolean;
  130656. set animate(value: boolean);
  130657. }
  130658. }
  130659. declare module BABYLON {
  130660. /** @hidden */
  130661. export var noisePixelShader: {
  130662. name: string;
  130663. shader: string;
  130664. };
  130665. }
  130666. declare module BABYLON {
  130667. /**
  130668. * Class used to generate noise procedural textures
  130669. */
  130670. export class NoiseProceduralTexture extends ProceduralTexture {
  130671. private _time;
  130672. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  130673. brightness: number;
  130674. /** Defines the number of octaves to process */
  130675. octaves: number;
  130676. /** Defines the level of persistence (0.8 by default) */
  130677. persistence: number;
  130678. /** Gets or sets animation speed factor (default is 1) */
  130679. animationSpeedFactor: number;
  130680. /**
  130681. * Creates a new NoiseProceduralTexture
  130682. * @param name defines the name fo the texture
  130683. * @param size defines the size of the texture (default is 256)
  130684. * @param scene defines the hosting scene
  130685. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  130686. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  130687. */
  130688. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  130689. private _updateShaderUniforms;
  130690. protected _getDefines(): string;
  130691. /** Generate the current state of the procedural texture */
  130692. render(useCameraPostProcess?: boolean): void;
  130693. /**
  130694. * Serializes this noise procedural texture
  130695. * @returns a serialized noise procedural texture object
  130696. */
  130697. serialize(): any;
  130698. /**
  130699. * Clone the texture.
  130700. * @returns the cloned texture
  130701. */
  130702. clone(): NoiseProceduralTexture;
  130703. /**
  130704. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  130705. * @param parsedTexture defines parsed texture data
  130706. * @param scene defines the current scene
  130707. * @param rootUrl defines the root URL containing noise procedural texture information
  130708. * @returns a parsed NoiseProceduralTexture
  130709. */
  130710. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  130711. }
  130712. }
  130713. declare module BABYLON {
  130714. /**
  130715. * Raw cube texture where the raw buffers are passed in
  130716. */
  130717. export class RawCubeTexture extends CubeTexture {
  130718. /**
  130719. * Creates a cube texture where the raw buffers are passed in.
  130720. * @param scene defines the scene the texture is attached to
  130721. * @param data defines the array of data to use to create each face
  130722. * @param size defines the size of the textures
  130723. * @param format defines the format of the data
  130724. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  130725. * @param generateMipMaps defines if the engine should generate the mip levels
  130726. * @param invertY defines if data must be stored with Y axis inverted
  130727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  130728. * @param compression defines the compression used (null by default)
  130729. */
  130730. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  130731. /**
  130732. * Updates the raw cube texture.
  130733. * @param data defines the data to store
  130734. * @param format defines the data format
  130735. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130736. * @param invertY defines if data must be stored with Y axis inverted
  130737. * @param compression defines the compression used (null by default)
  130738. * @param level defines which level of the texture to update
  130739. */
  130740. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  130741. /**
  130742. * Updates a raw cube texture with RGBD encoded data.
  130743. * @param data defines the array of data [mipmap][face] to use to create each face
  130744. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  130745. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130746. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130747. * @returns a promsie that resolves when the operation is complete
  130748. */
  130749. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  130750. /**
  130751. * Clones the raw cube texture.
  130752. * @return a new cube texture
  130753. */
  130754. clone(): CubeTexture;
  130755. /** @hidden */
  130756. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  130757. }
  130758. }
  130759. declare module BABYLON {
  130760. /**
  130761. * Class used to store 3D textures containing user data
  130762. */
  130763. export class RawTexture3D extends Texture {
  130764. /** Gets or sets the texture format to use */
  130765. format: number;
  130766. private _engine;
  130767. /**
  130768. * Create a new RawTexture3D
  130769. * @param data defines the data of the texture
  130770. * @param width defines the width of the texture
  130771. * @param height defines the height of the texture
  130772. * @param depth defines the depth of the texture
  130773. * @param format defines the texture format to use
  130774. * @param scene defines the hosting scene
  130775. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  130776. * @param invertY defines if texture must be stored with Y axis inverted
  130777. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130778. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130779. */
  130780. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  130781. /** Gets or sets the texture format to use */
  130782. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  130783. /**
  130784. * Update the texture with new data
  130785. * @param data defines the data to store in the texture
  130786. */
  130787. update(data: ArrayBufferView): void;
  130788. }
  130789. }
  130790. declare module BABYLON {
  130791. /**
  130792. * Class used to store 2D array textures containing user data
  130793. */
  130794. export class RawTexture2DArray extends Texture {
  130795. /** Gets or sets the texture format to use */
  130796. format: number;
  130797. private _engine;
  130798. /**
  130799. * Create a new RawTexture2DArray
  130800. * @param data defines the data of the texture
  130801. * @param width defines the width of the texture
  130802. * @param height defines the height of the texture
  130803. * @param depth defines the number of layers of the texture
  130804. * @param format defines the texture format to use
  130805. * @param scene defines the hosting scene
  130806. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  130807. * @param invertY defines if texture must be stored with Y axis inverted
  130808. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  130809. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  130810. */
  130811. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  130812. /** Gets or sets the texture format to use */
  130813. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  130814. /**
  130815. * Update the texture with new data
  130816. * @param data defines the data to store in the texture
  130817. */
  130818. update(data: ArrayBufferView): void;
  130819. }
  130820. }
  130821. declare module BABYLON {
  130822. /**
  130823. * Creates a refraction texture used by refraction channel of the standard material.
  130824. * It is like a mirror but to see through a material.
  130825. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130826. */
  130827. export class RefractionTexture extends RenderTargetTexture {
  130828. /**
  130829. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  130830. * 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.
  130831. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130832. */
  130833. refractionPlane: Plane;
  130834. /**
  130835. * Define how deep under the surface we should see.
  130836. */
  130837. depth: number;
  130838. /**
  130839. * Creates a refraction texture used by refraction channel of the standard material.
  130840. * It is like a mirror but to see through a material.
  130841. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  130842. * @param name Define the texture name
  130843. * @param size Define the size of the underlying texture
  130844. * @param scene Define the scene the refraction belongs to
  130845. * @param generateMipMaps Define if we need to generate mips level for the refraction
  130846. */
  130847. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  130848. /**
  130849. * Clone the refraction texture.
  130850. * @returns the cloned texture
  130851. */
  130852. clone(): RefractionTexture;
  130853. /**
  130854. * Serialize the texture to a JSON representation you could use in Parse later on
  130855. * @returns the serialized JSON representation
  130856. */
  130857. serialize(): any;
  130858. }
  130859. }
  130860. declare module BABYLON {
  130861. /**
  130862. * Defines the options related to the creation of an HtmlElementTexture
  130863. */
  130864. export interface IHtmlElementTextureOptions {
  130865. /**
  130866. * Defines wether mip maps should be created or not.
  130867. */
  130868. generateMipMaps?: boolean;
  130869. /**
  130870. * Defines the sampling mode of the texture.
  130871. */
  130872. samplingMode?: number;
  130873. /**
  130874. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  130875. */
  130876. engine: Nullable<ThinEngine>;
  130877. /**
  130878. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  130879. */
  130880. scene: Nullable<Scene>;
  130881. }
  130882. /**
  130883. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  130884. * To be as efficient as possible depending on your constraints nothing aside the first upload
  130885. * is automatically managed.
  130886. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  130887. * in your application.
  130888. *
  130889. * As the update is not automatic, you need to call them manually.
  130890. */
  130891. export class HtmlElementTexture extends BaseTexture {
  130892. /**
  130893. * The texture URL.
  130894. */
  130895. element: HTMLVideoElement | HTMLCanvasElement;
  130896. private static readonly DefaultOptions;
  130897. private _textureMatrix;
  130898. private _engine;
  130899. private _isVideo;
  130900. private _generateMipMaps;
  130901. private _samplingMode;
  130902. /**
  130903. * Instantiates a HtmlElementTexture from the following parameters.
  130904. *
  130905. * @param name Defines the name of the texture
  130906. * @param element Defines the video or canvas the texture is filled with
  130907. * @param options Defines the other none mandatory texture creation options
  130908. */
  130909. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  130910. private _createInternalTexture;
  130911. /**
  130912. * Returns the texture matrix used in most of the material.
  130913. */
  130914. getTextureMatrix(): Matrix;
  130915. /**
  130916. * Updates the content of the texture.
  130917. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  130918. */
  130919. update(invertY?: Nullable<boolean>): void;
  130920. }
  130921. }
  130922. declare module BABYLON {
  130923. /**
  130924. * Defines the basic options interface of a TexturePacker Frame
  130925. */
  130926. export interface ITexturePackerFrame {
  130927. /**
  130928. * The frame ID
  130929. */
  130930. id: number;
  130931. /**
  130932. * The frames Scale
  130933. */
  130934. scale: Vector2;
  130935. /**
  130936. * The Frames offset
  130937. */
  130938. offset: Vector2;
  130939. }
  130940. /**
  130941. * This is a support class for frame Data on texture packer sets.
  130942. */
  130943. export class TexturePackerFrame implements ITexturePackerFrame {
  130944. /**
  130945. * The frame ID
  130946. */
  130947. id: number;
  130948. /**
  130949. * The frames Scale
  130950. */
  130951. scale: Vector2;
  130952. /**
  130953. * The Frames offset
  130954. */
  130955. offset: Vector2;
  130956. /**
  130957. * Initializes a texture package frame.
  130958. * @param id The numerical frame identifier
  130959. * @param scale Scalar Vector2 for UV frame
  130960. * @param offset Vector2 for the frame position in UV units.
  130961. * @returns TexturePackerFrame
  130962. */
  130963. constructor(id: number, scale: Vector2, offset: Vector2);
  130964. }
  130965. }
  130966. declare module BABYLON {
  130967. /**
  130968. * Defines the basic options interface of a TexturePacker
  130969. */
  130970. export interface ITexturePackerOptions {
  130971. /**
  130972. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  130973. */
  130974. map?: string[];
  130975. /**
  130976. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130977. */
  130978. uvsIn?: string;
  130979. /**
  130980. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  130981. */
  130982. uvsOut?: string;
  130983. /**
  130984. * number representing the layout style. Defaults to LAYOUT_STRIP
  130985. */
  130986. layout?: number;
  130987. /**
  130988. * number of columns if using custom column count layout(2). This defaults to 4.
  130989. */
  130990. colnum?: number;
  130991. /**
  130992. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  130993. */
  130994. updateInputMeshes?: boolean;
  130995. /**
  130996. * boolean flag to dispose all the source textures. Defaults to true.
  130997. */
  130998. disposeSources?: boolean;
  130999. /**
  131000. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  131001. */
  131002. fillBlanks?: boolean;
  131003. /**
  131004. * string value representing the context fill style color. Defaults to 'black'.
  131005. */
  131006. customFillColor?: string;
  131007. /**
  131008. * Width and Height Value of each Frame in the TexturePacker Sets
  131009. */
  131010. frameSize?: number;
  131011. /**
  131012. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  131013. */
  131014. paddingRatio?: number;
  131015. /**
  131016. * Number that declares the fill method for the padding gutter.
  131017. */
  131018. paddingMode?: number;
  131019. /**
  131020. * If in SUBUV_COLOR padding mode what color to use.
  131021. */
  131022. paddingColor?: Color3 | Color4;
  131023. }
  131024. /**
  131025. * Defines the basic interface of a TexturePacker JSON File
  131026. */
  131027. export interface ITexturePackerJSON {
  131028. /**
  131029. * The frame ID
  131030. */
  131031. name: string;
  131032. /**
  131033. * The base64 channel data
  131034. */
  131035. sets: any;
  131036. /**
  131037. * The options of the Packer
  131038. */
  131039. options: ITexturePackerOptions;
  131040. /**
  131041. * The frame data of the Packer
  131042. */
  131043. frames: Array<number>;
  131044. }
  131045. /**
  131046. * This is a support class that generates a series of packed texture sets.
  131047. * @see https://doc.babylonjs.com/babylon101/materials
  131048. */
  131049. export class TexturePacker {
  131050. /** Packer Layout Constant 0 */
  131051. static readonly LAYOUT_STRIP: number;
  131052. /** Packer Layout Constant 1 */
  131053. static readonly LAYOUT_POWER2: number;
  131054. /** Packer Layout Constant 2 */
  131055. static readonly LAYOUT_COLNUM: number;
  131056. /** Packer Layout Constant 0 */
  131057. static readonly SUBUV_WRAP: number;
  131058. /** Packer Layout Constant 1 */
  131059. static readonly SUBUV_EXTEND: number;
  131060. /** Packer Layout Constant 2 */
  131061. static readonly SUBUV_COLOR: number;
  131062. /** The Name of the Texture Package */
  131063. name: string;
  131064. /** The scene scope of the TexturePacker */
  131065. scene: Scene;
  131066. /** The Meshes to target */
  131067. meshes: AbstractMesh[];
  131068. /** Arguments passed with the Constructor */
  131069. options: ITexturePackerOptions;
  131070. /** The promise that is started upon initialization */
  131071. promise: Nullable<Promise<TexturePacker | string>>;
  131072. /** The Container object for the channel sets that are generated */
  131073. sets: object;
  131074. /** The Container array for the frames that are generated */
  131075. frames: TexturePackerFrame[];
  131076. /** The expected number of textures the system is parsing. */
  131077. private _expecting;
  131078. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  131079. private _paddingValue;
  131080. /**
  131081. * Initializes a texture package series from an array of meshes or a single mesh.
  131082. * @param name The name of the package
  131083. * @param meshes The target meshes to compose the package from
  131084. * @param options The arguments that texture packer should follow while building.
  131085. * @param scene The scene which the textures are scoped to.
  131086. * @returns TexturePacker
  131087. */
  131088. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  131089. /**
  131090. * Starts the package process
  131091. * @param resolve The promises resolution function
  131092. * @returns TexturePacker
  131093. */
  131094. private _createFrames;
  131095. /**
  131096. * Calculates the Size of the Channel Sets
  131097. * @returns Vector2
  131098. */
  131099. private _calculateSize;
  131100. /**
  131101. * Calculates the UV data for the frames.
  131102. * @param baseSize the base frameSize
  131103. * @param padding the base frame padding
  131104. * @param dtSize size of the Dynamic Texture for that channel
  131105. * @param dtUnits is 1/dtSize
  131106. * @param update flag to update the input meshes
  131107. */
  131108. private _calculateMeshUVFrames;
  131109. /**
  131110. * Calculates the frames Offset.
  131111. * @param index of the frame
  131112. * @returns Vector2
  131113. */
  131114. private _getFrameOffset;
  131115. /**
  131116. * Updates a Mesh to the frame data
  131117. * @param mesh that is the target
  131118. * @param frameID or the frame index
  131119. */
  131120. private _updateMeshUV;
  131121. /**
  131122. * Updates a Meshes materials to use the texture packer channels
  131123. * @param m is the mesh to target
  131124. * @param force all channels on the packer to be set.
  131125. */
  131126. private _updateTextureReferences;
  131127. /**
  131128. * Public method to set a Mesh to a frame
  131129. * @param m that is the target
  131130. * @param frameID or the frame index
  131131. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  131132. */
  131133. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  131134. /**
  131135. * Starts the async promise to compile the texture packer.
  131136. * @returns Promise<void>
  131137. */
  131138. processAsync(): Promise<void>;
  131139. /**
  131140. * Disposes all textures associated with this packer
  131141. */
  131142. dispose(): void;
  131143. /**
  131144. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  131145. * @param imageType is the image type to use.
  131146. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  131147. */
  131148. download(imageType?: string, quality?: number): void;
  131149. /**
  131150. * Public method to load a texturePacker JSON file.
  131151. * @param data of the JSON file in string format.
  131152. */
  131153. updateFromJSON(data: string): void;
  131154. }
  131155. }
  131156. declare module BABYLON {
  131157. /**
  131158. * Enum used to define the target of a block
  131159. */
  131160. export enum NodeMaterialBlockTargets {
  131161. /** Vertex shader */
  131162. Vertex = 1,
  131163. /** Fragment shader */
  131164. Fragment = 2,
  131165. /** Neutral */
  131166. Neutral = 4,
  131167. /** Vertex and Fragment */
  131168. VertexAndFragment = 3
  131169. }
  131170. }
  131171. declare module BABYLON {
  131172. /**
  131173. * Defines the kind of connection point for node based material
  131174. */
  131175. export enum NodeMaterialBlockConnectionPointTypes {
  131176. /** Float */
  131177. Float = 1,
  131178. /** Int */
  131179. Int = 2,
  131180. /** Vector2 */
  131181. Vector2 = 4,
  131182. /** Vector3 */
  131183. Vector3 = 8,
  131184. /** Vector4 */
  131185. Vector4 = 16,
  131186. /** Color3 */
  131187. Color3 = 32,
  131188. /** Color4 */
  131189. Color4 = 64,
  131190. /** Matrix */
  131191. Matrix = 128,
  131192. /** Detect type based on connection */
  131193. AutoDetect = 1024,
  131194. /** Output type that will be defined by input type */
  131195. BasedOnInput = 2048
  131196. }
  131197. }
  131198. declare module BABYLON {
  131199. /**
  131200. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  131201. */
  131202. export enum NodeMaterialBlockConnectionPointMode {
  131203. /** Value is an uniform */
  131204. Uniform = 0,
  131205. /** Value is a mesh attribute */
  131206. Attribute = 1,
  131207. /** Value is a varying between vertex and fragment shaders */
  131208. Varying = 2,
  131209. /** Mode is undefined */
  131210. Undefined = 3
  131211. }
  131212. }
  131213. declare module BABYLON {
  131214. /**
  131215. * Enum used to define system values e.g. values automatically provided by the system
  131216. */
  131217. export enum NodeMaterialSystemValues {
  131218. /** World */
  131219. World = 1,
  131220. /** View */
  131221. View = 2,
  131222. /** Projection */
  131223. Projection = 3,
  131224. /** ViewProjection */
  131225. ViewProjection = 4,
  131226. /** WorldView */
  131227. WorldView = 5,
  131228. /** WorldViewProjection */
  131229. WorldViewProjection = 6,
  131230. /** CameraPosition */
  131231. CameraPosition = 7,
  131232. /** Fog Color */
  131233. FogColor = 8,
  131234. /** Delta time */
  131235. DeltaTime = 9
  131236. }
  131237. }
  131238. declare module BABYLON {
  131239. /**
  131240. * Root class for all node material optimizers
  131241. */
  131242. export class NodeMaterialOptimizer {
  131243. /**
  131244. * Function used to optimize a NodeMaterial graph
  131245. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  131246. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  131247. */
  131248. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  131249. }
  131250. }
  131251. declare module BABYLON {
  131252. /**
  131253. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  131254. */
  131255. export class TransformBlock extends NodeMaterialBlock {
  131256. /**
  131257. * Defines the value to use to complement W value to transform it to a Vector4
  131258. */
  131259. complementW: number;
  131260. /**
  131261. * Defines the value to use to complement z value to transform it to a Vector4
  131262. */
  131263. complementZ: number;
  131264. /**
  131265. * Creates a new TransformBlock
  131266. * @param name defines the block name
  131267. */
  131268. constructor(name: string);
  131269. /**
  131270. * Gets the current class name
  131271. * @returns the class name
  131272. */
  131273. getClassName(): string;
  131274. /**
  131275. * Gets the vector input
  131276. */
  131277. get vector(): NodeMaterialConnectionPoint;
  131278. /**
  131279. * Gets the output component
  131280. */
  131281. get output(): NodeMaterialConnectionPoint;
  131282. /**
  131283. * Gets the xyz output component
  131284. */
  131285. get xyz(): NodeMaterialConnectionPoint;
  131286. /**
  131287. * Gets the matrix transform input
  131288. */
  131289. get transform(): NodeMaterialConnectionPoint;
  131290. protected _buildBlock(state: NodeMaterialBuildState): this;
  131291. serialize(): any;
  131292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131293. protected _dumpPropertiesCode(): string;
  131294. }
  131295. }
  131296. declare module BABYLON {
  131297. /**
  131298. * Block used to output the vertex position
  131299. */
  131300. export class VertexOutputBlock extends NodeMaterialBlock {
  131301. /**
  131302. * Creates a new VertexOutputBlock
  131303. * @param name defines the block name
  131304. */
  131305. constructor(name: string);
  131306. /**
  131307. * Gets the current class name
  131308. * @returns the class name
  131309. */
  131310. getClassName(): string;
  131311. /**
  131312. * Gets the vector input component
  131313. */
  131314. get vector(): NodeMaterialConnectionPoint;
  131315. protected _buildBlock(state: NodeMaterialBuildState): this;
  131316. }
  131317. }
  131318. declare module BABYLON {
  131319. /**
  131320. * Block used to output the final color
  131321. */
  131322. export class FragmentOutputBlock extends NodeMaterialBlock {
  131323. /**
  131324. * Create a new FragmentOutputBlock
  131325. * @param name defines the block name
  131326. */
  131327. constructor(name: string);
  131328. /**
  131329. * Gets the current class name
  131330. * @returns the class name
  131331. */
  131332. getClassName(): string;
  131333. /**
  131334. * Gets the rgba input component
  131335. */
  131336. get rgba(): NodeMaterialConnectionPoint;
  131337. /**
  131338. * Gets the rgb input component
  131339. */
  131340. get rgb(): NodeMaterialConnectionPoint;
  131341. /**
  131342. * Gets the a input component
  131343. */
  131344. get a(): NodeMaterialConnectionPoint;
  131345. protected _buildBlock(state: NodeMaterialBuildState): this;
  131346. }
  131347. }
  131348. declare module BABYLON {
  131349. /**
  131350. * Block used to read a reflection texture from a sampler
  131351. */
  131352. export class ReflectionTextureBlock extends NodeMaterialBlock {
  131353. private _define3DName;
  131354. private _defineCubicName;
  131355. private _defineExplicitName;
  131356. private _defineProjectionName;
  131357. private _defineLocalCubicName;
  131358. private _defineSphericalName;
  131359. private _definePlanarName;
  131360. private _defineEquirectangularName;
  131361. private _defineMirroredEquirectangularFixedName;
  131362. private _defineEquirectangularFixedName;
  131363. private _defineSkyboxName;
  131364. private _cubeSamplerName;
  131365. private _2DSamplerName;
  131366. private _positionUVWName;
  131367. private _directionWName;
  131368. private _reflectionCoordsName;
  131369. private _reflection2DCoordsName;
  131370. private _reflectionColorName;
  131371. private _reflectionMatrixName;
  131372. /**
  131373. * Gets or sets the texture associated with the node
  131374. */
  131375. texture: Nullable<BaseTexture>;
  131376. /**
  131377. * Create a new TextureBlock
  131378. * @param name defines the block name
  131379. */
  131380. constructor(name: string);
  131381. /**
  131382. * Gets the current class name
  131383. * @returns the class name
  131384. */
  131385. getClassName(): string;
  131386. /**
  131387. * Gets the world position input component
  131388. */
  131389. get position(): NodeMaterialConnectionPoint;
  131390. /**
  131391. * Gets the world position input component
  131392. */
  131393. get worldPosition(): NodeMaterialConnectionPoint;
  131394. /**
  131395. * Gets the world normal input component
  131396. */
  131397. get worldNormal(): NodeMaterialConnectionPoint;
  131398. /**
  131399. * Gets the world input component
  131400. */
  131401. get world(): NodeMaterialConnectionPoint;
  131402. /**
  131403. * Gets the camera (or eye) position component
  131404. */
  131405. get cameraPosition(): NodeMaterialConnectionPoint;
  131406. /**
  131407. * Gets the view input component
  131408. */
  131409. get view(): NodeMaterialConnectionPoint;
  131410. /**
  131411. * Gets the rgb output component
  131412. */
  131413. get rgb(): NodeMaterialConnectionPoint;
  131414. /**
  131415. * Gets the r output component
  131416. */
  131417. get r(): NodeMaterialConnectionPoint;
  131418. /**
  131419. * Gets the g output component
  131420. */
  131421. get g(): NodeMaterialConnectionPoint;
  131422. /**
  131423. * Gets the b output component
  131424. */
  131425. get b(): NodeMaterialConnectionPoint;
  131426. autoConfigure(material: NodeMaterial): void;
  131427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131428. isReady(): boolean;
  131429. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131430. private _injectVertexCode;
  131431. private _writeOutput;
  131432. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131433. protected _dumpPropertiesCode(): string;
  131434. serialize(): any;
  131435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131436. }
  131437. }
  131438. declare module BABYLON {
  131439. /**
  131440. * Interface used to configure the node material editor
  131441. */
  131442. export interface INodeMaterialEditorOptions {
  131443. /** Define the URl to load node editor script */
  131444. editorURL?: string;
  131445. }
  131446. /** @hidden */
  131447. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  131448. NORMAL: boolean;
  131449. TANGENT: boolean;
  131450. UV1: boolean;
  131451. /** BONES */
  131452. NUM_BONE_INFLUENCERS: number;
  131453. BonesPerMesh: number;
  131454. BONETEXTURE: boolean;
  131455. /** MORPH TARGETS */
  131456. MORPHTARGETS: boolean;
  131457. MORPHTARGETS_NORMAL: boolean;
  131458. MORPHTARGETS_TANGENT: boolean;
  131459. MORPHTARGETS_UV: boolean;
  131460. NUM_MORPH_INFLUENCERS: number;
  131461. /** IMAGE PROCESSING */
  131462. IMAGEPROCESSING: boolean;
  131463. VIGNETTE: boolean;
  131464. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131465. VIGNETTEBLENDMODEOPAQUE: boolean;
  131466. TONEMAPPING: boolean;
  131467. TONEMAPPING_ACES: boolean;
  131468. CONTRAST: boolean;
  131469. EXPOSURE: boolean;
  131470. COLORCURVES: boolean;
  131471. COLORGRADING: boolean;
  131472. COLORGRADING3D: boolean;
  131473. SAMPLER3DGREENDEPTH: boolean;
  131474. SAMPLER3DBGRMAP: boolean;
  131475. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131476. /** MISC. */
  131477. BUMPDIRECTUV: number;
  131478. constructor();
  131479. setValue(name: string, value: boolean): void;
  131480. }
  131481. /**
  131482. * Class used to configure NodeMaterial
  131483. */
  131484. export interface INodeMaterialOptions {
  131485. /**
  131486. * Defines if blocks should emit comments
  131487. */
  131488. emitComments: boolean;
  131489. }
  131490. /**
  131491. * Class used to create a node based material built by assembling shader blocks
  131492. */
  131493. export class NodeMaterial extends PushMaterial {
  131494. private static _BuildIdGenerator;
  131495. private _options;
  131496. private _vertexCompilationState;
  131497. private _fragmentCompilationState;
  131498. private _sharedData;
  131499. private _buildId;
  131500. private _buildWasSuccessful;
  131501. private _cachedWorldViewMatrix;
  131502. private _cachedWorldViewProjectionMatrix;
  131503. private _optimizers;
  131504. private _animationFrame;
  131505. /** Define the Url to load node editor script */
  131506. static EditorURL: string;
  131507. /** Define the Url to load snippets */
  131508. static SnippetUrl: string;
  131509. private BJSNODEMATERIALEDITOR;
  131510. /** Get the inspector from bundle or global */
  131511. private _getGlobalNodeMaterialEditor;
  131512. /**
  131513. * Gets or sets data used by visual editor
  131514. * @see https://nme.babylonjs.com
  131515. */
  131516. editorData: any;
  131517. /**
  131518. * 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)
  131519. */
  131520. ignoreAlpha: boolean;
  131521. /**
  131522. * Defines the maximum number of lights that can be used in the material
  131523. */
  131524. maxSimultaneousLights: number;
  131525. /**
  131526. * Observable raised when the material is built
  131527. */
  131528. onBuildObservable: Observable<NodeMaterial>;
  131529. /**
  131530. * Gets or sets the root nodes of the material vertex shader
  131531. */
  131532. _vertexOutputNodes: NodeMaterialBlock[];
  131533. /**
  131534. * Gets or sets the root nodes of the material fragment (pixel) shader
  131535. */
  131536. _fragmentOutputNodes: NodeMaterialBlock[];
  131537. /** Gets or sets options to control the node material overall behavior */
  131538. get options(): INodeMaterialOptions;
  131539. set options(options: INodeMaterialOptions);
  131540. /**
  131541. * Default configuration related to image processing available in the standard Material.
  131542. */
  131543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131544. /**
  131545. * Gets the image processing configuration used either in this material.
  131546. */
  131547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  131548. /**
  131549. * Sets the Default image processing configuration used either in the this material.
  131550. *
  131551. * If sets to null, the scene one is in use.
  131552. */
  131553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  131554. /**
  131555. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  131556. */
  131557. attachedBlocks: NodeMaterialBlock[];
  131558. /**
  131559. * Create a new node based material
  131560. * @param name defines the material name
  131561. * @param scene defines the hosting scene
  131562. * @param options defines creation option
  131563. */
  131564. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  131565. /**
  131566. * Gets the current class name of the material e.g. "NodeMaterial"
  131567. * @returns the class name
  131568. */
  131569. getClassName(): string;
  131570. /**
  131571. * Keep track of the image processing observer to allow dispose and replace.
  131572. */
  131573. private _imageProcessingObserver;
  131574. /**
  131575. * Attaches a new image processing configuration to the Standard Material.
  131576. * @param configuration
  131577. */
  131578. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131579. /**
  131580. * Get a block by its name
  131581. * @param name defines the name of the block to retrieve
  131582. * @returns the required block or null if not found
  131583. */
  131584. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  131585. /**
  131586. * Get a block by its name
  131587. * @param predicate defines the predicate used to find the good candidate
  131588. * @returns the required block or null if not found
  131589. */
  131590. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  131591. /**
  131592. * Get an input block by its name
  131593. * @param predicate defines the predicate used to find the good candidate
  131594. * @returns the required input block or null if not found
  131595. */
  131596. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  131597. /**
  131598. * Gets the list of input blocks attached to this material
  131599. * @returns an array of InputBlocks
  131600. */
  131601. getInputBlocks(): InputBlock[];
  131602. /**
  131603. * Adds a new optimizer to the list of optimizers
  131604. * @param optimizer defines the optimizers to add
  131605. * @returns the current material
  131606. */
  131607. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131608. /**
  131609. * Remove an optimizer from the list of optimizers
  131610. * @param optimizer defines the optimizers to remove
  131611. * @returns the current material
  131612. */
  131613. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131614. /**
  131615. * Add a new block to the list of output nodes
  131616. * @param node defines the node to add
  131617. * @returns the current material
  131618. */
  131619. addOutputNode(node: NodeMaterialBlock): this;
  131620. /**
  131621. * Remove a block from the list of root nodes
  131622. * @param node defines the node to remove
  131623. * @returns the current material
  131624. */
  131625. removeOutputNode(node: NodeMaterialBlock): this;
  131626. private _addVertexOutputNode;
  131627. private _removeVertexOutputNode;
  131628. private _addFragmentOutputNode;
  131629. private _removeFragmentOutputNode;
  131630. /**
  131631. * Specifies if the material will require alpha blending
  131632. * @returns a boolean specifying if alpha blending is needed
  131633. */
  131634. needAlphaBlending(): boolean;
  131635. /**
  131636. * Specifies if this material should be rendered in alpha test mode
  131637. * @returns a boolean specifying if an alpha test is needed.
  131638. */
  131639. needAlphaTesting(): boolean;
  131640. private _initializeBlock;
  131641. private _resetDualBlocks;
  131642. /**
  131643. * Remove a block from the current node material
  131644. * @param block defines the block to remove
  131645. */
  131646. removeBlock(block: NodeMaterialBlock): void;
  131647. /**
  131648. * Build the material and generates the inner effect
  131649. * @param verbose defines if the build should log activity
  131650. */
  131651. build(verbose?: boolean): void;
  131652. /**
  131653. * Runs an otpimization phase to try to improve the shader code
  131654. */
  131655. optimize(): void;
  131656. private _prepareDefinesForAttributes;
  131657. /**
  131658. * Get if the submesh is ready to be used and all its information available.
  131659. * Child classes can use it to update shaders
  131660. * @param mesh defines the mesh to check
  131661. * @param subMesh defines which submesh to check
  131662. * @param useInstances specifies that instances should be used
  131663. * @returns a boolean indicating that the submesh is ready or not
  131664. */
  131665. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131666. /**
  131667. * Get a string representing the shaders built by the current node graph
  131668. */
  131669. get compiledShaders(): string;
  131670. /**
  131671. * Binds the world matrix to the material
  131672. * @param world defines the world transformation matrix
  131673. */
  131674. bindOnlyWorldMatrix(world: Matrix): void;
  131675. /**
  131676. * Binds the submesh to this material by preparing the effect and shader to draw
  131677. * @param world defines the world transformation matrix
  131678. * @param mesh defines the mesh containing the submesh
  131679. * @param subMesh defines the submesh to bind the material to
  131680. */
  131681. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131682. /**
  131683. * Gets the active textures from the material
  131684. * @returns an array of textures
  131685. */
  131686. getActiveTextures(): BaseTexture[];
  131687. /**
  131688. * Gets the list of texture blocks
  131689. * @returns an array of texture blocks
  131690. */
  131691. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  131692. /**
  131693. * Specifies if the material uses a texture
  131694. * @param texture defines the texture to check against the material
  131695. * @returns a boolean specifying if the material uses the texture
  131696. */
  131697. hasTexture(texture: BaseTexture): boolean;
  131698. /**
  131699. * Disposes the material
  131700. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  131701. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  131702. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  131703. */
  131704. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  131705. /** Creates the node editor window. */
  131706. private _createNodeEditor;
  131707. /**
  131708. * Launch the node material editor
  131709. * @param config Define the configuration of the editor
  131710. * @return a promise fulfilled when the node editor is visible
  131711. */
  131712. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  131713. /**
  131714. * Clear the current material
  131715. */
  131716. clear(): void;
  131717. /**
  131718. * Clear the current material and set it to a default state
  131719. */
  131720. setToDefault(): void;
  131721. /**
  131722. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  131723. * @param url defines the url to load from
  131724. * @returns a promise that will fullfil when the material is fully loaded
  131725. */
  131726. loadAsync(url: string): Promise<void>;
  131727. private _gatherBlocks;
  131728. /**
  131729. * Generate a string containing the code declaration required to create an equivalent of this material
  131730. * @returns a string
  131731. */
  131732. generateCode(): string;
  131733. /**
  131734. * Serializes this material in a JSON representation
  131735. * @returns the serialized material object
  131736. */
  131737. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  131738. private _restoreConnections;
  131739. /**
  131740. * Clear the current graph and load a new one from a serialization object
  131741. * @param source defines the JSON representation of the material
  131742. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131743. */
  131744. loadFromSerialization(source: any, rootUrl?: string): void;
  131745. /**
  131746. * Makes a duplicate of the current material.
  131747. * @param name - name to use for the new material.
  131748. */
  131749. clone(name: string): NodeMaterial;
  131750. /**
  131751. * Creates a node material from parsed material data
  131752. * @param source defines the JSON representation of the material
  131753. * @param scene defines the hosting scene
  131754. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131755. * @returns a new node material
  131756. */
  131757. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  131758. /**
  131759. * Creates a node material from a snippet saved in a remote file
  131760. * @param name defines the name of the material to create
  131761. * @param url defines the url to load from
  131762. * @param scene defines the hosting scene
  131763. * @returns a promise that will resolve to the new node material
  131764. */
  131765. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  131766. /**
  131767. * Creates a node material from a snippet saved by the node material editor
  131768. * @param snippetId defines the snippet to load
  131769. * @param scene defines the hosting scene
  131770. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131771. * @returns a promise that will resolve to the new node material
  131772. */
  131773. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  131774. /**
  131775. * Creates a new node material set to default basic configuration
  131776. * @param name defines the name of the material
  131777. * @param scene defines the hosting scene
  131778. * @returns a new NodeMaterial
  131779. */
  131780. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  131781. }
  131782. }
  131783. declare module BABYLON {
  131784. /**
  131785. * Block used to read a texture from a sampler
  131786. */
  131787. export class TextureBlock extends NodeMaterialBlock {
  131788. private _defineName;
  131789. private _linearDefineName;
  131790. private _tempTextureRead;
  131791. private _samplerName;
  131792. private _transformedUVName;
  131793. private _textureTransformName;
  131794. private _textureInfoName;
  131795. private _mainUVName;
  131796. private _mainUVDefineName;
  131797. /**
  131798. * Gets or sets the texture associated with the node
  131799. */
  131800. texture: Nullable<Texture>;
  131801. /**
  131802. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  131803. */
  131804. convertToGammaSpace: boolean;
  131805. /**
  131806. * Create a new TextureBlock
  131807. * @param name defines the block name
  131808. */
  131809. constructor(name: string);
  131810. /**
  131811. * Gets the current class name
  131812. * @returns the class name
  131813. */
  131814. getClassName(): string;
  131815. /**
  131816. * Gets the uv input component
  131817. */
  131818. get uv(): NodeMaterialConnectionPoint;
  131819. /**
  131820. * Gets the rgba output component
  131821. */
  131822. get rgba(): NodeMaterialConnectionPoint;
  131823. /**
  131824. * Gets the rgb output component
  131825. */
  131826. get rgb(): NodeMaterialConnectionPoint;
  131827. /**
  131828. * Gets the r output component
  131829. */
  131830. get r(): NodeMaterialConnectionPoint;
  131831. /**
  131832. * Gets the g output component
  131833. */
  131834. get g(): NodeMaterialConnectionPoint;
  131835. /**
  131836. * Gets the b output component
  131837. */
  131838. get b(): NodeMaterialConnectionPoint;
  131839. /**
  131840. * Gets the a output component
  131841. */
  131842. get a(): NodeMaterialConnectionPoint;
  131843. get target(): NodeMaterialBlockTargets;
  131844. autoConfigure(material: NodeMaterial): void;
  131845. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131846. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131847. isReady(): boolean;
  131848. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131849. private get _isMixed();
  131850. private _injectVertexCode;
  131851. private _writeTextureRead;
  131852. private _writeOutput;
  131853. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131854. protected _dumpPropertiesCode(): string;
  131855. serialize(): any;
  131856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131857. }
  131858. }
  131859. declare module BABYLON {
  131860. /**
  131861. * Class used to store shared data between 2 NodeMaterialBuildState
  131862. */
  131863. export class NodeMaterialBuildStateSharedData {
  131864. /**
  131865. * Gets the list of emitted varyings
  131866. */
  131867. temps: string[];
  131868. /**
  131869. * Gets the list of emitted varyings
  131870. */
  131871. varyings: string[];
  131872. /**
  131873. * Gets the varying declaration string
  131874. */
  131875. varyingDeclaration: string;
  131876. /**
  131877. * Input blocks
  131878. */
  131879. inputBlocks: InputBlock[];
  131880. /**
  131881. * Input blocks
  131882. */
  131883. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  131884. /**
  131885. * Bindable blocks (Blocks that need to set data to the effect)
  131886. */
  131887. bindableBlocks: NodeMaterialBlock[];
  131888. /**
  131889. * List of blocks that can provide a compilation fallback
  131890. */
  131891. blocksWithFallbacks: NodeMaterialBlock[];
  131892. /**
  131893. * List of blocks that can provide a define update
  131894. */
  131895. blocksWithDefines: NodeMaterialBlock[];
  131896. /**
  131897. * List of blocks that can provide a repeatable content
  131898. */
  131899. repeatableContentBlocks: NodeMaterialBlock[];
  131900. /**
  131901. * List of blocks that can provide a dynamic list of uniforms
  131902. */
  131903. dynamicUniformBlocks: NodeMaterialBlock[];
  131904. /**
  131905. * List of blocks that can block the isReady function for the material
  131906. */
  131907. blockingBlocks: NodeMaterialBlock[];
  131908. /**
  131909. * Gets the list of animated inputs
  131910. */
  131911. animatedInputs: InputBlock[];
  131912. /**
  131913. * Build Id used to avoid multiple recompilations
  131914. */
  131915. buildId: number;
  131916. /** List of emitted variables */
  131917. variableNames: {
  131918. [key: string]: number;
  131919. };
  131920. /** List of emitted defines */
  131921. defineNames: {
  131922. [key: string]: number;
  131923. };
  131924. /** Should emit comments? */
  131925. emitComments: boolean;
  131926. /** Emit build activity */
  131927. verbose: boolean;
  131928. /** Gets or sets the hosting scene */
  131929. scene: Scene;
  131930. /**
  131931. * Gets the compilation hints emitted at compilation time
  131932. */
  131933. hints: {
  131934. needWorldViewMatrix: boolean;
  131935. needWorldViewProjectionMatrix: boolean;
  131936. needAlphaBlending: boolean;
  131937. needAlphaTesting: boolean;
  131938. };
  131939. /**
  131940. * List of compilation checks
  131941. */
  131942. checks: {
  131943. emitVertex: boolean;
  131944. emitFragment: boolean;
  131945. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  131946. };
  131947. /** Creates a new shared data */
  131948. constructor();
  131949. /**
  131950. * Emits console errors and exceptions if there is a failing check
  131951. */
  131952. emitErrors(): void;
  131953. }
  131954. }
  131955. declare module BABYLON {
  131956. /**
  131957. * Class used to store node based material build state
  131958. */
  131959. export class NodeMaterialBuildState {
  131960. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  131961. supportUniformBuffers: boolean;
  131962. /**
  131963. * Gets the list of emitted attributes
  131964. */
  131965. attributes: string[];
  131966. /**
  131967. * Gets the list of emitted uniforms
  131968. */
  131969. uniforms: string[];
  131970. /**
  131971. * Gets the list of emitted constants
  131972. */
  131973. constants: string[];
  131974. /**
  131975. * Gets the list of emitted samplers
  131976. */
  131977. samplers: string[];
  131978. /**
  131979. * Gets the list of emitted functions
  131980. */
  131981. functions: {
  131982. [key: string]: string;
  131983. };
  131984. /**
  131985. * Gets the list of emitted extensions
  131986. */
  131987. extensions: {
  131988. [key: string]: string;
  131989. };
  131990. /**
  131991. * Gets the target of the compilation state
  131992. */
  131993. target: NodeMaterialBlockTargets;
  131994. /**
  131995. * Gets the list of emitted counters
  131996. */
  131997. counters: {
  131998. [key: string]: number;
  131999. };
  132000. /**
  132001. * Shared data between multiple NodeMaterialBuildState instances
  132002. */
  132003. sharedData: NodeMaterialBuildStateSharedData;
  132004. /** @hidden */
  132005. _vertexState: NodeMaterialBuildState;
  132006. /** @hidden */
  132007. _attributeDeclaration: string;
  132008. /** @hidden */
  132009. _uniformDeclaration: string;
  132010. /** @hidden */
  132011. _constantDeclaration: string;
  132012. /** @hidden */
  132013. _samplerDeclaration: string;
  132014. /** @hidden */
  132015. _varyingTransfer: string;
  132016. private _repeatableContentAnchorIndex;
  132017. /** @hidden */
  132018. _builtCompilationString: string;
  132019. /**
  132020. * Gets the emitted compilation strings
  132021. */
  132022. compilationString: string;
  132023. /**
  132024. * Finalize the compilation strings
  132025. * @param state defines the current compilation state
  132026. */
  132027. finalize(state: NodeMaterialBuildState): void;
  132028. /** @hidden */
  132029. get _repeatableContentAnchor(): string;
  132030. /** @hidden */
  132031. _getFreeVariableName(prefix: string): string;
  132032. /** @hidden */
  132033. _getFreeDefineName(prefix: string): string;
  132034. /** @hidden */
  132035. _excludeVariableName(name: string): void;
  132036. /** @hidden */
  132037. _emit2DSampler(name: string): void;
  132038. /** @hidden */
  132039. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  132040. /** @hidden */
  132041. _emitExtension(name: string, extension: string): void;
  132042. /** @hidden */
  132043. _emitFunction(name: string, code: string, comments: string): void;
  132044. /** @hidden */
  132045. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  132046. replaceStrings?: {
  132047. search: RegExp;
  132048. replace: string;
  132049. }[];
  132050. repeatKey?: string;
  132051. }): string;
  132052. /** @hidden */
  132053. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  132054. repeatKey?: string;
  132055. removeAttributes?: boolean;
  132056. removeUniforms?: boolean;
  132057. removeVaryings?: boolean;
  132058. removeIfDef?: boolean;
  132059. replaceStrings?: {
  132060. search: RegExp;
  132061. replace: string;
  132062. }[];
  132063. }, storeKey?: string): void;
  132064. /** @hidden */
  132065. _registerTempVariable(name: string): boolean;
  132066. /** @hidden */
  132067. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  132068. /** @hidden */
  132069. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  132070. /** @hidden */
  132071. _emitFloat(value: number): string;
  132072. }
  132073. }
  132074. declare module BABYLON {
  132075. /**
  132076. * Defines a block that can be used inside a node based material
  132077. */
  132078. export class NodeMaterialBlock {
  132079. private _buildId;
  132080. private _buildTarget;
  132081. private _target;
  132082. private _isFinalMerger;
  132083. private _isInput;
  132084. protected _isUnique: boolean;
  132085. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  132086. inputsAreExclusive: boolean;
  132087. /** @hidden */
  132088. _codeVariableName: string;
  132089. /** @hidden */
  132090. _inputs: NodeMaterialConnectionPoint[];
  132091. /** @hidden */
  132092. _outputs: NodeMaterialConnectionPoint[];
  132093. /** @hidden */
  132094. _preparationId: number;
  132095. /**
  132096. * Gets or sets the name of the block
  132097. */
  132098. name: string;
  132099. /**
  132100. * Gets or sets the unique id of the node
  132101. */
  132102. uniqueId: number;
  132103. /**
  132104. * Gets or sets the comments associated with this block
  132105. */
  132106. comments: string;
  132107. /**
  132108. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  132109. */
  132110. get isUnique(): boolean;
  132111. /**
  132112. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  132113. */
  132114. get isFinalMerger(): boolean;
  132115. /**
  132116. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  132117. */
  132118. get isInput(): boolean;
  132119. /**
  132120. * Gets or sets the build Id
  132121. */
  132122. get buildId(): number;
  132123. set buildId(value: number);
  132124. /**
  132125. * Gets or sets the target of the block
  132126. */
  132127. get target(): NodeMaterialBlockTargets;
  132128. set target(value: NodeMaterialBlockTargets);
  132129. /**
  132130. * Gets the list of input points
  132131. */
  132132. get inputs(): NodeMaterialConnectionPoint[];
  132133. /** Gets the list of output points */
  132134. get outputs(): NodeMaterialConnectionPoint[];
  132135. /**
  132136. * Find an input by its name
  132137. * @param name defines the name of the input to look for
  132138. * @returns the input or null if not found
  132139. */
  132140. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132141. /**
  132142. * Find an output by its name
  132143. * @param name defines the name of the outputto look for
  132144. * @returns the output or null if not found
  132145. */
  132146. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132147. /**
  132148. * Creates a new NodeMaterialBlock
  132149. * @param name defines the block name
  132150. * @param target defines the target of that block (Vertex by default)
  132151. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  132152. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  132153. */
  132154. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  132155. /**
  132156. * Initialize the block and prepare the context for build
  132157. * @param state defines the state that will be used for the build
  132158. */
  132159. initialize(state: NodeMaterialBuildState): void;
  132160. /**
  132161. * Bind data to effect. Will only be called for blocks with isBindable === true
  132162. * @param effect defines the effect to bind data to
  132163. * @param nodeMaterial defines the hosting NodeMaterial
  132164. * @param mesh defines the mesh that will be rendered
  132165. */
  132166. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132167. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  132168. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  132169. protected _writeFloat(value: number): string;
  132170. /**
  132171. * Gets the current class name e.g. "NodeMaterialBlock"
  132172. * @returns the class name
  132173. */
  132174. getClassName(): string;
  132175. /**
  132176. * Register a new input. Must be called inside a block constructor
  132177. * @param name defines the connection point name
  132178. * @param type defines the connection point type
  132179. * @param isOptional defines a boolean indicating that this input can be omitted
  132180. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132181. * @returns the current block
  132182. */
  132183. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  132184. /**
  132185. * Register a new output. Must be called inside a block constructor
  132186. * @param name defines the connection point name
  132187. * @param type defines the connection point type
  132188. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132189. * @returns the current block
  132190. */
  132191. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  132192. /**
  132193. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  132194. * @param forOutput defines an optional connection point to check compatibility with
  132195. * @returns the first available input or null
  132196. */
  132197. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  132198. /**
  132199. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  132200. * @param forBlock defines an optional block to check compatibility with
  132201. * @returns the first available input or null
  132202. */
  132203. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  132204. /**
  132205. * Gets the sibling of the given output
  132206. * @param current defines the current output
  132207. * @returns the next output in the list or null
  132208. */
  132209. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  132210. /**
  132211. * Connect current block with another block
  132212. * @param other defines the block to connect with
  132213. * @param options define the various options to help pick the right connections
  132214. * @returns the current block
  132215. */
  132216. connectTo(other: NodeMaterialBlock, options?: {
  132217. input?: string;
  132218. output?: string;
  132219. outputSwizzle?: string;
  132220. }): this | undefined;
  132221. protected _buildBlock(state: NodeMaterialBuildState): void;
  132222. /**
  132223. * Add uniforms, samplers and uniform buffers at compilation time
  132224. * @param state defines the state to update
  132225. * @param nodeMaterial defines the node material requesting the update
  132226. * @param defines defines the material defines to update
  132227. * @param uniformBuffers defines the list of uniform buffer names
  132228. */
  132229. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132230. /**
  132231. * Add potential fallbacks if shader compilation fails
  132232. * @param mesh defines the mesh to be rendered
  132233. * @param fallbacks defines the current prioritized list of fallbacks
  132234. */
  132235. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  132236. /**
  132237. * Initialize defines for shader compilation
  132238. * @param mesh defines the mesh to be rendered
  132239. * @param nodeMaterial defines the node material requesting the update
  132240. * @param defines defines the material defines to update
  132241. * @param useInstances specifies that instances should be used
  132242. */
  132243. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132244. /**
  132245. * Update defines for shader compilation
  132246. * @param mesh defines the mesh to be rendered
  132247. * @param nodeMaterial defines the node material requesting the update
  132248. * @param defines defines the material defines to update
  132249. * @param useInstances specifies that instances should be used
  132250. */
  132251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132252. /**
  132253. * Lets the block try to connect some inputs automatically
  132254. * @param material defines the hosting NodeMaterial
  132255. */
  132256. autoConfigure(material: NodeMaterial): void;
  132257. /**
  132258. * Function called when a block is declared as repeatable content generator
  132259. * @param vertexShaderState defines the current compilation state for the vertex shader
  132260. * @param fragmentShaderState defines the current compilation state for the fragment shader
  132261. * @param mesh defines the mesh to be rendered
  132262. * @param defines defines the material defines to update
  132263. */
  132264. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132265. /**
  132266. * Checks if the block is ready
  132267. * @param mesh defines the mesh to be rendered
  132268. * @param nodeMaterial defines the node material requesting the update
  132269. * @param defines defines the material defines to update
  132270. * @param useInstances specifies that instances should be used
  132271. * @returns true if the block is ready
  132272. */
  132273. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  132274. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  132275. private _processBuild;
  132276. /**
  132277. * Compile the current node and generate the shader code
  132278. * @param state defines the current compilation state (uniforms, samplers, current string)
  132279. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  132280. * @returns true if already built
  132281. */
  132282. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  132283. protected _inputRename(name: string): string;
  132284. protected _outputRename(name: string): string;
  132285. protected _dumpPropertiesCode(): string;
  132286. /** @hidden */
  132287. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  132288. /** @hidden */
  132289. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  132290. /**
  132291. * Clone the current block to a new identical block
  132292. * @param scene defines the hosting scene
  132293. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132294. * @returns a copy of the current block
  132295. */
  132296. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  132297. /**
  132298. * Serializes this block in a JSON representation
  132299. * @returns the serialized block object
  132300. */
  132301. serialize(): any;
  132302. /** @hidden */
  132303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132304. /**
  132305. * Release resources
  132306. */
  132307. dispose(): void;
  132308. }
  132309. }
  132310. declare module BABYLON {
  132311. /**
  132312. * Enum defining the type of animations supported by InputBlock
  132313. */
  132314. export enum AnimatedInputBlockTypes {
  132315. /** No animation */
  132316. None = 0,
  132317. /** Time based animation. Will only work for floats */
  132318. Time = 1
  132319. }
  132320. }
  132321. declare module BABYLON {
  132322. /**
  132323. * Block used to expose an input value
  132324. */
  132325. export class InputBlock extends NodeMaterialBlock {
  132326. private _mode;
  132327. private _associatedVariableName;
  132328. private _storedValue;
  132329. private _valueCallback;
  132330. private _type;
  132331. private _animationType;
  132332. /** Gets or set a value used to limit the range of float values */
  132333. min: number;
  132334. /** Gets or set a value used to limit the range of float values */
  132335. max: number;
  132336. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  132337. isBoolean: boolean;
  132338. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  132339. matrixMode: number;
  132340. /** @hidden */
  132341. _systemValue: Nullable<NodeMaterialSystemValues>;
  132342. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  132343. visibleInInspector: boolean;
  132344. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  132345. isConstant: boolean;
  132346. /** Gets or sets the group to use to display this block in the Inspector */
  132347. groupInInspector: string;
  132348. /** Gets an observable raised when the value is changed */
  132349. onValueChangedObservable: Observable<InputBlock>;
  132350. /**
  132351. * Gets or sets the connection point type (default is float)
  132352. */
  132353. get type(): NodeMaterialBlockConnectionPointTypes;
  132354. /**
  132355. * Creates a new InputBlock
  132356. * @param name defines the block name
  132357. * @param target defines the target of that block (Vertex by default)
  132358. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  132359. */
  132360. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  132361. /**
  132362. * Gets the output component
  132363. */
  132364. get output(): NodeMaterialConnectionPoint;
  132365. /**
  132366. * Set the source of this connection point to a vertex attribute
  132367. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  132368. * @returns the current connection point
  132369. */
  132370. setAsAttribute(attributeName?: string): InputBlock;
  132371. /**
  132372. * Set the source of this connection point to a system value
  132373. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  132374. * @returns the current connection point
  132375. */
  132376. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  132377. /**
  132378. * Gets or sets the value of that point.
  132379. * Please note that this value will be ignored if valueCallback is defined
  132380. */
  132381. get value(): any;
  132382. set value(value: any);
  132383. /**
  132384. * Gets or sets a callback used to get the value of that point.
  132385. * Please note that setting this value will force the connection point to ignore the value property
  132386. */
  132387. get valueCallback(): () => any;
  132388. set valueCallback(value: () => any);
  132389. /**
  132390. * Gets or sets the associated variable name in the shader
  132391. */
  132392. get associatedVariableName(): string;
  132393. set associatedVariableName(value: string);
  132394. /** Gets or sets the type of animation applied to the input */
  132395. get animationType(): AnimatedInputBlockTypes;
  132396. set animationType(value: AnimatedInputBlockTypes);
  132397. /**
  132398. * Gets a boolean indicating that this connection point not defined yet
  132399. */
  132400. get isUndefined(): boolean;
  132401. /**
  132402. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  132403. * In this case the connection point name must be the name of the uniform to use.
  132404. * Can only be set on inputs
  132405. */
  132406. get isUniform(): boolean;
  132407. set isUniform(value: boolean);
  132408. /**
  132409. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  132410. * In this case the connection point name must be the name of the attribute to use
  132411. * Can only be set on inputs
  132412. */
  132413. get isAttribute(): boolean;
  132414. set isAttribute(value: boolean);
  132415. /**
  132416. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  132417. * Can only be set on exit points
  132418. */
  132419. get isVarying(): boolean;
  132420. set isVarying(value: boolean);
  132421. /**
  132422. * Gets a boolean indicating that the current connection point is a system value
  132423. */
  132424. get isSystemValue(): boolean;
  132425. /**
  132426. * Gets or sets the current well known value or null if not defined as a system value
  132427. */
  132428. get systemValue(): Nullable<NodeMaterialSystemValues>;
  132429. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  132430. /**
  132431. * Gets the current class name
  132432. * @returns the class name
  132433. */
  132434. getClassName(): string;
  132435. /**
  132436. * Animate the input if animationType !== None
  132437. * @param scene defines the rendering scene
  132438. */
  132439. animate(scene: Scene): void;
  132440. private _emitDefine;
  132441. initialize(state: NodeMaterialBuildState): void;
  132442. /**
  132443. * Set the input block to its default value (based on its type)
  132444. */
  132445. setDefaultValue(): void;
  132446. private _emitConstant;
  132447. private _emit;
  132448. /** @hidden */
  132449. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  132450. /** @hidden */
  132451. _transmit(effect: Effect, scene: Scene): void;
  132452. protected _buildBlock(state: NodeMaterialBuildState): void;
  132453. protected _dumpPropertiesCode(): string;
  132454. dispose(): void;
  132455. serialize(): any;
  132456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132457. }
  132458. }
  132459. declare module BABYLON {
  132460. /**
  132461. * Enum used to define the compatibility state between two connection points
  132462. */
  132463. export enum NodeMaterialConnectionPointCompatibilityStates {
  132464. /** Points are compatibles */
  132465. Compatible = 0,
  132466. /** Points are incompatible because of their types */
  132467. TypeIncompatible = 1,
  132468. /** Points are incompatible because of their targets (vertex vs fragment) */
  132469. TargetIncompatible = 2
  132470. }
  132471. /**
  132472. * Defines the direction of a connection point
  132473. */
  132474. export enum NodeMaterialConnectionPointDirection {
  132475. /** Input */
  132476. Input = 0,
  132477. /** Output */
  132478. Output = 1
  132479. }
  132480. /**
  132481. * Defines a connection point for a block
  132482. */
  132483. export class NodeMaterialConnectionPoint {
  132484. /** @hidden */
  132485. _ownerBlock: NodeMaterialBlock;
  132486. /** @hidden */
  132487. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  132488. private _endpoints;
  132489. private _associatedVariableName;
  132490. private _direction;
  132491. /** @hidden */
  132492. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132493. /** @hidden */
  132494. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132495. private _type;
  132496. /** @hidden */
  132497. _enforceAssociatedVariableName: boolean;
  132498. /** Gets the direction of the point */
  132499. get direction(): NodeMaterialConnectionPointDirection;
  132500. /**
  132501. * Gets or sets the additional types supported by this connection point
  132502. */
  132503. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132504. /**
  132505. * Gets or sets the additional types excluded by this connection point
  132506. */
  132507. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132508. /**
  132509. * Observable triggered when this point is connected
  132510. */
  132511. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  132512. /**
  132513. * Gets or sets the associated variable name in the shader
  132514. */
  132515. get associatedVariableName(): string;
  132516. set associatedVariableName(value: string);
  132517. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  132518. get innerType(): NodeMaterialBlockConnectionPointTypes;
  132519. /**
  132520. * Gets or sets the connection point type (default is float)
  132521. */
  132522. get type(): NodeMaterialBlockConnectionPointTypes;
  132523. set type(value: NodeMaterialBlockConnectionPointTypes);
  132524. /**
  132525. * Gets or sets the connection point name
  132526. */
  132527. name: string;
  132528. /**
  132529. * Gets or sets a boolean indicating that this connection point can be omitted
  132530. */
  132531. isOptional: boolean;
  132532. /**
  132533. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  132534. */
  132535. define: string;
  132536. /** @hidden */
  132537. _prioritizeVertex: boolean;
  132538. private _target;
  132539. /** Gets or sets the target of that connection point */
  132540. get target(): NodeMaterialBlockTargets;
  132541. set target(value: NodeMaterialBlockTargets);
  132542. /**
  132543. * Gets a boolean indicating that the current point is connected
  132544. */
  132545. get isConnected(): boolean;
  132546. /**
  132547. * Gets a boolean indicating that the current point is connected to an input block
  132548. */
  132549. get isConnectedToInputBlock(): boolean;
  132550. /**
  132551. * Gets a the connected input block (if any)
  132552. */
  132553. get connectInputBlock(): Nullable<InputBlock>;
  132554. /** Get the other side of the connection (if any) */
  132555. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  132556. /** Get the block that owns this connection point */
  132557. get ownerBlock(): NodeMaterialBlock;
  132558. /** Get the block connected on the other side of this connection (if any) */
  132559. get sourceBlock(): Nullable<NodeMaterialBlock>;
  132560. /** Get the block connected on the endpoints of this connection (if any) */
  132561. get connectedBlocks(): Array<NodeMaterialBlock>;
  132562. /** Gets the list of connected endpoints */
  132563. get endpoints(): NodeMaterialConnectionPoint[];
  132564. /** Gets a boolean indicating if that output point is connected to at least one input */
  132565. get hasEndpoints(): boolean;
  132566. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  132567. get isConnectedInVertexShader(): boolean;
  132568. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  132569. get isConnectedInFragmentShader(): boolean;
  132570. /**
  132571. * Creates a new connection point
  132572. * @param name defines the connection point name
  132573. * @param ownerBlock defines the block hosting this connection point
  132574. * @param direction defines the direction of the connection point
  132575. */
  132576. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  132577. /**
  132578. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  132579. * @returns the class name
  132580. */
  132581. getClassName(): string;
  132582. /**
  132583. * Gets a boolean indicating if the current point can be connected to another point
  132584. * @param connectionPoint defines the other connection point
  132585. * @returns a boolean
  132586. */
  132587. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  132588. /**
  132589. * Gets a number indicating if the current point can be connected to another point
  132590. * @param connectionPoint defines the other connection point
  132591. * @returns a number defining the compatibility state
  132592. */
  132593. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  132594. /**
  132595. * Connect this point to another connection point
  132596. * @param connectionPoint defines the other connection point
  132597. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  132598. * @returns the current connection point
  132599. */
  132600. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  132601. /**
  132602. * Disconnect this point from one of his endpoint
  132603. * @param endpoint defines the other connection point
  132604. * @returns the current connection point
  132605. */
  132606. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  132607. /**
  132608. * Serializes this point in a JSON representation
  132609. * @returns the serialized point object
  132610. */
  132611. serialize(): any;
  132612. /**
  132613. * Release resources
  132614. */
  132615. dispose(): void;
  132616. }
  132617. }
  132618. declare module BABYLON {
  132619. /**
  132620. * Block used to add support for vertex skinning (bones)
  132621. */
  132622. export class BonesBlock extends NodeMaterialBlock {
  132623. /**
  132624. * Creates a new BonesBlock
  132625. * @param name defines the block name
  132626. */
  132627. constructor(name: string);
  132628. /**
  132629. * Initialize the block and prepare the context for build
  132630. * @param state defines the state that will be used for the build
  132631. */
  132632. initialize(state: NodeMaterialBuildState): void;
  132633. /**
  132634. * Gets the current class name
  132635. * @returns the class name
  132636. */
  132637. getClassName(): string;
  132638. /**
  132639. * Gets the matrix indices input component
  132640. */
  132641. get matricesIndices(): NodeMaterialConnectionPoint;
  132642. /**
  132643. * Gets the matrix weights input component
  132644. */
  132645. get matricesWeights(): NodeMaterialConnectionPoint;
  132646. /**
  132647. * Gets the extra matrix indices input component
  132648. */
  132649. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  132650. /**
  132651. * Gets the extra matrix weights input component
  132652. */
  132653. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  132654. /**
  132655. * Gets the world input component
  132656. */
  132657. get world(): NodeMaterialConnectionPoint;
  132658. /**
  132659. * Gets the output component
  132660. */
  132661. get output(): NodeMaterialConnectionPoint;
  132662. autoConfigure(material: NodeMaterial): void;
  132663. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  132664. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132666. protected _buildBlock(state: NodeMaterialBuildState): this;
  132667. }
  132668. }
  132669. declare module BABYLON {
  132670. /**
  132671. * Block used to add support for instances
  132672. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  132673. */
  132674. export class InstancesBlock extends NodeMaterialBlock {
  132675. /**
  132676. * Creates a new InstancesBlock
  132677. * @param name defines the block name
  132678. */
  132679. constructor(name: string);
  132680. /**
  132681. * Gets the current class name
  132682. * @returns the class name
  132683. */
  132684. getClassName(): string;
  132685. /**
  132686. * Gets the first world row input component
  132687. */
  132688. get world0(): NodeMaterialConnectionPoint;
  132689. /**
  132690. * Gets the second world row input component
  132691. */
  132692. get world1(): NodeMaterialConnectionPoint;
  132693. /**
  132694. * Gets the third world row input component
  132695. */
  132696. get world2(): NodeMaterialConnectionPoint;
  132697. /**
  132698. * Gets the forth world row input component
  132699. */
  132700. get world3(): NodeMaterialConnectionPoint;
  132701. /**
  132702. * Gets the world input component
  132703. */
  132704. get world(): NodeMaterialConnectionPoint;
  132705. /**
  132706. * Gets the output component
  132707. */
  132708. get output(): NodeMaterialConnectionPoint;
  132709. /**
  132710. * Gets the isntanceID component
  132711. */
  132712. get instanceID(): NodeMaterialConnectionPoint;
  132713. autoConfigure(material: NodeMaterial): void;
  132714. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132715. protected _buildBlock(state: NodeMaterialBuildState): this;
  132716. }
  132717. }
  132718. declare module BABYLON {
  132719. /**
  132720. * Block used to add morph targets support to vertex shader
  132721. */
  132722. export class MorphTargetsBlock extends NodeMaterialBlock {
  132723. private _repeatableContentAnchor;
  132724. /**
  132725. * Create a new MorphTargetsBlock
  132726. * @param name defines the block name
  132727. */
  132728. constructor(name: string);
  132729. /**
  132730. * Gets the current class name
  132731. * @returns the class name
  132732. */
  132733. getClassName(): string;
  132734. /**
  132735. * Gets the position input component
  132736. */
  132737. get position(): NodeMaterialConnectionPoint;
  132738. /**
  132739. * Gets the normal input component
  132740. */
  132741. get normal(): NodeMaterialConnectionPoint;
  132742. /**
  132743. * Gets the tangent input component
  132744. */
  132745. get tangent(): NodeMaterialConnectionPoint;
  132746. /**
  132747. * Gets the tangent input component
  132748. */
  132749. get uv(): NodeMaterialConnectionPoint;
  132750. /**
  132751. * Gets the position output component
  132752. */
  132753. get positionOutput(): NodeMaterialConnectionPoint;
  132754. /**
  132755. * Gets the normal output component
  132756. */
  132757. get normalOutput(): NodeMaterialConnectionPoint;
  132758. /**
  132759. * Gets the tangent output component
  132760. */
  132761. get tangentOutput(): NodeMaterialConnectionPoint;
  132762. /**
  132763. * Gets the tangent output component
  132764. */
  132765. get uvOutput(): NodeMaterialConnectionPoint;
  132766. initialize(state: NodeMaterialBuildState): void;
  132767. autoConfigure(material: NodeMaterial): void;
  132768. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132770. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132771. protected _buildBlock(state: NodeMaterialBuildState): this;
  132772. }
  132773. }
  132774. declare module BABYLON {
  132775. /**
  132776. * Block used to get data information from a light
  132777. */
  132778. export class LightInformationBlock extends NodeMaterialBlock {
  132779. private _lightDataUniformName;
  132780. private _lightColorUniformName;
  132781. private _lightTypeDefineName;
  132782. /**
  132783. * Gets or sets the light associated with this block
  132784. */
  132785. light: Nullable<Light>;
  132786. /**
  132787. * Creates a new LightInformationBlock
  132788. * @param name defines the block name
  132789. */
  132790. constructor(name: string);
  132791. /**
  132792. * Gets the current class name
  132793. * @returns the class name
  132794. */
  132795. getClassName(): string;
  132796. /**
  132797. * Gets the world position input component
  132798. */
  132799. get worldPosition(): NodeMaterialConnectionPoint;
  132800. /**
  132801. * Gets the direction output component
  132802. */
  132803. get direction(): NodeMaterialConnectionPoint;
  132804. /**
  132805. * Gets the direction output component
  132806. */
  132807. get color(): NodeMaterialConnectionPoint;
  132808. /**
  132809. * Gets the direction output component
  132810. */
  132811. get intensity(): NodeMaterialConnectionPoint;
  132812. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132813. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132814. protected _buildBlock(state: NodeMaterialBuildState): this;
  132815. serialize(): any;
  132816. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132817. }
  132818. }
  132819. declare module BABYLON {
  132820. /**
  132821. * Block used to add image processing support to fragment shader
  132822. */
  132823. export class ImageProcessingBlock extends NodeMaterialBlock {
  132824. /**
  132825. * Create a new ImageProcessingBlock
  132826. * @param name defines the block name
  132827. */
  132828. constructor(name: string);
  132829. /**
  132830. * Gets the current class name
  132831. * @returns the class name
  132832. */
  132833. getClassName(): string;
  132834. /**
  132835. * Gets the color input component
  132836. */
  132837. get color(): NodeMaterialConnectionPoint;
  132838. /**
  132839. * Gets the output component
  132840. */
  132841. get output(): NodeMaterialConnectionPoint;
  132842. /**
  132843. * Initialize the block and prepare the context for build
  132844. * @param state defines the state that will be used for the build
  132845. */
  132846. initialize(state: NodeMaterialBuildState): void;
  132847. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  132848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132850. protected _buildBlock(state: NodeMaterialBuildState): this;
  132851. }
  132852. }
  132853. declare module BABYLON {
  132854. /**
  132855. * Block used to pertub normals based on a normal map
  132856. */
  132857. export class PerturbNormalBlock extends NodeMaterialBlock {
  132858. private _tangentSpaceParameterName;
  132859. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  132860. invertX: boolean;
  132861. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  132862. invertY: boolean;
  132863. /**
  132864. * Create a new PerturbNormalBlock
  132865. * @param name defines the block name
  132866. */
  132867. constructor(name: string);
  132868. /**
  132869. * Gets the current class name
  132870. * @returns the class name
  132871. */
  132872. getClassName(): string;
  132873. /**
  132874. * Gets the world position input component
  132875. */
  132876. get worldPosition(): NodeMaterialConnectionPoint;
  132877. /**
  132878. * Gets the world normal input component
  132879. */
  132880. get worldNormal(): NodeMaterialConnectionPoint;
  132881. /**
  132882. * Gets the world tangent input component
  132883. */
  132884. get worldTangent(): NodeMaterialConnectionPoint;
  132885. /**
  132886. * Gets the uv input component
  132887. */
  132888. get uv(): NodeMaterialConnectionPoint;
  132889. /**
  132890. * Gets the normal map color input component
  132891. */
  132892. get normalMapColor(): NodeMaterialConnectionPoint;
  132893. /**
  132894. * Gets the strength input component
  132895. */
  132896. get strength(): NodeMaterialConnectionPoint;
  132897. /**
  132898. * Gets the output component
  132899. */
  132900. get output(): NodeMaterialConnectionPoint;
  132901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132903. autoConfigure(material: NodeMaterial): void;
  132904. protected _buildBlock(state: NodeMaterialBuildState): this;
  132905. protected _dumpPropertiesCode(): string;
  132906. serialize(): any;
  132907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132908. }
  132909. }
  132910. declare module BABYLON {
  132911. /**
  132912. * Block used to discard a pixel if a value is smaller than a cutoff
  132913. */
  132914. export class DiscardBlock extends NodeMaterialBlock {
  132915. /**
  132916. * Create a new DiscardBlock
  132917. * @param name defines the block name
  132918. */
  132919. constructor(name: string);
  132920. /**
  132921. * Gets the current class name
  132922. * @returns the class name
  132923. */
  132924. getClassName(): string;
  132925. /**
  132926. * Gets the color input component
  132927. */
  132928. get value(): NodeMaterialConnectionPoint;
  132929. /**
  132930. * Gets the cutoff input component
  132931. */
  132932. get cutoff(): NodeMaterialConnectionPoint;
  132933. protected _buildBlock(state: NodeMaterialBuildState): this;
  132934. }
  132935. }
  132936. declare module BABYLON {
  132937. /**
  132938. * Block used to test if the fragment shader is front facing
  132939. */
  132940. export class FrontFacingBlock extends NodeMaterialBlock {
  132941. /**
  132942. * Creates a new FrontFacingBlock
  132943. * @param name defines the block name
  132944. */
  132945. constructor(name: string);
  132946. /**
  132947. * Gets the current class name
  132948. * @returns the class name
  132949. */
  132950. getClassName(): string;
  132951. /**
  132952. * Gets the output component
  132953. */
  132954. get output(): NodeMaterialConnectionPoint;
  132955. protected _buildBlock(state: NodeMaterialBuildState): this;
  132956. }
  132957. }
  132958. declare module BABYLON {
  132959. /**
  132960. * Block used to get the derivative value on x and y of a given input
  132961. */
  132962. export class DerivativeBlock extends NodeMaterialBlock {
  132963. /**
  132964. * Create a new DerivativeBlock
  132965. * @param name defines the block name
  132966. */
  132967. constructor(name: string);
  132968. /**
  132969. * Gets the current class name
  132970. * @returns the class name
  132971. */
  132972. getClassName(): string;
  132973. /**
  132974. * Gets the input component
  132975. */
  132976. get input(): NodeMaterialConnectionPoint;
  132977. /**
  132978. * Gets the derivative output on x
  132979. */
  132980. get dx(): NodeMaterialConnectionPoint;
  132981. /**
  132982. * Gets the derivative output on y
  132983. */
  132984. get dy(): NodeMaterialConnectionPoint;
  132985. protected _buildBlock(state: NodeMaterialBuildState): this;
  132986. }
  132987. }
  132988. declare module BABYLON {
  132989. /**
  132990. * Block used to add support for scene fog
  132991. */
  132992. export class FogBlock extends NodeMaterialBlock {
  132993. private _fogDistanceName;
  132994. private _fogParameters;
  132995. /**
  132996. * Create a new FogBlock
  132997. * @param name defines the block name
  132998. */
  132999. constructor(name: string);
  133000. /**
  133001. * Gets the current class name
  133002. * @returns the class name
  133003. */
  133004. getClassName(): string;
  133005. /**
  133006. * Gets the world position input component
  133007. */
  133008. get worldPosition(): NodeMaterialConnectionPoint;
  133009. /**
  133010. * Gets the view input component
  133011. */
  133012. get view(): NodeMaterialConnectionPoint;
  133013. /**
  133014. * Gets the color input component
  133015. */
  133016. get input(): NodeMaterialConnectionPoint;
  133017. /**
  133018. * Gets the fog color input component
  133019. */
  133020. get fogColor(): NodeMaterialConnectionPoint;
  133021. /**
  133022. * Gets the output component
  133023. */
  133024. get output(): NodeMaterialConnectionPoint;
  133025. autoConfigure(material: NodeMaterial): void;
  133026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133027. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133028. protected _buildBlock(state: NodeMaterialBuildState): this;
  133029. }
  133030. }
  133031. declare module BABYLON {
  133032. /**
  133033. * Block used to add light in the fragment shader
  133034. */
  133035. export class LightBlock extends NodeMaterialBlock {
  133036. private _lightId;
  133037. /**
  133038. * Gets or sets the light associated with this block
  133039. */
  133040. light: Nullable<Light>;
  133041. /**
  133042. * Create a new LightBlock
  133043. * @param name defines the block name
  133044. */
  133045. constructor(name: string);
  133046. /**
  133047. * Gets the current class name
  133048. * @returns the class name
  133049. */
  133050. getClassName(): string;
  133051. /**
  133052. * Gets the world position input component
  133053. */
  133054. get worldPosition(): NodeMaterialConnectionPoint;
  133055. /**
  133056. * Gets the world normal input component
  133057. */
  133058. get worldNormal(): NodeMaterialConnectionPoint;
  133059. /**
  133060. * Gets the camera (or eye) position component
  133061. */
  133062. get cameraPosition(): NodeMaterialConnectionPoint;
  133063. /**
  133064. * Gets the glossiness component
  133065. */
  133066. get glossiness(): NodeMaterialConnectionPoint;
  133067. /**
  133068. * Gets the glossinness power component
  133069. */
  133070. get glossPower(): NodeMaterialConnectionPoint;
  133071. /**
  133072. * Gets the diffuse color component
  133073. */
  133074. get diffuseColor(): NodeMaterialConnectionPoint;
  133075. /**
  133076. * Gets the specular color component
  133077. */
  133078. get specularColor(): NodeMaterialConnectionPoint;
  133079. /**
  133080. * Gets the diffuse output component
  133081. */
  133082. get diffuseOutput(): NodeMaterialConnectionPoint;
  133083. /**
  133084. * Gets the specular output component
  133085. */
  133086. get specularOutput(): NodeMaterialConnectionPoint;
  133087. /**
  133088. * Gets the shadow output component
  133089. */
  133090. get shadow(): NodeMaterialConnectionPoint;
  133091. autoConfigure(material: NodeMaterial): void;
  133092. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133093. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  133094. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133095. private _injectVertexCode;
  133096. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133097. serialize(): any;
  133098. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133099. }
  133100. }
  133101. declare module BABYLON {
  133102. /**
  133103. * Block used to multiply 2 values
  133104. */
  133105. export class MultiplyBlock extends NodeMaterialBlock {
  133106. /**
  133107. * Creates a new MultiplyBlock
  133108. * @param name defines the block name
  133109. */
  133110. constructor(name: string);
  133111. /**
  133112. * Gets the current class name
  133113. * @returns the class name
  133114. */
  133115. getClassName(): string;
  133116. /**
  133117. * Gets the left operand input component
  133118. */
  133119. get left(): NodeMaterialConnectionPoint;
  133120. /**
  133121. * Gets the right operand input component
  133122. */
  133123. get right(): NodeMaterialConnectionPoint;
  133124. /**
  133125. * Gets the output component
  133126. */
  133127. get output(): NodeMaterialConnectionPoint;
  133128. protected _buildBlock(state: NodeMaterialBuildState): this;
  133129. }
  133130. }
  133131. declare module BABYLON {
  133132. /**
  133133. * Block used to add 2 vectors
  133134. */
  133135. export class AddBlock extends NodeMaterialBlock {
  133136. /**
  133137. * Creates a new AddBlock
  133138. * @param name defines the block name
  133139. */
  133140. constructor(name: string);
  133141. /**
  133142. * Gets the current class name
  133143. * @returns the class name
  133144. */
  133145. getClassName(): string;
  133146. /**
  133147. * Gets the left operand input component
  133148. */
  133149. get left(): NodeMaterialConnectionPoint;
  133150. /**
  133151. * Gets the right operand input component
  133152. */
  133153. get right(): NodeMaterialConnectionPoint;
  133154. /**
  133155. * Gets the output component
  133156. */
  133157. get output(): NodeMaterialConnectionPoint;
  133158. protected _buildBlock(state: NodeMaterialBuildState): this;
  133159. }
  133160. }
  133161. declare module BABYLON {
  133162. /**
  133163. * Block used to scale a vector by a float
  133164. */
  133165. export class ScaleBlock extends NodeMaterialBlock {
  133166. /**
  133167. * Creates a new ScaleBlock
  133168. * @param name defines the block name
  133169. */
  133170. constructor(name: string);
  133171. /**
  133172. * Gets the current class name
  133173. * @returns the class name
  133174. */
  133175. getClassName(): string;
  133176. /**
  133177. * Gets the input component
  133178. */
  133179. get input(): NodeMaterialConnectionPoint;
  133180. /**
  133181. * Gets the factor input component
  133182. */
  133183. get factor(): NodeMaterialConnectionPoint;
  133184. /**
  133185. * Gets the output component
  133186. */
  133187. get output(): NodeMaterialConnectionPoint;
  133188. protected _buildBlock(state: NodeMaterialBuildState): this;
  133189. }
  133190. }
  133191. declare module BABYLON {
  133192. /**
  133193. * Block used to clamp a float
  133194. */
  133195. export class ClampBlock extends NodeMaterialBlock {
  133196. /** Gets or sets the minimum range */
  133197. minimum: number;
  133198. /** Gets or sets the maximum range */
  133199. maximum: number;
  133200. /**
  133201. * Creates a new ClampBlock
  133202. * @param name defines the block name
  133203. */
  133204. constructor(name: string);
  133205. /**
  133206. * Gets the current class name
  133207. * @returns the class name
  133208. */
  133209. getClassName(): string;
  133210. /**
  133211. * Gets the value input component
  133212. */
  133213. get value(): NodeMaterialConnectionPoint;
  133214. /**
  133215. * Gets the output component
  133216. */
  133217. get output(): NodeMaterialConnectionPoint;
  133218. protected _buildBlock(state: NodeMaterialBuildState): this;
  133219. protected _dumpPropertiesCode(): string;
  133220. serialize(): any;
  133221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133222. }
  133223. }
  133224. declare module BABYLON {
  133225. /**
  133226. * Block used to apply a cross product between 2 vectors
  133227. */
  133228. export class CrossBlock extends NodeMaterialBlock {
  133229. /**
  133230. * Creates a new CrossBlock
  133231. * @param name defines the block name
  133232. */
  133233. constructor(name: string);
  133234. /**
  133235. * Gets the current class name
  133236. * @returns the class name
  133237. */
  133238. getClassName(): string;
  133239. /**
  133240. * Gets the left operand input component
  133241. */
  133242. get left(): NodeMaterialConnectionPoint;
  133243. /**
  133244. * Gets the right operand input component
  133245. */
  133246. get right(): NodeMaterialConnectionPoint;
  133247. /**
  133248. * Gets the output component
  133249. */
  133250. get output(): NodeMaterialConnectionPoint;
  133251. protected _buildBlock(state: NodeMaterialBuildState): this;
  133252. }
  133253. }
  133254. declare module BABYLON {
  133255. /**
  133256. * Block used to apply a dot product between 2 vectors
  133257. */
  133258. export class DotBlock extends NodeMaterialBlock {
  133259. /**
  133260. * Creates a new DotBlock
  133261. * @param name defines the block name
  133262. */
  133263. constructor(name: string);
  133264. /**
  133265. * Gets the current class name
  133266. * @returns the class name
  133267. */
  133268. getClassName(): string;
  133269. /**
  133270. * Gets the left operand input component
  133271. */
  133272. get left(): NodeMaterialConnectionPoint;
  133273. /**
  133274. * Gets the right operand input component
  133275. */
  133276. get right(): NodeMaterialConnectionPoint;
  133277. /**
  133278. * Gets the output component
  133279. */
  133280. get output(): NodeMaterialConnectionPoint;
  133281. protected _buildBlock(state: NodeMaterialBuildState): this;
  133282. }
  133283. }
  133284. declare module BABYLON {
  133285. /**
  133286. * Block used to remap a float from a range to a new one
  133287. */
  133288. export class RemapBlock extends NodeMaterialBlock {
  133289. /**
  133290. * Gets or sets the source range
  133291. */
  133292. sourceRange: Vector2;
  133293. /**
  133294. * Gets or sets the target range
  133295. */
  133296. targetRange: Vector2;
  133297. /**
  133298. * Creates a new RemapBlock
  133299. * @param name defines the block name
  133300. */
  133301. constructor(name: string);
  133302. /**
  133303. * Gets the current class name
  133304. * @returns the class name
  133305. */
  133306. getClassName(): string;
  133307. /**
  133308. * Gets the input component
  133309. */
  133310. get input(): NodeMaterialConnectionPoint;
  133311. /**
  133312. * Gets the source min input component
  133313. */
  133314. get sourceMin(): NodeMaterialConnectionPoint;
  133315. /**
  133316. * Gets the source max input component
  133317. */
  133318. get sourceMax(): NodeMaterialConnectionPoint;
  133319. /**
  133320. * Gets the target min input component
  133321. */
  133322. get targetMin(): NodeMaterialConnectionPoint;
  133323. /**
  133324. * Gets the target max input component
  133325. */
  133326. get targetMax(): NodeMaterialConnectionPoint;
  133327. /**
  133328. * Gets the output component
  133329. */
  133330. get output(): NodeMaterialConnectionPoint;
  133331. protected _buildBlock(state: NodeMaterialBuildState): this;
  133332. protected _dumpPropertiesCode(): string;
  133333. serialize(): any;
  133334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133335. }
  133336. }
  133337. declare module BABYLON {
  133338. /**
  133339. * Block used to normalize a vector
  133340. */
  133341. export class NormalizeBlock extends NodeMaterialBlock {
  133342. /**
  133343. * Creates a new NormalizeBlock
  133344. * @param name defines the block name
  133345. */
  133346. constructor(name: string);
  133347. /**
  133348. * Gets the current class name
  133349. * @returns the class name
  133350. */
  133351. getClassName(): string;
  133352. /**
  133353. * Gets the input component
  133354. */
  133355. get input(): NodeMaterialConnectionPoint;
  133356. /**
  133357. * Gets the output component
  133358. */
  133359. get output(): NodeMaterialConnectionPoint;
  133360. protected _buildBlock(state: NodeMaterialBuildState): this;
  133361. }
  133362. }
  133363. declare module BABYLON {
  133364. /**
  133365. * Operations supported by the Trigonometry block
  133366. */
  133367. export enum TrigonometryBlockOperations {
  133368. /** Cos */
  133369. Cos = 0,
  133370. /** Sin */
  133371. Sin = 1,
  133372. /** Abs */
  133373. Abs = 2,
  133374. /** Exp */
  133375. Exp = 3,
  133376. /** Exp2 */
  133377. Exp2 = 4,
  133378. /** Round */
  133379. Round = 5,
  133380. /** Floor */
  133381. Floor = 6,
  133382. /** Ceiling */
  133383. Ceiling = 7,
  133384. /** Square root */
  133385. Sqrt = 8,
  133386. /** Log */
  133387. Log = 9,
  133388. /** Tangent */
  133389. Tan = 10,
  133390. /** Arc tangent */
  133391. ArcTan = 11,
  133392. /** Arc cosinus */
  133393. ArcCos = 12,
  133394. /** Arc sinus */
  133395. ArcSin = 13,
  133396. /** Fraction */
  133397. Fract = 14,
  133398. /** Sign */
  133399. Sign = 15,
  133400. /** To radians (from degrees) */
  133401. Radians = 16,
  133402. /** To degrees (from radians) */
  133403. Degrees = 17
  133404. }
  133405. /**
  133406. * Block used to apply trigonometry operation to floats
  133407. */
  133408. export class TrigonometryBlock extends NodeMaterialBlock {
  133409. /**
  133410. * Gets or sets the operation applied by the block
  133411. */
  133412. operation: TrigonometryBlockOperations;
  133413. /**
  133414. * Creates a new TrigonometryBlock
  133415. * @param name defines the block name
  133416. */
  133417. constructor(name: string);
  133418. /**
  133419. * Gets the current class name
  133420. * @returns the class name
  133421. */
  133422. getClassName(): string;
  133423. /**
  133424. * Gets the input component
  133425. */
  133426. get input(): NodeMaterialConnectionPoint;
  133427. /**
  133428. * Gets the output component
  133429. */
  133430. get output(): NodeMaterialConnectionPoint;
  133431. protected _buildBlock(state: NodeMaterialBuildState): this;
  133432. serialize(): any;
  133433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133434. protected _dumpPropertiesCode(): string;
  133435. }
  133436. }
  133437. declare module BABYLON {
  133438. /**
  133439. * Block used to create a Color3/4 out of individual inputs (one for each component)
  133440. */
  133441. export class ColorMergerBlock extends NodeMaterialBlock {
  133442. /**
  133443. * Create a new ColorMergerBlock
  133444. * @param name defines the block name
  133445. */
  133446. constructor(name: string);
  133447. /**
  133448. * Gets the current class name
  133449. * @returns the class name
  133450. */
  133451. getClassName(): string;
  133452. /**
  133453. * Gets the rgb component (input)
  133454. */
  133455. get rgbIn(): NodeMaterialConnectionPoint;
  133456. /**
  133457. * Gets the r component (input)
  133458. */
  133459. get r(): NodeMaterialConnectionPoint;
  133460. /**
  133461. * Gets the g component (input)
  133462. */
  133463. get g(): NodeMaterialConnectionPoint;
  133464. /**
  133465. * Gets the b component (input)
  133466. */
  133467. get b(): NodeMaterialConnectionPoint;
  133468. /**
  133469. * Gets the a component (input)
  133470. */
  133471. get a(): NodeMaterialConnectionPoint;
  133472. /**
  133473. * Gets the rgba component (output)
  133474. */
  133475. get rgba(): NodeMaterialConnectionPoint;
  133476. /**
  133477. * Gets the rgb component (output)
  133478. */
  133479. get rgbOut(): NodeMaterialConnectionPoint;
  133480. /**
  133481. * Gets the rgb component (output)
  133482. * @deprecated Please use rgbOut instead.
  133483. */
  133484. get rgb(): NodeMaterialConnectionPoint;
  133485. protected _buildBlock(state: NodeMaterialBuildState): this;
  133486. }
  133487. }
  133488. declare module BABYLON {
  133489. /**
  133490. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  133491. */
  133492. export class VectorMergerBlock extends NodeMaterialBlock {
  133493. /**
  133494. * Create a new VectorMergerBlock
  133495. * @param name defines the block name
  133496. */
  133497. constructor(name: string);
  133498. /**
  133499. * Gets the current class name
  133500. * @returns the class name
  133501. */
  133502. getClassName(): string;
  133503. /**
  133504. * Gets the xyz component (input)
  133505. */
  133506. get xyzIn(): NodeMaterialConnectionPoint;
  133507. /**
  133508. * Gets the xy component (input)
  133509. */
  133510. get xyIn(): NodeMaterialConnectionPoint;
  133511. /**
  133512. * Gets the x component (input)
  133513. */
  133514. get x(): NodeMaterialConnectionPoint;
  133515. /**
  133516. * Gets the y component (input)
  133517. */
  133518. get y(): NodeMaterialConnectionPoint;
  133519. /**
  133520. * Gets the z component (input)
  133521. */
  133522. get z(): NodeMaterialConnectionPoint;
  133523. /**
  133524. * Gets the w component (input)
  133525. */
  133526. get w(): NodeMaterialConnectionPoint;
  133527. /**
  133528. * Gets the xyzw component (output)
  133529. */
  133530. get xyzw(): NodeMaterialConnectionPoint;
  133531. /**
  133532. * Gets the xyz component (output)
  133533. */
  133534. get xyzOut(): NodeMaterialConnectionPoint;
  133535. /**
  133536. * Gets the xy component (output)
  133537. */
  133538. get xyOut(): NodeMaterialConnectionPoint;
  133539. /**
  133540. * Gets the xy component (output)
  133541. * @deprecated Please use xyOut instead.
  133542. */
  133543. get xy(): NodeMaterialConnectionPoint;
  133544. /**
  133545. * Gets the xyz component (output)
  133546. * @deprecated Please use xyzOut instead.
  133547. */
  133548. get xyz(): NodeMaterialConnectionPoint;
  133549. protected _buildBlock(state: NodeMaterialBuildState): this;
  133550. }
  133551. }
  133552. declare module BABYLON {
  133553. /**
  133554. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  133555. */
  133556. export class ColorSplitterBlock extends NodeMaterialBlock {
  133557. /**
  133558. * Create a new ColorSplitterBlock
  133559. * @param name defines the block name
  133560. */
  133561. constructor(name: string);
  133562. /**
  133563. * Gets the current class name
  133564. * @returns the class name
  133565. */
  133566. getClassName(): string;
  133567. /**
  133568. * Gets the rgba component (input)
  133569. */
  133570. get rgba(): NodeMaterialConnectionPoint;
  133571. /**
  133572. * Gets the rgb component (input)
  133573. */
  133574. get rgbIn(): NodeMaterialConnectionPoint;
  133575. /**
  133576. * Gets the rgb component (output)
  133577. */
  133578. get rgbOut(): NodeMaterialConnectionPoint;
  133579. /**
  133580. * Gets the r component (output)
  133581. */
  133582. get r(): NodeMaterialConnectionPoint;
  133583. /**
  133584. * Gets the g component (output)
  133585. */
  133586. get g(): NodeMaterialConnectionPoint;
  133587. /**
  133588. * Gets the b component (output)
  133589. */
  133590. get b(): NodeMaterialConnectionPoint;
  133591. /**
  133592. * Gets the a component (output)
  133593. */
  133594. get a(): NodeMaterialConnectionPoint;
  133595. protected _inputRename(name: string): string;
  133596. protected _outputRename(name: string): string;
  133597. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133598. }
  133599. }
  133600. declare module BABYLON {
  133601. /**
  133602. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  133603. */
  133604. export class VectorSplitterBlock extends NodeMaterialBlock {
  133605. /**
  133606. * Create a new VectorSplitterBlock
  133607. * @param name defines the block name
  133608. */
  133609. constructor(name: string);
  133610. /**
  133611. * Gets the current class name
  133612. * @returns the class name
  133613. */
  133614. getClassName(): string;
  133615. /**
  133616. * Gets the xyzw component (input)
  133617. */
  133618. get xyzw(): NodeMaterialConnectionPoint;
  133619. /**
  133620. * Gets the xyz component (input)
  133621. */
  133622. get xyzIn(): NodeMaterialConnectionPoint;
  133623. /**
  133624. * Gets the xy component (input)
  133625. */
  133626. get xyIn(): NodeMaterialConnectionPoint;
  133627. /**
  133628. * Gets the xyz component (output)
  133629. */
  133630. get xyzOut(): NodeMaterialConnectionPoint;
  133631. /**
  133632. * Gets the xy component (output)
  133633. */
  133634. get xyOut(): NodeMaterialConnectionPoint;
  133635. /**
  133636. * Gets the x component (output)
  133637. */
  133638. get x(): NodeMaterialConnectionPoint;
  133639. /**
  133640. * Gets the y component (output)
  133641. */
  133642. get y(): NodeMaterialConnectionPoint;
  133643. /**
  133644. * Gets the z component (output)
  133645. */
  133646. get z(): NodeMaterialConnectionPoint;
  133647. /**
  133648. * Gets the w component (output)
  133649. */
  133650. get w(): NodeMaterialConnectionPoint;
  133651. protected _inputRename(name: string): string;
  133652. protected _outputRename(name: string): string;
  133653. protected _buildBlock(state: NodeMaterialBuildState): this;
  133654. }
  133655. }
  133656. declare module BABYLON {
  133657. /**
  133658. * Block used to lerp between 2 values
  133659. */
  133660. export class LerpBlock extends NodeMaterialBlock {
  133661. /**
  133662. * Creates a new LerpBlock
  133663. * @param name defines the block name
  133664. */
  133665. constructor(name: string);
  133666. /**
  133667. * Gets the current class name
  133668. * @returns the class name
  133669. */
  133670. getClassName(): string;
  133671. /**
  133672. * Gets the left operand input component
  133673. */
  133674. get left(): NodeMaterialConnectionPoint;
  133675. /**
  133676. * Gets the right operand input component
  133677. */
  133678. get right(): NodeMaterialConnectionPoint;
  133679. /**
  133680. * Gets the gradient operand input component
  133681. */
  133682. get gradient(): NodeMaterialConnectionPoint;
  133683. /**
  133684. * Gets the output component
  133685. */
  133686. get output(): NodeMaterialConnectionPoint;
  133687. protected _buildBlock(state: NodeMaterialBuildState): this;
  133688. }
  133689. }
  133690. declare module BABYLON {
  133691. /**
  133692. * Block used to divide 2 vectors
  133693. */
  133694. export class DivideBlock extends NodeMaterialBlock {
  133695. /**
  133696. * Creates a new DivideBlock
  133697. * @param name defines the block name
  133698. */
  133699. constructor(name: string);
  133700. /**
  133701. * Gets the current class name
  133702. * @returns the class name
  133703. */
  133704. getClassName(): string;
  133705. /**
  133706. * Gets the left operand input component
  133707. */
  133708. get left(): NodeMaterialConnectionPoint;
  133709. /**
  133710. * Gets the right operand input component
  133711. */
  133712. get right(): NodeMaterialConnectionPoint;
  133713. /**
  133714. * Gets the output component
  133715. */
  133716. get output(): NodeMaterialConnectionPoint;
  133717. protected _buildBlock(state: NodeMaterialBuildState): this;
  133718. }
  133719. }
  133720. declare module BABYLON {
  133721. /**
  133722. * Block used to subtract 2 vectors
  133723. */
  133724. export class SubtractBlock extends NodeMaterialBlock {
  133725. /**
  133726. * Creates a new SubtractBlock
  133727. * @param name defines the block name
  133728. */
  133729. constructor(name: string);
  133730. /**
  133731. * Gets the current class name
  133732. * @returns the class name
  133733. */
  133734. getClassName(): string;
  133735. /**
  133736. * Gets the left operand input component
  133737. */
  133738. get left(): NodeMaterialConnectionPoint;
  133739. /**
  133740. * Gets the right operand input component
  133741. */
  133742. get right(): NodeMaterialConnectionPoint;
  133743. /**
  133744. * Gets the output component
  133745. */
  133746. get output(): NodeMaterialConnectionPoint;
  133747. protected _buildBlock(state: NodeMaterialBuildState): this;
  133748. }
  133749. }
  133750. declare module BABYLON {
  133751. /**
  133752. * Block used to step a value
  133753. */
  133754. export class StepBlock extends NodeMaterialBlock {
  133755. /**
  133756. * Creates a new StepBlock
  133757. * @param name defines the block name
  133758. */
  133759. constructor(name: string);
  133760. /**
  133761. * Gets the current class name
  133762. * @returns the class name
  133763. */
  133764. getClassName(): string;
  133765. /**
  133766. * Gets the value operand input component
  133767. */
  133768. get value(): NodeMaterialConnectionPoint;
  133769. /**
  133770. * Gets the edge operand input component
  133771. */
  133772. get edge(): NodeMaterialConnectionPoint;
  133773. /**
  133774. * Gets the output component
  133775. */
  133776. get output(): NodeMaterialConnectionPoint;
  133777. protected _buildBlock(state: NodeMaterialBuildState): this;
  133778. }
  133779. }
  133780. declare module BABYLON {
  133781. /**
  133782. * Block used to get the opposite (1 - x) of a value
  133783. */
  133784. export class OneMinusBlock extends NodeMaterialBlock {
  133785. /**
  133786. * Creates a new OneMinusBlock
  133787. * @param name defines the block name
  133788. */
  133789. constructor(name: string);
  133790. /**
  133791. * Gets the current class name
  133792. * @returns the class name
  133793. */
  133794. getClassName(): string;
  133795. /**
  133796. * Gets the input component
  133797. */
  133798. get input(): NodeMaterialConnectionPoint;
  133799. /**
  133800. * Gets the output component
  133801. */
  133802. get output(): NodeMaterialConnectionPoint;
  133803. protected _buildBlock(state: NodeMaterialBuildState): this;
  133804. }
  133805. }
  133806. declare module BABYLON {
  133807. /**
  133808. * Block used to get the view direction
  133809. */
  133810. export class ViewDirectionBlock extends NodeMaterialBlock {
  133811. /**
  133812. * Creates a new ViewDirectionBlock
  133813. * @param name defines the block name
  133814. */
  133815. constructor(name: string);
  133816. /**
  133817. * Gets the current class name
  133818. * @returns the class name
  133819. */
  133820. getClassName(): string;
  133821. /**
  133822. * Gets the world position component
  133823. */
  133824. get worldPosition(): NodeMaterialConnectionPoint;
  133825. /**
  133826. * Gets the camera position component
  133827. */
  133828. get cameraPosition(): NodeMaterialConnectionPoint;
  133829. /**
  133830. * Gets the output component
  133831. */
  133832. get output(): NodeMaterialConnectionPoint;
  133833. autoConfigure(material: NodeMaterial): void;
  133834. protected _buildBlock(state: NodeMaterialBuildState): this;
  133835. }
  133836. }
  133837. declare module BABYLON {
  133838. /**
  133839. * Block used to compute fresnel value
  133840. */
  133841. export class FresnelBlock extends NodeMaterialBlock {
  133842. /**
  133843. * Create a new FresnelBlock
  133844. * @param name defines the block name
  133845. */
  133846. constructor(name: string);
  133847. /**
  133848. * Gets the current class name
  133849. * @returns the class name
  133850. */
  133851. getClassName(): string;
  133852. /**
  133853. * Gets the world normal input component
  133854. */
  133855. get worldNormal(): NodeMaterialConnectionPoint;
  133856. /**
  133857. * Gets the view direction input component
  133858. */
  133859. get viewDirection(): NodeMaterialConnectionPoint;
  133860. /**
  133861. * Gets the bias input component
  133862. */
  133863. get bias(): NodeMaterialConnectionPoint;
  133864. /**
  133865. * Gets the camera (or eye) position component
  133866. */
  133867. get power(): NodeMaterialConnectionPoint;
  133868. /**
  133869. * Gets the fresnel output component
  133870. */
  133871. get fresnel(): NodeMaterialConnectionPoint;
  133872. autoConfigure(material: NodeMaterial): void;
  133873. protected _buildBlock(state: NodeMaterialBuildState): this;
  133874. }
  133875. }
  133876. declare module BABYLON {
  133877. /**
  133878. * Block used to get the max of 2 values
  133879. */
  133880. export class MaxBlock extends NodeMaterialBlock {
  133881. /**
  133882. * Creates a new MaxBlock
  133883. * @param name defines the block name
  133884. */
  133885. constructor(name: string);
  133886. /**
  133887. * Gets the current class name
  133888. * @returns the class name
  133889. */
  133890. getClassName(): string;
  133891. /**
  133892. * Gets the left operand input component
  133893. */
  133894. get left(): NodeMaterialConnectionPoint;
  133895. /**
  133896. * Gets the right operand input component
  133897. */
  133898. get right(): NodeMaterialConnectionPoint;
  133899. /**
  133900. * Gets the output component
  133901. */
  133902. get output(): NodeMaterialConnectionPoint;
  133903. protected _buildBlock(state: NodeMaterialBuildState): this;
  133904. }
  133905. }
  133906. declare module BABYLON {
  133907. /**
  133908. * Block used to get the min of 2 values
  133909. */
  133910. export class MinBlock extends NodeMaterialBlock {
  133911. /**
  133912. * Creates a new MinBlock
  133913. * @param name defines the block name
  133914. */
  133915. constructor(name: string);
  133916. /**
  133917. * Gets the current class name
  133918. * @returns the class name
  133919. */
  133920. getClassName(): string;
  133921. /**
  133922. * Gets the left operand input component
  133923. */
  133924. get left(): NodeMaterialConnectionPoint;
  133925. /**
  133926. * Gets the right operand input component
  133927. */
  133928. get right(): NodeMaterialConnectionPoint;
  133929. /**
  133930. * Gets the output component
  133931. */
  133932. get output(): NodeMaterialConnectionPoint;
  133933. protected _buildBlock(state: NodeMaterialBuildState): this;
  133934. }
  133935. }
  133936. declare module BABYLON {
  133937. /**
  133938. * Block used to get the distance between 2 values
  133939. */
  133940. export class DistanceBlock extends NodeMaterialBlock {
  133941. /**
  133942. * Creates a new DistanceBlock
  133943. * @param name defines the block name
  133944. */
  133945. constructor(name: string);
  133946. /**
  133947. * Gets the current class name
  133948. * @returns the class name
  133949. */
  133950. getClassName(): string;
  133951. /**
  133952. * Gets the left operand input component
  133953. */
  133954. get left(): NodeMaterialConnectionPoint;
  133955. /**
  133956. * Gets the right operand input component
  133957. */
  133958. get right(): NodeMaterialConnectionPoint;
  133959. /**
  133960. * Gets the output component
  133961. */
  133962. get output(): NodeMaterialConnectionPoint;
  133963. protected _buildBlock(state: NodeMaterialBuildState): this;
  133964. }
  133965. }
  133966. declare module BABYLON {
  133967. /**
  133968. * Block used to get the length of a vector
  133969. */
  133970. export class LengthBlock extends NodeMaterialBlock {
  133971. /**
  133972. * Creates a new LengthBlock
  133973. * @param name defines the block name
  133974. */
  133975. constructor(name: string);
  133976. /**
  133977. * Gets the current class name
  133978. * @returns the class name
  133979. */
  133980. getClassName(): string;
  133981. /**
  133982. * Gets the value input component
  133983. */
  133984. get value(): NodeMaterialConnectionPoint;
  133985. /**
  133986. * Gets the output component
  133987. */
  133988. get output(): NodeMaterialConnectionPoint;
  133989. protected _buildBlock(state: NodeMaterialBuildState): this;
  133990. }
  133991. }
  133992. declare module BABYLON {
  133993. /**
  133994. * Block used to get negative version of a value (i.e. x * -1)
  133995. */
  133996. export class NegateBlock extends NodeMaterialBlock {
  133997. /**
  133998. * Creates a new NegateBlock
  133999. * @param name defines the block name
  134000. */
  134001. constructor(name: string);
  134002. /**
  134003. * Gets the current class name
  134004. * @returns the class name
  134005. */
  134006. getClassName(): string;
  134007. /**
  134008. * Gets the value input component
  134009. */
  134010. get value(): NodeMaterialConnectionPoint;
  134011. /**
  134012. * Gets the output component
  134013. */
  134014. get output(): NodeMaterialConnectionPoint;
  134015. protected _buildBlock(state: NodeMaterialBuildState): this;
  134016. }
  134017. }
  134018. declare module BABYLON {
  134019. /**
  134020. * Block used to get the value of the first parameter raised to the power of the second
  134021. */
  134022. export class PowBlock extends NodeMaterialBlock {
  134023. /**
  134024. * Creates a new PowBlock
  134025. * @param name defines the block name
  134026. */
  134027. constructor(name: string);
  134028. /**
  134029. * Gets the current class name
  134030. * @returns the class name
  134031. */
  134032. getClassName(): string;
  134033. /**
  134034. * Gets the value operand input component
  134035. */
  134036. get value(): NodeMaterialConnectionPoint;
  134037. /**
  134038. * Gets the power operand input component
  134039. */
  134040. get power(): NodeMaterialConnectionPoint;
  134041. /**
  134042. * Gets the output component
  134043. */
  134044. get output(): NodeMaterialConnectionPoint;
  134045. protected _buildBlock(state: NodeMaterialBuildState): this;
  134046. }
  134047. }
  134048. declare module BABYLON {
  134049. /**
  134050. * Block used to get a random number
  134051. */
  134052. export class RandomNumberBlock extends NodeMaterialBlock {
  134053. /**
  134054. * Creates a new RandomNumberBlock
  134055. * @param name defines the block name
  134056. */
  134057. constructor(name: string);
  134058. /**
  134059. * Gets the current class name
  134060. * @returns the class name
  134061. */
  134062. getClassName(): string;
  134063. /**
  134064. * Gets the seed input component
  134065. */
  134066. get seed(): NodeMaterialConnectionPoint;
  134067. /**
  134068. * Gets the output component
  134069. */
  134070. get output(): NodeMaterialConnectionPoint;
  134071. protected _buildBlock(state: NodeMaterialBuildState): this;
  134072. }
  134073. }
  134074. declare module BABYLON {
  134075. /**
  134076. * Block used to compute arc tangent of 2 values
  134077. */
  134078. export class ArcTan2Block extends NodeMaterialBlock {
  134079. /**
  134080. * Creates a new ArcTan2Block
  134081. * @param name defines the block name
  134082. */
  134083. constructor(name: string);
  134084. /**
  134085. * Gets the current class name
  134086. * @returns the class name
  134087. */
  134088. getClassName(): string;
  134089. /**
  134090. * Gets the x operand input component
  134091. */
  134092. get x(): NodeMaterialConnectionPoint;
  134093. /**
  134094. * Gets the y operand input component
  134095. */
  134096. get y(): NodeMaterialConnectionPoint;
  134097. /**
  134098. * Gets the output component
  134099. */
  134100. get output(): NodeMaterialConnectionPoint;
  134101. protected _buildBlock(state: NodeMaterialBuildState): this;
  134102. }
  134103. }
  134104. declare module BABYLON {
  134105. /**
  134106. * Block used to smooth step a value
  134107. */
  134108. export class SmoothStepBlock extends NodeMaterialBlock {
  134109. /**
  134110. * Creates a new SmoothStepBlock
  134111. * @param name defines the block name
  134112. */
  134113. constructor(name: string);
  134114. /**
  134115. * Gets the current class name
  134116. * @returns the class name
  134117. */
  134118. getClassName(): string;
  134119. /**
  134120. * Gets the value operand input component
  134121. */
  134122. get value(): NodeMaterialConnectionPoint;
  134123. /**
  134124. * Gets the first edge operand input component
  134125. */
  134126. get edge0(): NodeMaterialConnectionPoint;
  134127. /**
  134128. * Gets the second edge operand input component
  134129. */
  134130. get edge1(): NodeMaterialConnectionPoint;
  134131. /**
  134132. * Gets the output component
  134133. */
  134134. get output(): NodeMaterialConnectionPoint;
  134135. protected _buildBlock(state: NodeMaterialBuildState): this;
  134136. }
  134137. }
  134138. declare module BABYLON {
  134139. /**
  134140. * Block used to get the reciprocal (1 / x) of a value
  134141. */
  134142. export class ReciprocalBlock extends NodeMaterialBlock {
  134143. /**
  134144. * Creates a new ReciprocalBlock
  134145. * @param name defines the block name
  134146. */
  134147. constructor(name: string);
  134148. /**
  134149. * Gets the current class name
  134150. * @returns the class name
  134151. */
  134152. getClassName(): string;
  134153. /**
  134154. * Gets the input component
  134155. */
  134156. get input(): NodeMaterialConnectionPoint;
  134157. /**
  134158. * Gets the output component
  134159. */
  134160. get output(): NodeMaterialConnectionPoint;
  134161. protected _buildBlock(state: NodeMaterialBuildState): this;
  134162. }
  134163. }
  134164. declare module BABYLON {
  134165. /**
  134166. * Block used to replace a color by another one
  134167. */
  134168. export class ReplaceColorBlock extends NodeMaterialBlock {
  134169. /**
  134170. * Creates a new ReplaceColorBlock
  134171. * @param name defines the block name
  134172. */
  134173. constructor(name: string);
  134174. /**
  134175. * Gets the current class name
  134176. * @returns the class name
  134177. */
  134178. getClassName(): string;
  134179. /**
  134180. * Gets the value input component
  134181. */
  134182. get value(): NodeMaterialConnectionPoint;
  134183. /**
  134184. * Gets the reference input component
  134185. */
  134186. get reference(): NodeMaterialConnectionPoint;
  134187. /**
  134188. * Gets the distance input component
  134189. */
  134190. get distance(): NodeMaterialConnectionPoint;
  134191. /**
  134192. * Gets the replacement input component
  134193. */
  134194. get replacement(): NodeMaterialConnectionPoint;
  134195. /**
  134196. * Gets the output component
  134197. */
  134198. get output(): NodeMaterialConnectionPoint;
  134199. protected _buildBlock(state: NodeMaterialBuildState): this;
  134200. }
  134201. }
  134202. declare module BABYLON {
  134203. /**
  134204. * Block used to posterize a value
  134205. * @see https://en.wikipedia.org/wiki/Posterization
  134206. */
  134207. export class PosterizeBlock extends NodeMaterialBlock {
  134208. /**
  134209. * Creates a new PosterizeBlock
  134210. * @param name defines the block name
  134211. */
  134212. constructor(name: string);
  134213. /**
  134214. * Gets the current class name
  134215. * @returns the class name
  134216. */
  134217. getClassName(): string;
  134218. /**
  134219. * Gets the value input component
  134220. */
  134221. get value(): NodeMaterialConnectionPoint;
  134222. /**
  134223. * Gets the steps input component
  134224. */
  134225. get steps(): NodeMaterialConnectionPoint;
  134226. /**
  134227. * Gets the output component
  134228. */
  134229. get output(): NodeMaterialConnectionPoint;
  134230. protected _buildBlock(state: NodeMaterialBuildState): this;
  134231. }
  134232. }
  134233. declare module BABYLON {
  134234. /**
  134235. * Operations supported by the Wave block
  134236. */
  134237. export enum WaveBlockKind {
  134238. /** SawTooth */
  134239. SawTooth = 0,
  134240. /** Square */
  134241. Square = 1,
  134242. /** Triangle */
  134243. Triangle = 2
  134244. }
  134245. /**
  134246. * Block used to apply wave operation to floats
  134247. */
  134248. export class WaveBlock extends NodeMaterialBlock {
  134249. /**
  134250. * Gets or sets the kibnd of wave to be applied by the block
  134251. */
  134252. kind: WaveBlockKind;
  134253. /**
  134254. * Creates a new WaveBlock
  134255. * @param name defines the block name
  134256. */
  134257. constructor(name: string);
  134258. /**
  134259. * Gets the current class name
  134260. * @returns the class name
  134261. */
  134262. getClassName(): string;
  134263. /**
  134264. * Gets the input component
  134265. */
  134266. get input(): NodeMaterialConnectionPoint;
  134267. /**
  134268. * Gets the output component
  134269. */
  134270. get output(): NodeMaterialConnectionPoint;
  134271. protected _buildBlock(state: NodeMaterialBuildState): this;
  134272. serialize(): any;
  134273. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134274. }
  134275. }
  134276. declare module BABYLON {
  134277. /**
  134278. * Class used to store a color step for the GradientBlock
  134279. */
  134280. export class GradientBlockColorStep {
  134281. /**
  134282. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134283. */
  134284. step: number;
  134285. /**
  134286. * Gets or sets the color associated with this step
  134287. */
  134288. color: Color3;
  134289. /**
  134290. * Creates a new GradientBlockColorStep
  134291. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  134292. * @param color defines the color associated with this step
  134293. */
  134294. constructor(
  134295. /**
  134296. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134297. */
  134298. step: number,
  134299. /**
  134300. * Gets or sets the color associated with this step
  134301. */
  134302. color: Color3);
  134303. }
  134304. /**
  134305. * Block used to return a color from a gradient based on an input value between 0 and 1
  134306. */
  134307. export class GradientBlock extends NodeMaterialBlock {
  134308. /**
  134309. * Gets or sets the list of color steps
  134310. */
  134311. colorSteps: GradientBlockColorStep[];
  134312. /**
  134313. * Creates a new GradientBlock
  134314. * @param name defines the block name
  134315. */
  134316. constructor(name: string);
  134317. /**
  134318. * Gets the current class name
  134319. * @returns the class name
  134320. */
  134321. getClassName(): string;
  134322. /**
  134323. * Gets the gradient input component
  134324. */
  134325. get gradient(): NodeMaterialConnectionPoint;
  134326. /**
  134327. * Gets the output component
  134328. */
  134329. get output(): NodeMaterialConnectionPoint;
  134330. private _writeColorConstant;
  134331. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134332. serialize(): any;
  134333. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134334. protected _dumpPropertiesCode(): string;
  134335. }
  134336. }
  134337. declare module BABYLON {
  134338. /**
  134339. * Block used to normalize lerp between 2 values
  134340. */
  134341. export class NLerpBlock extends NodeMaterialBlock {
  134342. /**
  134343. * Creates a new NLerpBlock
  134344. * @param name defines the block name
  134345. */
  134346. constructor(name: string);
  134347. /**
  134348. * Gets the current class name
  134349. * @returns the class name
  134350. */
  134351. getClassName(): string;
  134352. /**
  134353. * Gets the left operand input component
  134354. */
  134355. get left(): NodeMaterialConnectionPoint;
  134356. /**
  134357. * Gets the right operand input component
  134358. */
  134359. get right(): NodeMaterialConnectionPoint;
  134360. /**
  134361. * Gets the gradient operand input component
  134362. */
  134363. get gradient(): NodeMaterialConnectionPoint;
  134364. /**
  134365. * Gets the output component
  134366. */
  134367. get output(): NodeMaterialConnectionPoint;
  134368. protected _buildBlock(state: NodeMaterialBuildState): this;
  134369. }
  134370. }
  134371. declare module BABYLON {
  134372. /**
  134373. * block used to Generate a Worley Noise 3D Noise Pattern
  134374. */
  134375. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  134376. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  134377. manhattanDistance: boolean;
  134378. /**
  134379. * Creates a new WorleyNoise3DBlock
  134380. * @param name defines the block name
  134381. */
  134382. constructor(name: string);
  134383. /**
  134384. * Gets the current class name
  134385. * @returns the class name
  134386. */
  134387. getClassName(): string;
  134388. /**
  134389. * Gets the seed input component
  134390. */
  134391. get seed(): NodeMaterialConnectionPoint;
  134392. /**
  134393. * Gets the jitter input component
  134394. */
  134395. get jitter(): NodeMaterialConnectionPoint;
  134396. /**
  134397. * Gets the output component
  134398. */
  134399. get output(): NodeMaterialConnectionPoint;
  134400. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134401. /**
  134402. * Exposes the properties to the UI?
  134403. */
  134404. protected _dumpPropertiesCode(): string;
  134405. /**
  134406. * Exposes the properties to the Seralize?
  134407. */
  134408. serialize(): any;
  134409. /**
  134410. * Exposes the properties to the deseralize?
  134411. */
  134412. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134413. }
  134414. }
  134415. declare module BABYLON {
  134416. /**
  134417. * block used to Generate a Simplex Perlin 3d Noise Pattern
  134418. */
  134419. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  134420. /**
  134421. * Creates a new SimplexPerlin3DBlock
  134422. * @param name defines the block name
  134423. */
  134424. constructor(name: string);
  134425. /**
  134426. * Gets the current class name
  134427. * @returns the class name
  134428. */
  134429. getClassName(): string;
  134430. /**
  134431. * Gets the seed operand input component
  134432. */
  134433. get seed(): NodeMaterialConnectionPoint;
  134434. /**
  134435. * Gets the output component
  134436. */
  134437. get output(): NodeMaterialConnectionPoint;
  134438. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134439. }
  134440. }
  134441. declare module BABYLON {
  134442. /**
  134443. * Block used to blend normals
  134444. */
  134445. export class NormalBlendBlock extends NodeMaterialBlock {
  134446. /**
  134447. * Creates a new NormalBlendBlock
  134448. * @param name defines the block name
  134449. */
  134450. constructor(name: string);
  134451. /**
  134452. * Gets the current class name
  134453. * @returns the class name
  134454. */
  134455. getClassName(): string;
  134456. /**
  134457. * Gets the first input component
  134458. */
  134459. get normalMap0(): NodeMaterialConnectionPoint;
  134460. /**
  134461. * Gets the second input component
  134462. */
  134463. get normalMap1(): NodeMaterialConnectionPoint;
  134464. /**
  134465. * Gets the output component
  134466. */
  134467. get output(): NodeMaterialConnectionPoint;
  134468. protected _buildBlock(state: NodeMaterialBuildState): this;
  134469. }
  134470. }
  134471. declare module BABYLON {
  134472. /**
  134473. * Block used to rotate a 2d vector by a given angle
  134474. */
  134475. export class Rotate2dBlock extends NodeMaterialBlock {
  134476. /**
  134477. * Creates a new Rotate2dBlock
  134478. * @param name defines the block name
  134479. */
  134480. constructor(name: string);
  134481. /**
  134482. * Gets the current class name
  134483. * @returns the class name
  134484. */
  134485. getClassName(): string;
  134486. /**
  134487. * Gets the input vector
  134488. */
  134489. get input(): NodeMaterialConnectionPoint;
  134490. /**
  134491. * Gets the input angle
  134492. */
  134493. get angle(): NodeMaterialConnectionPoint;
  134494. /**
  134495. * Gets the output component
  134496. */
  134497. get output(): NodeMaterialConnectionPoint;
  134498. autoConfigure(material: NodeMaterial): void;
  134499. protected _buildBlock(state: NodeMaterialBuildState): this;
  134500. }
  134501. }
  134502. declare module BABYLON {
  134503. /**
  134504. * Block used to get the reflected vector from a direction and a normal
  134505. */
  134506. export class ReflectBlock extends NodeMaterialBlock {
  134507. /**
  134508. * Creates a new ReflectBlock
  134509. * @param name defines the block name
  134510. */
  134511. constructor(name: string);
  134512. /**
  134513. * Gets the current class name
  134514. * @returns the class name
  134515. */
  134516. getClassName(): string;
  134517. /**
  134518. * Gets the incident component
  134519. */
  134520. get incident(): NodeMaterialConnectionPoint;
  134521. /**
  134522. * Gets the normal component
  134523. */
  134524. get normal(): NodeMaterialConnectionPoint;
  134525. /**
  134526. * Gets the output component
  134527. */
  134528. get output(): NodeMaterialConnectionPoint;
  134529. protected _buildBlock(state: NodeMaterialBuildState): this;
  134530. }
  134531. }
  134532. declare module BABYLON {
  134533. /**
  134534. * Block used to get the refracted vector from a direction and a normal
  134535. */
  134536. export class RefractBlock extends NodeMaterialBlock {
  134537. /**
  134538. * Creates a new RefractBlock
  134539. * @param name defines the block name
  134540. */
  134541. constructor(name: string);
  134542. /**
  134543. * Gets the current class name
  134544. * @returns the class name
  134545. */
  134546. getClassName(): string;
  134547. /**
  134548. * Gets the incident component
  134549. */
  134550. get incident(): NodeMaterialConnectionPoint;
  134551. /**
  134552. * Gets the normal component
  134553. */
  134554. get normal(): NodeMaterialConnectionPoint;
  134555. /**
  134556. * Gets the index of refraction component
  134557. */
  134558. get ior(): NodeMaterialConnectionPoint;
  134559. /**
  134560. * Gets the output component
  134561. */
  134562. get output(): NodeMaterialConnectionPoint;
  134563. protected _buildBlock(state: NodeMaterialBuildState): this;
  134564. }
  134565. }
  134566. declare module BABYLON {
  134567. /**
  134568. * Block used to desaturate a color
  134569. */
  134570. export class DesaturateBlock extends NodeMaterialBlock {
  134571. /**
  134572. * Creates a new DesaturateBlock
  134573. * @param name defines the block name
  134574. */
  134575. constructor(name: string);
  134576. /**
  134577. * Gets the current class name
  134578. * @returns the class name
  134579. */
  134580. getClassName(): string;
  134581. /**
  134582. * Gets the color operand input component
  134583. */
  134584. get color(): NodeMaterialConnectionPoint;
  134585. /**
  134586. * Gets the level operand input component
  134587. */
  134588. get level(): NodeMaterialConnectionPoint;
  134589. /**
  134590. * Gets the output component
  134591. */
  134592. get output(): NodeMaterialConnectionPoint;
  134593. protected _buildBlock(state: NodeMaterialBuildState): this;
  134594. }
  134595. }
  134596. declare module BABYLON {
  134597. /**
  134598. * Effect Render Options
  134599. */
  134600. export interface IEffectRendererOptions {
  134601. /**
  134602. * Defines the vertices positions.
  134603. */
  134604. positions?: number[];
  134605. /**
  134606. * Defines the indices.
  134607. */
  134608. indices?: number[];
  134609. }
  134610. /**
  134611. * Helper class to render one or more effects
  134612. */
  134613. export class EffectRenderer {
  134614. private engine;
  134615. private static _DefaultOptions;
  134616. private _vertexBuffers;
  134617. private _indexBuffer;
  134618. private _ringBufferIndex;
  134619. private _ringScreenBuffer;
  134620. private _fullscreenViewport;
  134621. private _getNextFrameBuffer;
  134622. /**
  134623. * Creates an effect renderer
  134624. * @param engine the engine to use for rendering
  134625. * @param options defines the options of the effect renderer
  134626. */
  134627. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  134628. /**
  134629. * Sets the current viewport in normalized coordinates 0-1
  134630. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  134631. */
  134632. setViewport(viewport?: Viewport): void;
  134633. /**
  134634. * Binds the embedded attributes buffer to the effect.
  134635. * @param effect Defines the effect to bind the attributes for
  134636. */
  134637. bindBuffers(effect: Effect): void;
  134638. /**
  134639. * Sets the current effect wrapper to use during draw.
  134640. * The effect needs to be ready before calling this api.
  134641. * This also sets the default full screen position attribute.
  134642. * @param effectWrapper Defines the effect to draw with
  134643. */
  134644. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  134645. /**
  134646. * Draws a full screen quad.
  134647. */
  134648. draw(): void;
  134649. /**
  134650. * renders one or more effects to a specified texture
  134651. * @param effectWrappers list of effects to renderer
  134652. * @param outputTexture texture to draw to, if null it will render to the screen
  134653. */
  134654. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  134655. /**
  134656. * Disposes of the effect renderer
  134657. */
  134658. dispose(): void;
  134659. }
  134660. /**
  134661. * Options to create an EffectWrapper
  134662. */
  134663. interface EffectWrapperCreationOptions {
  134664. /**
  134665. * Engine to use to create the effect
  134666. */
  134667. engine: ThinEngine;
  134668. /**
  134669. * Fragment shader for the effect
  134670. */
  134671. fragmentShader: string;
  134672. /**
  134673. * Vertex shader for the effect
  134674. */
  134675. vertexShader?: string;
  134676. /**
  134677. * Attributes to use in the shader
  134678. */
  134679. attributeNames?: Array<string>;
  134680. /**
  134681. * Uniforms to use in the shader
  134682. */
  134683. uniformNames?: Array<string>;
  134684. /**
  134685. * Texture sampler names to use in the shader
  134686. */
  134687. samplerNames?: Array<string>;
  134688. /**
  134689. * The friendly name of the effect displayed in Spector.
  134690. */
  134691. name?: string;
  134692. }
  134693. /**
  134694. * Wraps an effect to be used for rendering
  134695. */
  134696. export class EffectWrapper {
  134697. /**
  134698. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  134699. */
  134700. onApplyObservable: Observable<{}>;
  134701. /**
  134702. * The underlying effect
  134703. */
  134704. effect: Effect;
  134705. /**
  134706. * Creates an effect to be renderer
  134707. * @param creationOptions options to create the effect
  134708. */
  134709. constructor(creationOptions: EffectWrapperCreationOptions);
  134710. /**
  134711. * Disposes of the effect wrapper
  134712. */
  134713. dispose(): void;
  134714. }
  134715. }
  134716. declare module BABYLON {
  134717. /**
  134718. * Helper class to push actions to a pool of workers.
  134719. */
  134720. export class WorkerPool implements IDisposable {
  134721. private _workerInfos;
  134722. private _pendingActions;
  134723. /**
  134724. * Constructor
  134725. * @param workers Array of workers to use for actions
  134726. */
  134727. constructor(workers: Array<Worker>);
  134728. /**
  134729. * Terminates all workers and clears any pending actions.
  134730. */
  134731. dispose(): void;
  134732. /**
  134733. * Pushes an action to the worker pool. If all the workers are active, the action will be
  134734. * pended until a worker has completed its action.
  134735. * @param action The action to perform. Call onComplete when the action is complete.
  134736. */
  134737. push(action: (worker: Worker, onComplete: () => void) => void): void;
  134738. private _execute;
  134739. }
  134740. }
  134741. declare module BABYLON {
  134742. /**
  134743. * Configuration for Draco compression
  134744. */
  134745. export interface IDracoCompressionConfiguration {
  134746. /**
  134747. * Configuration for the decoder.
  134748. */
  134749. decoder: {
  134750. /**
  134751. * The url to the WebAssembly module.
  134752. */
  134753. wasmUrl?: string;
  134754. /**
  134755. * The url to the WebAssembly binary.
  134756. */
  134757. wasmBinaryUrl?: string;
  134758. /**
  134759. * The url to the fallback JavaScript module.
  134760. */
  134761. fallbackUrl?: string;
  134762. };
  134763. }
  134764. /**
  134765. * Draco compression (https://google.github.io/draco/)
  134766. *
  134767. * This class wraps the Draco module.
  134768. *
  134769. * **Encoder**
  134770. *
  134771. * The encoder is not currently implemented.
  134772. *
  134773. * **Decoder**
  134774. *
  134775. * 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.
  134776. *
  134777. * To update the configuration, use the following code:
  134778. * ```javascript
  134779. * DracoCompression.Configuration = {
  134780. * decoder: {
  134781. * wasmUrl: "<url to the WebAssembly library>",
  134782. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  134783. * fallbackUrl: "<url to the fallback JavaScript library>",
  134784. * }
  134785. * };
  134786. * ```
  134787. *
  134788. * 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.
  134789. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  134790. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  134791. *
  134792. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  134793. * ```javascript
  134794. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  134795. * ```
  134796. *
  134797. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  134798. */
  134799. export class DracoCompression implements IDisposable {
  134800. private _workerPoolPromise?;
  134801. private _decoderModulePromise?;
  134802. /**
  134803. * The configuration. Defaults to the following urls:
  134804. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  134805. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  134806. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  134807. */
  134808. static Configuration: IDracoCompressionConfiguration;
  134809. /**
  134810. * Returns true if the decoder configuration is available.
  134811. */
  134812. static get DecoderAvailable(): boolean;
  134813. /**
  134814. * Default number of workers to create when creating the draco compression object.
  134815. */
  134816. static DefaultNumWorkers: number;
  134817. private static GetDefaultNumWorkers;
  134818. private static _Default;
  134819. /**
  134820. * Default instance for the draco compression object.
  134821. */
  134822. static get Default(): DracoCompression;
  134823. /**
  134824. * Constructor
  134825. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  134826. */
  134827. constructor(numWorkers?: number);
  134828. /**
  134829. * Stop all async operations and release resources.
  134830. */
  134831. dispose(): void;
  134832. /**
  134833. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  134834. * @returns a promise that resolves when ready
  134835. */
  134836. whenReadyAsync(): Promise<void>;
  134837. /**
  134838. * Decode Draco compressed mesh data to vertex data.
  134839. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  134840. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  134841. * @returns A promise that resolves with the decoded vertex data
  134842. */
  134843. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  134844. [kind: string]: number;
  134845. }): Promise<VertexData>;
  134846. }
  134847. }
  134848. declare module BABYLON {
  134849. /**
  134850. * Class for building Constructive Solid Geometry
  134851. */
  134852. export class CSG {
  134853. private polygons;
  134854. /**
  134855. * The world matrix
  134856. */
  134857. matrix: Matrix;
  134858. /**
  134859. * Stores the position
  134860. */
  134861. position: Vector3;
  134862. /**
  134863. * Stores the rotation
  134864. */
  134865. rotation: Vector3;
  134866. /**
  134867. * Stores the rotation quaternion
  134868. */
  134869. rotationQuaternion: Nullable<Quaternion>;
  134870. /**
  134871. * Stores the scaling vector
  134872. */
  134873. scaling: Vector3;
  134874. /**
  134875. * Convert the Mesh to CSG
  134876. * @param mesh The Mesh to convert to CSG
  134877. * @returns A new CSG from the Mesh
  134878. */
  134879. static FromMesh(mesh: Mesh): CSG;
  134880. /**
  134881. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  134882. * @param polygons Polygons used to construct a CSG solid
  134883. */
  134884. private static FromPolygons;
  134885. /**
  134886. * Clones, or makes a deep copy, of the CSG
  134887. * @returns A new CSG
  134888. */
  134889. clone(): CSG;
  134890. /**
  134891. * Unions this CSG with another CSG
  134892. * @param csg The CSG to union against this CSG
  134893. * @returns The unioned CSG
  134894. */
  134895. union(csg: CSG): CSG;
  134896. /**
  134897. * Unions this CSG with another CSG in place
  134898. * @param csg The CSG to union against this CSG
  134899. */
  134900. unionInPlace(csg: CSG): void;
  134901. /**
  134902. * Subtracts this CSG with another CSG
  134903. * @param csg The CSG to subtract against this CSG
  134904. * @returns A new CSG
  134905. */
  134906. subtract(csg: CSG): CSG;
  134907. /**
  134908. * Subtracts this CSG with another CSG in place
  134909. * @param csg The CSG to subtact against this CSG
  134910. */
  134911. subtractInPlace(csg: CSG): void;
  134912. /**
  134913. * Intersect this CSG with another CSG
  134914. * @param csg The CSG to intersect against this CSG
  134915. * @returns A new CSG
  134916. */
  134917. intersect(csg: CSG): CSG;
  134918. /**
  134919. * Intersects this CSG with another CSG in place
  134920. * @param csg The CSG to intersect against this CSG
  134921. */
  134922. intersectInPlace(csg: CSG): void;
  134923. /**
  134924. * Return a new CSG solid with solid and empty space switched. This solid is
  134925. * not modified.
  134926. * @returns A new CSG solid with solid and empty space switched
  134927. */
  134928. inverse(): CSG;
  134929. /**
  134930. * Inverses the CSG in place
  134931. */
  134932. inverseInPlace(): void;
  134933. /**
  134934. * This is used to keep meshes transformations so they can be restored
  134935. * when we build back a Babylon Mesh
  134936. * NB : All CSG operations are performed in world coordinates
  134937. * @param csg The CSG to copy the transform attributes from
  134938. * @returns This CSG
  134939. */
  134940. copyTransformAttributes(csg: CSG): CSG;
  134941. /**
  134942. * Build Raw mesh from CSG
  134943. * Coordinates here are in world space
  134944. * @param name The name of the mesh geometry
  134945. * @param scene The Scene
  134946. * @param keepSubMeshes Specifies if the submeshes should be kept
  134947. * @returns A new Mesh
  134948. */
  134949. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  134950. /**
  134951. * Build Mesh from CSG taking material and transforms into account
  134952. * @param name The name of the Mesh
  134953. * @param material The material of the Mesh
  134954. * @param scene The Scene
  134955. * @param keepSubMeshes Specifies if submeshes should be kept
  134956. * @returns The new Mesh
  134957. */
  134958. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  134959. }
  134960. }
  134961. declare module BABYLON {
  134962. /**
  134963. * Class used to create a trail following a mesh
  134964. */
  134965. export class TrailMesh extends Mesh {
  134966. private _generator;
  134967. private _autoStart;
  134968. private _running;
  134969. private _diameter;
  134970. private _length;
  134971. private _sectionPolygonPointsCount;
  134972. private _sectionVectors;
  134973. private _sectionNormalVectors;
  134974. private _beforeRenderObserver;
  134975. /**
  134976. * @constructor
  134977. * @param name The value used by scene.getMeshByName() to do a lookup.
  134978. * @param generator The mesh or transform node to generate a trail.
  134979. * @param scene The scene to add this mesh to.
  134980. * @param diameter Diameter of trailing mesh. Default is 1.
  134981. * @param length Length of trailing mesh. Default is 60.
  134982. * @param autoStart Automatically start trailing mesh. Default true.
  134983. */
  134984. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  134985. /**
  134986. * "TrailMesh"
  134987. * @returns "TrailMesh"
  134988. */
  134989. getClassName(): string;
  134990. private _createMesh;
  134991. /**
  134992. * Start trailing mesh.
  134993. */
  134994. start(): void;
  134995. /**
  134996. * Stop trailing mesh.
  134997. */
  134998. stop(): void;
  134999. /**
  135000. * Update trailing mesh geometry.
  135001. */
  135002. update(): void;
  135003. /**
  135004. * Returns a new TrailMesh object.
  135005. * @param name is a string, the name given to the new mesh
  135006. * @param newGenerator use new generator object for cloned trail mesh
  135007. * @returns a new mesh
  135008. */
  135009. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  135010. /**
  135011. * Serializes this trail mesh
  135012. * @param serializationObject object to write serialization to
  135013. */
  135014. serialize(serializationObject: any): void;
  135015. /**
  135016. * Parses a serialized trail mesh
  135017. * @param parsedMesh the serialized mesh
  135018. * @param scene the scene to create the trail mesh in
  135019. * @returns the created trail mesh
  135020. */
  135021. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  135022. }
  135023. }
  135024. declare module BABYLON {
  135025. /**
  135026. * Class containing static functions to help procedurally build meshes
  135027. */
  135028. export class TiledBoxBuilder {
  135029. /**
  135030. * Creates a box mesh
  135031. * 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)
  135032. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135034. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135036. * @param name defines the name of the mesh
  135037. * @param options defines the options used to create the mesh
  135038. * @param scene defines the hosting scene
  135039. * @returns the box mesh
  135040. */
  135041. static CreateTiledBox(name: string, options: {
  135042. pattern?: number;
  135043. width?: number;
  135044. height?: number;
  135045. depth?: number;
  135046. tileSize?: number;
  135047. tileWidth?: number;
  135048. tileHeight?: number;
  135049. alignHorizontal?: number;
  135050. alignVertical?: number;
  135051. faceUV?: Vector4[];
  135052. faceColors?: Color4[];
  135053. sideOrientation?: number;
  135054. updatable?: boolean;
  135055. }, scene?: Nullable<Scene>): Mesh;
  135056. }
  135057. }
  135058. declare module BABYLON {
  135059. /**
  135060. * Class containing static functions to help procedurally build meshes
  135061. */
  135062. export class TorusKnotBuilder {
  135063. /**
  135064. * Creates a torus knot mesh
  135065. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135066. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135067. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135068. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135072. * @param name defines the name of the mesh
  135073. * @param options defines the options used to create the mesh
  135074. * @param scene defines the hosting scene
  135075. * @returns the torus knot mesh
  135076. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135077. */
  135078. static CreateTorusKnot(name: string, options: {
  135079. radius?: number;
  135080. tube?: number;
  135081. radialSegments?: number;
  135082. tubularSegments?: number;
  135083. p?: number;
  135084. q?: number;
  135085. updatable?: boolean;
  135086. sideOrientation?: number;
  135087. frontUVs?: Vector4;
  135088. backUVs?: Vector4;
  135089. }, scene: any): Mesh;
  135090. }
  135091. }
  135092. declare module BABYLON {
  135093. /**
  135094. * Polygon
  135095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  135096. */
  135097. export class Polygon {
  135098. /**
  135099. * Creates a rectangle
  135100. * @param xmin bottom X coord
  135101. * @param ymin bottom Y coord
  135102. * @param xmax top X coord
  135103. * @param ymax top Y coord
  135104. * @returns points that make the resulting rectation
  135105. */
  135106. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  135107. /**
  135108. * Creates a circle
  135109. * @param radius radius of circle
  135110. * @param cx scale in x
  135111. * @param cy scale in y
  135112. * @param numberOfSides number of sides that make up the circle
  135113. * @returns points that make the resulting circle
  135114. */
  135115. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  135116. /**
  135117. * Creates a polygon from input string
  135118. * @param input Input polygon data
  135119. * @returns the parsed points
  135120. */
  135121. static Parse(input: string): Vector2[];
  135122. /**
  135123. * Starts building a polygon from x and y coordinates
  135124. * @param x x coordinate
  135125. * @param y y coordinate
  135126. * @returns the started path2
  135127. */
  135128. static StartingAt(x: number, y: number): Path2;
  135129. }
  135130. /**
  135131. * Builds a polygon
  135132. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  135133. */
  135134. export class PolygonMeshBuilder {
  135135. private _points;
  135136. private _outlinepoints;
  135137. private _holes;
  135138. private _name;
  135139. private _scene;
  135140. private _epoints;
  135141. private _eholes;
  135142. private _addToepoint;
  135143. /**
  135144. * Babylon reference to the earcut plugin.
  135145. */
  135146. bjsEarcut: any;
  135147. /**
  135148. * Creates a PolygonMeshBuilder
  135149. * @param name name of the builder
  135150. * @param contours Path of the polygon
  135151. * @param scene scene to add to when creating the mesh
  135152. * @param earcutInjection can be used to inject your own earcut reference
  135153. */
  135154. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  135155. /**
  135156. * Adds a whole within the polygon
  135157. * @param hole Array of points defining the hole
  135158. * @returns this
  135159. */
  135160. addHole(hole: Vector2[]): PolygonMeshBuilder;
  135161. /**
  135162. * Creates the polygon
  135163. * @param updatable If the mesh should be updatable
  135164. * @param depth The depth of the mesh created
  135165. * @returns the created mesh
  135166. */
  135167. build(updatable?: boolean, depth?: number): Mesh;
  135168. /**
  135169. * Creates the polygon
  135170. * @param depth The depth of the mesh created
  135171. * @returns the created VertexData
  135172. */
  135173. buildVertexData(depth?: number): VertexData;
  135174. /**
  135175. * Adds a side to the polygon
  135176. * @param positions points that make the polygon
  135177. * @param normals normals of the polygon
  135178. * @param uvs uvs of the polygon
  135179. * @param indices indices of the polygon
  135180. * @param bounds bounds of the polygon
  135181. * @param points points of the polygon
  135182. * @param depth depth of the polygon
  135183. * @param flip flip of the polygon
  135184. */
  135185. private addSide;
  135186. }
  135187. }
  135188. declare module BABYLON {
  135189. /**
  135190. * Class containing static functions to help procedurally build meshes
  135191. */
  135192. export class PolygonBuilder {
  135193. /**
  135194. * Creates a polygon mesh
  135195. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135196. * * 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
  135197. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135200. * * Remember you can only change the shape positions, not their number when updating a polygon
  135201. * @param name defines the name of the mesh
  135202. * @param options defines the options used to create the mesh
  135203. * @param scene defines the hosting scene
  135204. * @param earcutInjection can be used to inject your own earcut reference
  135205. * @returns the polygon mesh
  135206. */
  135207. static CreatePolygon(name: string, options: {
  135208. shape: Vector3[];
  135209. holes?: Vector3[][];
  135210. depth?: number;
  135211. faceUV?: Vector4[];
  135212. faceColors?: Color4[];
  135213. updatable?: boolean;
  135214. sideOrientation?: number;
  135215. frontUVs?: Vector4;
  135216. backUVs?: Vector4;
  135217. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135218. /**
  135219. * Creates an extruded polygon mesh, with depth in the Y direction.
  135220. * * 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)
  135221. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135222. * @param name defines the name of the mesh
  135223. * @param options defines the options used to create the mesh
  135224. * @param scene defines the hosting scene
  135225. * @param earcutInjection can be used to inject your own earcut reference
  135226. * @returns the polygon mesh
  135227. */
  135228. static ExtrudePolygon(name: string, options: {
  135229. shape: Vector3[];
  135230. holes?: Vector3[][];
  135231. depth?: number;
  135232. faceUV?: Vector4[];
  135233. faceColors?: Color4[];
  135234. updatable?: boolean;
  135235. sideOrientation?: number;
  135236. frontUVs?: Vector4;
  135237. backUVs?: Vector4;
  135238. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135239. }
  135240. }
  135241. declare module BABYLON {
  135242. /**
  135243. * Class containing static functions to help procedurally build meshes
  135244. */
  135245. export class LatheBuilder {
  135246. /**
  135247. * Creates lathe mesh.
  135248. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135249. * * 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
  135250. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135251. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135252. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135253. * * 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
  135254. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135255. * * 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
  135256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135258. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135260. * @param name defines the name of the mesh
  135261. * @param options defines the options used to create the mesh
  135262. * @param scene defines the hosting scene
  135263. * @returns the lathe mesh
  135264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135265. */
  135266. static CreateLathe(name: string, options: {
  135267. shape: Vector3[];
  135268. radius?: number;
  135269. tessellation?: number;
  135270. clip?: number;
  135271. arc?: number;
  135272. closed?: boolean;
  135273. updatable?: boolean;
  135274. sideOrientation?: number;
  135275. frontUVs?: Vector4;
  135276. backUVs?: Vector4;
  135277. cap?: number;
  135278. invertUV?: boolean;
  135279. }, scene?: Nullable<Scene>): Mesh;
  135280. }
  135281. }
  135282. declare module BABYLON {
  135283. /**
  135284. * Class containing static functions to help procedurally build meshes
  135285. */
  135286. export class TiledPlaneBuilder {
  135287. /**
  135288. * Creates a tiled plane mesh
  135289. * * The parameter `pattern` will, depending on value, do nothing or
  135290. * * * flip (reflect about central vertical) alternate tiles across and up
  135291. * * * flip every tile on alternate rows
  135292. * * * rotate (180 degs) alternate tiles across and up
  135293. * * * rotate every tile on alternate rows
  135294. * * * flip and rotate alternate tiles across and up
  135295. * * * flip and rotate every tile on alternate rows
  135296. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  135297. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  135298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135299. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135300. * * 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)
  135301. * * 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)
  135302. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135303. * @param name defines the name of the mesh
  135304. * @param options defines the options used to create the mesh
  135305. * @param scene defines the hosting scene
  135306. * @returns the box mesh
  135307. */
  135308. static CreateTiledPlane(name: string, options: {
  135309. pattern?: number;
  135310. tileSize?: number;
  135311. tileWidth?: number;
  135312. tileHeight?: number;
  135313. size?: number;
  135314. width?: number;
  135315. height?: number;
  135316. alignHorizontal?: number;
  135317. alignVertical?: number;
  135318. sideOrientation?: number;
  135319. frontUVs?: Vector4;
  135320. backUVs?: Vector4;
  135321. updatable?: boolean;
  135322. }, scene?: Nullable<Scene>): Mesh;
  135323. }
  135324. }
  135325. declare module BABYLON {
  135326. /**
  135327. * Class containing static functions to help procedurally build meshes
  135328. */
  135329. export class TubeBuilder {
  135330. /**
  135331. * Creates a tube mesh.
  135332. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135333. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135334. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135335. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135336. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135337. * * 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)
  135338. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135339. * * 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
  135340. * * 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
  135341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135343. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135345. * @param name defines the name of the mesh
  135346. * @param options defines the options used to create the mesh
  135347. * @param scene defines the hosting scene
  135348. * @returns the tube mesh
  135349. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135350. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135351. */
  135352. static CreateTube(name: string, options: {
  135353. path: Vector3[];
  135354. radius?: number;
  135355. tessellation?: number;
  135356. radiusFunction?: {
  135357. (i: number, distance: number): number;
  135358. };
  135359. cap?: number;
  135360. arc?: number;
  135361. updatable?: boolean;
  135362. sideOrientation?: number;
  135363. frontUVs?: Vector4;
  135364. backUVs?: Vector4;
  135365. instance?: Mesh;
  135366. invertUV?: boolean;
  135367. }, scene?: Nullable<Scene>): Mesh;
  135368. }
  135369. }
  135370. declare module BABYLON {
  135371. /**
  135372. * Class containing static functions to help procedurally build meshes
  135373. */
  135374. export class IcoSphereBuilder {
  135375. /**
  135376. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135377. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135378. * * 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`)
  135379. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135380. * * 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
  135381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135384. * @param name defines the name of the mesh
  135385. * @param options defines the options used to create the mesh
  135386. * @param scene defines the hosting scene
  135387. * @returns the icosahedron mesh
  135388. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135389. */
  135390. static CreateIcoSphere(name: string, options: {
  135391. radius?: number;
  135392. radiusX?: number;
  135393. radiusY?: number;
  135394. radiusZ?: number;
  135395. flat?: boolean;
  135396. subdivisions?: number;
  135397. sideOrientation?: number;
  135398. frontUVs?: Vector4;
  135399. backUVs?: Vector4;
  135400. updatable?: boolean;
  135401. }, scene?: Nullable<Scene>): Mesh;
  135402. }
  135403. }
  135404. declare module BABYLON {
  135405. /**
  135406. * Class containing static functions to help procedurally build meshes
  135407. */
  135408. export class DecalBuilder {
  135409. /**
  135410. * Creates a decal mesh.
  135411. * 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
  135412. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135413. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135414. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135415. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135416. * @param name defines the name of the mesh
  135417. * @param sourceMesh defines the mesh where the decal must be applied
  135418. * @param options defines the options used to create the mesh
  135419. * @param scene defines the hosting scene
  135420. * @returns the decal mesh
  135421. * @see https://doc.babylonjs.com/how_to/decals
  135422. */
  135423. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135424. position?: Vector3;
  135425. normal?: Vector3;
  135426. size?: Vector3;
  135427. angle?: number;
  135428. }): Mesh;
  135429. }
  135430. }
  135431. declare module BABYLON {
  135432. /**
  135433. * Class containing static functions to help procedurally build meshes
  135434. */
  135435. export class MeshBuilder {
  135436. /**
  135437. * Creates a box mesh
  135438. * * The parameter `size` sets the size (float) of each box side (default 1)
  135439. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135440. * * 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)
  135441. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135445. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135446. * @param name defines the name of the mesh
  135447. * @param options defines the options used to create the mesh
  135448. * @param scene defines the hosting scene
  135449. * @returns the box mesh
  135450. */
  135451. static CreateBox(name: string, options: {
  135452. size?: number;
  135453. width?: number;
  135454. height?: number;
  135455. depth?: number;
  135456. faceUV?: Vector4[];
  135457. faceColors?: Color4[];
  135458. sideOrientation?: number;
  135459. frontUVs?: Vector4;
  135460. backUVs?: Vector4;
  135461. wrap?: boolean;
  135462. topBaseAt?: number;
  135463. bottomBaseAt?: number;
  135464. updatable?: boolean;
  135465. }, scene?: Nullable<Scene>): Mesh;
  135466. /**
  135467. * Creates a tiled box mesh
  135468. * * faceTiles sets the pattern, tile size and number of tiles for a face
  135469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135470. * @param name defines the name of the mesh
  135471. * @param options defines the options used to create the mesh
  135472. * @param scene defines the hosting scene
  135473. * @returns the tiled box mesh
  135474. */
  135475. static CreateTiledBox(name: string, options: {
  135476. pattern?: number;
  135477. size?: number;
  135478. width?: number;
  135479. height?: number;
  135480. depth: number;
  135481. tileSize?: number;
  135482. tileWidth?: number;
  135483. tileHeight?: number;
  135484. faceUV?: Vector4[];
  135485. faceColors?: Color4[];
  135486. alignHorizontal?: number;
  135487. alignVertical?: number;
  135488. sideOrientation?: number;
  135489. updatable?: boolean;
  135490. }, scene?: Nullable<Scene>): Mesh;
  135491. /**
  135492. * Creates a sphere mesh
  135493. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  135494. * * 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`)
  135495. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  135496. * * 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
  135497. * * 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)
  135498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135501. * @param name defines the name of the mesh
  135502. * @param options defines the options used to create the mesh
  135503. * @param scene defines the hosting scene
  135504. * @returns the sphere mesh
  135505. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  135506. */
  135507. static CreateSphere(name: string, options: {
  135508. segments?: number;
  135509. diameter?: number;
  135510. diameterX?: number;
  135511. diameterY?: number;
  135512. diameterZ?: number;
  135513. arc?: number;
  135514. slice?: number;
  135515. sideOrientation?: number;
  135516. frontUVs?: Vector4;
  135517. backUVs?: Vector4;
  135518. updatable?: boolean;
  135519. }, scene?: Nullable<Scene>): Mesh;
  135520. /**
  135521. * Creates a plane polygonal mesh. By default, this is a disc
  135522. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  135523. * * 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
  135524. * * 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
  135525. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135526. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135528. * @param name defines the name of the mesh
  135529. * @param options defines the options used to create the mesh
  135530. * @param scene defines the hosting scene
  135531. * @returns the plane polygonal mesh
  135532. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  135533. */
  135534. static CreateDisc(name: string, options: {
  135535. radius?: number;
  135536. tessellation?: number;
  135537. arc?: number;
  135538. updatable?: boolean;
  135539. sideOrientation?: number;
  135540. frontUVs?: Vector4;
  135541. backUVs?: Vector4;
  135542. }, scene?: Nullable<Scene>): Mesh;
  135543. /**
  135544. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135545. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135546. * * 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`)
  135547. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135548. * * 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
  135549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135552. * @param name defines the name of the mesh
  135553. * @param options defines the options used to create the mesh
  135554. * @param scene defines the hosting scene
  135555. * @returns the icosahedron mesh
  135556. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135557. */
  135558. static CreateIcoSphere(name: string, options: {
  135559. radius?: number;
  135560. radiusX?: number;
  135561. radiusY?: number;
  135562. radiusZ?: number;
  135563. flat?: boolean;
  135564. subdivisions?: number;
  135565. sideOrientation?: number;
  135566. frontUVs?: Vector4;
  135567. backUVs?: Vector4;
  135568. updatable?: boolean;
  135569. }, scene?: Nullable<Scene>): Mesh;
  135570. /**
  135571. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135572. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135573. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135574. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135575. * * 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
  135576. * * 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
  135577. * * 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
  135578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135581. * * 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
  135582. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135583. * * 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
  135584. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135586. * @param name defines the name of the mesh
  135587. * @param options defines the options used to create the mesh
  135588. * @param scene defines the hosting scene
  135589. * @returns the ribbon mesh
  135590. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135591. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135592. */
  135593. static CreateRibbon(name: string, options: {
  135594. pathArray: Vector3[][];
  135595. closeArray?: boolean;
  135596. closePath?: boolean;
  135597. offset?: number;
  135598. updatable?: boolean;
  135599. sideOrientation?: number;
  135600. frontUVs?: Vector4;
  135601. backUVs?: Vector4;
  135602. instance?: Mesh;
  135603. invertUV?: boolean;
  135604. uvs?: Vector2[];
  135605. colors?: Color4[];
  135606. }, scene?: Nullable<Scene>): Mesh;
  135607. /**
  135608. * Creates a cylinder or a cone mesh
  135609. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  135610. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  135611. * * 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.
  135612. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  135613. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  135614. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  135615. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  135616. * * 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).
  135617. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  135618. * * 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).
  135619. * * 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
  135620. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  135621. * * 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
  135622. * * 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.
  135623. * * If `enclose` is false, a ring surface is one element.
  135624. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  135625. * * 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
  135626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135629. * @param name defines the name of the mesh
  135630. * @param options defines the options used to create the mesh
  135631. * @param scene defines the hosting scene
  135632. * @returns the cylinder mesh
  135633. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  135634. */
  135635. static CreateCylinder(name: string, options: {
  135636. height?: number;
  135637. diameterTop?: number;
  135638. diameterBottom?: number;
  135639. diameter?: number;
  135640. tessellation?: number;
  135641. subdivisions?: number;
  135642. arc?: number;
  135643. faceColors?: Color4[];
  135644. faceUV?: Vector4[];
  135645. updatable?: boolean;
  135646. hasRings?: boolean;
  135647. enclose?: boolean;
  135648. cap?: number;
  135649. sideOrientation?: number;
  135650. frontUVs?: Vector4;
  135651. backUVs?: Vector4;
  135652. }, scene?: Nullable<Scene>): Mesh;
  135653. /**
  135654. * Creates a torus mesh
  135655. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  135656. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  135657. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  135658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135661. * @param name defines the name of the mesh
  135662. * @param options defines the options used to create the mesh
  135663. * @param scene defines the hosting scene
  135664. * @returns the torus mesh
  135665. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  135666. */
  135667. static CreateTorus(name: string, options: {
  135668. diameter?: number;
  135669. thickness?: number;
  135670. tessellation?: number;
  135671. updatable?: boolean;
  135672. sideOrientation?: number;
  135673. frontUVs?: Vector4;
  135674. backUVs?: Vector4;
  135675. }, scene?: Nullable<Scene>): Mesh;
  135676. /**
  135677. * Creates a torus knot mesh
  135678. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135679. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135680. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135681. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135685. * @param name defines the name of the mesh
  135686. * @param options defines the options used to create the mesh
  135687. * @param scene defines the hosting scene
  135688. * @returns the torus knot mesh
  135689. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135690. */
  135691. static CreateTorusKnot(name: string, options: {
  135692. radius?: number;
  135693. tube?: number;
  135694. radialSegments?: number;
  135695. tubularSegments?: number;
  135696. p?: number;
  135697. q?: number;
  135698. updatable?: boolean;
  135699. sideOrientation?: number;
  135700. frontUVs?: Vector4;
  135701. backUVs?: Vector4;
  135702. }, scene?: Nullable<Scene>): Mesh;
  135703. /**
  135704. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  135705. * * 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
  135706. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  135707. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  135708. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  135709. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  135710. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  135711. * * 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
  135712. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  135713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  135715. * @param name defines the name of the new line system
  135716. * @param options defines the options used to create the line system
  135717. * @param scene defines the hosting scene
  135718. * @returns a new line system mesh
  135719. */
  135720. static CreateLineSystem(name: string, options: {
  135721. lines: Vector3[][];
  135722. updatable?: boolean;
  135723. instance?: Nullable<LinesMesh>;
  135724. colors?: Nullable<Color4[][]>;
  135725. useVertexAlpha?: boolean;
  135726. }, scene: Nullable<Scene>): LinesMesh;
  135727. /**
  135728. * Creates a line mesh
  135729. * 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
  135730. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  135731. * * The parameter `points` is an array successive Vector3
  135732. * * 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
  135733. * * The optional parameter `colors` is an array of successive Color4, one per line point
  135734. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  135735. * * When updating an instance, remember that only point positions can change, not the number of points
  135736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  135738. * @param name defines the name of the new line system
  135739. * @param options defines the options used to create the line system
  135740. * @param scene defines the hosting scene
  135741. * @returns a new line mesh
  135742. */
  135743. static CreateLines(name: string, options: {
  135744. points: Vector3[];
  135745. updatable?: boolean;
  135746. instance?: Nullable<LinesMesh>;
  135747. colors?: Color4[];
  135748. useVertexAlpha?: boolean;
  135749. }, scene?: Nullable<Scene>): LinesMesh;
  135750. /**
  135751. * Creates a dashed line mesh
  135752. * * 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
  135753. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  135754. * * The parameter `points` is an array successive Vector3
  135755. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  135756. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  135757. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  135758. * * 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
  135759. * * When updating an instance, remember that only point positions can change, not the number of points
  135760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135761. * @param name defines the name of the mesh
  135762. * @param options defines the options used to create the mesh
  135763. * @param scene defines the hosting scene
  135764. * @returns the dashed line mesh
  135765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  135766. */
  135767. static CreateDashedLines(name: string, options: {
  135768. points: Vector3[];
  135769. dashSize?: number;
  135770. gapSize?: number;
  135771. dashNb?: number;
  135772. updatable?: boolean;
  135773. instance?: LinesMesh;
  135774. }, scene?: Nullable<Scene>): LinesMesh;
  135775. /**
  135776. * 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.
  135777. * * 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.
  135778. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135779. * * 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.
  135780. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135781. * * 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
  135782. * * 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
  135783. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135786. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135788. * @param name defines the name of the mesh
  135789. * @param options defines the options used to create the mesh
  135790. * @param scene defines the hosting scene
  135791. * @returns the extruded shape mesh
  135792. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135793. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135794. */
  135795. static ExtrudeShape(name: string, options: {
  135796. shape: Vector3[];
  135797. path: Vector3[];
  135798. scale?: number;
  135799. rotation?: number;
  135800. cap?: number;
  135801. updatable?: boolean;
  135802. sideOrientation?: number;
  135803. frontUVs?: Vector4;
  135804. backUVs?: Vector4;
  135805. instance?: Mesh;
  135806. invertUV?: boolean;
  135807. }, scene?: Nullable<Scene>): Mesh;
  135808. /**
  135809. * Creates an custom extruded shape mesh.
  135810. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135811. * * 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.
  135812. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135813. * * 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
  135814. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135815. * * 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
  135816. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135817. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135818. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135819. * * 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
  135820. * * 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
  135821. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135822. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135823. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135824. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135826. * @param name defines the name of the mesh
  135827. * @param options defines the options used to create the mesh
  135828. * @param scene defines the hosting scene
  135829. * @returns the custom extruded shape mesh
  135830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135833. */
  135834. static ExtrudeShapeCustom(name: string, options: {
  135835. shape: Vector3[];
  135836. path: Vector3[];
  135837. scaleFunction?: any;
  135838. rotationFunction?: any;
  135839. ribbonCloseArray?: boolean;
  135840. ribbonClosePath?: boolean;
  135841. cap?: number;
  135842. updatable?: boolean;
  135843. sideOrientation?: number;
  135844. frontUVs?: Vector4;
  135845. backUVs?: Vector4;
  135846. instance?: Mesh;
  135847. invertUV?: boolean;
  135848. }, scene?: Nullable<Scene>): Mesh;
  135849. /**
  135850. * Creates lathe mesh.
  135851. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135852. * * 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
  135853. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135854. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135855. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135856. * * 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
  135857. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135858. * * 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
  135859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135863. * @param name defines the name of the mesh
  135864. * @param options defines the options used to create the mesh
  135865. * @param scene defines the hosting scene
  135866. * @returns the lathe mesh
  135867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135868. */
  135869. static CreateLathe(name: string, options: {
  135870. shape: Vector3[];
  135871. radius?: number;
  135872. tessellation?: number;
  135873. clip?: number;
  135874. arc?: number;
  135875. closed?: boolean;
  135876. updatable?: boolean;
  135877. sideOrientation?: number;
  135878. frontUVs?: Vector4;
  135879. backUVs?: Vector4;
  135880. cap?: number;
  135881. invertUV?: boolean;
  135882. }, scene?: Nullable<Scene>): Mesh;
  135883. /**
  135884. * Creates a tiled plane mesh
  135885. * * You can set a limited pattern arrangement with the tiles
  135886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135889. * @param name defines the name of the mesh
  135890. * @param options defines the options used to create the mesh
  135891. * @param scene defines the hosting scene
  135892. * @returns the plane mesh
  135893. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  135894. */
  135895. static CreateTiledPlane(name: string, options: {
  135896. pattern?: number;
  135897. tileSize?: number;
  135898. tileWidth?: number;
  135899. tileHeight?: number;
  135900. size?: number;
  135901. width?: number;
  135902. height?: number;
  135903. alignHorizontal?: number;
  135904. alignVertical?: number;
  135905. sideOrientation?: number;
  135906. frontUVs?: Vector4;
  135907. backUVs?: Vector4;
  135908. updatable?: boolean;
  135909. }, scene?: Nullable<Scene>): Mesh;
  135910. /**
  135911. * Creates a plane mesh
  135912. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  135913. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  135914. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  135915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135918. * @param name defines the name of the mesh
  135919. * @param options defines the options used to create the mesh
  135920. * @param scene defines the hosting scene
  135921. * @returns the plane mesh
  135922. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  135923. */
  135924. static CreatePlane(name: string, options: {
  135925. size?: number;
  135926. width?: number;
  135927. height?: number;
  135928. sideOrientation?: number;
  135929. frontUVs?: Vector4;
  135930. backUVs?: Vector4;
  135931. updatable?: boolean;
  135932. sourcePlane?: Plane;
  135933. }, scene?: Nullable<Scene>): Mesh;
  135934. /**
  135935. * Creates a ground mesh
  135936. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  135937. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  135938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135939. * @param name defines the name of the mesh
  135940. * @param options defines the options used to create the mesh
  135941. * @param scene defines the hosting scene
  135942. * @returns the ground mesh
  135943. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  135944. */
  135945. static CreateGround(name: string, options: {
  135946. width?: number;
  135947. height?: number;
  135948. subdivisions?: number;
  135949. subdivisionsX?: number;
  135950. subdivisionsY?: number;
  135951. updatable?: boolean;
  135952. }, scene?: Nullable<Scene>): Mesh;
  135953. /**
  135954. * Creates a tiled ground mesh
  135955. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  135956. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  135957. * * 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
  135958. * * 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
  135959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135960. * @param name defines the name of the mesh
  135961. * @param options defines the options used to create the mesh
  135962. * @param scene defines the hosting scene
  135963. * @returns the tiled ground mesh
  135964. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  135965. */
  135966. static CreateTiledGround(name: string, options: {
  135967. xmin: number;
  135968. zmin: number;
  135969. xmax: number;
  135970. zmax: number;
  135971. subdivisions?: {
  135972. w: number;
  135973. h: number;
  135974. };
  135975. precision?: {
  135976. w: number;
  135977. h: number;
  135978. };
  135979. updatable?: boolean;
  135980. }, scene?: Nullable<Scene>): Mesh;
  135981. /**
  135982. * Creates a ground mesh from a height map
  135983. * * The parameter `url` sets the URL of the height map image resource.
  135984. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  135985. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  135986. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  135987. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  135988. * * 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.
  135989. * * 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).
  135990. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  135991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135992. * @param name defines the name of the mesh
  135993. * @param url defines the url to the height map
  135994. * @param options defines the options used to create the mesh
  135995. * @param scene defines the hosting scene
  135996. * @returns the ground mesh
  135997. * @see https://doc.babylonjs.com/babylon101/height_map
  135998. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  135999. */
  136000. static CreateGroundFromHeightMap(name: string, url: string, options: {
  136001. width?: number;
  136002. height?: number;
  136003. subdivisions?: number;
  136004. minHeight?: number;
  136005. maxHeight?: number;
  136006. colorFilter?: Color3;
  136007. alphaFilter?: number;
  136008. updatable?: boolean;
  136009. onReady?: (mesh: GroundMesh) => void;
  136010. }, scene?: Nullable<Scene>): GroundMesh;
  136011. /**
  136012. * Creates a polygon mesh
  136013. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  136014. * * 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
  136015. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  136018. * * Remember you can only change the shape positions, not their number when updating a polygon
  136019. * @param name defines the name of the mesh
  136020. * @param options defines the options used to create the mesh
  136021. * @param scene defines the hosting scene
  136022. * @param earcutInjection can be used to inject your own earcut reference
  136023. * @returns the polygon mesh
  136024. */
  136025. static CreatePolygon(name: string, options: {
  136026. shape: Vector3[];
  136027. holes?: Vector3[][];
  136028. depth?: number;
  136029. faceUV?: Vector4[];
  136030. faceColors?: Color4[];
  136031. updatable?: boolean;
  136032. sideOrientation?: number;
  136033. frontUVs?: Vector4;
  136034. backUVs?: Vector4;
  136035. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136036. /**
  136037. * Creates an extruded polygon mesh, with depth in the Y direction.
  136038. * * 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)
  136039. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136040. * @param name defines the name of the mesh
  136041. * @param options defines the options used to create the mesh
  136042. * @param scene defines the hosting scene
  136043. * @param earcutInjection can be used to inject your own earcut reference
  136044. * @returns the polygon mesh
  136045. */
  136046. static ExtrudePolygon(name: string, options: {
  136047. shape: Vector3[];
  136048. holes?: Vector3[][];
  136049. depth?: number;
  136050. faceUV?: Vector4[];
  136051. faceColors?: Color4[];
  136052. updatable?: boolean;
  136053. sideOrientation?: number;
  136054. frontUVs?: Vector4;
  136055. backUVs?: Vector4;
  136056. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136057. /**
  136058. * Creates a tube mesh.
  136059. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136060. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  136061. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  136062. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  136063. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  136064. * * 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)
  136065. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  136066. * * 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
  136067. * * 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
  136068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136070. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136072. * @param name defines the name of the mesh
  136073. * @param options defines the options used to create the mesh
  136074. * @param scene defines the hosting scene
  136075. * @returns the tube mesh
  136076. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136077. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  136078. */
  136079. static CreateTube(name: string, options: {
  136080. path: Vector3[];
  136081. radius?: number;
  136082. tessellation?: number;
  136083. radiusFunction?: {
  136084. (i: number, distance: number): number;
  136085. };
  136086. cap?: number;
  136087. arc?: number;
  136088. updatable?: boolean;
  136089. sideOrientation?: number;
  136090. frontUVs?: Vector4;
  136091. backUVs?: Vector4;
  136092. instance?: Mesh;
  136093. invertUV?: boolean;
  136094. }, scene?: Nullable<Scene>): Mesh;
  136095. /**
  136096. * Creates a polyhedron mesh
  136097. * * 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
  136098. * * The parameter `size` (positive float, default 1) sets the polygon size
  136099. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136100. * * 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`
  136101. * * 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
  136102. * * 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)`)
  136103. * * 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
  136104. * * 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
  136105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136108. * @param name defines the name of the mesh
  136109. * @param options defines the options used to create the mesh
  136110. * @param scene defines the hosting scene
  136111. * @returns the polyhedron mesh
  136112. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136113. */
  136114. static CreatePolyhedron(name: string, options: {
  136115. type?: number;
  136116. size?: number;
  136117. sizeX?: number;
  136118. sizeY?: number;
  136119. sizeZ?: number;
  136120. custom?: any;
  136121. faceUV?: Vector4[];
  136122. faceColors?: Color4[];
  136123. flat?: boolean;
  136124. updatable?: boolean;
  136125. sideOrientation?: number;
  136126. frontUVs?: Vector4;
  136127. backUVs?: Vector4;
  136128. }, scene?: Nullable<Scene>): Mesh;
  136129. /**
  136130. * Creates a decal mesh.
  136131. * 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
  136132. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  136133. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  136134. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  136135. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  136136. * @param name defines the name of the mesh
  136137. * @param sourceMesh defines the mesh where the decal must be applied
  136138. * @param options defines the options used to create the mesh
  136139. * @param scene defines the hosting scene
  136140. * @returns the decal mesh
  136141. * @see https://doc.babylonjs.com/how_to/decals
  136142. */
  136143. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  136144. position?: Vector3;
  136145. normal?: Vector3;
  136146. size?: Vector3;
  136147. angle?: number;
  136148. }): Mesh;
  136149. }
  136150. }
  136151. declare module BABYLON {
  136152. /**
  136153. * A simplifier interface for future simplification implementations
  136154. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136155. */
  136156. export interface ISimplifier {
  136157. /**
  136158. * Simplification of a given mesh according to the given settings.
  136159. * Since this requires computation, it is assumed that the function runs async.
  136160. * @param settings The settings of the simplification, including quality and distance
  136161. * @param successCallback A callback that will be called after the mesh was simplified.
  136162. * @param errorCallback in case of an error, this callback will be called. optional.
  136163. */
  136164. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  136165. }
  136166. /**
  136167. * Expected simplification settings.
  136168. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  136169. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136170. */
  136171. export interface ISimplificationSettings {
  136172. /**
  136173. * Gets or sets the expected quality
  136174. */
  136175. quality: number;
  136176. /**
  136177. * Gets or sets the distance when this optimized version should be used
  136178. */
  136179. distance: number;
  136180. /**
  136181. * Gets an already optimized mesh
  136182. */
  136183. optimizeMesh?: boolean;
  136184. }
  136185. /**
  136186. * Class used to specify simplification options
  136187. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136188. */
  136189. export class SimplificationSettings implements ISimplificationSettings {
  136190. /** expected quality */
  136191. quality: number;
  136192. /** distance when this optimized version should be used */
  136193. distance: number;
  136194. /** already optimized mesh */
  136195. optimizeMesh?: boolean | undefined;
  136196. /**
  136197. * Creates a SimplificationSettings
  136198. * @param quality expected quality
  136199. * @param distance distance when this optimized version should be used
  136200. * @param optimizeMesh already optimized mesh
  136201. */
  136202. constructor(
  136203. /** expected quality */
  136204. quality: number,
  136205. /** distance when this optimized version should be used */
  136206. distance: number,
  136207. /** already optimized mesh */
  136208. optimizeMesh?: boolean | undefined);
  136209. }
  136210. /**
  136211. * Interface used to define a simplification task
  136212. */
  136213. export interface ISimplificationTask {
  136214. /**
  136215. * Array of settings
  136216. */
  136217. settings: Array<ISimplificationSettings>;
  136218. /**
  136219. * Simplification type
  136220. */
  136221. simplificationType: SimplificationType;
  136222. /**
  136223. * Mesh to simplify
  136224. */
  136225. mesh: Mesh;
  136226. /**
  136227. * Callback called on success
  136228. */
  136229. successCallback?: () => void;
  136230. /**
  136231. * Defines if parallel processing can be used
  136232. */
  136233. parallelProcessing: boolean;
  136234. }
  136235. /**
  136236. * Queue used to order the simplification tasks
  136237. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136238. */
  136239. export class SimplificationQueue {
  136240. private _simplificationArray;
  136241. /**
  136242. * Gets a boolean indicating that the process is still running
  136243. */
  136244. running: boolean;
  136245. /**
  136246. * Creates a new queue
  136247. */
  136248. constructor();
  136249. /**
  136250. * Adds a new simplification task
  136251. * @param task defines a task to add
  136252. */
  136253. addTask(task: ISimplificationTask): void;
  136254. /**
  136255. * Execute next task
  136256. */
  136257. executeNext(): void;
  136258. /**
  136259. * Execute a simplification task
  136260. * @param task defines the task to run
  136261. */
  136262. runSimplification(task: ISimplificationTask): void;
  136263. private getSimplifier;
  136264. }
  136265. /**
  136266. * The implemented types of simplification
  136267. * At the moment only Quadratic Error Decimation is implemented
  136268. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136269. */
  136270. export enum SimplificationType {
  136271. /** Quadratic error decimation */
  136272. QUADRATIC = 0
  136273. }
  136274. /**
  136275. * An implementation of the Quadratic Error simplification algorithm.
  136276. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  136277. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  136278. * @author RaananW
  136279. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136280. */
  136281. export class QuadraticErrorSimplification implements ISimplifier {
  136282. private _mesh;
  136283. private triangles;
  136284. private vertices;
  136285. private references;
  136286. private _reconstructedMesh;
  136287. /** Gets or sets the number pf sync interations */
  136288. syncIterations: number;
  136289. /** Gets or sets the aggressiveness of the simplifier */
  136290. aggressiveness: number;
  136291. /** Gets or sets the number of allowed iterations for decimation */
  136292. decimationIterations: number;
  136293. /** Gets or sets the espilon to use for bounding box computation */
  136294. boundingBoxEpsilon: number;
  136295. /**
  136296. * Creates a new QuadraticErrorSimplification
  136297. * @param _mesh defines the target mesh
  136298. */
  136299. constructor(_mesh: Mesh);
  136300. /**
  136301. * Simplification of a given mesh according to the given settings.
  136302. * Since this requires computation, it is assumed that the function runs async.
  136303. * @param settings The settings of the simplification, including quality and distance
  136304. * @param successCallback A callback that will be called after the mesh was simplified.
  136305. */
  136306. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  136307. private runDecimation;
  136308. private initWithMesh;
  136309. private init;
  136310. private reconstructMesh;
  136311. private initDecimatedMesh;
  136312. private isFlipped;
  136313. private updateTriangles;
  136314. private identifyBorder;
  136315. private updateMesh;
  136316. private vertexError;
  136317. private calculateError;
  136318. }
  136319. }
  136320. declare module BABYLON {
  136321. interface Scene {
  136322. /** @hidden (Backing field) */
  136323. _simplificationQueue: SimplificationQueue;
  136324. /**
  136325. * Gets or sets the simplification queue attached to the scene
  136326. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136327. */
  136328. simplificationQueue: SimplificationQueue;
  136329. }
  136330. interface Mesh {
  136331. /**
  136332. * Simplify the mesh according to the given array of settings.
  136333. * Function will return immediately and will simplify async
  136334. * @param settings a collection of simplification settings
  136335. * @param parallelProcessing should all levels calculate parallel or one after the other
  136336. * @param simplificationType the type of simplification to run
  136337. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  136338. * @returns the current mesh
  136339. */
  136340. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  136341. }
  136342. /**
  136343. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  136344. * created in a scene
  136345. */
  136346. export class SimplicationQueueSceneComponent implements ISceneComponent {
  136347. /**
  136348. * The component name helpfull to identify the component in the list of scene components.
  136349. */
  136350. readonly name: string;
  136351. /**
  136352. * The scene the component belongs to.
  136353. */
  136354. scene: Scene;
  136355. /**
  136356. * Creates a new instance of the component for the given scene
  136357. * @param scene Defines the scene to register the component in
  136358. */
  136359. constructor(scene: Scene);
  136360. /**
  136361. * Registers the component in a given scene
  136362. */
  136363. register(): void;
  136364. /**
  136365. * Rebuilds the elements related to this component in case of
  136366. * context lost for instance.
  136367. */
  136368. rebuild(): void;
  136369. /**
  136370. * Disposes the component and the associated ressources
  136371. */
  136372. dispose(): void;
  136373. private _beforeCameraUpdate;
  136374. }
  136375. }
  136376. declare module BABYLON {
  136377. /**
  136378. * Navigation plugin interface to add navigation constrained by a navigation mesh
  136379. */
  136380. export interface INavigationEnginePlugin {
  136381. /**
  136382. * plugin name
  136383. */
  136384. name: string;
  136385. /**
  136386. * Creates a navigation mesh
  136387. * @param meshes array of all the geometry used to compute the navigatio mesh
  136388. * @param parameters bunch of parameters used to filter geometry
  136389. */
  136390. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  136391. /**
  136392. * Create a navigation mesh debug mesh
  136393. * @param scene is where the mesh will be added
  136394. * @returns debug display mesh
  136395. */
  136396. createDebugNavMesh(scene: Scene): Mesh;
  136397. /**
  136398. * Get a navigation mesh constrained position, closest to the parameter position
  136399. * @param position world position
  136400. * @returns the closest point to position constrained by the navigation mesh
  136401. */
  136402. getClosestPoint(position: Vector3): Vector3;
  136403. /**
  136404. * Get a navigation mesh constrained position, closest to the parameter position
  136405. * @param position world position
  136406. * @param result output the closest point to position constrained by the navigation mesh
  136407. */
  136408. getClosestPointToRef(position: Vector3, result: Vector3): void;
  136409. /**
  136410. * Get a navigation mesh constrained position, within a particular radius
  136411. * @param position world position
  136412. * @param maxRadius the maximum distance to the constrained world position
  136413. * @returns the closest point to position constrained by the navigation mesh
  136414. */
  136415. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  136416. /**
  136417. * Get a navigation mesh constrained position, within a particular radius
  136418. * @param position world position
  136419. * @param maxRadius the maximum distance to the constrained world position
  136420. * @param result output the closest point to position constrained by the navigation mesh
  136421. */
  136422. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  136423. /**
  136424. * Compute the final position from a segment made of destination-position
  136425. * @param position world position
  136426. * @param destination world position
  136427. * @returns the resulting point along the navmesh
  136428. */
  136429. moveAlong(position: Vector3, destination: Vector3): Vector3;
  136430. /**
  136431. * Compute the final position from a segment made of destination-position
  136432. * @param position world position
  136433. * @param destination world position
  136434. * @param result output the resulting point along the navmesh
  136435. */
  136436. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  136437. /**
  136438. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  136439. * @param start world position
  136440. * @param end world position
  136441. * @returns array containing world position composing the path
  136442. */
  136443. computePath(start: Vector3, end: Vector3): Vector3[];
  136444. /**
  136445. * If this plugin is supported
  136446. * @returns true if plugin is supported
  136447. */
  136448. isSupported(): boolean;
  136449. /**
  136450. * Create a new Crowd so you can add agents
  136451. * @param maxAgents the maximum agent count in the crowd
  136452. * @param maxAgentRadius the maximum radius an agent can have
  136453. * @param scene to attach the crowd to
  136454. * @returns the crowd you can add agents to
  136455. */
  136456. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  136457. /**
  136458. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136459. * The queries will try to find a solution within those bounds
  136460. * default is (1,1,1)
  136461. * @param extent x,y,z value that define the extent around the queries point of reference
  136462. */
  136463. setDefaultQueryExtent(extent: Vector3): void;
  136464. /**
  136465. * Get the Bounding box extent specified by setDefaultQueryExtent
  136466. * @returns the box extent values
  136467. */
  136468. getDefaultQueryExtent(): Vector3;
  136469. /**
  136470. * build the navmesh from a previously saved state using getNavmeshData
  136471. * @param data the Uint8Array returned by getNavmeshData
  136472. */
  136473. buildFromNavmeshData(data: Uint8Array): void;
  136474. /**
  136475. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  136476. * @returns data the Uint8Array that can be saved and reused
  136477. */
  136478. getNavmeshData(): Uint8Array;
  136479. /**
  136480. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136481. * @param result output the box extent values
  136482. */
  136483. getDefaultQueryExtentToRef(result: Vector3): void;
  136484. /**
  136485. * Release all resources
  136486. */
  136487. dispose(): void;
  136488. }
  136489. /**
  136490. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  136491. */
  136492. export interface ICrowd {
  136493. /**
  136494. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136495. * You can attach anything to that node. The node position is updated in the scene update tick.
  136496. * @param pos world position that will be constrained by the navigation mesh
  136497. * @param parameters agent parameters
  136498. * @param transform hooked to the agent that will be update by the scene
  136499. * @returns agent index
  136500. */
  136501. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136502. /**
  136503. * Returns the agent position in world space
  136504. * @param index agent index returned by addAgent
  136505. * @returns world space position
  136506. */
  136507. getAgentPosition(index: number): Vector3;
  136508. /**
  136509. * Gets the agent position result in world space
  136510. * @param index agent index returned by addAgent
  136511. * @param result output world space position
  136512. */
  136513. getAgentPositionToRef(index: number, result: Vector3): void;
  136514. /**
  136515. * Gets the agent velocity in world space
  136516. * @param index agent index returned by addAgent
  136517. * @returns world space velocity
  136518. */
  136519. getAgentVelocity(index: number): Vector3;
  136520. /**
  136521. * Gets the agent velocity result in world space
  136522. * @param index agent index returned by addAgent
  136523. * @param result output world space velocity
  136524. */
  136525. getAgentVelocityToRef(index: number, result: Vector3): void;
  136526. /**
  136527. * remove a particular agent previously created
  136528. * @param index agent index returned by addAgent
  136529. */
  136530. removeAgent(index: number): void;
  136531. /**
  136532. * get the list of all agents attached to this crowd
  136533. * @returns list of agent indices
  136534. */
  136535. getAgents(): number[];
  136536. /**
  136537. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136538. * @param deltaTime in seconds
  136539. */
  136540. update(deltaTime: number): void;
  136541. /**
  136542. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136543. * @param index agent index returned by addAgent
  136544. * @param destination targeted world position
  136545. */
  136546. agentGoto(index: number, destination: Vector3): void;
  136547. /**
  136548. * Teleport the agent to a new position
  136549. * @param index agent index returned by addAgent
  136550. * @param destination targeted world position
  136551. */
  136552. agentTeleport(index: number, destination: Vector3): void;
  136553. /**
  136554. * Update agent parameters
  136555. * @param index agent index returned by addAgent
  136556. * @param parameters agent parameters
  136557. */
  136558. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136559. /**
  136560. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136561. * The queries will try to find a solution within those bounds
  136562. * default is (1,1,1)
  136563. * @param extent x,y,z value that define the extent around the queries point of reference
  136564. */
  136565. setDefaultQueryExtent(extent: Vector3): void;
  136566. /**
  136567. * Get the Bounding box extent specified by setDefaultQueryExtent
  136568. * @returns the box extent values
  136569. */
  136570. getDefaultQueryExtent(): Vector3;
  136571. /**
  136572. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136573. * @param result output the box extent values
  136574. */
  136575. getDefaultQueryExtentToRef(result: Vector3): void;
  136576. /**
  136577. * Release all resources
  136578. */
  136579. dispose(): void;
  136580. }
  136581. /**
  136582. * Configures an agent
  136583. */
  136584. export interface IAgentParameters {
  136585. /**
  136586. * Agent radius. [Limit: >= 0]
  136587. */
  136588. radius: number;
  136589. /**
  136590. * Agent height. [Limit: > 0]
  136591. */
  136592. height: number;
  136593. /**
  136594. * Maximum allowed acceleration. [Limit: >= 0]
  136595. */
  136596. maxAcceleration: number;
  136597. /**
  136598. * Maximum allowed speed. [Limit: >= 0]
  136599. */
  136600. maxSpeed: number;
  136601. /**
  136602. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  136603. */
  136604. collisionQueryRange: number;
  136605. /**
  136606. * The path visibility optimization range. [Limit: > 0]
  136607. */
  136608. pathOptimizationRange: number;
  136609. /**
  136610. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  136611. */
  136612. separationWeight: number;
  136613. }
  136614. /**
  136615. * Configures the navigation mesh creation
  136616. */
  136617. export interface INavMeshParameters {
  136618. /**
  136619. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  136620. */
  136621. cs: number;
  136622. /**
  136623. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  136624. */
  136625. ch: number;
  136626. /**
  136627. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  136628. */
  136629. walkableSlopeAngle: number;
  136630. /**
  136631. * Minimum floor to 'ceiling' height that will still allow the floor area to
  136632. * be considered walkable. [Limit: >= 3] [Units: vx]
  136633. */
  136634. walkableHeight: number;
  136635. /**
  136636. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  136637. */
  136638. walkableClimb: number;
  136639. /**
  136640. * The distance to erode/shrink the walkable area of the heightfield away from
  136641. * obstructions. [Limit: >=0] [Units: vx]
  136642. */
  136643. walkableRadius: number;
  136644. /**
  136645. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  136646. */
  136647. maxEdgeLen: number;
  136648. /**
  136649. * The maximum distance a simplfied contour's border edges should deviate
  136650. * the original raw contour. [Limit: >=0] [Units: vx]
  136651. */
  136652. maxSimplificationError: number;
  136653. /**
  136654. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  136655. */
  136656. minRegionArea: number;
  136657. /**
  136658. * Any regions with a span count smaller than this value will, if possible,
  136659. * be merged with larger regions. [Limit: >=0] [Units: vx]
  136660. */
  136661. mergeRegionArea: number;
  136662. /**
  136663. * The maximum number of vertices allowed for polygons generated during the
  136664. * contour to polygon conversion process. [Limit: >= 3]
  136665. */
  136666. maxVertsPerPoly: number;
  136667. /**
  136668. * Sets the sampling distance to use when generating the detail mesh.
  136669. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  136670. */
  136671. detailSampleDist: number;
  136672. /**
  136673. * The maximum distance the detail mesh surface should deviate from heightfield
  136674. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  136675. */
  136676. detailSampleMaxError: number;
  136677. }
  136678. }
  136679. declare module BABYLON {
  136680. /**
  136681. * RecastJS navigation plugin
  136682. */
  136683. export class RecastJSPlugin implements INavigationEnginePlugin {
  136684. /**
  136685. * Reference to the Recast library
  136686. */
  136687. bjsRECAST: any;
  136688. /**
  136689. * plugin name
  136690. */
  136691. name: string;
  136692. /**
  136693. * the first navmesh created. We might extend this to support multiple navmeshes
  136694. */
  136695. navMesh: any;
  136696. /**
  136697. * Initializes the recastJS plugin
  136698. * @param recastInjection can be used to inject your own recast reference
  136699. */
  136700. constructor(recastInjection?: any);
  136701. /**
  136702. * Creates a navigation mesh
  136703. * @param meshes array of all the geometry used to compute the navigatio mesh
  136704. * @param parameters bunch of parameters used to filter geometry
  136705. */
  136706. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  136707. /**
  136708. * Create a navigation mesh debug mesh
  136709. * @param scene is where the mesh will be added
  136710. * @returns debug display mesh
  136711. */
  136712. createDebugNavMesh(scene: Scene): Mesh;
  136713. /**
  136714. * Get a navigation mesh constrained position, closest to the parameter position
  136715. * @param position world position
  136716. * @returns the closest point to position constrained by the navigation mesh
  136717. */
  136718. getClosestPoint(position: Vector3): Vector3;
  136719. /**
  136720. * Get a navigation mesh constrained position, closest to the parameter position
  136721. * @param position world position
  136722. * @param result output the closest point to position constrained by the navigation mesh
  136723. */
  136724. getClosestPointToRef(position: Vector3, result: Vector3): void;
  136725. /**
  136726. * Get a navigation mesh constrained position, within a particular radius
  136727. * @param position world position
  136728. * @param maxRadius the maximum distance to the constrained world position
  136729. * @returns the closest point to position constrained by the navigation mesh
  136730. */
  136731. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  136732. /**
  136733. * Get a navigation mesh constrained position, within a particular radius
  136734. * @param position world position
  136735. * @param maxRadius the maximum distance to the constrained world position
  136736. * @param result output the closest point to position constrained by the navigation mesh
  136737. */
  136738. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  136739. /**
  136740. * Compute the final position from a segment made of destination-position
  136741. * @param position world position
  136742. * @param destination world position
  136743. * @returns the resulting point along the navmesh
  136744. */
  136745. moveAlong(position: Vector3, destination: Vector3): Vector3;
  136746. /**
  136747. * Compute the final position from a segment made of destination-position
  136748. * @param position world position
  136749. * @param destination world position
  136750. * @param result output the resulting point along the navmesh
  136751. */
  136752. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  136753. /**
  136754. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  136755. * @param start world position
  136756. * @param end world position
  136757. * @returns array containing world position composing the path
  136758. */
  136759. computePath(start: Vector3, end: Vector3): Vector3[];
  136760. /**
  136761. * Create a new Crowd so you can add agents
  136762. * @param maxAgents the maximum agent count in the crowd
  136763. * @param maxAgentRadius the maximum radius an agent can have
  136764. * @param scene to attach the crowd to
  136765. * @returns the crowd you can add agents to
  136766. */
  136767. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  136768. /**
  136769. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136770. * The queries will try to find a solution within those bounds
  136771. * default is (1,1,1)
  136772. * @param extent x,y,z value that define the extent around the queries point of reference
  136773. */
  136774. setDefaultQueryExtent(extent: Vector3): void;
  136775. /**
  136776. * Get the Bounding box extent specified by setDefaultQueryExtent
  136777. * @returns the box extent values
  136778. */
  136779. getDefaultQueryExtent(): Vector3;
  136780. /**
  136781. * build the navmesh from a previously saved state using getNavmeshData
  136782. * @param data the Uint8Array returned by getNavmeshData
  136783. */
  136784. buildFromNavmeshData(data: Uint8Array): void;
  136785. /**
  136786. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  136787. * @returns data the Uint8Array that can be saved and reused
  136788. */
  136789. getNavmeshData(): Uint8Array;
  136790. /**
  136791. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136792. * @param result output the box extent values
  136793. */
  136794. getDefaultQueryExtentToRef(result: Vector3): void;
  136795. /**
  136796. * Disposes
  136797. */
  136798. dispose(): void;
  136799. /**
  136800. * If this plugin is supported
  136801. * @returns true if plugin is supported
  136802. */
  136803. isSupported(): boolean;
  136804. }
  136805. /**
  136806. * Recast detour crowd implementation
  136807. */
  136808. export class RecastJSCrowd implements ICrowd {
  136809. /**
  136810. * Recast/detour plugin
  136811. */
  136812. bjsRECASTPlugin: RecastJSPlugin;
  136813. /**
  136814. * Link to the detour crowd
  136815. */
  136816. recastCrowd: any;
  136817. /**
  136818. * One transform per agent
  136819. */
  136820. transforms: TransformNode[];
  136821. /**
  136822. * All agents created
  136823. */
  136824. agents: number[];
  136825. /**
  136826. * Link to the scene is kept to unregister the crowd from the scene
  136827. */
  136828. private _scene;
  136829. /**
  136830. * Observer for crowd updates
  136831. */
  136832. private _onBeforeAnimationsObserver;
  136833. /**
  136834. * Constructor
  136835. * @param plugin recastJS plugin
  136836. * @param maxAgents the maximum agent count in the crowd
  136837. * @param maxAgentRadius the maximum radius an agent can have
  136838. * @param scene to attach the crowd to
  136839. * @returns the crowd you can add agents to
  136840. */
  136841. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  136842. /**
  136843. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136844. * You can attach anything to that node. The node position is updated in the scene update tick.
  136845. * @param pos world position that will be constrained by the navigation mesh
  136846. * @param parameters agent parameters
  136847. * @param transform hooked to the agent that will be update by the scene
  136848. * @returns agent index
  136849. */
  136850. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136851. /**
  136852. * Returns the agent position in world space
  136853. * @param index agent index returned by addAgent
  136854. * @returns world space position
  136855. */
  136856. getAgentPosition(index: number): Vector3;
  136857. /**
  136858. * Returns the agent position result in world space
  136859. * @param index agent index returned by addAgent
  136860. * @param result output world space position
  136861. */
  136862. getAgentPositionToRef(index: number, result: Vector3): void;
  136863. /**
  136864. * Returns the agent velocity in world space
  136865. * @param index agent index returned by addAgent
  136866. * @returns world space velocity
  136867. */
  136868. getAgentVelocity(index: number): Vector3;
  136869. /**
  136870. * Returns the agent velocity result in world space
  136871. * @param index agent index returned by addAgent
  136872. * @param result output world space velocity
  136873. */
  136874. getAgentVelocityToRef(index: number, result: Vector3): void;
  136875. /**
  136876. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136877. * @param index agent index returned by addAgent
  136878. * @param destination targeted world position
  136879. */
  136880. agentGoto(index: number, destination: Vector3): void;
  136881. /**
  136882. * Teleport the agent to a new position
  136883. * @param index agent index returned by addAgent
  136884. * @param destination targeted world position
  136885. */
  136886. agentTeleport(index: number, destination: Vector3): void;
  136887. /**
  136888. * Update agent parameters
  136889. * @param index agent index returned by addAgent
  136890. * @param parameters agent parameters
  136891. */
  136892. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136893. /**
  136894. * remove a particular agent previously created
  136895. * @param index agent index returned by addAgent
  136896. */
  136897. removeAgent(index: number): void;
  136898. /**
  136899. * get the list of all agents attached to this crowd
  136900. * @returns list of agent indices
  136901. */
  136902. getAgents(): number[];
  136903. /**
  136904. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136905. * @param deltaTime in seconds
  136906. */
  136907. update(deltaTime: number): void;
  136908. /**
  136909. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136910. * The queries will try to find a solution within those bounds
  136911. * default is (1,1,1)
  136912. * @param extent x,y,z value that define the extent around the queries point of reference
  136913. */
  136914. setDefaultQueryExtent(extent: Vector3): void;
  136915. /**
  136916. * Get the Bounding box extent specified by setDefaultQueryExtent
  136917. * @returns the box extent values
  136918. */
  136919. getDefaultQueryExtent(): Vector3;
  136920. /**
  136921. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136922. * @param result output the box extent values
  136923. */
  136924. getDefaultQueryExtentToRef(result: Vector3): void;
  136925. /**
  136926. * Release all resources
  136927. */
  136928. dispose(): void;
  136929. }
  136930. }
  136931. declare module BABYLON {
  136932. /**
  136933. * Class used to enable access to IndexedDB
  136934. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  136935. */
  136936. export class Database implements IOfflineProvider {
  136937. private _callbackManifestChecked;
  136938. private _currentSceneUrl;
  136939. private _db;
  136940. private _enableSceneOffline;
  136941. private _enableTexturesOffline;
  136942. private _manifestVersionFound;
  136943. private _mustUpdateRessources;
  136944. private _hasReachedQuota;
  136945. private _isSupported;
  136946. private _idbFactory;
  136947. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  136948. private static IsUASupportingBlobStorage;
  136949. /**
  136950. * Gets a boolean indicating if Database storate is enabled (off by default)
  136951. */
  136952. static IDBStorageEnabled: boolean;
  136953. /**
  136954. * Gets a boolean indicating if scene must be saved in the database
  136955. */
  136956. get enableSceneOffline(): boolean;
  136957. /**
  136958. * Gets a boolean indicating if textures must be saved in the database
  136959. */
  136960. get enableTexturesOffline(): boolean;
  136961. /**
  136962. * Creates a new Database
  136963. * @param urlToScene defines the url to load the scene
  136964. * @param callbackManifestChecked defines the callback to use when manifest is checked
  136965. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  136966. */
  136967. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  136968. private static _ParseURL;
  136969. private static _ReturnFullUrlLocation;
  136970. private _checkManifestFile;
  136971. /**
  136972. * Open the database and make it available
  136973. * @param successCallback defines the callback to call on success
  136974. * @param errorCallback defines the callback to call on error
  136975. */
  136976. open(successCallback: () => void, errorCallback: () => void): void;
  136977. /**
  136978. * Loads an image from the database
  136979. * @param url defines the url to load from
  136980. * @param image defines the target DOM image
  136981. */
  136982. loadImage(url: string, image: HTMLImageElement): void;
  136983. private _loadImageFromDBAsync;
  136984. private _saveImageIntoDBAsync;
  136985. private _checkVersionFromDB;
  136986. private _loadVersionFromDBAsync;
  136987. private _saveVersionIntoDBAsync;
  136988. /**
  136989. * Loads a file from database
  136990. * @param url defines the URL to load from
  136991. * @param sceneLoaded defines a callback to call on success
  136992. * @param progressCallBack defines a callback to call when progress changed
  136993. * @param errorCallback defines a callback to call on error
  136994. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  136995. */
  136996. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  136997. private _loadFileAsync;
  136998. private _saveFileAsync;
  136999. /**
  137000. * Validates if xhr data is correct
  137001. * @param xhr defines the request to validate
  137002. * @param dataType defines the expected data type
  137003. * @returns true if data is correct
  137004. */
  137005. private static _ValidateXHRData;
  137006. }
  137007. }
  137008. declare module BABYLON {
  137009. /** @hidden */
  137010. export var gpuUpdateParticlesPixelShader: {
  137011. name: string;
  137012. shader: string;
  137013. };
  137014. }
  137015. declare module BABYLON {
  137016. /** @hidden */
  137017. export var gpuUpdateParticlesVertexShader: {
  137018. name: string;
  137019. shader: string;
  137020. };
  137021. }
  137022. declare module BABYLON {
  137023. /** @hidden */
  137024. export var clipPlaneFragmentDeclaration2: {
  137025. name: string;
  137026. shader: string;
  137027. };
  137028. }
  137029. declare module BABYLON {
  137030. /** @hidden */
  137031. export var gpuRenderParticlesPixelShader: {
  137032. name: string;
  137033. shader: string;
  137034. };
  137035. }
  137036. declare module BABYLON {
  137037. /** @hidden */
  137038. export var clipPlaneVertexDeclaration2: {
  137039. name: string;
  137040. shader: string;
  137041. };
  137042. }
  137043. declare module BABYLON {
  137044. /** @hidden */
  137045. export var gpuRenderParticlesVertexShader: {
  137046. name: string;
  137047. shader: string;
  137048. };
  137049. }
  137050. declare module BABYLON {
  137051. /**
  137052. * This represents a GPU particle system in Babylon
  137053. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  137054. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  137055. */
  137056. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  137057. /**
  137058. * The layer mask we are rendering the particles through.
  137059. */
  137060. layerMask: number;
  137061. private _capacity;
  137062. private _activeCount;
  137063. private _currentActiveCount;
  137064. private _accumulatedCount;
  137065. private _renderEffect;
  137066. private _updateEffect;
  137067. private _buffer0;
  137068. private _buffer1;
  137069. private _spriteBuffer;
  137070. private _updateVAO;
  137071. private _renderVAO;
  137072. private _targetIndex;
  137073. private _sourceBuffer;
  137074. private _targetBuffer;
  137075. private _engine;
  137076. private _currentRenderId;
  137077. private _started;
  137078. private _stopped;
  137079. private _timeDelta;
  137080. private _randomTexture;
  137081. private _randomTexture2;
  137082. private _attributesStrideSize;
  137083. private _updateEffectOptions;
  137084. private _randomTextureSize;
  137085. private _actualFrame;
  137086. private readonly _rawTextureWidth;
  137087. /**
  137088. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  137089. */
  137090. static get IsSupported(): boolean;
  137091. /**
  137092. * An event triggered when the system is disposed.
  137093. */
  137094. onDisposeObservable: Observable<GPUParticleSystem>;
  137095. /**
  137096. * Gets the maximum number of particles active at the same time.
  137097. * @returns The max number of active particles.
  137098. */
  137099. getCapacity(): number;
  137100. /**
  137101. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  137102. * to override the particles.
  137103. */
  137104. forceDepthWrite: boolean;
  137105. /**
  137106. * Gets or set the number of active particles
  137107. */
  137108. get activeParticleCount(): number;
  137109. set activeParticleCount(value: number);
  137110. private _preWarmDone;
  137111. /**
  137112. * Specifies if the particles are updated in emitter local space or world space.
  137113. * This is always false for GPU particles
  137114. */
  137115. get isLocal(): boolean;
  137116. set isLocal(value: boolean);
  137117. /**
  137118. * Is this system ready to be used/rendered
  137119. * @return true if the system is ready
  137120. */
  137121. isReady(): boolean;
  137122. /**
  137123. * Gets if the system has been started. (Note: this will still be true after stop is called)
  137124. * @returns True if it has been started, otherwise false.
  137125. */
  137126. isStarted(): boolean;
  137127. /**
  137128. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  137129. * @returns True if it has been stopped, otherwise false.
  137130. */
  137131. isStopped(): boolean;
  137132. /**
  137133. * Gets a boolean indicating that the system is stopping
  137134. * @returns true if the system is currently stopping
  137135. */
  137136. isStopping(): boolean;
  137137. /**
  137138. * Gets the number of particles active at the same time.
  137139. * @returns The number of active particles.
  137140. */
  137141. getActiveCount(): number;
  137142. /**
  137143. * Starts the particle system and begins to emit
  137144. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  137145. */
  137146. start(delay?: number): void;
  137147. /**
  137148. * Stops the particle system.
  137149. */
  137150. stop(): void;
  137151. /**
  137152. * Remove all active particles
  137153. */
  137154. reset(): void;
  137155. /**
  137156. * Returns the string "GPUParticleSystem"
  137157. * @returns a string containing the class name
  137158. */
  137159. getClassName(): string;
  137160. private _colorGradientsTexture;
  137161. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  137162. /**
  137163. * Adds a new color gradient
  137164. * @param gradient defines the gradient to use (between 0 and 1)
  137165. * @param color1 defines the color to affect to the specified gradient
  137166. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  137167. * @returns the current particle system
  137168. */
  137169. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  137170. private _refreshColorGradient;
  137171. /** Force the system to rebuild all gradients */
  137172. forceRefreshGradients(): void;
  137173. /**
  137174. * Remove a specific color gradient
  137175. * @param gradient defines the gradient to remove
  137176. * @returns the current particle system
  137177. */
  137178. removeColorGradient(gradient: number): GPUParticleSystem;
  137179. private _angularSpeedGradientsTexture;
  137180. private _sizeGradientsTexture;
  137181. private _velocityGradientsTexture;
  137182. private _limitVelocityGradientsTexture;
  137183. private _dragGradientsTexture;
  137184. private _addFactorGradient;
  137185. /**
  137186. * Adds a new size gradient
  137187. * @param gradient defines the gradient to use (between 0 and 1)
  137188. * @param factor defines the size factor to affect to the specified gradient
  137189. * @returns the current particle system
  137190. */
  137191. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  137192. /**
  137193. * Remove a specific size gradient
  137194. * @param gradient defines the gradient to remove
  137195. * @returns the current particle system
  137196. */
  137197. removeSizeGradient(gradient: number): GPUParticleSystem;
  137198. private _refreshFactorGradient;
  137199. /**
  137200. * Adds a new angular speed gradient
  137201. * @param gradient defines the gradient to use (between 0 and 1)
  137202. * @param factor defines the angular speed to affect to the specified gradient
  137203. * @returns the current particle system
  137204. */
  137205. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  137206. /**
  137207. * Remove a specific angular speed gradient
  137208. * @param gradient defines the gradient to remove
  137209. * @returns the current particle system
  137210. */
  137211. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  137212. /**
  137213. * Adds a new velocity gradient
  137214. * @param gradient defines the gradient to use (between 0 and 1)
  137215. * @param factor defines the velocity to affect to the specified gradient
  137216. * @returns the current particle system
  137217. */
  137218. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137219. /**
  137220. * Remove a specific velocity gradient
  137221. * @param gradient defines the gradient to remove
  137222. * @returns the current particle system
  137223. */
  137224. removeVelocityGradient(gradient: number): GPUParticleSystem;
  137225. /**
  137226. * Adds a new limit velocity gradient
  137227. * @param gradient defines the gradient to use (between 0 and 1)
  137228. * @param factor defines the limit velocity value to affect to the specified gradient
  137229. * @returns the current particle system
  137230. */
  137231. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137232. /**
  137233. * Remove a specific limit velocity gradient
  137234. * @param gradient defines the gradient to remove
  137235. * @returns the current particle system
  137236. */
  137237. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  137238. /**
  137239. * Adds a new drag gradient
  137240. * @param gradient defines the gradient to use (between 0 and 1)
  137241. * @param factor defines the drag value to affect to the specified gradient
  137242. * @returns the current particle system
  137243. */
  137244. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  137245. /**
  137246. * Remove a specific drag gradient
  137247. * @param gradient defines the gradient to remove
  137248. * @returns the current particle system
  137249. */
  137250. removeDragGradient(gradient: number): GPUParticleSystem;
  137251. /**
  137252. * Not supported by GPUParticleSystem
  137253. * @param gradient defines the gradient to use (between 0 and 1)
  137254. * @param factor defines the emit rate value to affect to the specified gradient
  137255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137256. * @returns the current particle system
  137257. */
  137258. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137259. /**
  137260. * Not supported by GPUParticleSystem
  137261. * @param gradient defines the gradient to remove
  137262. * @returns the current particle system
  137263. */
  137264. removeEmitRateGradient(gradient: number): IParticleSystem;
  137265. /**
  137266. * Not supported by GPUParticleSystem
  137267. * @param gradient defines the gradient to use (between 0 and 1)
  137268. * @param factor defines the start size value to affect to the specified gradient
  137269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137270. * @returns the current particle system
  137271. */
  137272. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137273. /**
  137274. * Not supported by GPUParticleSystem
  137275. * @param gradient defines the gradient to remove
  137276. * @returns the current particle system
  137277. */
  137278. removeStartSizeGradient(gradient: number): IParticleSystem;
  137279. /**
  137280. * Not supported by GPUParticleSystem
  137281. * @param gradient defines the gradient to use (between 0 and 1)
  137282. * @param min defines the color remap minimal range
  137283. * @param max defines the color remap maximal range
  137284. * @returns the current particle system
  137285. */
  137286. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137287. /**
  137288. * Not supported by GPUParticleSystem
  137289. * @param gradient defines the gradient to remove
  137290. * @returns the current particle system
  137291. */
  137292. removeColorRemapGradient(): IParticleSystem;
  137293. /**
  137294. * Not supported by GPUParticleSystem
  137295. * @param gradient defines the gradient to use (between 0 and 1)
  137296. * @param min defines the alpha remap minimal range
  137297. * @param max defines the alpha remap maximal range
  137298. * @returns the current particle system
  137299. */
  137300. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137301. /**
  137302. * Not supported by GPUParticleSystem
  137303. * @param gradient defines the gradient to remove
  137304. * @returns the current particle system
  137305. */
  137306. removeAlphaRemapGradient(): IParticleSystem;
  137307. /**
  137308. * Not supported by GPUParticleSystem
  137309. * @param gradient defines the gradient to use (between 0 and 1)
  137310. * @param color defines the color to affect to the specified gradient
  137311. * @returns the current particle system
  137312. */
  137313. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  137314. /**
  137315. * Not supported by GPUParticleSystem
  137316. * @param gradient defines the gradient to remove
  137317. * @returns the current particle system
  137318. */
  137319. removeRampGradient(): IParticleSystem;
  137320. /**
  137321. * Not supported by GPUParticleSystem
  137322. * @returns the list of ramp gradients
  137323. */
  137324. getRampGradients(): Nullable<Array<Color3Gradient>>;
  137325. /**
  137326. * Not supported by GPUParticleSystem
  137327. * Gets or sets a boolean indicating that ramp gradients must be used
  137328. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  137329. */
  137330. get useRampGradients(): boolean;
  137331. set useRampGradients(value: boolean);
  137332. /**
  137333. * Not supported by GPUParticleSystem
  137334. * @param gradient defines the gradient to use (between 0 and 1)
  137335. * @param factor defines the life time factor to affect to the specified gradient
  137336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137337. * @returns the current particle system
  137338. */
  137339. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137340. /**
  137341. * Not supported by GPUParticleSystem
  137342. * @param gradient defines the gradient to remove
  137343. * @returns the current particle system
  137344. */
  137345. removeLifeTimeGradient(gradient: number): IParticleSystem;
  137346. /**
  137347. * Instantiates a GPU particle system.
  137348. * 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.
  137349. * @param name The name of the particle system
  137350. * @param options The options used to create the system
  137351. * @param scene The scene the particle system belongs to
  137352. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  137353. */
  137354. constructor(name: string, options: Partial<{
  137355. capacity: number;
  137356. randomTextureSize: number;
  137357. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  137358. protected _reset(): void;
  137359. private _createUpdateVAO;
  137360. private _createRenderVAO;
  137361. private _initialize;
  137362. /** @hidden */
  137363. _recreateUpdateEffect(): void;
  137364. /** @hidden */
  137365. _recreateRenderEffect(): void;
  137366. /**
  137367. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  137368. * @param preWarm defines if we are in the pre-warmimg phase
  137369. */
  137370. animate(preWarm?: boolean): void;
  137371. private _createFactorGradientTexture;
  137372. private _createSizeGradientTexture;
  137373. private _createAngularSpeedGradientTexture;
  137374. private _createVelocityGradientTexture;
  137375. private _createLimitVelocityGradientTexture;
  137376. private _createDragGradientTexture;
  137377. private _createColorGradientTexture;
  137378. /**
  137379. * Renders the particle system in its current state
  137380. * @param preWarm defines if the system should only update the particles but not render them
  137381. * @returns the current number of particles
  137382. */
  137383. render(preWarm?: boolean): number;
  137384. /**
  137385. * Rebuilds the particle system
  137386. */
  137387. rebuild(): void;
  137388. private _releaseBuffers;
  137389. private _releaseVAOs;
  137390. /**
  137391. * Disposes the particle system and free the associated resources
  137392. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  137393. */
  137394. dispose(disposeTexture?: boolean): void;
  137395. /**
  137396. * Clones the particle system.
  137397. * @param name The name of the cloned object
  137398. * @param newEmitter The new emitter to use
  137399. * @returns the cloned particle system
  137400. */
  137401. clone(name: string, newEmitter: any): GPUParticleSystem;
  137402. /**
  137403. * Serializes the particle system to a JSON object.
  137404. * @returns the JSON object
  137405. */
  137406. serialize(): any;
  137407. /**
  137408. * Parses a JSON object to create a GPU particle system.
  137409. * @param parsedParticleSystem The JSON object to parse
  137410. * @param scene The scene to create the particle system in
  137411. * @param rootUrl The root url to use to load external dependencies like texture
  137412. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  137413. * @returns the parsed GPU particle system
  137414. */
  137415. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  137416. }
  137417. }
  137418. declare module BABYLON {
  137419. /**
  137420. * Represents a set of particle systems working together to create a specific effect
  137421. */
  137422. export class ParticleSystemSet implements IDisposable {
  137423. /**
  137424. * Gets or sets base Assets URL
  137425. */
  137426. static BaseAssetsUrl: string;
  137427. private _emitterCreationOptions;
  137428. private _emitterNode;
  137429. /**
  137430. * Gets the particle system list
  137431. */
  137432. systems: IParticleSystem[];
  137433. /**
  137434. * Gets the emitter node used with this set
  137435. */
  137436. get emitterNode(): Nullable<TransformNode>;
  137437. /**
  137438. * Creates a new emitter mesh as a sphere
  137439. * @param options defines the options used to create the sphere
  137440. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  137441. * @param scene defines the hosting scene
  137442. */
  137443. setEmitterAsSphere(options: {
  137444. diameter: number;
  137445. segments: number;
  137446. color: Color3;
  137447. }, renderingGroupId: number, scene: Scene): void;
  137448. /**
  137449. * Starts all particle systems of the set
  137450. * @param emitter defines an optional mesh to use as emitter for the particle systems
  137451. */
  137452. start(emitter?: AbstractMesh): void;
  137453. /**
  137454. * Release all associated resources
  137455. */
  137456. dispose(): void;
  137457. /**
  137458. * Serialize the set into a JSON compatible object
  137459. * @returns a JSON compatible representation of the set
  137460. */
  137461. serialize(): any;
  137462. /**
  137463. * Parse a new ParticleSystemSet from a serialized source
  137464. * @param data defines a JSON compatible representation of the set
  137465. * @param scene defines the hosting scene
  137466. * @param gpu defines if we want GPU particles or CPU particles
  137467. * @returns a new ParticleSystemSet
  137468. */
  137469. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  137470. }
  137471. }
  137472. declare module BABYLON {
  137473. /**
  137474. * This class is made for on one-liner static method to help creating particle system set.
  137475. */
  137476. export class ParticleHelper {
  137477. /**
  137478. * Gets or sets base Assets URL
  137479. */
  137480. static BaseAssetsUrl: string;
  137481. /**
  137482. * Create a default particle system that you can tweak
  137483. * @param emitter defines the emitter to use
  137484. * @param capacity defines the system capacity (default is 500 particles)
  137485. * @param scene defines the hosting scene
  137486. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  137487. * @returns the new Particle system
  137488. */
  137489. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  137490. /**
  137491. * This is the main static method (one-liner) of this helper to create different particle systems
  137492. * @param type This string represents the type to the particle system to create
  137493. * @param scene The scene where the particle system should live
  137494. * @param gpu If the system will use gpu
  137495. * @returns the ParticleSystemSet created
  137496. */
  137497. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  137498. /**
  137499. * Static function used to export a particle system to a ParticleSystemSet variable.
  137500. * Please note that the emitter shape is not exported
  137501. * @param systems defines the particle systems to export
  137502. * @returns the created particle system set
  137503. */
  137504. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  137505. }
  137506. }
  137507. declare module BABYLON {
  137508. interface Engine {
  137509. /**
  137510. * Create an effect to use with particle systems.
  137511. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  137512. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  137513. * @param uniformsNames defines a list of attribute names
  137514. * @param samplers defines an array of string used to represent textures
  137515. * @param defines defines the string containing the defines to use to compile the shaders
  137516. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  137517. * @param onCompiled defines a function to call when the effect creation is successful
  137518. * @param onError defines a function to call when the effect creation has failed
  137519. * @returns the new Effect
  137520. */
  137521. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  137522. }
  137523. interface Mesh {
  137524. /**
  137525. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  137526. * @returns an array of IParticleSystem
  137527. */
  137528. getEmittedParticleSystems(): IParticleSystem[];
  137529. /**
  137530. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  137531. * @returns an array of IParticleSystem
  137532. */
  137533. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  137534. }
  137535. /**
  137536. * @hidden
  137537. */
  137538. export var _IDoNeedToBeInTheBuild: number;
  137539. }
  137540. declare module BABYLON {
  137541. /** Defines the 4 color options */
  137542. export enum PointColor {
  137543. /** color value */
  137544. Color = 2,
  137545. /** uv value */
  137546. UV = 1,
  137547. /** random value */
  137548. Random = 0,
  137549. /** stated value */
  137550. Stated = 3
  137551. }
  137552. /**
  137553. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  137554. * 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.
  137555. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  137556. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  137557. *
  137558. * Full documentation here : TO BE ENTERED
  137559. */
  137560. export class PointsCloudSystem implements IDisposable {
  137561. /**
  137562. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  137563. * Example : var p = SPS.particles[i];
  137564. */
  137565. particles: CloudPoint[];
  137566. /**
  137567. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  137568. */
  137569. nbParticles: number;
  137570. /**
  137571. * This a counter for your own usage. It's not set by any SPS functions.
  137572. */
  137573. counter: number;
  137574. /**
  137575. * The PCS name. This name is also given to the underlying mesh.
  137576. */
  137577. name: string;
  137578. /**
  137579. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  137580. */
  137581. mesh: Mesh;
  137582. /**
  137583. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  137584. * Please read :
  137585. */
  137586. vars: any;
  137587. /**
  137588. * @hidden
  137589. */
  137590. _size: number;
  137591. private _scene;
  137592. private _promises;
  137593. private _positions;
  137594. private _indices;
  137595. private _normals;
  137596. private _colors;
  137597. private _uvs;
  137598. private _indices32;
  137599. private _positions32;
  137600. private _colors32;
  137601. private _uvs32;
  137602. private _updatable;
  137603. private _isVisibilityBoxLocked;
  137604. private _alwaysVisible;
  137605. private _groups;
  137606. private _groupCounter;
  137607. private _computeParticleColor;
  137608. private _computeParticleTexture;
  137609. private _computeParticleRotation;
  137610. private _computeBoundingBox;
  137611. private _isReady;
  137612. /**
  137613. * Creates a PCS (Points Cloud System) object
  137614. * @param name (String) is the PCS name, this will be the underlying mesh name
  137615. * @param pointSize (number) is the size for each point
  137616. * @param scene (Scene) is the scene in which the PCS is added
  137617. * @param options defines the options of the PCS e.g.
  137618. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  137619. */
  137620. constructor(name: string, pointSize: number, scene: Scene, options?: {
  137621. updatable?: boolean;
  137622. });
  137623. /**
  137624. * Builds the PCS underlying mesh. Returns a standard Mesh.
  137625. * If no points were added to the PCS, the returned mesh is just a single point.
  137626. * @returns a promise for the created mesh
  137627. */
  137628. buildMeshAsync(): Promise<Mesh>;
  137629. /**
  137630. * @hidden
  137631. */
  137632. private _buildMesh;
  137633. private _addParticle;
  137634. private _randomUnitVector;
  137635. private _getColorIndicesForCoord;
  137636. private _setPointsColorOrUV;
  137637. private _colorFromTexture;
  137638. private _calculateDensity;
  137639. /**
  137640. * Adds points to the PCS in random positions within a unit sphere
  137641. * @param nb (positive integer) the number of particles to be created from this model
  137642. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  137643. * @returns the number of groups in the system
  137644. */
  137645. addPoints(nb: number, pointFunction?: any): number;
  137646. /**
  137647. * Adds points to the PCS from the surface of the model shape
  137648. * @param mesh is any Mesh object that will be used as a surface model for the points
  137649. * @param nb (positive integer) the number of particles to be created from this model
  137650. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  137651. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  137652. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  137653. * @returns the number of groups in the system
  137654. */
  137655. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  137656. /**
  137657. * Adds points to the PCS inside the model shape
  137658. * @param mesh is any Mesh object that will be used as a surface model for the points
  137659. * @param nb (positive integer) the number of particles to be created from this model
  137660. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  137661. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  137662. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  137663. * @returns the number of groups in the system
  137664. */
  137665. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  137666. /**
  137667. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  137668. * This method calls `updateParticle()` for each particle of the SPS.
  137669. * For an animated SPS, it is usually called within the render loop.
  137670. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  137671. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  137672. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  137673. * @returns the PCS.
  137674. */
  137675. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  137676. /**
  137677. * Disposes the PCS.
  137678. */
  137679. dispose(): void;
  137680. /**
  137681. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  137682. * doc :
  137683. * @returns the PCS.
  137684. */
  137685. refreshVisibleSize(): PointsCloudSystem;
  137686. /**
  137687. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  137688. * @param size the size (float) of the visibility box
  137689. * note : this doesn't lock the PCS mesh bounding box.
  137690. * doc :
  137691. */
  137692. setVisibilityBox(size: number): void;
  137693. /**
  137694. * Gets whether the PCS is always visible or not
  137695. * doc :
  137696. */
  137697. get isAlwaysVisible(): boolean;
  137698. /**
  137699. * Sets the PCS as always visible or not
  137700. * doc :
  137701. */
  137702. set isAlwaysVisible(val: boolean);
  137703. /**
  137704. * Tells to `setParticles()` to compute the particle rotations or not
  137705. * Default value : false. The PCS is faster when it's set to false
  137706. * Note : particle rotations are only applied to parent particles
  137707. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  137708. */
  137709. set computeParticleRotation(val: boolean);
  137710. /**
  137711. * Tells to `setParticles()` to compute the particle colors or not.
  137712. * Default value : true. The PCS is faster when it's set to false.
  137713. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  137714. */
  137715. set computeParticleColor(val: boolean);
  137716. set computeParticleTexture(val: boolean);
  137717. /**
  137718. * Gets if `setParticles()` computes the particle colors or not.
  137719. * Default value : false. The PCS is faster when it's set to false.
  137720. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  137721. */
  137722. get computeParticleColor(): boolean;
  137723. /**
  137724. * Gets if `setParticles()` computes the particle textures or not.
  137725. * Default value : false. The PCS is faster when it's set to false.
  137726. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  137727. */
  137728. get computeParticleTexture(): boolean;
  137729. /**
  137730. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  137731. */
  137732. set computeBoundingBox(val: boolean);
  137733. /**
  137734. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  137735. */
  137736. get computeBoundingBox(): boolean;
  137737. /**
  137738. * This function does nothing. It may be overwritten to set all the particle first values.
  137739. * The PCS doesn't call this function, you may have to call it by your own.
  137740. * doc :
  137741. */
  137742. initParticles(): void;
  137743. /**
  137744. * This function does nothing. It may be overwritten to recycle a particle
  137745. * The PCS doesn't call this function, you can to call it
  137746. * doc :
  137747. * @param particle The particle to recycle
  137748. * @returns the recycled particle
  137749. */
  137750. recycleParticle(particle: CloudPoint): CloudPoint;
  137751. /**
  137752. * Updates a particle : this function should be overwritten by the user.
  137753. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  137754. * doc :
  137755. * @example : just set a particle position or velocity and recycle conditions
  137756. * @param particle The particle to update
  137757. * @returns the updated particle
  137758. */
  137759. updateParticle(particle: CloudPoint): CloudPoint;
  137760. /**
  137761. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  137762. * This does nothing and may be overwritten by the user.
  137763. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  137764. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  137765. * @param update the boolean update value actually passed to setParticles()
  137766. */
  137767. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  137768. /**
  137769. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  137770. * This will be passed three parameters.
  137771. * This does nothing and may be overwritten by the user.
  137772. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  137773. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  137774. * @param update the boolean update value actually passed to setParticles()
  137775. */
  137776. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  137777. }
  137778. }
  137779. declare module BABYLON {
  137780. /**
  137781. * Represents one particle of a points cloud system.
  137782. */
  137783. export class CloudPoint {
  137784. /**
  137785. * particle global index
  137786. */
  137787. idx: number;
  137788. /**
  137789. * The color of the particle
  137790. */
  137791. color: Nullable<Color4>;
  137792. /**
  137793. * The world space position of the particle.
  137794. */
  137795. position: Vector3;
  137796. /**
  137797. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  137798. */
  137799. rotation: Vector3;
  137800. /**
  137801. * The world space rotation quaternion of the particle.
  137802. */
  137803. rotationQuaternion: Nullable<Quaternion>;
  137804. /**
  137805. * The uv of the particle.
  137806. */
  137807. uv: Nullable<Vector2>;
  137808. /**
  137809. * The current speed of the particle.
  137810. */
  137811. velocity: Vector3;
  137812. /**
  137813. * The pivot point in the particle local space.
  137814. */
  137815. pivot: Vector3;
  137816. /**
  137817. * Must the particle be translated from its pivot point in its local space ?
  137818. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  137819. * Default : false
  137820. */
  137821. translateFromPivot: boolean;
  137822. /**
  137823. * Index of this particle in the global "positions" array (Internal use)
  137824. * @hidden
  137825. */
  137826. _pos: number;
  137827. /**
  137828. * @hidden Index of this particle in the global "indices" array (Internal use)
  137829. */
  137830. _ind: number;
  137831. /**
  137832. * Group this particle belongs to
  137833. */
  137834. _group: PointsGroup;
  137835. /**
  137836. * Group id of this particle
  137837. */
  137838. groupId: number;
  137839. /**
  137840. * Index of the particle in its group id (Internal use)
  137841. */
  137842. idxInGroup: number;
  137843. /**
  137844. * @hidden Particle BoundingInfo object (Internal use)
  137845. */
  137846. _boundingInfo: BoundingInfo;
  137847. /**
  137848. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  137849. */
  137850. _pcs: PointsCloudSystem;
  137851. /**
  137852. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  137853. */
  137854. _stillInvisible: boolean;
  137855. /**
  137856. * @hidden Last computed particle rotation matrix
  137857. */
  137858. _rotationMatrix: number[];
  137859. /**
  137860. * Parent particle Id, if any.
  137861. * Default null.
  137862. */
  137863. parentId: Nullable<number>;
  137864. /**
  137865. * @hidden Internal global position in the PCS.
  137866. */
  137867. _globalPosition: Vector3;
  137868. /**
  137869. * Creates a Point Cloud object.
  137870. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  137871. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  137872. * @param group (PointsGroup) is the group the particle belongs to
  137873. * @param groupId (integer) is the group identifier in the PCS.
  137874. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  137875. * @param pcs defines the PCS it is associated to
  137876. */
  137877. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  137878. /**
  137879. * get point size
  137880. */
  137881. get size(): Vector3;
  137882. /**
  137883. * Set point size
  137884. */
  137885. set size(scale: Vector3);
  137886. /**
  137887. * Legacy support, changed quaternion to rotationQuaternion
  137888. */
  137889. get quaternion(): Nullable<Quaternion>;
  137890. /**
  137891. * Legacy support, changed quaternion to rotationQuaternion
  137892. */
  137893. set quaternion(q: Nullable<Quaternion>);
  137894. /**
  137895. * Returns a boolean. True if the particle intersects a mesh, else false
  137896. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  137897. * @param target is the object (point or mesh) what the intersection is computed against
  137898. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  137899. * @returns true if it intersects
  137900. */
  137901. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  137902. /**
  137903. * get the rotation matrix of the particle
  137904. * @hidden
  137905. */
  137906. getRotationMatrix(m: Matrix): void;
  137907. }
  137908. /**
  137909. * Represents a group of points in a points cloud system
  137910. * * PCS internal tool, don't use it manually.
  137911. */
  137912. export class PointsGroup {
  137913. /**
  137914. * The group id
  137915. * @hidden
  137916. */
  137917. groupID: number;
  137918. /**
  137919. * image data for group (internal use)
  137920. * @hidden
  137921. */
  137922. _groupImageData: Nullable<ArrayBufferView>;
  137923. /**
  137924. * Image Width (internal use)
  137925. * @hidden
  137926. */
  137927. _groupImgWidth: number;
  137928. /**
  137929. * Image Height (internal use)
  137930. * @hidden
  137931. */
  137932. _groupImgHeight: number;
  137933. /**
  137934. * Custom position function (internal use)
  137935. * @hidden
  137936. */
  137937. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  137938. /**
  137939. * density per facet for surface points
  137940. * @hidden
  137941. */
  137942. _groupDensity: number[];
  137943. /**
  137944. * Only when points are colored by texture carries pointer to texture list array
  137945. * @hidden
  137946. */
  137947. _textureNb: number;
  137948. /**
  137949. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  137950. * PCS internal tool, don't use it manually.
  137951. * @hidden
  137952. */
  137953. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  137954. }
  137955. }
  137956. declare module BABYLON {
  137957. interface Scene {
  137958. /** @hidden (Backing field) */
  137959. _physicsEngine: Nullable<IPhysicsEngine>;
  137960. /** @hidden */
  137961. _physicsTimeAccumulator: number;
  137962. /**
  137963. * Gets the current physics engine
  137964. * @returns a IPhysicsEngine or null if none attached
  137965. */
  137966. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  137967. /**
  137968. * Enables physics to the current scene
  137969. * @param gravity defines the scene's gravity for the physics engine
  137970. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  137971. * @return a boolean indicating if the physics engine was initialized
  137972. */
  137973. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  137974. /**
  137975. * Disables and disposes the physics engine associated with the scene
  137976. */
  137977. disablePhysicsEngine(): void;
  137978. /**
  137979. * Gets a boolean indicating if there is an active physics engine
  137980. * @returns a boolean indicating if there is an active physics engine
  137981. */
  137982. isPhysicsEnabled(): boolean;
  137983. /**
  137984. * Deletes a physics compound impostor
  137985. * @param compound defines the compound to delete
  137986. */
  137987. deleteCompoundImpostor(compound: any): void;
  137988. /**
  137989. * An event triggered when physic simulation is about to be run
  137990. */
  137991. onBeforePhysicsObservable: Observable<Scene>;
  137992. /**
  137993. * An event triggered when physic simulation has been done
  137994. */
  137995. onAfterPhysicsObservable: Observable<Scene>;
  137996. }
  137997. interface AbstractMesh {
  137998. /** @hidden */
  137999. _physicsImpostor: Nullable<PhysicsImpostor>;
  138000. /**
  138001. * Gets or sets impostor used for physic simulation
  138002. * @see http://doc.babylonjs.com/features/physics_engine
  138003. */
  138004. physicsImpostor: Nullable<PhysicsImpostor>;
  138005. /**
  138006. * Gets the current physics impostor
  138007. * @see http://doc.babylonjs.com/features/physics_engine
  138008. * @returns a physics impostor or null
  138009. */
  138010. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  138011. /** Apply a physic impulse to the mesh
  138012. * @param force defines the force to apply
  138013. * @param contactPoint defines where to apply the force
  138014. * @returns the current mesh
  138015. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  138016. */
  138017. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  138018. /**
  138019. * Creates a physic joint between two meshes
  138020. * @param otherMesh defines the other mesh to use
  138021. * @param pivot1 defines the pivot to use on this mesh
  138022. * @param pivot2 defines the pivot to use on the other mesh
  138023. * @param options defines additional options (can be plugin dependent)
  138024. * @returns the current mesh
  138025. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  138026. */
  138027. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  138028. /** @hidden */
  138029. _disposePhysicsObserver: Nullable<Observer<Node>>;
  138030. }
  138031. /**
  138032. * Defines the physics engine scene component responsible to manage a physics engine
  138033. */
  138034. export class PhysicsEngineSceneComponent implements ISceneComponent {
  138035. /**
  138036. * The component name helpful to identify the component in the list of scene components.
  138037. */
  138038. readonly name: string;
  138039. /**
  138040. * The scene the component belongs to.
  138041. */
  138042. scene: Scene;
  138043. /**
  138044. * Creates a new instance of the component for the given scene
  138045. * @param scene Defines the scene to register the component in
  138046. */
  138047. constructor(scene: Scene);
  138048. /**
  138049. * Registers the component in a given scene
  138050. */
  138051. register(): void;
  138052. /**
  138053. * Rebuilds the elements related to this component in case of
  138054. * context lost for instance.
  138055. */
  138056. rebuild(): void;
  138057. /**
  138058. * Disposes the component and the associated ressources
  138059. */
  138060. dispose(): void;
  138061. }
  138062. }
  138063. declare module BABYLON {
  138064. /**
  138065. * A helper for physics simulations
  138066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138067. */
  138068. export class PhysicsHelper {
  138069. private _scene;
  138070. private _physicsEngine;
  138071. /**
  138072. * Initializes the Physics helper
  138073. * @param scene Babylon.js scene
  138074. */
  138075. constructor(scene: Scene);
  138076. /**
  138077. * Applies a radial explosion impulse
  138078. * @param origin the origin of the explosion
  138079. * @param radiusOrEventOptions the radius or the options of radial explosion
  138080. * @param strength the explosion strength
  138081. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138082. * @returns A physics radial explosion event, or null
  138083. */
  138084. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138085. /**
  138086. * Applies a radial explosion force
  138087. * @param origin the origin of the explosion
  138088. * @param radiusOrEventOptions the radius or the options of radial explosion
  138089. * @param strength the explosion strength
  138090. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138091. * @returns A physics radial explosion event, or null
  138092. */
  138093. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138094. /**
  138095. * Creates a gravitational field
  138096. * @param origin the origin of the explosion
  138097. * @param radiusOrEventOptions the radius or the options of radial explosion
  138098. * @param strength the explosion strength
  138099. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138100. * @returns A physics gravitational field event, or null
  138101. */
  138102. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  138103. /**
  138104. * Creates a physics updraft event
  138105. * @param origin the origin of the updraft
  138106. * @param radiusOrEventOptions the radius or the options of the updraft
  138107. * @param strength the strength of the updraft
  138108. * @param height the height of the updraft
  138109. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  138110. * @returns A physics updraft event, or null
  138111. */
  138112. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  138113. /**
  138114. * Creates a physics vortex event
  138115. * @param origin the of the vortex
  138116. * @param radiusOrEventOptions the radius or the options of the vortex
  138117. * @param strength the strength of the vortex
  138118. * @param height the height of the vortex
  138119. * @returns a Physics vortex event, or null
  138120. * A physics vortex event or null
  138121. */
  138122. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  138123. }
  138124. /**
  138125. * Represents a physics radial explosion event
  138126. */
  138127. class PhysicsRadialExplosionEvent {
  138128. private _scene;
  138129. private _options;
  138130. private _sphere;
  138131. private _dataFetched;
  138132. /**
  138133. * Initializes a radial explosioin event
  138134. * @param _scene BabylonJS scene
  138135. * @param _options The options for the vortex event
  138136. */
  138137. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  138138. /**
  138139. * Returns the data related to the radial explosion event (sphere).
  138140. * @returns The radial explosion event data
  138141. */
  138142. getData(): PhysicsRadialExplosionEventData;
  138143. /**
  138144. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  138145. * @param impostor A physics imposter
  138146. * @param origin the origin of the explosion
  138147. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  138148. */
  138149. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  138150. /**
  138151. * Triggers affecterd impostors callbacks
  138152. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  138153. */
  138154. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  138155. /**
  138156. * Disposes the sphere.
  138157. * @param force Specifies if the sphere should be disposed by force
  138158. */
  138159. dispose(force?: boolean): void;
  138160. /*** Helpers ***/
  138161. private _prepareSphere;
  138162. private _intersectsWithSphere;
  138163. }
  138164. /**
  138165. * Represents a gravitational field event
  138166. */
  138167. class PhysicsGravitationalFieldEvent {
  138168. private _physicsHelper;
  138169. private _scene;
  138170. private _origin;
  138171. private _options;
  138172. private _tickCallback;
  138173. private _sphere;
  138174. private _dataFetched;
  138175. /**
  138176. * Initializes the physics gravitational field event
  138177. * @param _physicsHelper A physics helper
  138178. * @param _scene BabylonJS scene
  138179. * @param _origin The origin position of the gravitational field event
  138180. * @param _options The options for the vortex event
  138181. */
  138182. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  138183. /**
  138184. * Returns the data related to the gravitational field event (sphere).
  138185. * @returns A gravitational field event
  138186. */
  138187. getData(): PhysicsGravitationalFieldEventData;
  138188. /**
  138189. * Enables the gravitational field.
  138190. */
  138191. enable(): void;
  138192. /**
  138193. * Disables the gravitational field.
  138194. */
  138195. disable(): void;
  138196. /**
  138197. * Disposes the sphere.
  138198. * @param force The force to dispose from the gravitational field event
  138199. */
  138200. dispose(force?: boolean): void;
  138201. private _tick;
  138202. }
  138203. /**
  138204. * Represents a physics updraft event
  138205. */
  138206. class PhysicsUpdraftEvent {
  138207. private _scene;
  138208. private _origin;
  138209. private _options;
  138210. private _physicsEngine;
  138211. private _originTop;
  138212. private _originDirection;
  138213. private _tickCallback;
  138214. private _cylinder;
  138215. private _cylinderPosition;
  138216. private _dataFetched;
  138217. /**
  138218. * Initializes the physics updraft event
  138219. * @param _scene BabylonJS scene
  138220. * @param _origin The origin position of the updraft
  138221. * @param _options The options for the updraft event
  138222. */
  138223. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  138224. /**
  138225. * Returns the data related to the updraft event (cylinder).
  138226. * @returns A physics updraft event
  138227. */
  138228. getData(): PhysicsUpdraftEventData;
  138229. /**
  138230. * Enables the updraft.
  138231. */
  138232. enable(): void;
  138233. /**
  138234. * Disables the updraft.
  138235. */
  138236. disable(): void;
  138237. /**
  138238. * Disposes the cylinder.
  138239. * @param force Specifies if the updraft should be disposed by force
  138240. */
  138241. dispose(force?: boolean): void;
  138242. private getImpostorHitData;
  138243. private _tick;
  138244. /*** Helpers ***/
  138245. private _prepareCylinder;
  138246. private _intersectsWithCylinder;
  138247. }
  138248. /**
  138249. * Represents a physics vortex event
  138250. */
  138251. class PhysicsVortexEvent {
  138252. private _scene;
  138253. private _origin;
  138254. private _options;
  138255. private _physicsEngine;
  138256. private _originTop;
  138257. private _tickCallback;
  138258. private _cylinder;
  138259. private _cylinderPosition;
  138260. private _dataFetched;
  138261. /**
  138262. * Initializes the physics vortex event
  138263. * @param _scene The BabylonJS scene
  138264. * @param _origin The origin position of the vortex
  138265. * @param _options The options for the vortex event
  138266. */
  138267. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  138268. /**
  138269. * Returns the data related to the vortex event (cylinder).
  138270. * @returns The physics vortex event data
  138271. */
  138272. getData(): PhysicsVortexEventData;
  138273. /**
  138274. * Enables the vortex.
  138275. */
  138276. enable(): void;
  138277. /**
  138278. * Disables the cortex.
  138279. */
  138280. disable(): void;
  138281. /**
  138282. * Disposes the sphere.
  138283. * @param force
  138284. */
  138285. dispose(force?: boolean): void;
  138286. private getImpostorHitData;
  138287. private _tick;
  138288. /*** Helpers ***/
  138289. private _prepareCylinder;
  138290. private _intersectsWithCylinder;
  138291. }
  138292. /**
  138293. * Options fot the radial explosion event
  138294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138295. */
  138296. export class PhysicsRadialExplosionEventOptions {
  138297. /**
  138298. * The radius of the sphere for the radial explosion.
  138299. */
  138300. radius: number;
  138301. /**
  138302. * The strenth of the explosion.
  138303. */
  138304. strength: number;
  138305. /**
  138306. * The strenght of the force in correspondence to the distance of the affected object
  138307. */
  138308. falloff: PhysicsRadialImpulseFalloff;
  138309. /**
  138310. * Sphere options for the radial explosion.
  138311. */
  138312. sphere: {
  138313. segments: number;
  138314. diameter: number;
  138315. };
  138316. /**
  138317. * Sphere options for the radial explosion.
  138318. */
  138319. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  138320. }
  138321. /**
  138322. * Options fot the updraft event
  138323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138324. */
  138325. export class PhysicsUpdraftEventOptions {
  138326. /**
  138327. * The radius of the cylinder for the vortex
  138328. */
  138329. radius: number;
  138330. /**
  138331. * The strenth of the updraft.
  138332. */
  138333. strength: number;
  138334. /**
  138335. * The height of the cylinder for the updraft.
  138336. */
  138337. height: number;
  138338. /**
  138339. * The mode for the the updraft.
  138340. */
  138341. updraftMode: PhysicsUpdraftMode;
  138342. }
  138343. /**
  138344. * Options fot the vortex event
  138345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138346. */
  138347. export class PhysicsVortexEventOptions {
  138348. /**
  138349. * The radius of the cylinder for the vortex
  138350. */
  138351. radius: number;
  138352. /**
  138353. * The strenth of the vortex.
  138354. */
  138355. strength: number;
  138356. /**
  138357. * The height of the cylinder for the vortex.
  138358. */
  138359. height: number;
  138360. /**
  138361. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  138362. */
  138363. centripetalForceThreshold: number;
  138364. /**
  138365. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  138366. */
  138367. centripetalForceMultiplier: number;
  138368. /**
  138369. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  138370. */
  138371. centrifugalForceMultiplier: number;
  138372. /**
  138373. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  138374. */
  138375. updraftForceMultiplier: number;
  138376. }
  138377. /**
  138378. * The strenght of the force in correspondence to the distance of the affected object
  138379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138380. */
  138381. export enum PhysicsRadialImpulseFalloff {
  138382. /** Defines that impulse is constant in strength across it's whole radius */
  138383. Constant = 0,
  138384. /** Defines that impulse gets weaker if it's further from the origin */
  138385. Linear = 1
  138386. }
  138387. /**
  138388. * The strength of the force in correspondence to the distance of the affected object
  138389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138390. */
  138391. export enum PhysicsUpdraftMode {
  138392. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  138393. Center = 0,
  138394. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  138395. Perpendicular = 1
  138396. }
  138397. /**
  138398. * Interface for a physics hit data
  138399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138400. */
  138401. export interface PhysicsHitData {
  138402. /**
  138403. * The force applied at the contact point
  138404. */
  138405. force: Vector3;
  138406. /**
  138407. * The contact point
  138408. */
  138409. contactPoint: Vector3;
  138410. /**
  138411. * The distance from the origin to the contact point
  138412. */
  138413. distanceFromOrigin: number;
  138414. }
  138415. /**
  138416. * Interface for radial explosion event data
  138417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138418. */
  138419. export interface PhysicsRadialExplosionEventData {
  138420. /**
  138421. * A sphere used for the radial explosion event
  138422. */
  138423. sphere: Mesh;
  138424. }
  138425. /**
  138426. * Interface for gravitational field event data
  138427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138428. */
  138429. export interface PhysicsGravitationalFieldEventData {
  138430. /**
  138431. * A sphere mesh used for the gravitational field event
  138432. */
  138433. sphere: Mesh;
  138434. }
  138435. /**
  138436. * Interface for updraft event data
  138437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138438. */
  138439. export interface PhysicsUpdraftEventData {
  138440. /**
  138441. * A cylinder used for the updraft event
  138442. */
  138443. cylinder: Mesh;
  138444. }
  138445. /**
  138446. * Interface for vortex event data
  138447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138448. */
  138449. export interface PhysicsVortexEventData {
  138450. /**
  138451. * A cylinder used for the vortex event
  138452. */
  138453. cylinder: Mesh;
  138454. }
  138455. /**
  138456. * Interface for an affected physics impostor
  138457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138458. */
  138459. export interface PhysicsAffectedImpostorWithData {
  138460. /**
  138461. * The impostor affected by the effect
  138462. */
  138463. impostor: PhysicsImpostor;
  138464. /**
  138465. * The data about the hit/horce from the explosion
  138466. */
  138467. hitData: PhysicsHitData;
  138468. }
  138469. }
  138470. declare module BABYLON {
  138471. /** @hidden */
  138472. export var blackAndWhitePixelShader: {
  138473. name: string;
  138474. shader: string;
  138475. };
  138476. }
  138477. declare module BABYLON {
  138478. /**
  138479. * Post process used to render in black and white
  138480. */
  138481. export class BlackAndWhitePostProcess extends PostProcess {
  138482. /**
  138483. * Linear about to convert he result to black and white (default: 1)
  138484. */
  138485. degree: number;
  138486. /**
  138487. * Creates a black and white post process
  138488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  138489. * @param name The name of the effect.
  138490. * @param options The required width/height ratio to downsize to before computing the render pass.
  138491. * @param camera The camera to apply the render pass to.
  138492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138493. * @param engine The engine which the post process will be applied. (default: current engine)
  138494. * @param reusable If the post process can be reused on the same frame. (default: false)
  138495. */
  138496. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138497. }
  138498. }
  138499. declare module BABYLON {
  138500. /**
  138501. * This represents a set of one or more post processes in Babylon.
  138502. * A post process can be used to apply a shader to a texture after it is rendered.
  138503. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138504. */
  138505. export class PostProcessRenderEffect {
  138506. private _postProcesses;
  138507. private _getPostProcesses;
  138508. private _singleInstance;
  138509. private _cameras;
  138510. private _indicesForCamera;
  138511. /**
  138512. * Name of the effect
  138513. * @hidden
  138514. */
  138515. _name: string;
  138516. /**
  138517. * Instantiates a post process render effect.
  138518. * A post process can be used to apply a shader to a texture after it is rendered.
  138519. * @param engine The engine the effect is tied to
  138520. * @param name The name of the effect
  138521. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  138522. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  138523. */
  138524. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  138525. /**
  138526. * Checks if all the post processes in the effect are supported.
  138527. */
  138528. get isSupported(): boolean;
  138529. /**
  138530. * Updates the current state of the effect
  138531. * @hidden
  138532. */
  138533. _update(): void;
  138534. /**
  138535. * Attaches the effect on cameras
  138536. * @param cameras The camera to attach to.
  138537. * @hidden
  138538. */
  138539. _attachCameras(cameras: Camera): void;
  138540. /**
  138541. * Attaches the effect on cameras
  138542. * @param cameras The camera to attach to.
  138543. * @hidden
  138544. */
  138545. _attachCameras(cameras: Camera[]): void;
  138546. /**
  138547. * Detaches the effect on cameras
  138548. * @param cameras The camera to detatch from.
  138549. * @hidden
  138550. */
  138551. _detachCameras(cameras: Camera): void;
  138552. /**
  138553. * Detatches the effect on cameras
  138554. * @param cameras The camera to detatch from.
  138555. * @hidden
  138556. */
  138557. _detachCameras(cameras: Camera[]): void;
  138558. /**
  138559. * Enables the effect on given cameras
  138560. * @param cameras The camera to enable.
  138561. * @hidden
  138562. */
  138563. _enable(cameras: Camera): void;
  138564. /**
  138565. * Enables the effect on given cameras
  138566. * @param cameras The camera to enable.
  138567. * @hidden
  138568. */
  138569. _enable(cameras: Nullable<Camera[]>): void;
  138570. /**
  138571. * Disables the effect on the given cameras
  138572. * @param cameras The camera to disable.
  138573. * @hidden
  138574. */
  138575. _disable(cameras: Camera): void;
  138576. /**
  138577. * Disables the effect on the given cameras
  138578. * @param cameras The camera to disable.
  138579. * @hidden
  138580. */
  138581. _disable(cameras: Nullable<Camera[]>): void;
  138582. /**
  138583. * Gets a list of the post processes contained in the effect.
  138584. * @param camera The camera to get the post processes on.
  138585. * @returns The list of the post processes in the effect.
  138586. */
  138587. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  138588. }
  138589. }
  138590. declare module BABYLON {
  138591. /** @hidden */
  138592. export var extractHighlightsPixelShader: {
  138593. name: string;
  138594. shader: string;
  138595. };
  138596. }
  138597. declare module BABYLON {
  138598. /**
  138599. * 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.
  138600. */
  138601. export class ExtractHighlightsPostProcess extends PostProcess {
  138602. /**
  138603. * The luminance threshold, pixels below this value will be set to black.
  138604. */
  138605. threshold: number;
  138606. /** @hidden */
  138607. _exposure: number;
  138608. /**
  138609. * Post process which has the input texture to be used when performing highlight extraction
  138610. * @hidden
  138611. */
  138612. _inputPostProcess: Nullable<PostProcess>;
  138613. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138614. }
  138615. }
  138616. declare module BABYLON {
  138617. /** @hidden */
  138618. export var bloomMergePixelShader: {
  138619. name: string;
  138620. shader: string;
  138621. };
  138622. }
  138623. declare module BABYLON {
  138624. /**
  138625. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  138626. */
  138627. export class BloomMergePostProcess extends PostProcess {
  138628. /** Weight of the bloom to be added to the original input. */
  138629. weight: number;
  138630. /**
  138631. * Creates a new instance of @see BloomMergePostProcess
  138632. * @param name The name of the effect.
  138633. * @param originalFromInput Post process which's input will be used for the merge.
  138634. * @param blurred Blurred highlights post process which's output will be used.
  138635. * @param weight Weight of the bloom to be added to the original input.
  138636. * @param options The required width/height ratio to downsize to before computing the render pass.
  138637. * @param camera The camera to apply the render pass to.
  138638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138639. * @param engine The engine which the post process will be applied. (default: current engine)
  138640. * @param reusable If the post process can be reused on the same frame. (default: false)
  138641. * @param textureType Type of textures used when performing the post process. (default: 0)
  138642. * @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)
  138643. */
  138644. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  138645. /** Weight of the bloom to be added to the original input. */
  138646. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138647. }
  138648. }
  138649. declare module BABYLON {
  138650. /**
  138651. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  138652. */
  138653. export class BloomEffect extends PostProcessRenderEffect {
  138654. private bloomScale;
  138655. /**
  138656. * @hidden Internal
  138657. */
  138658. _effects: Array<PostProcess>;
  138659. /**
  138660. * @hidden Internal
  138661. */
  138662. _downscale: ExtractHighlightsPostProcess;
  138663. private _blurX;
  138664. private _blurY;
  138665. private _merge;
  138666. /**
  138667. * The luminance threshold to find bright areas of the image to bloom.
  138668. */
  138669. get threshold(): number;
  138670. set threshold(value: number);
  138671. /**
  138672. * The strength of the bloom.
  138673. */
  138674. get weight(): number;
  138675. set weight(value: number);
  138676. /**
  138677. * Specifies the size of the bloom blur kernel, relative to the final output size
  138678. */
  138679. get kernel(): number;
  138680. set kernel(value: number);
  138681. /**
  138682. * Creates a new instance of @see BloomEffect
  138683. * @param scene The scene the effect belongs to.
  138684. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  138685. * @param bloomKernel The size of the kernel to be used when applying the blur.
  138686. * @param bloomWeight The the strength of bloom.
  138687. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  138688. * @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)
  138689. */
  138690. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  138691. /**
  138692. * Disposes each of the internal effects for a given camera.
  138693. * @param camera The camera to dispose the effect on.
  138694. */
  138695. disposeEffects(camera: Camera): void;
  138696. /**
  138697. * @hidden Internal
  138698. */
  138699. _updateEffects(): void;
  138700. /**
  138701. * Internal
  138702. * @returns if all the contained post processes are ready.
  138703. * @hidden
  138704. */
  138705. _isReady(): boolean;
  138706. }
  138707. }
  138708. declare module BABYLON {
  138709. /** @hidden */
  138710. export var chromaticAberrationPixelShader: {
  138711. name: string;
  138712. shader: string;
  138713. };
  138714. }
  138715. declare module BABYLON {
  138716. /**
  138717. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  138718. */
  138719. export class ChromaticAberrationPostProcess extends PostProcess {
  138720. /**
  138721. * The amount of seperation of rgb channels (default: 30)
  138722. */
  138723. aberrationAmount: number;
  138724. /**
  138725. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  138726. */
  138727. radialIntensity: number;
  138728. /**
  138729. * 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))
  138730. */
  138731. direction: Vector2;
  138732. /**
  138733. * 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))
  138734. */
  138735. centerPosition: Vector2;
  138736. /**
  138737. * Creates a new instance ChromaticAberrationPostProcess
  138738. * @param name The name of the effect.
  138739. * @param screenWidth The width of the screen to apply the effect on.
  138740. * @param screenHeight The height of the screen to apply the effect on.
  138741. * @param options The required width/height ratio to downsize to before computing the render pass.
  138742. * @param camera The camera to apply the render pass to.
  138743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138744. * @param engine The engine which the post process will be applied. (default: current engine)
  138745. * @param reusable If the post process can be reused on the same frame. (default: false)
  138746. * @param textureType Type of textures used when performing the post process. (default: 0)
  138747. * @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)
  138748. */
  138749. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138750. }
  138751. }
  138752. declare module BABYLON {
  138753. /** @hidden */
  138754. export var circleOfConfusionPixelShader: {
  138755. name: string;
  138756. shader: string;
  138757. };
  138758. }
  138759. declare module BABYLON {
  138760. /**
  138761. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  138762. */
  138763. export class CircleOfConfusionPostProcess extends PostProcess {
  138764. /**
  138765. * 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.
  138766. */
  138767. lensSize: number;
  138768. /**
  138769. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  138770. */
  138771. fStop: number;
  138772. /**
  138773. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  138774. */
  138775. focusDistance: number;
  138776. /**
  138777. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  138778. */
  138779. focalLength: number;
  138780. private _depthTexture;
  138781. /**
  138782. * Creates a new instance CircleOfConfusionPostProcess
  138783. * @param name The name of the effect.
  138784. * @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.
  138785. * @param options The required width/height ratio to downsize to before computing the render pass.
  138786. * @param camera The camera to apply the render pass to.
  138787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138788. * @param engine The engine which the post process will be applied. (default: current engine)
  138789. * @param reusable If the post process can be reused on the same frame. (default: false)
  138790. * @param textureType Type of textures used when performing the post process. (default: 0)
  138791. * @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)
  138792. */
  138793. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138794. /**
  138795. * 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.
  138796. */
  138797. set depthTexture(value: RenderTargetTexture);
  138798. }
  138799. }
  138800. declare module BABYLON {
  138801. /** @hidden */
  138802. export var colorCorrectionPixelShader: {
  138803. name: string;
  138804. shader: string;
  138805. };
  138806. }
  138807. declare module BABYLON {
  138808. /**
  138809. *
  138810. * This post-process allows the modification of rendered colors by using
  138811. * a 'look-up table' (LUT). This effect is also called Color Grading.
  138812. *
  138813. * The object needs to be provided an url to a texture containing the color
  138814. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  138815. * Use an image editing software to tweak the LUT to match your needs.
  138816. *
  138817. * For an example of a color LUT, see here:
  138818. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  138819. * For explanations on color grading, see here:
  138820. * @see http://udn.epicgames.com/Three/ColorGrading.html
  138821. *
  138822. */
  138823. export class ColorCorrectionPostProcess extends PostProcess {
  138824. private _colorTableTexture;
  138825. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138826. }
  138827. }
  138828. declare module BABYLON {
  138829. /** @hidden */
  138830. export var convolutionPixelShader: {
  138831. name: string;
  138832. shader: string;
  138833. };
  138834. }
  138835. declare module BABYLON {
  138836. /**
  138837. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  138838. * input texture to perform effects such as edge detection or sharpening
  138839. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138840. */
  138841. export class ConvolutionPostProcess extends PostProcess {
  138842. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  138843. kernel: number[];
  138844. /**
  138845. * Creates a new instance ConvolutionPostProcess
  138846. * @param name The name of the effect.
  138847. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  138848. * @param options The required width/height ratio to downsize to before computing the render pass.
  138849. * @param camera The camera to apply the render pass to.
  138850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138851. * @param engine The engine which the post process will be applied. (default: current engine)
  138852. * @param reusable If the post process can be reused on the same frame. (default: false)
  138853. * @param textureType Type of textures used when performing the post process. (default: 0)
  138854. */
  138855. constructor(name: string,
  138856. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  138857. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  138858. /**
  138859. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138860. */
  138861. static EdgeDetect0Kernel: number[];
  138862. /**
  138863. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138864. */
  138865. static EdgeDetect1Kernel: number[];
  138866. /**
  138867. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138868. */
  138869. static EdgeDetect2Kernel: number[];
  138870. /**
  138871. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138872. */
  138873. static SharpenKernel: number[];
  138874. /**
  138875. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138876. */
  138877. static EmbossKernel: number[];
  138878. /**
  138879. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  138880. */
  138881. static GaussianKernel: number[];
  138882. }
  138883. }
  138884. declare module BABYLON {
  138885. /**
  138886. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  138887. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  138888. * based on samples that have a large difference in distance than the center pixel.
  138889. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  138890. */
  138891. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  138892. direction: Vector2;
  138893. /**
  138894. * Creates a new instance CircleOfConfusionPostProcess
  138895. * @param name The name of the effect.
  138896. * @param scene The scene the effect belongs to.
  138897. * @param direction The direction the blur should be applied.
  138898. * @param kernel The size of the kernel used to blur.
  138899. * @param options The required width/height ratio to downsize to before computing the render pass.
  138900. * @param camera The camera to apply the render pass to.
  138901. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  138902. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  138903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138904. * @param engine The engine which the post process will be applied. (default: current engine)
  138905. * @param reusable If the post process can be reused on the same frame. (default: false)
  138906. * @param textureType Type of textures used when performing the post process. (default: 0)
  138907. * @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)
  138908. */
  138909. 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);
  138910. }
  138911. }
  138912. declare module BABYLON {
  138913. /** @hidden */
  138914. export var depthOfFieldMergePixelShader: {
  138915. name: string;
  138916. shader: string;
  138917. };
  138918. }
  138919. declare module BABYLON {
  138920. /**
  138921. * Options to be set when merging outputs from the default pipeline.
  138922. */
  138923. export class DepthOfFieldMergePostProcessOptions {
  138924. /**
  138925. * The original image to merge on top of
  138926. */
  138927. originalFromInput: PostProcess;
  138928. /**
  138929. * Parameters to perform the merge of the depth of field effect
  138930. */
  138931. depthOfField?: {
  138932. circleOfConfusion: PostProcess;
  138933. blurSteps: Array<PostProcess>;
  138934. };
  138935. /**
  138936. * Parameters to perform the merge of bloom effect
  138937. */
  138938. bloom?: {
  138939. blurred: PostProcess;
  138940. weight: number;
  138941. };
  138942. }
  138943. /**
  138944. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  138945. */
  138946. export class DepthOfFieldMergePostProcess extends PostProcess {
  138947. private blurSteps;
  138948. /**
  138949. * Creates a new instance of DepthOfFieldMergePostProcess
  138950. * @param name The name of the effect.
  138951. * @param originalFromInput Post process which's input will be used for the merge.
  138952. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  138953. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  138954. * @param options The required width/height ratio to downsize to before computing the render pass.
  138955. * @param camera The camera to apply the render pass to.
  138956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138957. * @param engine The engine which the post process will be applied. (default: current engine)
  138958. * @param reusable If the post process can be reused on the same frame. (default: false)
  138959. * @param textureType Type of textures used when performing the post process. (default: 0)
  138960. * @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)
  138961. */
  138962. 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);
  138963. /**
  138964. * Updates the effect with the current post process compile time values and recompiles the shader.
  138965. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  138966. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  138967. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  138968. * @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
  138969. * @param onCompiled Called when the shader has been compiled.
  138970. * @param onError Called if there is an error when compiling a shader.
  138971. */
  138972. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  138973. }
  138974. }
  138975. declare module BABYLON {
  138976. /**
  138977. * Specifies the level of max blur that should be applied when using the depth of field effect
  138978. */
  138979. export enum DepthOfFieldEffectBlurLevel {
  138980. /**
  138981. * Subtle blur
  138982. */
  138983. Low = 0,
  138984. /**
  138985. * Medium blur
  138986. */
  138987. Medium = 1,
  138988. /**
  138989. * Large blur
  138990. */
  138991. High = 2
  138992. }
  138993. /**
  138994. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  138995. */
  138996. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  138997. private _circleOfConfusion;
  138998. /**
  138999. * @hidden Internal, blurs from high to low
  139000. */
  139001. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  139002. private _depthOfFieldBlurY;
  139003. private _dofMerge;
  139004. /**
  139005. * @hidden Internal post processes in depth of field effect
  139006. */
  139007. _effects: Array<PostProcess>;
  139008. /**
  139009. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  139010. */
  139011. set focalLength(value: number);
  139012. get focalLength(): number;
  139013. /**
  139014. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139015. */
  139016. set fStop(value: number);
  139017. get fStop(): number;
  139018. /**
  139019. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139020. */
  139021. set focusDistance(value: number);
  139022. get focusDistance(): number;
  139023. /**
  139024. * 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.
  139025. */
  139026. set lensSize(value: number);
  139027. get lensSize(): number;
  139028. /**
  139029. * Creates a new instance DepthOfFieldEffect
  139030. * @param scene The scene the effect belongs to.
  139031. * @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.
  139032. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139033. * @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)
  139034. */
  139035. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  139036. /**
  139037. * Get the current class name of the current effet
  139038. * @returns "DepthOfFieldEffect"
  139039. */
  139040. getClassName(): string;
  139041. /**
  139042. * 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.
  139043. */
  139044. set depthTexture(value: RenderTargetTexture);
  139045. /**
  139046. * Disposes each of the internal effects for a given camera.
  139047. * @param camera The camera to dispose the effect on.
  139048. */
  139049. disposeEffects(camera: Camera): void;
  139050. /**
  139051. * @hidden Internal
  139052. */
  139053. _updateEffects(): void;
  139054. /**
  139055. * Internal
  139056. * @returns if all the contained post processes are ready.
  139057. * @hidden
  139058. */
  139059. _isReady(): boolean;
  139060. }
  139061. }
  139062. declare module BABYLON {
  139063. /** @hidden */
  139064. export var displayPassPixelShader: {
  139065. name: string;
  139066. shader: string;
  139067. };
  139068. }
  139069. declare module BABYLON {
  139070. /**
  139071. * DisplayPassPostProcess which produces an output the same as it's input
  139072. */
  139073. export class DisplayPassPostProcess extends PostProcess {
  139074. /**
  139075. * Creates the DisplayPassPostProcess
  139076. * @param name The name of the effect.
  139077. * @param options The required width/height ratio to downsize to before computing the render pass.
  139078. * @param camera The camera to apply the render pass to.
  139079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139080. * @param engine The engine which the post process will be applied. (default: current engine)
  139081. * @param reusable If the post process can be reused on the same frame. (default: false)
  139082. */
  139083. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139084. }
  139085. }
  139086. declare module BABYLON {
  139087. /** @hidden */
  139088. export var filterPixelShader: {
  139089. name: string;
  139090. shader: string;
  139091. };
  139092. }
  139093. declare module BABYLON {
  139094. /**
  139095. * Applies a kernel filter to the image
  139096. */
  139097. export class FilterPostProcess extends PostProcess {
  139098. /** The matrix to be applied to the image */
  139099. kernelMatrix: Matrix;
  139100. /**
  139101. *
  139102. * @param name The name of the effect.
  139103. * @param kernelMatrix The matrix to be applied to the image
  139104. * @param options The required width/height ratio to downsize to before computing the render pass.
  139105. * @param camera The camera to apply the render pass to.
  139106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139107. * @param engine The engine which the post process will be applied. (default: current engine)
  139108. * @param reusable If the post process can be reused on the same frame. (default: false)
  139109. */
  139110. constructor(name: string,
  139111. /** The matrix to be applied to the image */
  139112. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139113. }
  139114. }
  139115. declare module BABYLON {
  139116. /** @hidden */
  139117. export var fxaaPixelShader: {
  139118. name: string;
  139119. shader: string;
  139120. };
  139121. }
  139122. declare module BABYLON {
  139123. /** @hidden */
  139124. export var fxaaVertexShader: {
  139125. name: string;
  139126. shader: string;
  139127. };
  139128. }
  139129. declare module BABYLON {
  139130. /**
  139131. * Fxaa post process
  139132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  139133. */
  139134. export class FxaaPostProcess extends PostProcess {
  139135. /** @hidden */
  139136. texelWidth: number;
  139137. /** @hidden */
  139138. texelHeight: number;
  139139. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139140. private _getDefines;
  139141. }
  139142. }
  139143. declare module BABYLON {
  139144. /** @hidden */
  139145. export var grainPixelShader: {
  139146. name: string;
  139147. shader: string;
  139148. };
  139149. }
  139150. declare module BABYLON {
  139151. /**
  139152. * The GrainPostProcess adds noise to the image at mid luminance levels
  139153. */
  139154. export class GrainPostProcess extends PostProcess {
  139155. /**
  139156. * The intensity of the grain added (default: 30)
  139157. */
  139158. intensity: number;
  139159. /**
  139160. * If the grain should be randomized on every frame
  139161. */
  139162. animated: boolean;
  139163. /**
  139164. * Creates a new instance of @see GrainPostProcess
  139165. * @param name The name of the effect.
  139166. * @param options The required width/height ratio to downsize to before computing the render pass.
  139167. * @param camera The camera to apply the render pass to.
  139168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139169. * @param engine The engine which the post process will be applied. (default: current engine)
  139170. * @param reusable If the post process can be reused on the same frame. (default: false)
  139171. * @param textureType Type of textures used when performing the post process. (default: 0)
  139172. * @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)
  139173. */
  139174. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139175. }
  139176. }
  139177. declare module BABYLON {
  139178. /** @hidden */
  139179. export var highlightsPixelShader: {
  139180. name: string;
  139181. shader: string;
  139182. };
  139183. }
  139184. declare module BABYLON {
  139185. /**
  139186. * Extracts highlights from the image
  139187. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139188. */
  139189. export class HighlightsPostProcess extends PostProcess {
  139190. /**
  139191. * Extracts highlights from the image
  139192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139193. * @param name The name of the effect.
  139194. * @param options The required width/height ratio to downsize to before computing the render pass.
  139195. * @param camera The camera to apply the render pass to.
  139196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139197. * @param engine The engine which the post process will be applied. (default: current engine)
  139198. * @param reusable If the post process can be reused on the same frame. (default: false)
  139199. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  139200. */
  139201. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139202. }
  139203. }
  139204. declare module BABYLON {
  139205. /** @hidden */
  139206. export var mrtFragmentDeclaration: {
  139207. name: string;
  139208. shader: string;
  139209. };
  139210. }
  139211. declare module BABYLON {
  139212. /** @hidden */
  139213. export var geometryPixelShader: {
  139214. name: string;
  139215. shader: string;
  139216. };
  139217. }
  139218. declare module BABYLON {
  139219. /** @hidden */
  139220. export var geometryVertexShader: {
  139221. name: string;
  139222. shader: string;
  139223. };
  139224. }
  139225. declare module BABYLON {
  139226. /** @hidden */
  139227. interface ISavedTransformationMatrix {
  139228. world: Matrix;
  139229. viewProjection: Matrix;
  139230. }
  139231. /**
  139232. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  139233. */
  139234. export class GeometryBufferRenderer {
  139235. /**
  139236. * Constant used to retrieve the position texture index in the G-Buffer textures array
  139237. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  139238. */
  139239. static readonly POSITION_TEXTURE_TYPE: number;
  139240. /**
  139241. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  139242. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  139243. */
  139244. static readonly VELOCITY_TEXTURE_TYPE: number;
  139245. /**
  139246. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  139247. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  139248. */
  139249. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  139250. /**
  139251. * Dictionary used to store the previous transformation matrices of each rendered mesh
  139252. * in order to compute objects velocities when enableVelocity is set to "true"
  139253. * @hidden
  139254. */
  139255. _previousTransformationMatrices: {
  139256. [index: number]: ISavedTransformationMatrix;
  139257. };
  139258. /**
  139259. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  139260. * in order to compute objects velocities when enableVelocity is set to "true"
  139261. * @hidden
  139262. */
  139263. _previousBonesTransformationMatrices: {
  139264. [index: number]: Float32Array;
  139265. };
  139266. /**
  139267. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  139268. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  139269. */
  139270. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  139271. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  139272. renderTransparentMeshes: boolean;
  139273. private _scene;
  139274. private _multiRenderTarget;
  139275. private _ratio;
  139276. private _enablePosition;
  139277. private _enableVelocity;
  139278. private _enableReflectivity;
  139279. private _positionIndex;
  139280. private _velocityIndex;
  139281. private _reflectivityIndex;
  139282. protected _effect: Effect;
  139283. protected _cachedDefines: string;
  139284. /**
  139285. * Set the render list (meshes to be rendered) used in the G buffer.
  139286. */
  139287. set renderList(meshes: Mesh[]);
  139288. /**
  139289. * Gets wether or not G buffer are supported by the running hardware.
  139290. * This requires draw buffer supports
  139291. */
  139292. get isSupported(): boolean;
  139293. /**
  139294. * Returns the index of the given texture type in the G-Buffer textures array
  139295. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  139296. * @returns the index of the given texture type in the G-Buffer textures array
  139297. */
  139298. getTextureIndex(textureType: number): number;
  139299. /**
  139300. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  139301. */
  139302. get enablePosition(): boolean;
  139303. /**
  139304. * Sets whether or not objects positions are enabled for the G buffer.
  139305. */
  139306. set enablePosition(enable: boolean);
  139307. /**
  139308. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  139309. */
  139310. get enableVelocity(): boolean;
  139311. /**
  139312. * Sets wether or not objects velocities are enabled for the G buffer.
  139313. */
  139314. set enableVelocity(enable: boolean);
  139315. /**
  139316. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  139317. */
  139318. get enableReflectivity(): boolean;
  139319. /**
  139320. * Sets wether or not objects roughness are enabled for the G buffer.
  139321. */
  139322. set enableReflectivity(enable: boolean);
  139323. /**
  139324. * Gets the scene associated with the buffer.
  139325. */
  139326. get scene(): Scene;
  139327. /**
  139328. * Gets the ratio used by the buffer during its creation.
  139329. * How big is the buffer related to the main canvas.
  139330. */
  139331. get ratio(): number;
  139332. /** @hidden */
  139333. static _SceneComponentInitialization: (scene: Scene) => void;
  139334. /**
  139335. * Creates a new G Buffer for the scene
  139336. * @param scene The scene the buffer belongs to
  139337. * @param ratio How big is the buffer related to the main canvas.
  139338. */
  139339. constructor(scene: Scene, ratio?: number);
  139340. /**
  139341. * Checks wether everything is ready to render a submesh to the G buffer.
  139342. * @param subMesh the submesh to check readiness for
  139343. * @param useInstances is the mesh drawn using instance or not
  139344. * @returns true if ready otherwise false
  139345. */
  139346. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139347. /**
  139348. * Gets the current underlying G Buffer.
  139349. * @returns the buffer
  139350. */
  139351. getGBuffer(): MultiRenderTarget;
  139352. /**
  139353. * Gets the number of samples used to render the buffer (anti aliasing).
  139354. */
  139355. get samples(): number;
  139356. /**
  139357. * Sets the number of samples used to render the buffer (anti aliasing).
  139358. */
  139359. set samples(value: number);
  139360. /**
  139361. * Disposes the renderer and frees up associated resources.
  139362. */
  139363. dispose(): void;
  139364. protected _createRenderTargets(): void;
  139365. private _copyBonesTransformationMatrices;
  139366. }
  139367. }
  139368. declare module BABYLON {
  139369. interface Scene {
  139370. /** @hidden (Backing field) */
  139371. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139372. /**
  139373. * Gets or Sets the current geometry buffer associated to the scene.
  139374. */
  139375. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139376. /**
  139377. * Enables a GeometryBufferRender and associates it with the scene
  139378. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  139379. * @returns the GeometryBufferRenderer
  139380. */
  139381. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  139382. /**
  139383. * Disables the GeometryBufferRender associated with the scene
  139384. */
  139385. disableGeometryBufferRenderer(): void;
  139386. }
  139387. /**
  139388. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  139389. * in several rendering techniques.
  139390. */
  139391. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  139392. /**
  139393. * The component name helpful to identify the component in the list of scene components.
  139394. */
  139395. readonly name: string;
  139396. /**
  139397. * The scene the component belongs to.
  139398. */
  139399. scene: Scene;
  139400. /**
  139401. * Creates a new instance of the component for the given scene
  139402. * @param scene Defines the scene to register the component in
  139403. */
  139404. constructor(scene: Scene);
  139405. /**
  139406. * Registers the component in a given scene
  139407. */
  139408. register(): void;
  139409. /**
  139410. * Rebuilds the elements related to this component in case of
  139411. * context lost for instance.
  139412. */
  139413. rebuild(): void;
  139414. /**
  139415. * Disposes the component and the associated ressources
  139416. */
  139417. dispose(): void;
  139418. private _gatherRenderTargets;
  139419. }
  139420. }
  139421. declare module BABYLON {
  139422. /** @hidden */
  139423. export var motionBlurPixelShader: {
  139424. name: string;
  139425. shader: string;
  139426. };
  139427. }
  139428. declare module BABYLON {
  139429. /**
  139430. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  139431. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  139432. * As an example, all you have to do is to create the post-process:
  139433. * var mb = new BABYLON.MotionBlurPostProcess(
  139434. * 'mb', // The name of the effect.
  139435. * scene, // The scene containing the objects to blur according to their velocity.
  139436. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  139437. * camera // The camera to apply the render pass to.
  139438. * );
  139439. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  139440. */
  139441. export class MotionBlurPostProcess extends PostProcess {
  139442. /**
  139443. * Defines how much the image is blurred by the movement. Default value is equal to 1
  139444. */
  139445. motionStrength: number;
  139446. /**
  139447. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  139448. */
  139449. get motionBlurSamples(): number;
  139450. /**
  139451. * Sets the number of iterations to be used for motion blur quality
  139452. */
  139453. set motionBlurSamples(samples: number);
  139454. private _motionBlurSamples;
  139455. private _geometryBufferRenderer;
  139456. /**
  139457. * Creates a new instance MotionBlurPostProcess
  139458. * @param name The name of the effect.
  139459. * @param scene The scene containing the objects to blur according to their velocity.
  139460. * @param options The required width/height ratio to downsize to before computing the render pass.
  139461. * @param camera The camera to apply the render pass to.
  139462. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139463. * @param engine The engine which the post process will be applied. (default: current engine)
  139464. * @param reusable If the post process can be reused on the same frame. (default: false)
  139465. * @param textureType Type of textures used when performing the post process. (default: 0)
  139466. * @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)
  139467. */
  139468. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139469. /**
  139470. * Excludes the given skinned mesh from computing bones velocities.
  139471. * 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.
  139472. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  139473. */
  139474. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139475. /**
  139476. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  139477. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  139478. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  139479. */
  139480. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139481. /**
  139482. * Disposes the post process.
  139483. * @param camera The camera to dispose the post process on.
  139484. */
  139485. dispose(camera?: Camera): void;
  139486. }
  139487. }
  139488. declare module BABYLON {
  139489. /** @hidden */
  139490. export var refractionPixelShader: {
  139491. name: string;
  139492. shader: string;
  139493. };
  139494. }
  139495. declare module BABYLON {
  139496. /**
  139497. * Post process which applies a refractin texture
  139498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139499. */
  139500. export class RefractionPostProcess extends PostProcess {
  139501. /** the base color of the refraction (used to taint the rendering) */
  139502. color: Color3;
  139503. /** simulated refraction depth */
  139504. depth: number;
  139505. /** the coefficient of the base color (0 to remove base color tainting) */
  139506. colorLevel: number;
  139507. private _refTexture;
  139508. private _ownRefractionTexture;
  139509. /**
  139510. * Gets or sets the refraction texture
  139511. * Please note that you are responsible for disposing the texture if you set it manually
  139512. */
  139513. get refractionTexture(): Texture;
  139514. set refractionTexture(value: Texture);
  139515. /**
  139516. * Initializes the RefractionPostProcess
  139517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139518. * @param name The name of the effect.
  139519. * @param refractionTextureUrl Url of the refraction texture to use
  139520. * @param color the base color of the refraction (used to taint the rendering)
  139521. * @param depth simulated refraction depth
  139522. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  139523. * @param camera The camera to apply the render pass to.
  139524. * @param options The required width/height ratio to downsize to before computing the render pass.
  139525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139526. * @param engine The engine which the post process will be applied. (default: current engine)
  139527. * @param reusable If the post process can be reused on the same frame. (default: false)
  139528. */
  139529. constructor(name: string, refractionTextureUrl: string,
  139530. /** the base color of the refraction (used to taint the rendering) */
  139531. color: Color3,
  139532. /** simulated refraction depth */
  139533. depth: number,
  139534. /** the coefficient of the base color (0 to remove base color tainting) */
  139535. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139536. /**
  139537. * Disposes of the post process
  139538. * @param camera Camera to dispose post process on
  139539. */
  139540. dispose(camera: Camera): void;
  139541. }
  139542. }
  139543. declare module BABYLON {
  139544. /** @hidden */
  139545. export var sharpenPixelShader: {
  139546. name: string;
  139547. shader: string;
  139548. };
  139549. }
  139550. declare module BABYLON {
  139551. /**
  139552. * The SharpenPostProcess applies a sharpen kernel to every pixel
  139553. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139554. */
  139555. export class SharpenPostProcess extends PostProcess {
  139556. /**
  139557. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  139558. */
  139559. colorAmount: number;
  139560. /**
  139561. * How much sharpness should be applied (default: 0.3)
  139562. */
  139563. edgeAmount: number;
  139564. /**
  139565. * Creates a new instance ConvolutionPostProcess
  139566. * @param name The name of the effect.
  139567. * @param options The required width/height ratio to downsize to before computing the render pass.
  139568. * @param camera The camera to apply the render pass to.
  139569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139570. * @param engine The engine which the post process will be applied. (default: current engine)
  139571. * @param reusable If the post process can be reused on the same frame. (default: false)
  139572. * @param textureType Type of textures used when performing the post process. (default: 0)
  139573. * @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)
  139574. */
  139575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139576. }
  139577. }
  139578. declare module BABYLON {
  139579. /**
  139580. * PostProcessRenderPipeline
  139581. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139582. */
  139583. export class PostProcessRenderPipeline {
  139584. private engine;
  139585. private _renderEffects;
  139586. private _renderEffectsForIsolatedPass;
  139587. /**
  139588. * List of inspectable custom properties (used by the Inspector)
  139589. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  139590. */
  139591. inspectableCustomProperties: IInspectable[];
  139592. /**
  139593. * @hidden
  139594. */
  139595. protected _cameras: Camera[];
  139596. /** @hidden */
  139597. _name: string;
  139598. /**
  139599. * Gets pipeline name
  139600. */
  139601. get name(): string;
  139602. /** Gets the list of attached cameras */
  139603. get cameras(): Camera[];
  139604. /**
  139605. * Initializes a PostProcessRenderPipeline
  139606. * @param engine engine to add the pipeline to
  139607. * @param name name of the pipeline
  139608. */
  139609. constructor(engine: Engine, name: string);
  139610. /**
  139611. * Gets the class name
  139612. * @returns "PostProcessRenderPipeline"
  139613. */
  139614. getClassName(): string;
  139615. /**
  139616. * If all the render effects in the pipeline are supported
  139617. */
  139618. get isSupported(): boolean;
  139619. /**
  139620. * Adds an effect to the pipeline
  139621. * @param renderEffect the effect to add
  139622. */
  139623. addEffect(renderEffect: PostProcessRenderEffect): void;
  139624. /** @hidden */
  139625. _rebuild(): void;
  139626. /** @hidden */
  139627. _enableEffect(renderEffectName: string, cameras: Camera): void;
  139628. /** @hidden */
  139629. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  139630. /** @hidden */
  139631. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  139632. /** @hidden */
  139633. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  139634. /** @hidden */
  139635. _attachCameras(cameras: Camera, unique: boolean): void;
  139636. /** @hidden */
  139637. _attachCameras(cameras: Camera[], unique: boolean): void;
  139638. /** @hidden */
  139639. _detachCameras(cameras: Camera): void;
  139640. /** @hidden */
  139641. _detachCameras(cameras: Nullable<Camera[]>): void;
  139642. /** @hidden */
  139643. _update(): void;
  139644. /** @hidden */
  139645. _reset(): void;
  139646. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  139647. /**
  139648. * Disposes of the pipeline
  139649. */
  139650. dispose(): void;
  139651. }
  139652. }
  139653. declare module BABYLON {
  139654. /**
  139655. * PostProcessRenderPipelineManager class
  139656. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139657. */
  139658. export class PostProcessRenderPipelineManager {
  139659. private _renderPipelines;
  139660. /**
  139661. * Initializes a PostProcessRenderPipelineManager
  139662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139663. */
  139664. constructor();
  139665. /**
  139666. * Gets the list of supported render pipelines
  139667. */
  139668. get supportedPipelines(): PostProcessRenderPipeline[];
  139669. /**
  139670. * Adds a pipeline to the manager
  139671. * @param renderPipeline The pipeline to add
  139672. */
  139673. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  139674. /**
  139675. * Attaches a camera to the pipeline
  139676. * @param renderPipelineName The name of the pipeline to attach to
  139677. * @param cameras the camera to attach
  139678. * @param unique if the camera can be attached multiple times to the pipeline
  139679. */
  139680. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  139681. /**
  139682. * Detaches a camera from the pipeline
  139683. * @param renderPipelineName The name of the pipeline to detach from
  139684. * @param cameras the camera to detach
  139685. */
  139686. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  139687. /**
  139688. * Enables an effect by name on a pipeline
  139689. * @param renderPipelineName the name of the pipeline to enable the effect in
  139690. * @param renderEffectName the name of the effect to enable
  139691. * @param cameras the cameras that the effect should be enabled on
  139692. */
  139693. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  139694. /**
  139695. * Disables an effect by name on a pipeline
  139696. * @param renderPipelineName the name of the pipeline to disable the effect in
  139697. * @param renderEffectName the name of the effect to disable
  139698. * @param cameras the cameras that the effect should be disabled on
  139699. */
  139700. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  139701. /**
  139702. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  139703. */
  139704. update(): void;
  139705. /** @hidden */
  139706. _rebuild(): void;
  139707. /**
  139708. * Disposes of the manager and pipelines
  139709. */
  139710. dispose(): void;
  139711. }
  139712. }
  139713. declare module BABYLON {
  139714. interface Scene {
  139715. /** @hidden (Backing field) */
  139716. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  139717. /**
  139718. * Gets the postprocess render pipeline manager
  139719. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139720. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  139721. */
  139722. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  139723. }
  139724. /**
  139725. * Defines the Render Pipeline scene component responsible to rendering pipelines
  139726. */
  139727. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  139728. /**
  139729. * The component name helpfull to identify the component in the list of scene components.
  139730. */
  139731. readonly name: string;
  139732. /**
  139733. * The scene the component belongs to.
  139734. */
  139735. scene: Scene;
  139736. /**
  139737. * Creates a new instance of the component for the given scene
  139738. * @param scene Defines the scene to register the component in
  139739. */
  139740. constructor(scene: Scene);
  139741. /**
  139742. * Registers the component in a given scene
  139743. */
  139744. register(): void;
  139745. /**
  139746. * Rebuilds the elements related to this component in case of
  139747. * context lost for instance.
  139748. */
  139749. rebuild(): void;
  139750. /**
  139751. * Disposes the component and the associated ressources
  139752. */
  139753. dispose(): void;
  139754. private _gatherRenderTargets;
  139755. }
  139756. }
  139757. declare module BABYLON {
  139758. /**
  139759. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  139760. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  139761. */
  139762. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139763. private _scene;
  139764. private _camerasToBeAttached;
  139765. /**
  139766. * ID of the sharpen post process,
  139767. */
  139768. private readonly SharpenPostProcessId;
  139769. /**
  139770. * @ignore
  139771. * ID of the image processing post process;
  139772. */
  139773. readonly ImageProcessingPostProcessId: string;
  139774. /**
  139775. * @ignore
  139776. * ID of the Fast Approximate Anti-Aliasing post process;
  139777. */
  139778. readonly FxaaPostProcessId: string;
  139779. /**
  139780. * ID of the chromatic aberration post process,
  139781. */
  139782. private readonly ChromaticAberrationPostProcessId;
  139783. /**
  139784. * ID of the grain post process
  139785. */
  139786. private readonly GrainPostProcessId;
  139787. /**
  139788. * Sharpen post process which will apply a sharpen convolution to enhance edges
  139789. */
  139790. sharpen: SharpenPostProcess;
  139791. private _sharpenEffect;
  139792. private bloom;
  139793. /**
  139794. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  139795. */
  139796. depthOfField: DepthOfFieldEffect;
  139797. /**
  139798. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139799. */
  139800. fxaa: FxaaPostProcess;
  139801. /**
  139802. * Image post processing pass used to perform operations such as tone mapping or color grading.
  139803. */
  139804. imageProcessing: ImageProcessingPostProcess;
  139805. /**
  139806. * Chromatic aberration post process which will shift rgb colors in the image
  139807. */
  139808. chromaticAberration: ChromaticAberrationPostProcess;
  139809. private _chromaticAberrationEffect;
  139810. /**
  139811. * Grain post process which add noise to the image
  139812. */
  139813. grain: GrainPostProcess;
  139814. private _grainEffect;
  139815. /**
  139816. * Glow post process which adds a glow to emissive areas of the image
  139817. */
  139818. private _glowLayer;
  139819. /**
  139820. * Animations which can be used to tweak settings over a period of time
  139821. */
  139822. animations: Animation[];
  139823. private _imageProcessingConfigurationObserver;
  139824. private _sharpenEnabled;
  139825. private _bloomEnabled;
  139826. private _depthOfFieldEnabled;
  139827. private _depthOfFieldBlurLevel;
  139828. private _fxaaEnabled;
  139829. private _imageProcessingEnabled;
  139830. private _defaultPipelineTextureType;
  139831. private _bloomScale;
  139832. private _chromaticAberrationEnabled;
  139833. private _grainEnabled;
  139834. private _buildAllowed;
  139835. /**
  139836. * Gets active scene
  139837. */
  139838. get scene(): Scene;
  139839. /**
  139840. * Enable or disable the sharpen process from the pipeline
  139841. */
  139842. set sharpenEnabled(enabled: boolean);
  139843. get sharpenEnabled(): boolean;
  139844. private _resizeObserver;
  139845. private _hardwareScaleLevel;
  139846. private _bloomKernel;
  139847. /**
  139848. * Specifies the size of the bloom blur kernel, relative to the final output size
  139849. */
  139850. get bloomKernel(): number;
  139851. set bloomKernel(value: number);
  139852. /**
  139853. * Specifies the weight of the bloom in the final rendering
  139854. */
  139855. private _bloomWeight;
  139856. /**
  139857. * Specifies the luma threshold for the area that will be blurred by the bloom
  139858. */
  139859. private _bloomThreshold;
  139860. private _hdr;
  139861. /**
  139862. * The strength of the bloom.
  139863. */
  139864. set bloomWeight(value: number);
  139865. get bloomWeight(): number;
  139866. /**
  139867. * The strength of the bloom.
  139868. */
  139869. set bloomThreshold(value: number);
  139870. get bloomThreshold(): number;
  139871. /**
  139872. * The scale of the bloom, lower value will provide better performance.
  139873. */
  139874. set bloomScale(value: number);
  139875. get bloomScale(): number;
  139876. /**
  139877. * Enable or disable the bloom from the pipeline
  139878. */
  139879. set bloomEnabled(enabled: boolean);
  139880. get bloomEnabled(): boolean;
  139881. private _rebuildBloom;
  139882. /**
  139883. * If the depth of field is enabled.
  139884. */
  139885. get depthOfFieldEnabled(): boolean;
  139886. set depthOfFieldEnabled(enabled: boolean);
  139887. /**
  139888. * Blur level of the depth of field effect. (Higher blur will effect performance)
  139889. */
  139890. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  139891. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  139892. /**
  139893. * If the anti aliasing is enabled.
  139894. */
  139895. set fxaaEnabled(enabled: boolean);
  139896. get fxaaEnabled(): boolean;
  139897. private _samples;
  139898. /**
  139899. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139900. */
  139901. set samples(sampleCount: number);
  139902. get samples(): number;
  139903. /**
  139904. * If image processing is enabled.
  139905. */
  139906. set imageProcessingEnabled(enabled: boolean);
  139907. get imageProcessingEnabled(): boolean;
  139908. /**
  139909. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  139910. */
  139911. set glowLayerEnabled(enabled: boolean);
  139912. get glowLayerEnabled(): boolean;
  139913. /**
  139914. * Gets the glow layer (or null if not defined)
  139915. */
  139916. get glowLayer(): Nullable<GlowLayer>;
  139917. /**
  139918. * Enable or disable the chromaticAberration process from the pipeline
  139919. */
  139920. set chromaticAberrationEnabled(enabled: boolean);
  139921. get chromaticAberrationEnabled(): boolean;
  139922. /**
  139923. * Enable or disable the grain process from the pipeline
  139924. */
  139925. set grainEnabled(enabled: boolean);
  139926. get grainEnabled(): boolean;
  139927. /**
  139928. * @constructor
  139929. * @param name - The rendering pipeline name (default: "")
  139930. * @param hdr - If high dynamic range textures should be used (default: true)
  139931. * @param scene - The scene linked to this pipeline (default: the last created scene)
  139932. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  139933. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  139934. */
  139935. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  139936. /**
  139937. * Get the class name
  139938. * @returns "DefaultRenderingPipeline"
  139939. */
  139940. getClassName(): string;
  139941. /**
  139942. * Force the compilation of the entire pipeline.
  139943. */
  139944. prepare(): void;
  139945. private _hasCleared;
  139946. private _prevPostProcess;
  139947. private _prevPrevPostProcess;
  139948. private _setAutoClearAndTextureSharing;
  139949. private _depthOfFieldSceneObserver;
  139950. private _buildPipeline;
  139951. private _disposePostProcesses;
  139952. /**
  139953. * Adds a camera to the pipeline
  139954. * @param camera the camera to be added
  139955. */
  139956. addCamera(camera: Camera): void;
  139957. /**
  139958. * Removes a camera from the pipeline
  139959. * @param camera the camera to remove
  139960. */
  139961. removeCamera(camera: Camera): void;
  139962. /**
  139963. * Dispose of the pipeline and stop all post processes
  139964. */
  139965. dispose(): void;
  139966. /**
  139967. * Serialize the rendering pipeline (Used when exporting)
  139968. * @returns the serialized object
  139969. */
  139970. serialize(): any;
  139971. /**
  139972. * Parse the serialized pipeline
  139973. * @param source Source pipeline.
  139974. * @param scene The scene to load the pipeline to.
  139975. * @param rootUrl The URL of the serialized pipeline.
  139976. * @returns An instantiated pipeline from the serialized object.
  139977. */
  139978. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  139979. }
  139980. }
  139981. declare module BABYLON {
  139982. /** @hidden */
  139983. export var lensHighlightsPixelShader: {
  139984. name: string;
  139985. shader: string;
  139986. };
  139987. }
  139988. declare module BABYLON {
  139989. /** @hidden */
  139990. export var depthOfFieldPixelShader: {
  139991. name: string;
  139992. shader: string;
  139993. };
  139994. }
  139995. declare module BABYLON {
  139996. /**
  139997. * BABYLON.JS Chromatic Aberration GLSL Shader
  139998. * Author: Olivier Guyot
  139999. * Separates very slightly R, G and B colors on the edges of the screen
  140000. * Inspired by Francois Tarlier & Martins Upitis
  140001. */
  140002. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  140003. /**
  140004. * @ignore
  140005. * The chromatic aberration PostProcess id in the pipeline
  140006. */
  140007. LensChromaticAberrationEffect: string;
  140008. /**
  140009. * @ignore
  140010. * The highlights enhancing PostProcess id in the pipeline
  140011. */
  140012. HighlightsEnhancingEffect: string;
  140013. /**
  140014. * @ignore
  140015. * The depth-of-field PostProcess id in the pipeline
  140016. */
  140017. LensDepthOfFieldEffect: string;
  140018. private _scene;
  140019. private _depthTexture;
  140020. private _grainTexture;
  140021. private _chromaticAberrationPostProcess;
  140022. private _highlightsPostProcess;
  140023. private _depthOfFieldPostProcess;
  140024. private _edgeBlur;
  140025. private _grainAmount;
  140026. private _chromaticAberration;
  140027. private _distortion;
  140028. private _highlightsGain;
  140029. private _highlightsThreshold;
  140030. private _dofDistance;
  140031. private _dofAperture;
  140032. private _dofDarken;
  140033. private _dofPentagon;
  140034. private _blurNoise;
  140035. /**
  140036. * @constructor
  140037. *
  140038. * Effect parameters are as follow:
  140039. * {
  140040. * chromatic_aberration: number; // from 0 to x (1 for realism)
  140041. * edge_blur: number; // from 0 to x (1 for realism)
  140042. * distortion: number; // from 0 to x (1 for realism)
  140043. * grain_amount: number; // from 0 to 1
  140044. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  140045. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  140046. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  140047. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  140048. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  140049. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  140050. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  140051. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  140052. * }
  140053. * Note: if an effect parameter is unset, effect is disabled
  140054. *
  140055. * @param name The rendering pipeline name
  140056. * @param parameters - An object containing all parameters (see above)
  140057. * @param scene The scene linked to this pipeline
  140058. * @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)
  140059. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140060. */
  140061. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  140062. /**
  140063. * Get the class name
  140064. * @returns "LensRenderingPipeline"
  140065. */
  140066. getClassName(): string;
  140067. /**
  140068. * Gets associated scene
  140069. */
  140070. get scene(): Scene;
  140071. /**
  140072. * Gets or sets the edge blur
  140073. */
  140074. get edgeBlur(): number;
  140075. set edgeBlur(value: number);
  140076. /**
  140077. * Gets or sets the grain amount
  140078. */
  140079. get grainAmount(): number;
  140080. set grainAmount(value: number);
  140081. /**
  140082. * Gets or sets the chromatic aberration amount
  140083. */
  140084. get chromaticAberration(): number;
  140085. set chromaticAberration(value: number);
  140086. /**
  140087. * Gets or sets the depth of field aperture
  140088. */
  140089. get dofAperture(): number;
  140090. set dofAperture(value: number);
  140091. /**
  140092. * Gets or sets the edge distortion
  140093. */
  140094. get edgeDistortion(): number;
  140095. set edgeDistortion(value: number);
  140096. /**
  140097. * Gets or sets the depth of field distortion
  140098. */
  140099. get dofDistortion(): number;
  140100. set dofDistortion(value: number);
  140101. /**
  140102. * Gets or sets the darken out of focus amount
  140103. */
  140104. get darkenOutOfFocus(): number;
  140105. set darkenOutOfFocus(value: number);
  140106. /**
  140107. * Gets or sets a boolean indicating if blur noise is enabled
  140108. */
  140109. get blurNoise(): boolean;
  140110. set blurNoise(value: boolean);
  140111. /**
  140112. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  140113. */
  140114. get pentagonBokeh(): boolean;
  140115. set pentagonBokeh(value: boolean);
  140116. /**
  140117. * Gets or sets the highlight grain amount
  140118. */
  140119. get highlightsGain(): number;
  140120. set highlightsGain(value: number);
  140121. /**
  140122. * Gets or sets the highlight threshold
  140123. */
  140124. get highlightsThreshold(): number;
  140125. set highlightsThreshold(value: number);
  140126. /**
  140127. * Sets the amount of blur at the edges
  140128. * @param amount blur amount
  140129. */
  140130. setEdgeBlur(amount: number): void;
  140131. /**
  140132. * Sets edge blur to 0
  140133. */
  140134. disableEdgeBlur(): void;
  140135. /**
  140136. * Sets the amout of grain
  140137. * @param amount Amount of grain
  140138. */
  140139. setGrainAmount(amount: number): void;
  140140. /**
  140141. * Set grain amount to 0
  140142. */
  140143. disableGrain(): void;
  140144. /**
  140145. * Sets the chromatic aberration amount
  140146. * @param amount amount of chromatic aberration
  140147. */
  140148. setChromaticAberration(amount: number): void;
  140149. /**
  140150. * Sets chromatic aberration amount to 0
  140151. */
  140152. disableChromaticAberration(): void;
  140153. /**
  140154. * Sets the EdgeDistortion amount
  140155. * @param amount amount of EdgeDistortion
  140156. */
  140157. setEdgeDistortion(amount: number): void;
  140158. /**
  140159. * Sets edge distortion to 0
  140160. */
  140161. disableEdgeDistortion(): void;
  140162. /**
  140163. * Sets the FocusDistance amount
  140164. * @param amount amount of FocusDistance
  140165. */
  140166. setFocusDistance(amount: number): void;
  140167. /**
  140168. * Disables depth of field
  140169. */
  140170. disableDepthOfField(): void;
  140171. /**
  140172. * Sets the Aperture amount
  140173. * @param amount amount of Aperture
  140174. */
  140175. setAperture(amount: number): void;
  140176. /**
  140177. * Sets the DarkenOutOfFocus amount
  140178. * @param amount amount of DarkenOutOfFocus
  140179. */
  140180. setDarkenOutOfFocus(amount: number): void;
  140181. private _pentagonBokehIsEnabled;
  140182. /**
  140183. * Creates a pentagon bokeh effect
  140184. */
  140185. enablePentagonBokeh(): void;
  140186. /**
  140187. * Disables the pentagon bokeh effect
  140188. */
  140189. disablePentagonBokeh(): void;
  140190. /**
  140191. * Enables noise blur
  140192. */
  140193. enableNoiseBlur(): void;
  140194. /**
  140195. * Disables noise blur
  140196. */
  140197. disableNoiseBlur(): void;
  140198. /**
  140199. * Sets the HighlightsGain amount
  140200. * @param amount amount of HighlightsGain
  140201. */
  140202. setHighlightsGain(amount: number): void;
  140203. /**
  140204. * Sets the HighlightsThreshold amount
  140205. * @param amount amount of HighlightsThreshold
  140206. */
  140207. setHighlightsThreshold(amount: number): void;
  140208. /**
  140209. * Disables highlights
  140210. */
  140211. disableHighlights(): void;
  140212. /**
  140213. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  140214. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  140215. */
  140216. dispose(disableDepthRender?: boolean): void;
  140217. private _createChromaticAberrationPostProcess;
  140218. private _createHighlightsPostProcess;
  140219. private _createDepthOfFieldPostProcess;
  140220. private _createGrainTexture;
  140221. }
  140222. }
  140223. declare module BABYLON {
  140224. /** @hidden */
  140225. export var ssao2PixelShader: {
  140226. name: string;
  140227. shader: string;
  140228. };
  140229. }
  140230. declare module BABYLON {
  140231. /** @hidden */
  140232. export var ssaoCombinePixelShader: {
  140233. name: string;
  140234. shader: string;
  140235. };
  140236. }
  140237. declare module BABYLON {
  140238. /**
  140239. * Render pipeline to produce ssao effect
  140240. */
  140241. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  140242. /**
  140243. * @ignore
  140244. * The PassPostProcess id in the pipeline that contains the original scene color
  140245. */
  140246. SSAOOriginalSceneColorEffect: string;
  140247. /**
  140248. * @ignore
  140249. * The SSAO PostProcess id in the pipeline
  140250. */
  140251. SSAORenderEffect: string;
  140252. /**
  140253. * @ignore
  140254. * The horizontal blur PostProcess id in the pipeline
  140255. */
  140256. SSAOBlurHRenderEffect: string;
  140257. /**
  140258. * @ignore
  140259. * The vertical blur PostProcess id in the pipeline
  140260. */
  140261. SSAOBlurVRenderEffect: string;
  140262. /**
  140263. * @ignore
  140264. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140265. */
  140266. SSAOCombineRenderEffect: string;
  140267. /**
  140268. * The output strength of the SSAO post-process. Default value is 1.0.
  140269. */
  140270. totalStrength: number;
  140271. /**
  140272. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  140273. */
  140274. maxZ: number;
  140275. /**
  140276. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  140277. */
  140278. minZAspect: number;
  140279. private _samples;
  140280. /**
  140281. * Number of samples used for the SSAO calculations. Default value is 8
  140282. */
  140283. set samples(n: number);
  140284. get samples(): number;
  140285. private _textureSamples;
  140286. /**
  140287. * Number of samples to use for antialiasing
  140288. */
  140289. set textureSamples(n: number);
  140290. get textureSamples(): number;
  140291. /**
  140292. * Ratio object used for SSAO ratio and blur ratio
  140293. */
  140294. private _ratio;
  140295. /**
  140296. * Dynamically generated sphere sampler.
  140297. */
  140298. private _sampleSphere;
  140299. /**
  140300. * Blur filter offsets
  140301. */
  140302. private _samplerOffsets;
  140303. private _expensiveBlur;
  140304. /**
  140305. * If bilateral blur should be used
  140306. */
  140307. set expensiveBlur(b: boolean);
  140308. get expensiveBlur(): boolean;
  140309. /**
  140310. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  140311. */
  140312. radius: number;
  140313. /**
  140314. * The base color of the SSAO post-process
  140315. * The final result is "base + ssao" between [0, 1]
  140316. */
  140317. base: number;
  140318. /**
  140319. * Support test.
  140320. */
  140321. static get IsSupported(): boolean;
  140322. private _scene;
  140323. private _depthTexture;
  140324. private _normalTexture;
  140325. private _randomTexture;
  140326. private _originalColorPostProcess;
  140327. private _ssaoPostProcess;
  140328. private _blurHPostProcess;
  140329. private _blurVPostProcess;
  140330. private _ssaoCombinePostProcess;
  140331. /**
  140332. * Gets active scene
  140333. */
  140334. get scene(): Scene;
  140335. /**
  140336. * @constructor
  140337. * @param name The rendering pipeline name
  140338. * @param scene The scene linked to this pipeline
  140339. * @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 }
  140340. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140341. */
  140342. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140343. /**
  140344. * Get the class name
  140345. * @returns "SSAO2RenderingPipeline"
  140346. */
  140347. getClassName(): string;
  140348. /**
  140349. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140350. */
  140351. dispose(disableGeometryBufferRenderer?: boolean): void;
  140352. private _createBlurPostProcess;
  140353. /** @hidden */
  140354. _rebuild(): void;
  140355. private _bits;
  140356. private _radicalInverse_VdC;
  140357. private _hammersley;
  140358. private _hemisphereSample_uniform;
  140359. private _generateHemisphere;
  140360. private _createSSAOPostProcess;
  140361. private _createSSAOCombinePostProcess;
  140362. private _createRandomTexture;
  140363. /**
  140364. * Serialize the rendering pipeline (Used when exporting)
  140365. * @returns the serialized object
  140366. */
  140367. serialize(): any;
  140368. /**
  140369. * Parse the serialized pipeline
  140370. * @param source Source pipeline.
  140371. * @param scene The scene to load the pipeline to.
  140372. * @param rootUrl The URL of the serialized pipeline.
  140373. * @returns An instantiated pipeline from the serialized object.
  140374. */
  140375. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  140376. }
  140377. }
  140378. declare module BABYLON {
  140379. /** @hidden */
  140380. export var ssaoPixelShader: {
  140381. name: string;
  140382. shader: string;
  140383. };
  140384. }
  140385. declare module BABYLON {
  140386. /**
  140387. * Render pipeline to produce ssao effect
  140388. */
  140389. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  140390. /**
  140391. * @ignore
  140392. * The PassPostProcess id in the pipeline that contains the original scene color
  140393. */
  140394. SSAOOriginalSceneColorEffect: string;
  140395. /**
  140396. * @ignore
  140397. * The SSAO PostProcess id in the pipeline
  140398. */
  140399. SSAORenderEffect: string;
  140400. /**
  140401. * @ignore
  140402. * The horizontal blur PostProcess id in the pipeline
  140403. */
  140404. SSAOBlurHRenderEffect: string;
  140405. /**
  140406. * @ignore
  140407. * The vertical blur PostProcess id in the pipeline
  140408. */
  140409. SSAOBlurVRenderEffect: string;
  140410. /**
  140411. * @ignore
  140412. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140413. */
  140414. SSAOCombineRenderEffect: string;
  140415. /**
  140416. * The output strength of the SSAO post-process. Default value is 1.0.
  140417. */
  140418. totalStrength: number;
  140419. /**
  140420. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  140421. */
  140422. radius: number;
  140423. /**
  140424. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  140425. * Must not be equal to fallOff and superior to fallOff.
  140426. * Default value is 0.0075
  140427. */
  140428. area: number;
  140429. /**
  140430. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  140431. * Must not be equal to area and inferior to area.
  140432. * Default value is 0.000001
  140433. */
  140434. fallOff: number;
  140435. /**
  140436. * The base color of the SSAO post-process
  140437. * The final result is "base + ssao" between [0, 1]
  140438. */
  140439. base: number;
  140440. private _scene;
  140441. private _depthTexture;
  140442. private _randomTexture;
  140443. private _originalColorPostProcess;
  140444. private _ssaoPostProcess;
  140445. private _blurHPostProcess;
  140446. private _blurVPostProcess;
  140447. private _ssaoCombinePostProcess;
  140448. private _firstUpdate;
  140449. /**
  140450. * Gets active scene
  140451. */
  140452. get scene(): Scene;
  140453. /**
  140454. * @constructor
  140455. * @param name - The rendering pipeline name
  140456. * @param scene - The scene linked to this pipeline
  140457. * @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 }
  140458. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  140459. */
  140460. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140461. /**
  140462. * Get the class name
  140463. * @returns "SSAORenderingPipeline"
  140464. */
  140465. getClassName(): string;
  140466. /**
  140467. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140468. */
  140469. dispose(disableDepthRender?: boolean): void;
  140470. private _createBlurPostProcess;
  140471. /** @hidden */
  140472. _rebuild(): void;
  140473. private _createSSAOPostProcess;
  140474. private _createSSAOCombinePostProcess;
  140475. private _createRandomTexture;
  140476. }
  140477. }
  140478. declare module BABYLON {
  140479. /** @hidden */
  140480. export var screenSpaceReflectionPixelShader: {
  140481. name: string;
  140482. shader: string;
  140483. };
  140484. }
  140485. declare module BABYLON {
  140486. /**
  140487. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  140488. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  140489. */
  140490. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  140491. /**
  140492. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  140493. */
  140494. threshold: number;
  140495. /**
  140496. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  140497. */
  140498. strength: number;
  140499. /**
  140500. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  140501. */
  140502. reflectionSpecularFalloffExponent: number;
  140503. /**
  140504. * 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]
  140505. */
  140506. step: number;
  140507. /**
  140508. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  140509. */
  140510. roughnessFactor: number;
  140511. private _geometryBufferRenderer;
  140512. private _enableSmoothReflections;
  140513. private _reflectionSamples;
  140514. private _smoothSteps;
  140515. /**
  140516. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  140517. * @param name The name of the effect.
  140518. * @param scene The scene containing the objects to calculate reflections.
  140519. * @param options The required width/height ratio to downsize to before computing the render pass.
  140520. * @param camera The camera to apply the render pass to.
  140521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140522. * @param engine The engine which the post process will be applied. (default: current engine)
  140523. * @param reusable If the post process can be reused on the same frame. (default: false)
  140524. * @param textureType Type of textures used when performing the post process. (default: 0)
  140525. * @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)
  140526. */
  140527. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140528. /**
  140529. * Gets wether or not smoothing reflections is enabled.
  140530. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140531. */
  140532. get enableSmoothReflections(): boolean;
  140533. /**
  140534. * Sets wether or not smoothing reflections is enabled.
  140535. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140536. */
  140537. set enableSmoothReflections(enabled: boolean);
  140538. /**
  140539. * Gets the number of samples taken while computing reflections. More samples count is high,
  140540. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140541. */
  140542. get reflectionSamples(): number;
  140543. /**
  140544. * Sets the number of samples taken while computing reflections. More samples count is high,
  140545. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140546. */
  140547. set reflectionSamples(samples: number);
  140548. /**
  140549. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  140550. * more the post-process will require GPU power and can generate a drop in FPS.
  140551. * Default value (5.0) work pretty well in all cases but can be adjusted.
  140552. */
  140553. get smoothSteps(): number;
  140554. set smoothSteps(steps: number);
  140555. private _updateEffectDefines;
  140556. }
  140557. }
  140558. declare module BABYLON {
  140559. /** @hidden */
  140560. export var standardPixelShader: {
  140561. name: string;
  140562. shader: string;
  140563. };
  140564. }
  140565. declare module BABYLON {
  140566. /**
  140567. * Standard rendering pipeline
  140568. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140569. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  140570. */
  140571. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140572. /**
  140573. * Public members
  140574. */
  140575. /**
  140576. * Post-process which contains the original scene color before the pipeline applies all the effects
  140577. */
  140578. originalPostProcess: Nullable<PostProcess>;
  140579. /**
  140580. * Post-process used to down scale an image x4
  140581. */
  140582. downSampleX4PostProcess: Nullable<PostProcess>;
  140583. /**
  140584. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  140585. */
  140586. brightPassPostProcess: Nullable<PostProcess>;
  140587. /**
  140588. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  140589. */
  140590. blurHPostProcesses: PostProcess[];
  140591. /**
  140592. * Post-process array storing all the vertical blur post-processes used by the pipeline
  140593. */
  140594. blurVPostProcesses: PostProcess[];
  140595. /**
  140596. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  140597. */
  140598. textureAdderPostProcess: Nullable<PostProcess>;
  140599. /**
  140600. * Post-process used to create volumetric lighting effect
  140601. */
  140602. volumetricLightPostProcess: Nullable<PostProcess>;
  140603. /**
  140604. * Post-process used to smooth the previous volumetric light post-process on the X axis
  140605. */
  140606. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  140607. /**
  140608. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  140609. */
  140610. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  140611. /**
  140612. * Post-process used to merge the volumetric light effect and the real scene color
  140613. */
  140614. volumetricLightMergePostProces: Nullable<PostProcess>;
  140615. /**
  140616. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  140617. */
  140618. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  140619. /**
  140620. * Base post-process used to calculate the average luminance of the final image for HDR
  140621. */
  140622. luminancePostProcess: Nullable<PostProcess>;
  140623. /**
  140624. * Post-processes used to create down sample post-processes in order to get
  140625. * the average luminance of the final image for HDR
  140626. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  140627. */
  140628. luminanceDownSamplePostProcesses: PostProcess[];
  140629. /**
  140630. * Post-process used to create a HDR effect (light adaptation)
  140631. */
  140632. hdrPostProcess: Nullable<PostProcess>;
  140633. /**
  140634. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  140635. */
  140636. textureAdderFinalPostProcess: Nullable<PostProcess>;
  140637. /**
  140638. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  140639. */
  140640. lensFlareFinalPostProcess: Nullable<PostProcess>;
  140641. /**
  140642. * Post-process used to merge the final HDR post-process and the real scene color
  140643. */
  140644. hdrFinalPostProcess: Nullable<PostProcess>;
  140645. /**
  140646. * Post-process used to create a lens flare effect
  140647. */
  140648. lensFlarePostProcess: Nullable<PostProcess>;
  140649. /**
  140650. * Post-process that merges the result of the lens flare post-process and the real scene color
  140651. */
  140652. lensFlareComposePostProcess: Nullable<PostProcess>;
  140653. /**
  140654. * Post-process used to create a motion blur effect
  140655. */
  140656. motionBlurPostProcess: Nullable<PostProcess>;
  140657. /**
  140658. * Post-process used to create a depth of field effect
  140659. */
  140660. depthOfFieldPostProcess: Nullable<PostProcess>;
  140661. /**
  140662. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  140663. */
  140664. fxaaPostProcess: Nullable<FxaaPostProcess>;
  140665. /**
  140666. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  140667. */
  140668. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  140669. /**
  140670. * Represents the brightness threshold in order to configure the illuminated surfaces
  140671. */
  140672. brightThreshold: number;
  140673. /**
  140674. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  140675. */
  140676. blurWidth: number;
  140677. /**
  140678. * Sets if the blur for highlighted surfaces must be only horizontal
  140679. */
  140680. horizontalBlur: boolean;
  140681. /**
  140682. * Gets the overall exposure used by the pipeline
  140683. */
  140684. get exposure(): number;
  140685. /**
  140686. * Sets the overall exposure used by the pipeline
  140687. */
  140688. set exposure(value: number);
  140689. /**
  140690. * Texture used typically to simulate "dirty" on camera lens
  140691. */
  140692. lensTexture: Nullable<Texture>;
  140693. /**
  140694. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  140695. */
  140696. volumetricLightCoefficient: number;
  140697. /**
  140698. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  140699. */
  140700. volumetricLightPower: number;
  140701. /**
  140702. * Used the set the blur intensity to smooth the volumetric lights
  140703. */
  140704. volumetricLightBlurScale: number;
  140705. /**
  140706. * Light (spot or directional) used to generate the volumetric lights rays
  140707. * The source light must have a shadow generate so the pipeline can get its
  140708. * depth map
  140709. */
  140710. sourceLight: Nullable<SpotLight | DirectionalLight>;
  140711. /**
  140712. * For eye adaptation, represents the minimum luminance the eye can see
  140713. */
  140714. hdrMinimumLuminance: number;
  140715. /**
  140716. * For eye adaptation, represents the decrease luminance speed
  140717. */
  140718. hdrDecreaseRate: number;
  140719. /**
  140720. * For eye adaptation, represents the increase luminance speed
  140721. */
  140722. hdrIncreaseRate: number;
  140723. /**
  140724. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  140725. */
  140726. get hdrAutoExposure(): boolean;
  140727. /**
  140728. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  140729. */
  140730. set hdrAutoExposure(value: boolean);
  140731. /**
  140732. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  140733. */
  140734. lensColorTexture: Nullable<Texture>;
  140735. /**
  140736. * The overall strengh for the lens flare effect
  140737. */
  140738. lensFlareStrength: number;
  140739. /**
  140740. * Dispersion coefficient for lens flare ghosts
  140741. */
  140742. lensFlareGhostDispersal: number;
  140743. /**
  140744. * Main lens flare halo width
  140745. */
  140746. lensFlareHaloWidth: number;
  140747. /**
  140748. * Based on the lens distortion effect, defines how much the lens flare result
  140749. * is distorted
  140750. */
  140751. lensFlareDistortionStrength: number;
  140752. /**
  140753. * Configures the blur intensity used for for lens flare (halo)
  140754. */
  140755. lensFlareBlurWidth: number;
  140756. /**
  140757. * Lens star texture must be used to simulate rays on the flares and is available
  140758. * in the documentation
  140759. */
  140760. lensStarTexture: Nullable<Texture>;
  140761. /**
  140762. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  140763. * flare effect by taking account of the dirt texture
  140764. */
  140765. lensFlareDirtTexture: Nullable<Texture>;
  140766. /**
  140767. * Represents the focal length for the depth of field effect
  140768. */
  140769. depthOfFieldDistance: number;
  140770. /**
  140771. * Represents the blur intensity for the blurred part of the depth of field effect
  140772. */
  140773. depthOfFieldBlurWidth: number;
  140774. /**
  140775. * Gets how much the image is blurred by the movement while using the motion blur post-process
  140776. */
  140777. get motionStrength(): number;
  140778. /**
  140779. * Sets how much the image is blurred by the movement while using the motion blur post-process
  140780. */
  140781. set motionStrength(strength: number);
  140782. /**
  140783. * Gets wether or not the motion blur post-process is object based or screen based.
  140784. */
  140785. get objectBasedMotionBlur(): boolean;
  140786. /**
  140787. * Sets wether or not the motion blur post-process should be object based or screen based
  140788. */
  140789. set objectBasedMotionBlur(value: boolean);
  140790. /**
  140791. * List of animations for the pipeline (IAnimatable implementation)
  140792. */
  140793. animations: Animation[];
  140794. /**
  140795. * Private members
  140796. */
  140797. private _scene;
  140798. private _currentDepthOfFieldSource;
  140799. private _basePostProcess;
  140800. private _fixedExposure;
  140801. private _currentExposure;
  140802. private _hdrAutoExposure;
  140803. private _hdrCurrentLuminance;
  140804. private _motionStrength;
  140805. private _isObjectBasedMotionBlur;
  140806. private _floatTextureType;
  140807. private _camerasToBeAttached;
  140808. private _ratio;
  140809. private _bloomEnabled;
  140810. private _depthOfFieldEnabled;
  140811. private _vlsEnabled;
  140812. private _lensFlareEnabled;
  140813. private _hdrEnabled;
  140814. private _motionBlurEnabled;
  140815. private _fxaaEnabled;
  140816. private _screenSpaceReflectionsEnabled;
  140817. private _motionBlurSamples;
  140818. private _volumetricLightStepsCount;
  140819. private _samples;
  140820. /**
  140821. * @ignore
  140822. * Specifies if the bloom pipeline is enabled
  140823. */
  140824. get BloomEnabled(): boolean;
  140825. set BloomEnabled(enabled: boolean);
  140826. /**
  140827. * @ignore
  140828. * Specifies if the depth of field pipeline is enabed
  140829. */
  140830. get DepthOfFieldEnabled(): boolean;
  140831. set DepthOfFieldEnabled(enabled: boolean);
  140832. /**
  140833. * @ignore
  140834. * Specifies if the lens flare pipeline is enabed
  140835. */
  140836. get LensFlareEnabled(): boolean;
  140837. set LensFlareEnabled(enabled: boolean);
  140838. /**
  140839. * @ignore
  140840. * Specifies if the HDR pipeline is enabled
  140841. */
  140842. get HDREnabled(): boolean;
  140843. set HDREnabled(enabled: boolean);
  140844. /**
  140845. * @ignore
  140846. * Specifies if the volumetric lights scattering effect is enabled
  140847. */
  140848. get VLSEnabled(): boolean;
  140849. set VLSEnabled(enabled: boolean);
  140850. /**
  140851. * @ignore
  140852. * Specifies if the motion blur effect is enabled
  140853. */
  140854. get MotionBlurEnabled(): boolean;
  140855. set MotionBlurEnabled(enabled: boolean);
  140856. /**
  140857. * Specifies if anti-aliasing is enabled
  140858. */
  140859. get fxaaEnabled(): boolean;
  140860. set fxaaEnabled(enabled: boolean);
  140861. /**
  140862. * Specifies if screen space reflections are enabled.
  140863. */
  140864. get screenSpaceReflectionsEnabled(): boolean;
  140865. set screenSpaceReflectionsEnabled(enabled: boolean);
  140866. /**
  140867. * Specifies the number of steps used to calculate the volumetric lights
  140868. * Typically in interval [50, 200]
  140869. */
  140870. get volumetricLightStepsCount(): number;
  140871. set volumetricLightStepsCount(count: number);
  140872. /**
  140873. * Specifies the number of samples used for the motion blur effect
  140874. * Typically in interval [16, 64]
  140875. */
  140876. get motionBlurSamples(): number;
  140877. set motionBlurSamples(samples: number);
  140878. /**
  140879. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140880. */
  140881. get samples(): number;
  140882. set samples(sampleCount: number);
  140883. /**
  140884. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140885. * @constructor
  140886. * @param name The rendering pipeline name
  140887. * @param scene The scene linked to this pipeline
  140888. * @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)
  140889. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  140890. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140891. */
  140892. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  140893. private _buildPipeline;
  140894. private _createDownSampleX4PostProcess;
  140895. private _createBrightPassPostProcess;
  140896. private _createBlurPostProcesses;
  140897. private _createTextureAdderPostProcess;
  140898. private _createVolumetricLightPostProcess;
  140899. private _createLuminancePostProcesses;
  140900. private _createHdrPostProcess;
  140901. private _createLensFlarePostProcess;
  140902. private _createDepthOfFieldPostProcess;
  140903. private _createMotionBlurPostProcess;
  140904. private _getDepthTexture;
  140905. private _disposePostProcesses;
  140906. /**
  140907. * Dispose of the pipeline and stop all post processes
  140908. */
  140909. dispose(): void;
  140910. /**
  140911. * Serialize the rendering pipeline (Used when exporting)
  140912. * @returns the serialized object
  140913. */
  140914. serialize(): any;
  140915. /**
  140916. * Parse the serialized pipeline
  140917. * @param source Source pipeline.
  140918. * @param scene The scene to load the pipeline to.
  140919. * @param rootUrl The URL of the serialized pipeline.
  140920. * @returns An instantiated pipeline from the serialized object.
  140921. */
  140922. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  140923. /**
  140924. * Luminance steps
  140925. */
  140926. static LuminanceSteps: number;
  140927. }
  140928. }
  140929. declare module BABYLON {
  140930. /** @hidden */
  140931. export var tonemapPixelShader: {
  140932. name: string;
  140933. shader: string;
  140934. };
  140935. }
  140936. declare module BABYLON {
  140937. /** Defines operator used for tonemapping */
  140938. export enum TonemappingOperator {
  140939. /** Hable */
  140940. Hable = 0,
  140941. /** Reinhard */
  140942. Reinhard = 1,
  140943. /** HejiDawson */
  140944. HejiDawson = 2,
  140945. /** Photographic */
  140946. Photographic = 3
  140947. }
  140948. /**
  140949. * Defines a post process to apply tone mapping
  140950. */
  140951. export class TonemapPostProcess extends PostProcess {
  140952. private _operator;
  140953. /** Defines the required exposure adjustement */
  140954. exposureAdjustment: number;
  140955. /**
  140956. * Creates a new TonemapPostProcess
  140957. * @param name defines the name of the postprocess
  140958. * @param _operator defines the operator to use
  140959. * @param exposureAdjustment defines the required exposure adjustement
  140960. * @param camera defines the camera to use (can be null)
  140961. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  140962. * @param engine defines the hosting engine (can be ignore if camera is set)
  140963. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  140964. */
  140965. constructor(name: string, _operator: TonemappingOperator,
  140966. /** Defines the required exposure adjustement */
  140967. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  140968. }
  140969. }
  140970. declare module BABYLON {
  140971. /** @hidden */
  140972. export var volumetricLightScatteringPixelShader: {
  140973. name: string;
  140974. shader: string;
  140975. };
  140976. }
  140977. declare module BABYLON {
  140978. /** @hidden */
  140979. export var volumetricLightScatteringPassVertexShader: {
  140980. name: string;
  140981. shader: string;
  140982. };
  140983. }
  140984. declare module BABYLON {
  140985. /** @hidden */
  140986. export var volumetricLightScatteringPassPixelShader: {
  140987. name: string;
  140988. shader: string;
  140989. };
  140990. }
  140991. declare module BABYLON {
  140992. /**
  140993. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  140994. */
  140995. export class VolumetricLightScatteringPostProcess extends PostProcess {
  140996. private _volumetricLightScatteringPass;
  140997. private _volumetricLightScatteringRTT;
  140998. private _viewPort;
  140999. private _screenCoordinates;
  141000. private _cachedDefines;
  141001. /**
  141002. * If not undefined, the mesh position is computed from the attached node position
  141003. */
  141004. attachedNode: {
  141005. position: Vector3;
  141006. };
  141007. /**
  141008. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  141009. */
  141010. customMeshPosition: Vector3;
  141011. /**
  141012. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  141013. */
  141014. useCustomMeshPosition: boolean;
  141015. /**
  141016. * If the post-process should inverse the light scattering direction
  141017. */
  141018. invert: boolean;
  141019. /**
  141020. * The internal mesh used by the post-process
  141021. */
  141022. mesh: Mesh;
  141023. /**
  141024. * @hidden
  141025. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  141026. */
  141027. get useDiffuseColor(): boolean;
  141028. set useDiffuseColor(useDiffuseColor: boolean);
  141029. /**
  141030. * Array containing the excluded meshes not rendered in the internal pass
  141031. */
  141032. excludedMeshes: AbstractMesh[];
  141033. /**
  141034. * Controls the overall intensity of the post-process
  141035. */
  141036. exposure: number;
  141037. /**
  141038. * Dissipates each sample's contribution in range [0, 1]
  141039. */
  141040. decay: number;
  141041. /**
  141042. * Controls the overall intensity of each sample
  141043. */
  141044. weight: number;
  141045. /**
  141046. * Controls the density of each sample
  141047. */
  141048. density: number;
  141049. /**
  141050. * @constructor
  141051. * @param name The post-process name
  141052. * @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)
  141053. * @param camera The camera that the post-process will be attached to
  141054. * @param mesh The mesh used to create the light scattering
  141055. * @param samples The post-process quality, default 100
  141056. * @param samplingModeThe post-process filtering mode
  141057. * @param engine The babylon engine
  141058. * @param reusable If the post-process is reusable
  141059. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  141060. */
  141061. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  141062. /**
  141063. * Returns the string "VolumetricLightScatteringPostProcess"
  141064. * @returns "VolumetricLightScatteringPostProcess"
  141065. */
  141066. getClassName(): string;
  141067. private _isReady;
  141068. /**
  141069. * Sets the new light position for light scattering effect
  141070. * @param position The new custom light position
  141071. */
  141072. setCustomMeshPosition(position: Vector3): void;
  141073. /**
  141074. * Returns the light position for light scattering effect
  141075. * @return Vector3 The custom light position
  141076. */
  141077. getCustomMeshPosition(): Vector3;
  141078. /**
  141079. * Disposes the internal assets and detaches the post-process from the camera
  141080. */
  141081. dispose(camera: Camera): void;
  141082. /**
  141083. * Returns the render target texture used by the post-process
  141084. * @return the render target texture used by the post-process
  141085. */
  141086. getPass(): RenderTargetTexture;
  141087. private _meshExcluded;
  141088. private _createPass;
  141089. private _updateMeshScreenCoordinates;
  141090. /**
  141091. * Creates a default mesh for the Volumeric Light Scattering post-process
  141092. * @param name The mesh name
  141093. * @param scene The scene where to create the mesh
  141094. * @return the default mesh
  141095. */
  141096. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  141097. }
  141098. }
  141099. declare module BABYLON {
  141100. interface Scene {
  141101. /** @hidden (Backing field) */
  141102. _boundingBoxRenderer: BoundingBoxRenderer;
  141103. /** @hidden (Backing field) */
  141104. _forceShowBoundingBoxes: boolean;
  141105. /**
  141106. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  141107. */
  141108. forceShowBoundingBoxes: boolean;
  141109. /**
  141110. * Gets the bounding box renderer associated with the scene
  141111. * @returns a BoundingBoxRenderer
  141112. */
  141113. getBoundingBoxRenderer(): BoundingBoxRenderer;
  141114. }
  141115. interface AbstractMesh {
  141116. /** @hidden (Backing field) */
  141117. _showBoundingBox: boolean;
  141118. /**
  141119. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  141120. */
  141121. showBoundingBox: boolean;
  141122. }
  141123. /**
  141124. * Component responsible of rendering the bounding box of the meshes in a scene.
  141125. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  141126. */
  141127. export class BoundingBoxRenderer implements ISceneComponent {
  141128. /**
  141129. * The component name helpfull to identify the component in the list of scene components.
  141130. */
  141131. readonly name: string;
  141132. /**
  141133. * The scene the component belongs to.
  141134. */
  141135. scene: Scene;
  141136. /**
  141137. * Color of the bounding box lines placed in front of an object
  141138. */
  141139. frontColor: Color3;
  141140. /**
  141141. * Color of the bounding box lines placed behind an object
  141142. */
  141143. backColor: Color3;
  141144. /**
  141145. * Defines if the renderer should show the back lines or not
  141146. */
  141147. showBackLines: boolean;
  141148. /**
  141149. * @hidden
  141150. */
  141151. renderList: SmartArray<BoundingBox>;
  141152. private _colorShader;
  141153. private _vertexBuffers;
  141154. private _indexBuffer;
  141155. private _fillIndexBuffer;
  141156. private _fillIndexData;
  141157. /**
  141158. * Instantiates a new bounding box renderer in a scene.
  141159. * @param scene the scene the renderer renders in
  141160. */
  141161. constructor(scene: Scene);
  141162. /**
  141163. * Registers the component in a given scene
  141164. */
  141165. register(): void;
  141166. private _evaluateSubMesh;
  141167. private _activeMesh;
  141168. private _prepareRessources;
  141169. private _createIndexBuffer;
  141170. /**
  141171. * Rebuilds the elements related to this component in case of
  141172. * context lost for instance.
  141173. */
  141174. rebuild(): void;
  141175. /**
  141176. * @hidden
  141177. */
  141178. reset(): void;
  141179. /**
  141180. * Render the bounding boxes of a specific rendering group
  141181. * @param renderingGroupId defines the rendering group to render
  141182. */
  141183. render(renderingGroupId: number): void;
  141184. /**
  141185. * In case of occlusion queries, we can render the occlusion bounding box through this method
  141186. * @param mesh Define the mesh to render the occlusion bounding box for
  141187. */
  141188. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  141189. /**
  141190. * Dispose and release the resources attached to this renderer.
  141191. */
  141192. dispose(): void;
  141193. }
  141194. }
  141195. declare module BABYLON {
  141196. interface Scene {
  141197. /** @hidden (Backing field) */
  141198. _depthRenderer: {
  141199. [id: string]: DepthRenderer;
  141200. };
  141201. /**
  141202. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  141203. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  141204. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141205. * @returns the created depth renderer
  141206. */
  141207. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  141208. /**
  141209. * Disables a depth renderer for a given camera
  141210. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  141211. */
  141212. disableDepthRenderer(camera?: Nullable<Camera>): void;
  141213. }
  141214. /**
  141215. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  141216. * in several rendering techniques.
  141217. */
  141218. export class DepthRendererSceneComponent implements ISceneComponent {
  141219. /**
  141220. * The component name helpfull to identify the component in the list of scene components.
  141221. */
  141222. readonly name: string;
  141223. /**
  141224. * The scene the component belongs to.
  141225. */
  141226. scene: Scene;
  141227. /**
  141228. * Creates a new instance of the component for the given scene
  141229. * @param scene Defines the scene to register the component in
  141230. */
  141231. constructor(scene: Scene);
  141232. /**
  141233. * Registers the component in a given scene
  141234. */
  141235. register(): void;
  141236. /**
  141237. * Rebuilds the elements related to this component in case of
  141238. * context lost for instance.
  141239. */
  141240. rebuild(): void;
  141241. /**
  141242. * Disposes the component and the associated ressources
  141243. */
  141244. dispose(): void;
  141245. private _gatherRenderTargets;
  141246. private _gatherActiveCameraRenderTargets;
  141247. }
  141248. }
  141249. declare module BABYLON {
  141250. /** @hidden */
  141251. export var outlinePixelShader: {
  141252. name: string;
  141253. shader: string;
  141254. };
  141255. }
  141256. declare module BABYLON {
  141257. /** @hidden */
  141258. export var outlineVertexShader: {
  141259. name: string;
  141260. shader: string;
  141261. };
  141262. }
  141263. declare module BABYLON {
  141264. interface Scene {
  141265. /** @hidden */
  141266. _outlineRenderer: OutlineRenderer;
  141267. /**
  141268. * Gets the outline renderer associated with the scene
  141269. * @returns a OutlineRenderer
  141270. */
  141271. getOutlineRenderer(): OutlineRenderer;
  141272. }
  141273. interface AbstractMesh {
  141274. /** @hidden (Backing field) */
  141275. _renderOutline: boolean;
  141276. /**
  141277. * Gets or sets a boolean indicating if the outline must be rendered as well
  141278. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  141279. */
  141280. renderOutline: boolean;
  141281. /** @hidden (Backing field) */
  141282. _renderOverlay: boolean;
  141283. /**
  141284. * Gets or sets a boolean indicating if the overlay must be rendered as well
  141285. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  141286. */
  141287. renderOverlay: boolean;
  141288. }
  141289. /**
  141290. * This class is responsible to draw bothe outline/overlay of meshes.
  141291. * It should not be used directly but through the available method on mesh.
  141292. */
  141293. export class OutlineRenderer implements ISceneComponent {
  141294. /**
  141295. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  141296. */
  141297. private static _StencilReference;
  141298. /**
  141299. * The name of the component. Each component must have a unique name.
  141300. */
  141301. name: string;
  141302. /**
  141303. * The scene the component belongs to.
  141304. */
  141305. scene: Scene;
  141306. /**
  141307. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  141308. */
  141309. zOffset: number;
  141310. private _engine;
  141311. private _effect;
  141312. private _cachedDefines;
  141313. private _savedDepthWrite;
  141314. /**
  141315. * Instantiates a new outline renderer. (There could be only one per scene).
  141316. * @param scene Defines the scene it belongs to
  141317. */
  141318. constructor(scene: Scene);
  141319. /**
  141320. * Register the component to one instance of a scene.
  141321. */
  141322. register(): void;
  141323. /**
  141324. * Rebuilds the elements related to this component in case of
  141325. * context lost for instance.
  141326. */
  141327. rebuild(): void;
  141328. /**
  141329. * Disposes the component and the associated ressources.
  141330. */
  141331. dispose(): void;
  141332. /**
  141333. * Renders the outline in the canvas.
  141334. * @param subMesh Defines the sumesh to render
  141335. * @param batch Defines the batch of meshes in case of instances
  141336. * @param useOverlay Defines if the rendering is for the overlay or the outline
  141337. */
  141338. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  141339. /**
  141340. * Returns whether or not the outline renderer is ready for a given submesh.
  141341. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  141342. * @param subMesh Defines the submesh to check readyness for
  141343. * @param useInstances Defines wheter wee are trying to render instances or not
  141344. * @returns true if ready otherwise false
  141345. */
  141346. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141347. private _beforeRenderingMesh;
  141348. private _afterRenderingMesh;
  141349. }
  141350. }
  141351. declare module BABYLON {
  141352. /**
  141353. * Defines the basic options interface of a Sprite Frame Source Size.
  141354. */
  141355. export interface ISpriteJSONSpriteSourceSize {
  141356. /**
  141357. * number of the original width of the Frame
  141358. */
  141359. w: number;
  141360. /**
  141361. * number of the original height of the Frame
  141362. */
  141363. h: number;
  141364. }
  141365. /**
  141366. * Defines the basic options interface of a Sprite Frame Data.
  141367. */
  141368. export interface ISpriteJSONSpriteFrameData {
  141369. /**
  141370. * number of the x offset of the Frame
  141371. */
  141372. x: number;
  141373. /**
  141374. * number of the y offset of the Frame
  141375. */
  141376. y: number;
  141377. /**
  141378. * number of the width of the Frame
  141379. */
  141380. w: number;
  141381. /**
  141382. * number of the height of the Frame
  141383. */
  141384. h: number;
  141385. }
  141386. /**
  141387. * Defines the basic options interface of a JSON Sprite.
  141388. */
  141389. export interface ISpriteJSONSprite {
  141390. /**
  141391. * string name of the Frame
  141392. */
  141393. filename: string;
  141394. /**
  141395. * ISpriteJSONSpriteFrame basic object of the frame data
  141396. */
  141397. frame: ISpriteJSONSpriteFrameData;
  141398. /**
  141399. * boolean to flag is the frame was rotated.
  141400. */
  141401. rotated: boolean;
  141402. /**
  141403. * boolean to flag is the frame was trimmed.
  141404. */
  141405. trimmed: boolean;
  141406. /**
  141407. * ISpriteJSONSpriteFrame basic object of the source data
  141408. */
  141409. spriteSourceSize: ISpriteJSONSpriteFrameData;
  141410. /**
  141411. * ISpriteJSONSpriteFrame basic object of the source data
  141412. */
  141413. sourceSize: ISpriteJSONSpriteSourceSize;
  141414. }
  141415. /**
  141416. * Defines the basic options interface of a JSON atlas.
  141417. */
  141418. export interface ISpriteJSONAtlas {
  141419. /**
  141420. * Array of objects that contain the frame data.
  141421. */
  141422. frames: Array<ISpriteJSONSprite>;
  141423. /**
  141424. * object basic object containing the sprite meta data.
  141425. */
  141426. meta?: object;
  141427. }
  141428. }
  141429. declare module BABYLON {
  141430. /** @hidden */
  141431. export var spriteMapPixelShader: {
  141432. name: string;
  141433. shader: string;
  141434. };
  141435. }
  141436. declare module BABYLON {
  141437. /** @hidden */
  141438. export var spriteMapVertexShader: {
  141439. name: string;
  141440. shader: string;
  141441. };
  141442. }
  141443. declare module BABYLON {
  141444. /**
  141445. * Defines the basic options interface of a SpriteMap
  141446. */
  141447. export interface ISpriteMapOptions {
  141448. /**
  141449. * Vector2 of the number of cells in the grid.
  141450. */
  141451. stageSize?: Vector2;
  141452. /**
  141453. * Vector2 of the size of the output plane in World Units.
  141454. */
  141455. outputSize?: Vector2;
  141456. /**
  141457. * Vector3 of the position of the output plane in World Units.
  141458. */
  141459. outputPosition?: Vector3;
  141460. /**
  141461. * Vector3 of the rotation of the output plane.
  141462. */
  141463. outputRotation?: Vector3;
  141464. /**
  141465. * number of layers that the system will reserve in resources.
  141466. */
  141467. layerCount?: number;
  141468. /**
  141469. * number of max animation frames a single cell will reserve in resources.
  141470. */
  141471. maxAnimationFrames?: number;
  141472. /**
  141473. * number cell index of the base tile when the system compiles.
  141474. */
  141475. baseTile?: number;
  141476. /**
  141477. * boolean flip the sprite after its been repositioned by the framing data.
  141478. */
  141479. flipU?: boolean;
  141480. /**
  141481. * Vector3 scalar of the global RGB values of the SpriteMap.
  141482. */
  141483. colorMultiply?: Vector3;
  141484. }
  141485. /**
  141486. * Defines the IDisposable interface in order to be cleanable from resources.
  141487. */
  141488. export interface ISpriteMap extends IDisposable {
  141489. /**
  141490. * String name of the SpriteMap.
  141491. */
  141492. name: string;
  141493. /**
  141494. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  141495. */
  141496. atlasJSON: ISpriteJSONAtlas;
  141497. /**
  141498. * Texture of the SpriteMap.
  141499. */
  141500. spriteSheet: Texture;
  141501. /**
  141502. * The parameters to initialize the SpriteMap with.
  141503. */
  141504. options: ISpriteMapOptions;
  141505. }
  141506. /**
  141507. * Class used to manage a grid restricted sprite deployment on an Output plane.
  141508. */
  141509. export class SpriteMap implements ISpriteMap {
  141510. /** The Name of the spriteMap */
  141511. name: string;
  141512. /** The JSON file with the frame and meta data */
  141513. atlasJSON: ISpriteJSONAtlas;
  141514. /** The systems Sprite Sheet Texture */
  141515. spriteSheet: Texture;
  141516. /** Arguments passed with the Constructor */
  141517. options: ISpriteMapOptions;
  141518. /** Public Sprite Storage array, parsed from atlasJSON */
  141519. sprites: Array<ISpriteJSONSprite>;
  141520. /** Returns the Number of Sprites in the System */
  141521. get spriteCount(): number;
  141522. /** Returns the Position of Output Plane*/
  141523. get position(): Vector3;
  141524. /** Returns the Position of Output Plane*/
  141525. set position(v: Vector3);
  141526. /** Returns the Rotation of Output Plane*/
  141527. get rotation(): Vector3;
  141528. /** Returns the Rotation of Output Plane*/
  141529. set rotation(v: Vector3);
  141530. /** Sets the AnimationMap*/
  141531. get animationMap(): RawTexture;
  141532. /** Sets the AnimationMap*/
  141533. set animationMap(v: RawTexture);
  141534. /** Scene that the SpriteMap was created in */
  141535. private _scene;
  141536. /** Texture Buffer of Float32 that holds tile frame data*/
  141537. private _frameMap;
  141538. /** Texture Buffers of Float32 that holds tileMap data*/
  141539. private _tileMaps;
  141540. /** Texture Buffer of Float32 that holds Animation Data*/
  141541. private _animationMap;
  141542. /** Custom ShaderMaterial Central to the System*/
  141543. private _material;
  141544. /** Custom ShaderMaterial Central to the System*/
  141545. private _output;
  141546. /** Systems Time Ticker*/
  141547. private _time;
  141548. /**
  141549. * Creates a new SpriteMap
  141550. * @param name defines the SpriteMaps Name
  141551. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  141552. * @param spriteSheet is the Texture that the Sprites are on.
  141553. * @param options a basic deployment configuration
  141554. * @param scene The Scene that the map is deployed on
  141555. */
  141556. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  141557. /**
  141558. * Returns tileID location
  141559. * @returns Vector2 the cell position ID
  141560. */
  141561. getTileID(): Vector2;
  141562. /**
  141563. * Gets the UV location of the mouse over the SpriteMap.
  141564. * @returns Vector2 the UV position of the mouse interaction
  141565. */
  141566. getMousePosition(): Vector2;
  141567. /**
  141568. * Creates the "frame" texture Buffer
  141569. * -------------------------------------
  141570. * Structure of frames
  141571. * "filename": "Falling-Water-2.png",
  141572. * "frame": {"x":69,"y":103,"w":24,"h":32},
  141573. * "rotated": true,
  141574. * "trimmed": true,
  141575. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  141576. * "sourceSize": {"w":32,"h":32}
  141577. * @returns RawTexture of the frameMap
  141578. */
  141579. private _createFrameBuffer;
  141580. /**
  141581. * Creates the tileMap texture Buffer
  141582. * @param buffer normally and array of numbers, or a false to generate from scratch
  141583. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  141584. * @returns RawTexture of the tileMap
  141585. */
  141586. private _createTileBuffer;
  141587. /**
  141588. * Modifies the data of the tileMaps
  141589. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  141590. * @param pos is the iVector2 Coordinates of the Tile
  141591. * @param tile The SpriteIndex of the new Tile
  141592. */
  141593. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  141594. /**
  141595. * Creates the animationMap texture Buffer
  141596. * @param buffer normally and array of numbers, or a false to generate from scratch
  141597. * @returns RawTexture of the animationMap
  141598. */
  141599. private _createTileAnimationBuffer;
  141600. /**
  141601. * Modifies the data of the animationMap
  141602. * @param cellID is the Index of the Sprite
  141603. * @param _frame is the target Animation frame
  141604. * @param toCell is the Target Index of the next frame of the animation
  141605. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  141606. * @param speed is a global scalar of the time variable on the map.
  141607. */
  141608. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  141609. /**
  141610. * Exports the .tilemaps file
  141611. */
  141612. saveTileMaps(): void;
  141613. /**
  141614. * Imports the .tilemaps file
  141615. * @param url of the .tilemaps file
  141616. */
  141617. loadTileMaps(url: string): void;
  141618. /**
  141619. * Release associated resources
  141620. */
  141621. dispose(): void;
  141622. }
  141623. }
  141624. declare module BABYLON {
  141625. /**
  141626. * Class used to manage multiple sprites of different sizes on the same spritesheet
  141627. * @see http://doc.babylonjs.com/babylon101/sprites
  141628. */
  141629. export class SpritePackedManager extends SpriteManager {
  141630. /** defines the packed manager's name */
  141631. name: string;
  141632. /**
  141633. * Creates a new sprite manager from a packed sprite sheet
  141634. * @param name defines the manager's name
  141635. * @param imgUrl defines the sprite sheet url
  141636. * @param capacity defines the maximum allowed number of sprites
  141637. * @param scene defines the hosting scene
  141638. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  141639. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  141640. * @param samplingMode defines the smapling mode to use with spritesheet
  141641. * @param fromPacked set to true; do not alter
  141642. */
  141643. constructor(
  141644. /** defines the packed manager's name */
  141645. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  141646. }
  141647. }
  141648. declare module BABYLON {
  141649. /**
  141650. * Defines the list of states available for a task inside a AssetsManager
  141651. */
  141652. export enum AssetTaskState {
  141653. /**
  141654. * Initialization
  141655. */
  141656. INIT = 0,
  141657. /**
  141658. * Running
  141659. */
  141660. RUNNING = 1,
  141661. /**
  141662. * Done
  141663. */
  141664. DONE = 2,
  141665. /**
  141666. * Error
  141667. */
  141668. ERROR = 3
  141669. }
  141670. /**
  141671. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  141672. */
  141673. export abstract class AbstractAssetTask {
  141674. /**
  141675. * Task name
  141676. */ name: string;
  141677. /**
  141678. * Callback called when the task is successful
  141679. */
  141680. onSuccess: (task: any) => void;
  141681. /**
  141682. * Callback called when the task is not successful
  141683. */
  141684. onError: (task: any, message?: string, exception?: any) => void;
  141685. /**
  141686. * Creates a new AssetsManager
  141687. * @param name defines the name of the task
  141688. */
  141689. constructor(
  141690. /**
  141691. * Task name
  141692. */ name: string);
  141693. private _isCompleted;
  141694. private _taskState;
  141695. private _errorObject;
  141696. /**
  141697. * Get if the task is completed
  141698. */
  141699. get isCompleted(): boolean;
  141700. /**
  141701. * Gets the current state of the task
  141702. */
  141703. get taskState(): AssetTaskState;
  141704. /**
  141705. * Gets the current error object (if task is in error)
  141706. */
  141707. get errorObject(): {
  141708. message?: string;
  141709. exception?: any;
  141710. };
  141711. /**
  141712. * Internal only
  141713. * @hidden
  141714. */
  141715. _setErrorObject(message?: string, exception?: any): void;
  141716. /**
  141717. * Execute the current task
  141718. * @param scene defines the scene where you want your assets to be loaded
  141719. * @param onSuccess is a callback called when the task is successfully executed
  141720. * @param onError is a callback called if an error occurs
  141721. */
  141722. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141723. /**
  141724. * Execute the current task
  141725. * @param scene defines the scene where you want your assets to be loaded
  141726. * @param onSuccess is a callback called when the task is successfully executed
  141727. * @param onError is a callback called if an error occurs
  141728. */
  141729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141730. /**
  141731. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  141732. * This can be used with failed tasks that have the reason for failure fixed.
  141733. */
  141734. reset(): void;
  141735. private onErrorCallback;
  141736. private onDoneCallback;
  141737. }
  141738. /**
  141739. * Define the interface used by progress events raised during assets loading
  141740. */
  141741. export interface IAssetsProgressEvent {
  141742. /**
  141743. * Defines the number of remaining tasks to process
  141744. */
  141745. remainingCount: number;
  141746. /**
  141747. * Defines the total number of tasks
  141748. */
  141749. totalCount: number;
  141750. /**
  141751. * Defines the task that was just processed
  141752. */
  141753. task: AbstractAssetTask;
  141754. }
  141755. /**
  141756. * Class used to share progress information about assets loading
  141757. */
  141758. export class AssetsProgressEvent implements IAssetsProgressEvent {
  141759. /**
  141760. * Defines the number of remaining tasks to process
  141761. */
  141762. remainingCount: number;
  141763. /**
  141764. * Defines the total number of tasks
  141765. */
  141766. totalCount: number;
  141767. /**
  141768. * Defines the task that was just processed
  141769. */
  141770. task: AbstractAssetTask;
  141771. /**
  141772. * Creates a AssetsProgressEvent
  141773. * @param remainingCount defines the number of remaining tasks to process
  141774. * @param totalCount defines the total number of tasks
  141775. * @param task defines the task that was just processed
  141776. */
  141777. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  141778. }
  141779. /**
  141780. * Define a task used by AssetsManager to load meshes
  141781. */
  141782. export class MeshAssetTask extends AbstractAssetTask {
  141783. /**
  141784. * Defines the name of the task
  141785. */
  141786. name: string;
  141787. /**
  141788. * Defines the list of mesh's names you want to load
  141789. */
  141790. meshesNames: any;
  141791. /**
  141792. * Defines the root url to use as a base to load your meshes and associated resources
  141793. */
  141794. rootUrl: string;
  141795. /**
  141796. * Defines the filename of the scene to load from
  141797. */
  141798. sceneFilename: string;
  141799. /**
  141800. * Gets the list of loaded meshes
  141801. */
  141802. loadedMeshes: Array<AbstractMesh>;
  141803. /**
  141804. * Gets the list of loaded particle systems
  141805. */
  141806. loadedParticleSystems: Array<IParticleSystem>;
  141807. /**
  141808. * Gets the list of loaded skeletons
  141809. */
  141810. loadedSkeletons: Array<Skeleton>;
  141811. /**
  141812. * Gets the list of loaded animation groups
  141813. */
  141814. loadedAnimationGroups: Array<AnimationGroup>;
  141815. /**
  141816. * Callback called when the task is successful
  141817. */
  141818. onSuccess: (task: MeshAssetTask) => void;
  141819. /**
  141820. * Callback called when the task is successful
  141821. */
  141822. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  141823. /**
  141824. * Creates a new MeshAssetTask
  141825. * @param name defines the name of the task
  141826. * @param meshesNames defines the list of mesh's names you want to load
  141827. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  141828. * @param sceneFilename defines the filename of the scene to load from
  141829. */
  141830. constructor(
  141831. /**
  141832. * Defines the name of the task
  141833. */
  141834. name: string,
  141835. /**
  141836. * Defines the list of mesh's names you want to load
  141837. */
  141838. meshesNames: any,
  141839. /**
  141840. * Defines the root url to use as a base to load your meshes and associated resources
  141841. */
  141842. rootUrl: string,
  141843. /**
  141844. * Defines the filename of the scene to load from
  141845. */
  141846. sceneFilename: string);
  141847. /**
  141848. * Execute the current task
  141849. * @param scene defines the scene where you want your assets to be loaded
  141850. * @param onSuccess is a callback called when the task is successfully executed
  141851. * @param onError is a callback called if an error occurs
  141852. */
  141853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141854. }
  141855. /**
  141856. * Define a task used by AssetsManager to load text content
  141857. */
  141858. export class TextFileAssetTask extends AbstractAssetTask {
  141859. /**
  141860. * Defines the name of the task
  141861. */
  141862. name: string;
  141863. /**
  141864. * Defines the location of the file to load
  141865. */
  141866. url: string;
  141867. /**
  141868. * Gets the loaded text string
  141869. */
  141870. text: string;
  141871. /**
  141872. * Callback called when the task is successful
  141873. */
  141874. onSuccess: (task: TextFileAssetTask) => void;
  141875. /**
  141876. * Callback called when the task is successful
  141877. */
  141878. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  141879. /**
  141880. * Creates a new TextFileAssetTask object
  141881. * @param name defines the name of the task
  141882. * @param url defines the location of the file to load
  141883. */
  141884. constructor(
  141885. /**
  141886. * Defines the name of the task
  141887. */
  141888. name: string,
  141889. /**
  141890. * Defines the location of the file to load
  141891. */
  141892. url: string);
  141893. /**
  141894. * Execute the current task
  141895. * @param scene defines the scene where you want your assets to be loaded
  141896. * @param onSuccess is a callback called when the task is successfully executed
  141897. * @param onError is a callback called if an error occurs
  141898. */
  141899. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141900. }
  141901. /**
  141902. * Define a task used by AssetsManager to load binary data
  141903. */
  141904. export class BinaryFileAssetTask extends AbstractAssetTask {
  141905. /**
  141906. * Defines the name of the task
  141907. */
  141908. name: string;
  141909. /**
  141910. * Defines the location of the file to load
  141911. */
  141912. url: string;
  141913. /**
  141914. * Gets the lodaded data (as an array buffer)
  141915. */
  141916. data: ArrayBuffer;
  141917. /**
  141918. * Callback called when the task is successful
  141919. */
  141920. onSuccess: (task: BinaryFileAssetTask) => void;
  141921. /**
  141922. * Callback called when the task is successful
  141923. */
  141924. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  141925. /**
  141926. * Creates a new BinaryFileAssetTask object
  141927. * @param name defines the name of the new task
  141928. * @param url defines the location of the file to load
  141929. */
  141930. constructor(
  141931. /**
  141932. * Defines the name of the task
  141933. */
  141934. name: string,
  141935. /**
  141936. * Defines the location of the file to load
  141937. */
  141938. url: string);
  141939. /**
  141940. * Execute the current task
  141941. * @param scene defines the scene where you want your assets to be loaded
  141942. * @param onSuccess is a callback called when the task is successfully executed
  141943. * @param onError is a callback called if an error occurs
  141944. */
  141945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141946. }
  141947. /**
  141948. * Define a task used by AssetsManager to load images
  141949. */
  141950. export class ImageAssetTask extends AbstractAssetTask {
  141951. /**
  141952. * Defines the name of the task
  141953. */
  141954. name: string;
  141955. /**
  141956. * Defines the location of the image to load
  141957. */
  141958. url: string;
  141959. /**
  141960. * Gets the loaded images
  141961. */
  141962. image: HTMLImageElement;
  141963. /**
  141964. * Callback called when the task is successful
  141965. */
  141966. onSuccess: (task: ImageAssetTask) => void;
  141967. /**
  141968. * Callback called when the task is successful
  141969. */
  141970. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  141971. /**
  141972. * Creates a new ImageAssetTask
  141973. * @param name defines the name of the task
  141974. * @param url defines the location of the image to load
  141975. */
  141976. constructor(
  141977. /**
  141978. * Defines the name of the task
  141979. */
  141980. name: string,
  141981. /**
  141982. * Defines the location of the image to load
  141983. */
  141984. url: string);
  141985. /**
  141986. * Execute the current task
  141987. * @param scene defines the scene where you want your assets to be loaded
  141988. * @param onSuccess is a callback called when the task is successfully executed
  141989. * @param onError is a callback called if an error occurs
  141990. */
  141991. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141992. }
  141993. /**
  141994. * Defines the interface used by texture loading tasks
  141995. */
  141996. export interface ITextureAssetTask<TEX extends BaseTexture> {
  141997. /**
  141998. * Gets the loaded texture
  141999. */
  142000. texture: TEX;
  142001. }
  142002. /**
  142003. * Define a task used by AssetsManager to load 2D textures
  142004. */
  142005. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  142006. /**
  142007. * Defines the name of the task
  142008. */
  142009. name: string;
  142010. /**
  142011. * Defines the location of the file to load
  142012. */
  142013. url: string;
  142014. /**
  142015. * Defines if mipmap should not be generated (default is false)
  142016. */
  142017. noMipmap?: boolean | undefined;
  142018. /**
  142019. * Defines if texture must be inverted on Y axis (default is false)
  142020. */
  142021. invertY?: boolean | undefined;
  142022. /**
  142023. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142024. */
  142025. samplingMode: number;
  142026. /**
  142027. * Gets the loaded texture
  142028. */
  142029. texture: Texture;
  142030. /**
  142031. * Callback called when the task is successful
  142032. */
  142033. onSuccess: (task: TextureAssetTask) => void;
  142034. /**
  142035. * Callback called when the task is successful
  142036. */
  142037. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  142038. /**
  142039. * Creates a new TextureAssetTask object
  142040. * @param name defines the name of the task
  142041. * @param url defines the location of the file to load
  142042. * @param noMipmap defines if mipmap should not be generated (default is false)
  142043. * @param invertY defines if texture must be inverted on Y axis (default is false)
  142044. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142045. */
  142046. constructor(
  142047. /**
  142048. * Defines the name of the task
  142049. */
  142050. name: string,
  142051. /**
  142052. * Defines the location of the file to load
  142053. */
  142054. url: string,
  142055. /**
  142056. * Defines if mipmap should not be generated (default is false)
  142057. */
  142058. noMipmap?: boolean | undefined,
  142059. /**
  142060. * Defines if texture must be inverted on Y axis (default is false)
  142061. */
  142062. invertY?: boolean | undefined,
  142063. /**
  142064. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142065. */
  142066. samplingMode?: number);
  142067. /**
  142068. * Execute the current task
  142069. * @param scene defines the scene where you want your assets to be loaded
  142070. * @param onSuccess is a callback called when the task is successfully executed
  142071. * @param onError is a callback called if an error occurs
  142072. */
  142073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142074. }
  142075. /**
  142076. * Define a task used by AssetsManager to load cube textures
  142077. */
  142078. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  142079. /**
  142080. * Defines the name of the task
  142081. */
  142082. name: string;
  142083. /**
  142084. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142085. */
  142086. url: string;
  142087. /**
  142088. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142089. */
  142090. extensions?: string[] | undefined;
  142091. /**
  142092. * Defines if mipmaps should not be generated (default is false)
  142093. */
  142094. noMipmap?: boolean | undefined;
  142095. /**
  142096. * Defines the explicit list of files (undefined by default)
  142097. */
  142098. files?: string[] | undefined;
  142099. /**
  142100. * Gets the loaded texture
  142101. */
  142102. texture: CubeTexture;
  142103. /**
  142104. * Callback called when the task is successful
  142105. */
  142106. onSuccess: (task: CubeTextureAssetTask) => void;
  142107. /**
  142108. * Callback called when the task is successful
  142109. */
  142110. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  142111. /**
  142112. * Creates a new CubeTextureAssetTask
  142113. * @param name defines the name of the task
  142114. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142115. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142116. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142117. * @param files defines the explicit list of files (undefined by default)
  142118. */
  142119. constructor(
  142120. /**
  142121. * Defines the name of the task
  142122. */
  142123. name: string,
  142124. /**
  142125. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142126. */
  142127. url: string,
  142128. /**
  142129. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142130. */
  142131. extensions?: string[] | undefined,
  142132. /**
  142133. * Defines if mipmaps should not be generated (default is false)
  142134. */
  142135. noMipmap?: boolean | undefined,
  142136. /**
  142137. * Defines the explicit list of files (undefined by default)
  142138. */
  142139. files?: string[] | undefined);
  142140. /**
  142141. * Execute the current task
  142142. * @param scene defines the scene where you want your assets to be loaded
  142143. * @param onSuccess is a callback called when the task is successfully executed
  142144. * @param onError is a callback called if an error occurs
  142145. */
  142146. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142147. }
  142148. /**
  142149. * Define a task used by AssetsManager to load HDR cube textures
  142150. */
  142151. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  142152. /**
  142153. * Defines the name of the task
  142154. */
  142155. name: string;
  142156. /**
  142157. * Defines the location of the file to load
  142158. */
  142159. url: string;
  142160. /**
  142161. * Defines the desired size (the more it increases the longer the generation will be)
  142162. */
  142163. size: number;
  142164. /**
  142165. * Defines if mipmaps should not be generated (default is false)
  142166. */
  142167. noMipmap: boolean;
  142168. /**
  142169. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142170. */
  142171. generateHarmonics: boolean;
  142172. /**
  142173. * 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)
  142174. */
  142175. gammaSpace: boolean;
  142176. /**
  142177. * Internal Use Only
  142178. */
  142179. reserved: boolean;
  142180. /**
  142181. * Gets the loaded texture
  142182. */
  142183. texture: HDRCubeTexture;
  142184. /**
  142185. * Callback called when the task is successful
  142186. */
  142187. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  142188. /**
  142189. * Callback called when the task is successful
  142190. */
  142191. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  142192. /**
  142193. * Creates a new HDRCubeTextureAssetTask object
  142194. * @param name defines the name of the task
  142195. * @param url defines the location of the file to load
  142196. * @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.
  142197. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142198. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142199. * @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)
  142200. * @param reserved Internal use only
  142201. */
  142202. constructor(
  142203. /**
  142204. * Defines the name of the task
  142205. */
  142206. name: string,
  142207. /**
  142208. * Defines the location of the file to load
  142209. */
  142210. url: string,
  142211. /**
  142212. * Defines the desired size (the more it increases the longer the generation will be)
  142213. */
  142214. size: number,
  142215. /**
  142216. * Defines if mipmaps should not be generated (default is false)
  142217. */
  142218. noMipmap?: boolean,
  142219. /**
  142220. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142221. */
  142222. generateHarmonics?: boolean,
  142223. /**
  142224. * 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)
  142225. */
  142226. gammaSpace?: boolean,
  142227. /**
  142228. * Internal Use Only
  142229. */
  142230. reserved?: boolean);
  142231. /**
  142232. * Execute the current task
  142233. * @param scene defines the scene where you want your assets to be loaded
  142234. * @param onSuccess is a callback called when the task is successfully executed
  142235. * @param onError is a callback called if an error occurs
  142236. */
  142237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142238. }
  142239. /**
  142240. * Define a task used by AssetsManager to load Equirectangular cube textures
  142241. */
  142242. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  142243. /**
  142244. * Defines the name of the task
  142245. */
  142246. name: string;
  142247. /**
  142248. * Defines the location of the file to load
  142249. */
  142250. url: string;
  142251. /**
  142252. * Defines the desired size (the more it increases the longer the generation will be)
  142253. */
  142254. size: number;
  142255. /**
  142256. * Defines if mipmaps should not be generated (default is false)
  142257. */
  142258. noMipmap: boolean;
  142259. /**
  142260. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142261. * but the standard material would require them in Gamma space) (default is true)
  142262. */
  142263. gammaSpace: boolean;
  142264. /**
  142265. * Gets the loaded texture
  142266. */
  142267. texture: EquiRectangularCubeTexture;
  142268. /**
  142269. * Callback called when the task is successful
  142270. */
  142271. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  142272. /**
  142273. * Callback called when the task is successful
  142274. */
  142275. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  142276. /**
  142277. * Creates a new EquiRectangularCubeTextureAssetTask object
  142278. * @param name defines the name of the task
  142279. * @param url defines the location of the file to load
  142280. * @param size defines the desired size (the more it increases the longer the generation will be)
  142281. * If the size is omitted this implies you are using a preprocessed cubemap.
  142282. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142283. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  142284. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  142285. * (default is true)
  142286. */
  142287. constructor(
  142288. /**
  142289. * Defines the name of the task
  142290. */
  142291. name: string,
  142292. /**
  142293. * Defines the location of the file to load
  142294. */
  142295. url: string,
  142296. /**
  142297. * Defines the desired size (the more it increases the longer the generation will be)
  142298. */
  142299. size: number,
  142300. /**
  142301. * Defines if mipmaps should not be generated (default is false)
  142302. */
  142303. noMipmap?: boolean,
  142304. /**
  142305. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142306. * but the standard material would require them in Gamma space) (default is true)
  142307. */
  142308. gammaSpace?: boolean);
  142309. /**
  142310. * Execute the current task
  142311. * @param scene defines the scene where you want your assets to be loaded
  142312. * @param onSuccess is a callback called when the task is successfully executed
  142313. * @param onError is a callback called if an error occurs
  142314. */
  142315. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142316. }
  142317. /**
  142318. * This class can be used to easily import assets into a scene
  142319. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  142320. */
  142321. export class AssetsManager {
  142322. private _scene;
  142323. private _isLoading;
  142324. protected _tasks: AbstractAssetTask[];
  142325. protected _waitingTasksCount: number;
  142326. protected _totalTasksCount: number;
  142327. /**
  142328. * Callback called when all tasks are processed
  142329. */
  142330. onFinish: (tasks: AbstractAssetTask[]) => void;
  142331. /**
  142332. * Callback called when a task is successful
  142333. */
  142334. onTaskSuccess: (task: AbstractAssetTask) => void;
  142335. /**
  142336. * Callback called when a task had an error
  142337. */
  142338. onTaskError: (task: AbstractAssetTask) => void;
  142339. /**
  142340. * Callback called when a task is done (whatever the result is)
  142341. */
  142342. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  142343. /**
  142344. * Observable called when all tasks are processed
  142345. */
  142346. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  142347. /**
  142348. * Observable called when a task had an error
  142349. */
  142350. onTaskErrorObservable: Observable<AbstractAssetTask>;
  142351. /**
  142352. * Observable called when all tasks were executed
  142353. */
  142354. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  142355. /**
  142356. * Observable called when a task is done (whatever the result is)
  142357. */
  142358. onProgressObservable: Observable<IAssetsProgressEvent>;
  142359. /**
  142360. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  142361. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  142362. */
  142363. useDefaultLoadingScreen: boolean;
  142364. /**
  142365. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  142366. * when all assets have been downloaded.
  142367. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  142368. */
  142369. autoHideLoadingUI: boolean;
  142370. /**
  142371. * Creates a new AssetsManager
  142372. * @param scene defines the scene to work on
  142373. */
  142374. constructor(scene: Scene);
  142375. /**
  142376. * Add a MeshAssetTask to the list of active tasks
  142377. * @param taskName defines the name of the new task
  142378. * @param meshesNames defines the name of meshes to load
  142379. * @param rootUrl defines the root url to use to locate files
  142380. * @param sceneFilename defines the filename of the scene file
  142381. * @returns a new MeshAssetTask object
  142382. */
  142383. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  142384. /**
  142385. * Add a TextFileAssetTask to the list of active tasks
  142386. * @param taskName defines the name of the new task
  142387. * @param url defines the url of the file to load
  142388. * @returns a new TextFileAssetTask object
  142389. */
  142390. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  142391. /**
  142392. * Add a BinaryFileAssetTask to the list of active tasks
  142393. * @param taskName defines the name of the new task
  142394. * @param url defines the url of the file to load
  142395. * @returns a new BinaryFileAssetTask object
  142396. */
  142397. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  142398. /**
  142399. * Add a ImageAssetTask to the list of active tasks
  142400. * @param taskName defines the name of the new task
  142401. * @param url defines the url of the file to load
  142402. * @returns a new ImageAssetTask object
  142403. */
  142404. addImageTask(taskName: string, url: string): ImageAssetTask;
  142405. /**
  142406. * Add a TextureAssetTask to the list of active tasks
  142407. * @param taskName defines the name of the new task
  142408. * @param url defines the url of the file to load
  142409. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142410. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  142411. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142412. * @returns a new TextureAssetTask object
  142413. */
  142414. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  142415. /**
  142416. * Add a CubeTextureAssetTask to the list of active tasks
  142417. * @param taskName defines the name of the new task
  142418. * @param url defines the url of the file to load
  142419. * @param extensions defines the extension to use to load the cube map (can be null)
  142420. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142421. * @param files defines the list of files to load (can be null)
  142422. * @returns a new CubeTextureAssetTask object
  142423. */
  142424. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  142425. /**
  142426. *
  142427. * Add a HDRCubeTextureAssetTask to the list of active tasks
  142428. * @param taskName defines the name of the new task
  142429. * @param url defines the url of the file to load
  142430. * @param size defines the size you want for the cubemap (can be null)
  142431. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142432. * @param generateHarmonics defines if you want to automatically generate (true by default)
  142433. * @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)
  142434. * @param reserved Internal use only
  142435. * @returns a new HDRCubeTextureAssetTask object
  142436. */
  142437. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  142438. /**
  142439. *
  142440. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  142441. * @param taskName defines the name of the new task
  142442. * @param url defines the url of the file to load
  142443. * @param size defines the size you want for the cubemap (can be null)
  142444. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142445. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142446. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142447. * @returns a new EquiRectangularCubeTextureAssetTask object
  142448. */
  142449. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  142450. /**
  142451. * Remove a task from the assets manager.
  142452. * @param task the task to remove
  142453. */
  142454. removeTask(task: AbstractAssetTask): void;
  142455. private _decreaseWaitingTasksCount;
  142456. private _runTask;
  142457. /**
  142458. * Reset the AssetsManager and remove all tasks
  142459. * @return the current instance of the AssetsManager
  142460. */
  142461. reset(): AssetsManager;
  142462. /**
  142463. * Start the loading process
  142464. * @return the current instance of the AssetsManager
  142465. */
  142466. load(): AssetsManager;
  142467. /**
  142468. * Start the loading process as an async operation
  142469. * @return a promise returning the list of failed tasks
  142470. */
  142471. loadAsync(): Promise<void>;
  142472. }
  142473. }
  142474. declare module BABYLON {
  142475. /**
  142476. * Wrapper class for promise with external resolve and reject.
  142477. */
  142478. export class Deferred<T> {
  142479. /**
  142480. * The promise associated with this deferred object.
  142481. */
  142482. readonly promise: Promise<T>;
  142483. private _resolve;
  142484. private _reject;
  142485. /**
  142486. * The resolve method of the promise associated with this deferred object.
  142487. */
  142488. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  142489. /**
  142490. * The reject method of the promise associated with this deferred object.
  142491. */
  142492. get reject(): (reason?: any) => void;
  142493. /**
  142494. * Constructor for this deferred object.
  142495. */
  142496. constructor();
  142497. }
  142498. }
  142499. declare module BABYLON {
  142500. /**
  142501. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  142502. */
  142503. export class MeshExploder {
  142504. private _centerMesh;
  142505. private _meshes;
  142506. private _meshesOrigins;
  142507. private _toCenterVectors;
  142508. private _scaledDirection;
  142509. private _newPosition;
  142510. private _centerPosition;
  142511. /**
  142512. * Explodes meshes from a center mesh.
  142513. * @param meshes The meshes to explode.
  142514. * @param centerMesh The mesh to be center of explosion.
  142515. */
  142516. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  142517. private _setCenterMesh;
  142518. /**
  142519. * Get class name
  142520. * @returns "MeshExploder"
  142521. */
  142522. getClassName(): string;
  142523. /**
  142524. * "Exploded meshes"
  142525. * @returns Array of meshes with the centerMesh at index 0.
  142526. */
  142527. getMeshes(): Array<Mesh>;
  142528. /**
  142529. * Explodes meshes giving a specific direction
  142530. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  142531. */
  142532. explode(direction?: number): void;
  142533. }
  142534. }
  142535. declare module BABYLON {
  142536. /**
  142537. * Class used to help managing file picking and drag'n'drop
  142538. */
  142539. export class FilesInput {
  142540. /**
  142541. * List of files ready to be loaded
  142542. */
  142543. static get FilesToLoad(): {
  142544. [key: string]: File;
  142545. };
  142546. /**
  142547. * Callback called when a file is processed
  142548. */
  142549. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  142550. private _engine;
  142551. private _currentScene;
  142552. private _sceneLoadedCallback;
  142553. private _progressCallback;
  142554. private _additionalRenderLoopLogicCallback;
  142555. private _textureLoadingCallback;
  142556. private _startingProcessingFilesCallback;
  142557. private _onReloadCallback;
  142558. private _errorCallback;
  142559. private _elementToMonitor;
  142560. private _sceneFileToLoad;
  142561. private _filesToLoad;
  142562. /**
  142563. * Creates a new FilesInput
  142564. * @param engine defines the rendering engine
  142565. * @param scene defines the hosting scene
  142566. * @param sceneLoadedCallback callback called when scene is loaded
  142567. * @param progressCallback callback called to track progress
  142568. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  142569. * @param textureLoadingCallback callback called when a texture is loading
  142570. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  142571. * @param onReloadCallback callback called when a reload is requested
  142572. * @param errorCallback callback call if an error occurs
  142573. */
  142574. 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);
  142575. private _dragEnterHandler;
  142576. private _dragOverHandler;
  142577. private _dropHandler;
  142578. /**
  142579. * Calls this function to listen to drag'n'drop events on a specific DOM element
  142580. * @param elementToMonitor defines the DOM element to track
  142581. */
  142582. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  142583. /**
  142584. * Release all associated resources
  142585. */
  142586. dispose(): void;
  142587. private renderFunction;
  142588. private drag;
  142589. private drop;
  142590. private _traverseFolder;
  142591. private _processFiles;
  142592. /**
  142593. * Load files from a drop event
  142594. * @param event defines the drop event to use as source
  142595. */
  142596. loadFiles(event: any): void;
  142597. private _processReload;
  142598. /**
  142599. * Reload the current scene from the loaded files
  142600. */
  142601. reload(): void;
  142602. }
  142603. }
  142604. declare module BABYLON {
  142605. /**
  142606. * Defines the root class used to create scene optimization to use with SceneOptimizer
  142607. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142608. */
  142609. export class SceneOptimization {
  142610. /**
  142611. * Defines the priority of this optimization (0 by default which means first in the list)
  142612. */
  142613. priority: number;
  142614. /**
  142615. * Gets a string describing the action executed by the current optimization
  142616. * @returns description string
  142617. */
  142618. getDescription(): string;
  142619. /**
  142620. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142621. * @param scene defines the current scene where to apply this optimization
  142622. * @param optimizer defines the current optimizer
  142623. * @returns true if everything that can be done was applied
  142624. */
  142625. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142626. /**
  142627. * Creates the SceneOptimization object
  142628. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  142629. * @param desc defines the description associated with the optimization
  142630. */
  142631. constructor(
  142632. /**
  142633. * Defines the priority of this optimization (0 by default which means first in the list)
  142634. */
  142635. priority?: number);
  142636. }
  142637. /**
  142638. * Defines an optimization used to reduce the size of render target textures
  142639. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142640. */
  142641. export class TextureOptimization extends SceneOptimization {
  142642. /**
  142643. * Defines the priority of this optimization (0 by default which means first in the list)
  142644. */
  142645. priority: number;
  142646. /**
  142647. * 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
  142648. */
  142649. maximumSize: number;
  142650. /**
  142651. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  142652. */
  142653. step: number;
  142654. /**
  142655. * Gets a string describing the action executed by the current optimization
  142656. * @returns description string
  142657. */
  142658. getDescription(): string;
  142659. /**
  142660. * Creates the TextureOptimization object
  142661. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  142662. * @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
  142663. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  142664. */
  142665. constructor(
  142666. /**
  142667. * Defines the priority of this optimization (0 by default which means first in the list)
  142668. */
  142669. priority?: number,
  142670. /**
  142671. * 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
  142672. */
  142673. maximumSize?: number,
  142674. /**
  142675. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  142676. */
  142677. step?: number);
  142678. /**
  142679. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142680. * @param scene defines the current scene where to apply this optimization
  142681. * @param optimizer defines the current optimizer
  142682. * @returns true if everything that can be done was applied
  142683. */
  142684. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142685. }
  142686. /**
  142687. * Defines an optimization used to increase or decrease the rendering resolution
  142688. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142689. */
  142690. export class HardwareScalingOptimization extends SceneOptimization {
  142691. /**
  142692. * Defines the priority of this optimization (0 by default which means first in the list)
  142693. */
  142694. priority: number;
  142695. /**
  142696. * Defines the maximum scale to use (2 by default)
  142697. */
  142698. maximumScale: number;
  142699. /**
  142700. * Defines the step to use between two passes (0.5 by default)
  142701. */
  142702. step: number;
  142703. private _currentScale;
  142704. private _directionOffset;
  142705. /**
  142706. * Gets a string describing the action executed by the current optimization
  142707. * @return description string
  142708. */
  142709. getDescription(): string;
  142710. /**
  142711. * Creates the HardwareScalingOptimization object
  142712. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  142713. * @param maximumScale defines the maximum scale to use (2 by default)
  142714. * @param step defines the step to use between two passes (0.5 by default)
  142715. */
  142716. constructor(
  142717. /**
  142718. * Defines the priority of this optimization (0 by default which means first in the list)
  142719. */
  142720. priority?: number,
  142721. /**
  142722. * Defines the maximum scale to use (2 by default)
  142723. */
  142724. maximumScale?: number,
  142725. /**
  142726. * Defines the step to use between two passes (0.5 by default)
  142727. */
  142728. step?: number);
  142729. /**
  142730. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142731. * @param scene defines the current scene where to apply this optimization
  142732. * @param optimizer defines the current optimizer
  142733. * @returns true if everything that can be done was applied
  142734. */
  142735. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142736. }
  142737. /**
  142738. * Defines an optimization used to remove shadows
  142739. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142740. */
  142741. export class ShadowsOptimization extends SceneOptimization {
  142742. /**
  142743. * Gets a string describing the action executed by the current optimization
  142744. * @return description string
  142745. */
  142746. getDescription(): string;
  142747. /**
  142748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142749. * @param scene defines the current scene where to apply this optimization
  142750. * @param optimizer defines the current optimizer
  142751. * @returns true if everything that can be done was applied
  142752. */
  142753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142754. }
  142755. /**
  142756. * Defines an optimization used to turn post-processes off
  142757. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142758. */
  142759. export class PostProcessesOptimization extends SceneOptimization {
  142760. /**
  142761. * Gets a string describing the action executed by the current optimization
  142762. * @return description string
  142763. */
  142764. getDescription(): string;
  142765. /**
  142766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142767. * @param scene defines the current scene where to apply this optimization
  142768. * @param optimizer defines the current optimizer
  142769. * @returns true if everything that can be done was applied
  142770. */
  142771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142772. }
  142773. /**
  142774. * Defines an optimization used to turn lens flares off
  142775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142776. */
  142777. export class LensFlaresOptimization extends SceneOptimization {
  142778. /**
  142779. * Gets a string describing the action executed by the current optimization
  142780. * @return description string
  142781. */
  142782. getDescription(): string;
  142783. /**
  142784. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142785. * @param scene defines the current scene where to apply this optimization
  142786. * @param optimizer defines the current optimizer
  142787. * @returns true if everything that can be done was applied
  142788. */
  142789. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142790. }
  142791. /**
  142792. * Defines an optimization based on user defined callback.
  142793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142794. */
  142795. export class CustomOptimization extends SceneOptimization {
  142796. /**
  142797. * Callback called to apply the custom optimization.
  142798. */
  142799. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  142800. /**
  142801. * Callback called to get custom description
  142802. */
  142803. onGetDescription: () => string;
  142804. /**
  142805. * Gets a string describing the action executed by the current optimization
  142806. * @returns description string
  142807. */
  142808. getDescription(): string;
  142809. /**
  142810. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142811. * @param scene defines the current scene where to apply this optimization
  142812. * @param optimizer defines the current optimizer
  142813. * @returns true if everything that can be done was applied
  142814. */
  142815. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142816. }
  142817. /**
  142818. * Defines an optimization used to turn particles off
  142819. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142820. */
  142821. export class ParticlesOptimization extends SceneOptimization {
  142822. /**
  142823. * Gets a string describing the action executed by the current optimization
  142824. * @return description string
  142825. */
  142826. getDescription(): string;
  142827. /**
  142828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142829. * @param scene defines the current scene where to apply this optimization
  142830. * @param optimizer defines the current optimizer
  142831. * @returns true if everything that can be done was applied
  142832. */
  142833. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142834. }
  142835. /**
  142836. * Defines an optimization used to turn render targets off
  142837. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142838. */
  142839. export class RenderTargetsOptimization extends SceneOptimization {
  142840. /**
  142841. * Gets a string describing the action executed by the current optimization
  142842. * @return description string
  142843. */
  142844. getDescription(): string;
  142845. /**
  142846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142847. * @param scene defines the current scene where to apply this optimization
  142848. * @param optimizer defines the current optimizer
  142849. * @returns true if everything that can be done was applied
  142850. */
  142851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  142852. }
  142853. /**
  142854. * Defines an optimization used to merge meshes with compatible materials
  142855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142856. */
  142857. export class MergeMeshesOptimization extends SceneOptimization {
  142858. private static _UpdateSelectionTree;
  142859. /**
  142860. * Gets or sets a boolean which defines if optimization octree has to be updated
  142861. */
  142862. static get UpdateSelectionTree(): boolean;
  142863. /**
  142864. * Gets or sets a boolean which defines if optimization octree has to be updated
  142865. */
  142866. static set UpdateSelectionTree(value: boolean);
  142867. /**
  142868. * Gets a string describing the action executed by the current optimization
  142869. * @return description string
  142870. */
  142871. getDescription(): string;
  142872. private _canBeMerged;
  142873. /**
  142874. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  142875. * @param scene defines the current scene where to apply this optimization
  142876. * @param optimizer defines the current optimizer
  142877. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  142878. * @returns true if everything that can be done was applied
  142879. */
  142880. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  142881. }
  142882. /**
  142883. * Defines a list of options used by SceneOptimizer
  142884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142885. */
  142886. export class SceneOptimizerOptions {
  142887. /**
  142888. * Defines the target frame rate to reach (60 by default)
  142889. */
  142890. targetFrameRate: number;
  142891. /**
  142892. * Defines the interval between two checkes (2000ms by default)
  142893. */
  142894. trackerDuration: number;
  142895. /**
  142896. * Gets the list of optimizations to apply
  142897. */
  142898. optimizations: SceneOptimization[];
  142899. /**
  142900. * Creates a new list of options used by SceneOptimizer
  142901. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  142902. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  142903. */
  142904. constructor(
  142905. /**
  142906. * Defines the target frame rate to reach (60 by default)
  142907. */
  142908. targetFrameRate?: number,
  142909. /**
  142910. * Defines the interval between two checkes (2000ms by default)
  142911. */
  142912. trackerDuration?: number);
  142913. /**
  142914. * Add a new optimization
  142915. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  142916. * @returns the current SceneOptimizerOptions
  142917. */
  142918. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  142919. /**
  142920. * Add a new custom optimization
  142921. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  142922. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  142923. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  142924. * @returns the current SceneOptimizerOptions
  142925. */
  142926. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  142927. /**
  142928. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  142929. * @param targetFrameRate defines the target frame rate (60 by default)
  142930. * @returns a SceneOptimizerOptions object
  142931. */
  142932. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142933. /**
  142934. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  142935. * @param targetFrameRate defines the target frame rate (60 by default)
  142936. * @returns a SceneOptimizerOptions object
  142937. */
  142938. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142939. /**
  142940. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  142941. * @param targetFrameRate defines the target frame rate (60 by default)
  142942. * @returns a SceneOptimizerOptions object
  142943. */
  142944. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  142945. }
  142946. /**
  142947. * Class used to run optimizations in order to reach a target frame rate
  142948. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142949. */
  142950. export class SceneOptimizer implements IDisposable {
  142951. private _isRunning;
  142952. private _options;
  142953. private _scene;
  142954. private _currentPriorityLevel;
  142955. private _targetFrameRate;
  142956. private _trackerDuration;
  142957. private _currentFrameRate;
  142958. private _sceneDisposeObserver;
  142959. private _improvementMode;
  142960. /**
  142961. * Defines an observable called when the optimizer reaches the target frame rate
  142962. */
  142963. onSuccessObservable: Observable<SceneOptimizer>;
  142964. /**
  142965. * Defines an observable called when the optimizer enables an optimization
  142966. */
  142967. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  142968. /**
  142969. * Defines an observable called when the optimizer is not able to reach the target frame rate
  142970. */
  142971. onFailureObservable: Observable<SceneOptimizer>;
  142972. /**
  142973. * Gets a boolean indicating if the optimizer is in improvement mode
  142974. */
  142975. get isInImprovementMode(): boolean;
  142976. /**
  142977. * Gets the current priority level (0 at start)
  142978. */
  142979. get currentPriorityLevel(): number;
  142980. /**
  142981. * Gets the current frame rate checked by the SceneOptimizer
  142982. */
  142983. get currentFrameRate(): number;
  142984. /**
  142985. * Gets or sets the current target frame rate (60 by default)
  142986. */
  142987. get targetFrameRate(): number;
  142988. /**
  142989. * Gets or sets the current target frame rate (60 by default)
  142990. */
  142991. set targetFrameRate(value: number);
  142992. /**
  142993. * Gets or sets the current interval between two checks (every 2000ms by default)
  142994. */
  142995. get trackerDuration(): number;
  142996. /**
  142997. * Gets or sets the current interval between two checks (every 2000ms by default)
  142998. */
  142999. set trackerDuration(value: number);
  143000. /**
  143001. * Gets the list of active optimizations
  143002. */
  143003. get optimizations(): SceneOptimization[];
  143004. /**
  143005. * Creates a new SceneOptimizer
  143006. * @param scene defines the scene to work on
  143007. * @param options defines the options to use with the SceneOptimizer
  143008. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  143009. * @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)
  143010. */
  143011. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  143012. /**
  143013. * Stops the current optimizer
  143014. */
  143015. stop(): void;
  143016. /**
  143017. * Reset the optimizer to initial step (current priority level = 0)
  143018. */
  143019. reset(): void;
  143020. /**
  143021. * Start the optimizer. By default it will try to reach a specific framerate
  143022. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  143023. */
  143024. start(): void;
  143025. private _checkCurrentState;
  143026. /**
  143027. * Release all resources
  143028. */
  143029. dispose(): void;
  143030. /**
  143031. * Helper function to create a SceneOptimizer with one single line of code
  143032. * @param scene defines the scene to work on
  143033. * @param options defines the options to use with the SceneOptimizer
  143034. * @param onSuccess defines a callback to call on success
  143035. * @param onFailure defines a callback to call on failure
  143036. * @returns the new SceneOptimizer object
  143037. */
  143038. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  143039. }
  143040. }
  143041. declare module BABYLON {
  143042. /**
  143043. * Class used to serialize a scene into a string
  143044. */
  143045. export class SceneSerializer {
  143046. /**
  143047. * Clear cache used by a previous serialization
  143048. */
  143049. static ClearCache(): void;
  143050. /**
  143051. * Serialize a scene into a JSON compatible object
  143052. * @param scene defines the scene to serialize
  143053. * @returns a JSON compatible object
  143054. */
  143055. static Serialize(scene: Scene): any;
  143056. /**
  143057. * Serialize a mesh into a JSON compatible object
  143058. * @param toSerialize defines the mesh to serialize
  143059. * @param withParents defines if parents must be serialized as well
  143060. * @param withChildren defines if children must be serialized as well
  143061. * @returns a JSON compatible object
  143062. */
  143063. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  143064. }
  143065. }
  143066. declare module BABYLON {
  143067. /**
  143068. * Class used to host texture specific utilities
  143069. */
  143070. export class TextureTools {
  143071. /**
  143072. * Uses the GPU to create a copy texture rescaled at a given size
  143073. * @param texture Texture to copy from
  143074. * @param width defines the desired width
  143075. * @param height defines the desired height
  143076. * @param useBilinearMode defines if bilinear mode has to be used
  143077. * @return the generated texture
  143078. */
  143079. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  143080. }
  143081. }
  143082. declare module BABYLON {
  143083. /**
  143084. * This represents the different options available for the video capture.
  143085. */
  143086. export interface VideoRecorderOptions {
  143087. /** Defines the mime type of the video. */
  143088. mimeType: string;
  143089. /** Defines the FPS the video should be recorded at. */
  143090. fps: number;
  143091. /** Defines the chunk size for the recording data. */
  143092. recordChunckSize: number;
  143093. /** The audio tracks to attach to the recording. */
  143094. audioTracks?: MediaStreamTrack[];
  143095. }
  143096. /**
  143097. * This can help with recording videos from BabylonJS.
  143098. * This is based on the available WebRTC functionalities of the browser.
  143099. *
  143100. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  143101. */
  143102. export class VideoRecorder {
  143103. private static readonly _defaultOptions;
  143104. /**
  143105. * Returns whether or not the VideoRecorder is available in your browser.
  143106. * @param engine Defines the Babylon Engine.
  143107. * @returns true if supported otherwise false.
  143108. */
  143109. static IsSupported(engine: Engine): boolean;
  143110. private readonly _options;
  143111. private _canvas;
  143112. private _mediaRecorder;
  143113. private _recordedChunks;
  143114. private _fileName;
  143115. private _resolve;
  143116. private _reject;
  143117. /**
  143118. * True when a recording is already in progress.
  143119. */
  143120. get isRecording(): boolean;
  143121. /**
  143122. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  143123. * @param engine Defines the BabylonJS Engine you wish to record.
  143124. * @param options Defines options that can be used to customize the capture.
  143125. */
  143126. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  143127. /**
  143128. * Stops the current recording before the default capture timeout passed in the startRecording function.
  143129. */
  143130. stopRecording(): void;
  143131. /**
  143132. * Starts recording the canvas for a max duration specified in parameters.
  143133. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  143134. * If null no automatic download will start and you can rely on the promise to get the data back.
  143135. * @param maxDuration Defines the maximum recording time in seconds.
  143136. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  143137. * @return A promise callback at the end of the recording with the video data in Blob.
  143138. */
  143139. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  143140. /**
  143141. * Releases internal resources used during the recording.
  143142. */
  143143. dispose(): void;
  143144. private _handleDataAvailable;
  143145. private _handleError;
  143146. private _handleStop;
  143147. }
  143148. }
  143149. declare module BABYLON {
  143150. /**
  143151. * Class containing a set of static utilities functions for screenshots
  143152. */
  143153. export class ScreenshotTools {
  143154. /**
  143155. * Captures a screenshot of the current rendering
  143156. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143157. * @param engine defines the rendering engine
  143158. * @param camera defines the source camera
  143159. * @param size This parameter can be set to a single number or to an object with the
  143160. * following (optional) properties: precision, width, height. If a single number is passed,
  143161. * it will be used for both width and height. If an object is passed, the screenshot size
  143162. * will be derived from the parameters. The precision property is a multiplier allowing
  143163. * rendering at a higher or lower resolution
  143164. * @param successCallback defines the callback receives a single parameter which contains the
  143165. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143166. * src parameter of an <img> to display it
  143167. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143168. * Check your browser for supported MIME types
  143169. */
  143170. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  143171. /**
  143172. * Captures a screenshot of the current rendering
  143173. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143174. * @param engine defines the rendering engine
  143175. * @param camera defines the source camera
  143176. * @param size This parameter can be set to a single number or to an object with the
  143177. * following (optional) properties: precision, width, height. If a single number is passed,
  143178. * it will be used for both width and height. If an object is passed, the screenshot size
  143179. * will be derived from the parameters. The precision property is a multiplier allowing
  143180. * rendering at a higher or lower resolution
  143181. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143182. * Check your browser for supported MIME types
  143183. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143184. * to the src parameter of an <img> to display it
  143185. */
  143186. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  143187. /**
  143188. * Generates an image screenshot from the specified camera.
  143189. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143190. * @param engine The engine to use for rendering
  143191. * @param camera The camera to use for rendering
  143192. * @param size This parameter can be set to a single number or to an object with the
  143193. * following (optional) properties: precision, width, height. If a single number is passed,
  143194. * it will be used for both width and height. If an object is passed, the screenshot size
  143195. * will be derived from the parameters. The precision property is a multiplier allowing
  143196. * rendering at a higher or lower resolution
  143197. * @param successCallback The callback receives a single parameter which contains the
  143198. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143199. * src parameter of an <img> to display it
  143200. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143201. * Check your browser for supported MIME types
  143202. * @param samples Texture samples (default: 1)
  143203. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143204. * @param fileName A name for for the downloaded file.
  143205. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143206. */
  143207. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  143208. /**
  143209. * Generates an image screenshot from the specified camera.
  143210. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143211. * @param engine The engine to use for rendering
  143212. * @param camera The camera to use for rendering
  143213. * @param size This parameter can be set to a single number or to an object with the
  143214. * following (optional) properties: precision, width, height. If a single number is passed,
  143215. * it will be used for both width and height. If an object is passed, the screenshot size
  143216. * will be derived from the parameters. The precision property is a multiplier allowing
  143217. * rendering at a higher or lower resolution
  143218. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143219. * Check your browser for supported MIME types
  143220. * @param samples Texture samples (default: 1)
  143221. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143222. * @param fileName A name for for the downloaded file.
  143223. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143224. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143225. * to the src parameter of an <img> to display it
  143226. */
  143227. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  143228. /**
  143229. * Gets height and width for screenshot size
  143230. * @private
  143231. */
  143232. private static _getScreenshotSize;
  143233. }
  143234. }
  143235. declare module BABYLON {
  143236. /**
  143237. * Interface for a data buffer
  143238. */
  143239. export interface IDataBuffer {
  143240. /**
  143241. * Reads bytes from the data buffer.
  143242. * @param byteOffset The byte offset to read
  143243. * @param byteLength The byte length to read
  143244. * @returns A promise that resolves when the bytes are read
  143245. */
  143246. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  143247. /**
  143248. * The byte length of the buffer.
  143249. */
  143250. readonly byteLength: number;
  143251. }
  143252. /**
  143253. * Utility class for reading from a data buffer
  143254. */
  143255. export class DataReader {
  143256. /**
  143257. * The data buffer associated with this data reader.
  143258. */
  143259. readonly buffer: IDataBuffer;
  143260. /**
  143261. * The current byte offset from the beginning of the data buffer.
  143262. */
  143263. byteOffset: number;
  143264. private _dataView;
  143265. private _dataByteOffset;
  143266. /**
  143267. * Constructor
  143268. * @param buffer The buffer to read
  143269. */
  143270. constructor(buffer: IDataBuffer);
  143271. /**
  143272. * Loads the given byte length.
  143273. * @param byteLength The byte length to load
  143274. * @returns A promise that resolves when the load is complete
  143275. */
  143276. loadAsync(byteLength: number): Promise<void>;
  143277. /**
  143278. * Read a unsigned 32-bit integer from the currently loaded data range.
  143279. * @returns The 32-bit integer read
  143280. */
  143281. readUint32(): number;
  143282. /**
  143283. * Read a byte array from the currently loaded data range.
  143284. * @param byteLength The byte length to read
  143285. * @returns The byte array read
  143286. */
  143287. readUint8Array(byteLength: number): Uint8Array;
  143288. /**
  143289. * Read a string from the currently loaded data range.
  143290. * @param byteLength The byte length to read
  143291. * @returns The string read
  143292. */
  143293. readString(byteLength: number): string;
  143294. /**
  143295. * Skips the given byte length the currently loaded data range.
  143296. * @param byteLength The byte length to skip
  143297. */
  143298. skipBytes(byteLength: number): void;
  143299. }
  143300. }
  143301. declare module BABYLON {
  143302. /**
  143303. * Class for storing data to local storage if available or in-memory storage otherwise
  143304. */
  143305. export class DataStorage {
  143306. private static _Storage;
  143307. private static _GetStorage;
  143308. /**
  143309. * Reads a string from the data storage
  143310. * @param key The key to read
  143311. * @param defaultValue The value if the key doesn't exist
  143312. * @returns The string value
  143313. */
  143314. static ReadString(key: string, defaultValue: string): string;
  143315. /**
  143316. * Writes a string to the data storage
  143317. * @param key The key to write
  143318. * @param value The value to write
  143319. */
  143320. static WriteString(key: string, value: string): void;
  143321. /**
  143322. * Reads a boolean from the data storage
  143323. * @param key The key to read
  143324. * @param defaultValue The value if the key doesn't exist
  143325. * @returns The boolean value
  143326. */
  143327. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  143328. /**
  143329. * Writes a boolean to the data storage
  143330. * @param key The key to write
  143331. * @param value The value to write
  143332. */
  143333. static WriteBoolean(key: string, value: boolean): void;
  143334. /**
  143335. * Reads a number from the data storage
  143336. * @param key The key to read
  143337. * @param defaultValue The value if the key doesn't exist
  143338. * @returns The number value
  143339. */
  143340. static ReadNumber(key: string, defaultValue: number): number;
  143341. /**
  143342. * Writes a number to the data storage
  143343. * @param key The key to write
  143344. * @param value The value to write
  143345. */
  143346. static WriteNumber(key: string, value: number): void;
  143347. }
  143348. }
  143349. declare module BABYLON {
  143350. /**
  143351. * Options used for hit testing
  143352. */
  143353. export interface IWebXRLegacyHitTestOptions {
  143354. /**
  143355. * Only test when user interacted with the scene. Default - hit test every frame
  143356. */
  143357. testOnPointerDownOnly?: boolean;
  143358. /**
  143359. * The node to use to transform the local results to world coordinates
  143360. */
  143361. worldParentNode?: TransformNode;
  143362. }
  143363. /**
  143364. * Interface defining the babylon result of raycasting/hit-test
  143365. */
  143366. export interface IWebXRLegacyHitResult {
  143367. /**
  143368. * Transformation matrix that can be applied to a node that will put it in the hit point location
  143369. */
  143370. transformationMatrix: Matrix;
  143371. /**
  143372. * The native hit test result
  143373. */
  143374. xrHitResult: XRHitResult | XRHitTestResult;
  143375. }
  143376. /**
  143377. * The currently-working hit-test module.
  143378. * Hit test (or Ray-casting) is used to interact with the real world.
  143379. * For further information read here - https://github.com/immersive-web/hit-test
  143380. */
  143381. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  143382. /**
  143383. * options to use when constructing this feature
  143384. */
  143385. readonly options: IWebXRLegacyHitTestOptions;
  143386. private _direction;
  143387. private _mat;
  143388. private _onSelectEnabled;
  143389. private _origin;
  143390. /**
  143391. * The module's name
  143392. */
  143393. static readonly Name: string;
  143394. /**
  143395. * The (Babylon) version of this module.
  143396. * This is an integer representing the implementation version.
  143397. * This number does not correspond to the WebXR specs version
  143398. */
  143399. static readonly Version: number;
  143400. /**
  143401. * Populated with the last native XR Hit Results
  143402. */
  143403. lastNativeXRHitResults: XRHitResult[];
  143404. /**
  143405. * Triggered when new babylon (transformed) hit test results are available
  143406. */
  143407. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  143408. /**
  143409. * Creates a new instance of the (legacy version) hit test feature
  143410. * @param _xrSessionManager an instance of WebXRSessionManager
  143411. * @param options options to use when constructing this feature
  143412. */
  143413. constructor(_xrSessionManager: WebXRSessionManager,
  143414. /**
  143415. * options to use when constructing this feature
  143416. */
  143417. options?: IWebXRLegacyHitTestOptions);
  143418. /**
  143419. * execute a hit test with an XR Ray
  143420. *
  143421. * @param xrSession a native xrSession that will execute this hit test
  143422. * @param xrRay the ray (position and direction) to use for ray-casting
  143423. * @param referenceSpace native XR reference space to use for the hit-test
  143424. * @param filter filter function that will filter the results
  143425. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143426. */
  143427. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  143428. /**
  143429. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  143430. * @param event the (select) event to use to select with
  143431. * @param referenceSpace the reference space to use for this hit test
  143432. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143433. */
  143434. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143435. /**
  143436. * attach this feature
  143437. * Will usually be called by the features manager
  143438. *
  143439. * @returns true if successful.
  143440. */
  143441. attach(): boolean;
  143442. /**
  143443. * detach this feature.
  143444. * Will usually be called by the features manager
  143445. *
  143446. * @returns true if successful.
  143447. */
  143448. detach(): boolean;
  143449. /**
  143450. * Dispose this feature and all of the resources attached
  143451. */
  143452. dispose(): void;
  143453. protected _onXRFrame(frame: XRFrame): void;
  143454. private _onHitTestResults;
  143455. private _onSelect;
  143456. }
  143457. }
  143458. declare module BABYLON {
  143459. /**
  143460. * Options used in the plane detector module
  143461. */
  143462. export interface IWebXRPlaneDetectorOptions {
  143463. /**
  143464. * The node to use to transform the local results to world coordinates
  143465. */
  143466. worldParentNode?: TransformNode;
  143467. }
  143468. /**
  143469. * A babylon interface for a WebXR plane.
  143470. * A Plane is actually a polygon, built from N points in space
  143471. *
  143472. * Supported in chrome 79, not supported in canary 81 ATM
  143473. */
  143474. export interface IWebXRPlane {
  143475. /**
  143476. * a babylon-assigned ID for this polygon
  143477. */
  143478. id: number;
  143479. /**
  143480. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  143481. */
  143482. polygonDefinition: Array<Vector3>;
  143483. /**
  143484. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  143485. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  143486. */
  143487. transformationMatrix: Matrix;
  143488. /**
  143489. * the native xr-plane object
  143490. */
  143491. xrPlane: XRPlane;
  143492. }
  143493. /**
  143494. * The plane detector is used to detect planes in the real world when in AR
  143495. * For more information see https://github.com/immersive-web/real-world-geometry/
  143496. */
  143497. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  143498. private _options;
  143499. private _detectedPlanes;
  143500. private _enabled;
  143501. private _lastFrameDetected;
  143502. /**
  143503. * The module's name
  143504. */
  143505. static readonly Name: string;
  143506. /**
  143507. * The (Babylon) version of this module.
  143508. * This is an integer representing the implementation version.
  143509. * This number does not correspond to the WebXR specs version
  143510. */
  143511. static readonly Version: number;
  143512. /**
  143513. * Observers registered here will be executed when a new plane was added to the session
  143514. */
  143515. onPlaneAddedObservable: Observable<IWebXRPlane>;
  143516. /**
  143517. * Observers registered here will be executed when a plane is no longer detected in the session
  143518. */
  143519. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  143520. /**
  143521. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  143522. * This can execute N times every frame
  143523. */
  143524. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  143525. /**
  143526. * construct a new Plane Detector
  143527. * @param _xrSessionManager an instance of xr Session manager
  143528. * @param _options configuration to use when constructing this feature
  143529. */
  143530. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  143531. /**
  143532. * Dispose this feature and all of the resources attached
  143533. */
  143534. dispose(): void;
  143535. protected _onXRFrame(frame: XRFrame): void;
  143536. private _init;
  143537. private _updatePlaneWithXRPlane;
  143538. /**
  143539. * avoiding using Array.find for global support.
  143540. * @param xrPlane the plane to find in the array
  143541. */
  143542. private findIndexInPlaneArray;
  143543. }
  143544. }
  143545. declare module BABYLON {
  143546. /**
  143547. * Configuration options of the anchor system
  143548. */
  143549. export interface IWebXRAnchorSystemOptions {
  143550. /**
  143551. * Should a new anchor be added every time a select event is triggered
  143552. */
  143553. addAnchorOnSelect?: boolean;
  143554. /**
  143555. * should the anchor system use plane detection.
  143556. * If set to true, the plane-detection feature should be set using setPlaneDetector
  143557. */
  143558. usePlaneDetection?: boolean;
  143559. /**
  143560. * a node that will be used to convert local to world coordinates
  143561. */
  143562. worldParentNode?: TransformNode;
  143563. }
  143564. /**
  143565. * A babylon container for an XR Anchor
  143566. */
  143567. export interface IWebXRAnchor {
  143568. /**
  143569. * A babylon-assigned ID for this anchor
  143570. */
  143571. id: number;
  143572. /**
  143573. * Transformation matrix to apply to an object attached to this anchor
  143574. */
  143575. transformationMatrix: Matrix;
  143576. /**
  143577. * The native anchor object
  143578. */
  143579. xrAnchor: XRAnchor;
  143580. }
  143581. /**
  143582. * An implementation of the anchor system of WebXR.
  143583. * Note that the current documented implementation is not available in any browser. Future implementations
  143584. * will use the frame to create an anchor and not the session or a detected plane
  143585. * For further information see https://github.com/immersive-web/anchors/
  143586. */
  143587. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  143588. private _options;
  143589. private _enabled;
  143590. private _hitTestModule;
  143591. private _lastFrameDetected;
  143592. private _onSelect;
  143593. private _planeDetector;
  143594. private _trackedAnchors;
  143595. /**
  143596. * The module's name
  143597. */
  143598. static readonly Name: string;
  143599. /**
  143600. * The (Babylon) version of this module.
  143601. * This is an integer representing the implementation version.
  143602. * This number does not correspond to the WebXR specs version
  143603. */
  143604. static readonly Version: number;
  143605. /**
  143606. * Observers registered here will be executed when a new anchor was added to the session
  143607. */
  143608. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  143609. /**
  143610. * Observers registered here will be executed when an anchor was removed from the session
  143611. */
  143612. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  143613. /**
  143614. * Observers registered here will be executed when an existing anchor updates
  143615. * This can execute N times every frame
  143616. */
  143617. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  143618. /**
  143619. * constructs a new anchor system
  143620. * @param _xrSessionManager an instance of WebXRSessionManager
  143621. * @param _options configuration object for this feature
  143622. */
  143623. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  143624. /**
  143625. * Add anchor at a specific XR point.
  143626. *
  143627. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  143628. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  143629. * @returns a promise the fulfills when the anchor was created
  143630. */
  143631. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  143632. /**
  143633. * attach this feature
  143634. * Will usually be called by the features manager
  143635. *
  143636. * @returns true if successful.
  143637. */
  143638. attach(): boolean;
  143639. /**
  143640. * detach this feature.
  143641. * Will usually be called by the features manager
  143642. *
  143643. * @returns true if successful.
  143644. */
  143645. detach(): boolean;
  143646. /**
  143647. * Dispose this feature and all of the resources attached
  143648. */
  143649. dispose(): void;
  143650. /**
  143651. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  143652. * @param hitTestModule the hit-test module to use.
  143653. */
  143654. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  143655. /**
  143656. * set the plane detector to use in order to create anchors from frames
  143657. * @param planeDetector the plane-detector module to use
  143658. * @param enable enable plane-anchors. default is true
  143659. */
  143660. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  143661. protected _onXRFrame(frame: XRFrame): void;
  143662. /**
  143663. * avoiding using Array.find for global support.
  143664. * @param xrAnchor the plane to find in the array
  143665. */
  143666. private _findIndexInAnchorArray;
  143667. private _updateAnchorWithXRFrame;
  143668. }
  143669. }
  143670. declare module BABYLON {
  143671. /**
  143672. * Options interface for the background remover plugin
  143673. */
  143674. export interface IWebXRBackgroundRemoverOptions {
  143675. /**
  143676. * Further background meshes to disable when entering AR
  143677. */
  143678. backgroundMeshes?: AbstractMesh[];
  143679. /**
  143680. * flags to configure the removal of the environment helper.
  143681. * If not set, the entire background will be removed. If set, flags should be set as well.
  143682. */
  143683. environmentHelperRemovalFlags?: {
  143684. /**
  143685. * Should the skybox be removed (default false)
  143686. */
  143687. skyBox?: boolean;
  143688. /**
  143689. * Should the ground be removed (default false)
  143690. */
  143691. ground?: boolean;
  143692. };
  143693. /**
  143694. * don't disable the environment helper
  143695. */
  143696. ignoreEnvironmentHelper?: boolean;
  143697. }
  143698. /**
  143699. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  143700. */
  143701. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  143702. /**
  143703. * read-only options to be used in this module
  143704. */
  143705. readonly options: IWebXRBackgroundRemoverOptions;
  143706. /**
  143707. * The module's name
  143708. */
  143709. static readonly Name: string;
  143710. /**
  143711. * The (Babylon) version of this module.
  143712. * This is an integer representing the implementation version.
  143713. * This number does not correspond to the WebXR specs version
  143714. */
  143715. static readonly Version: number;
  143716. /**
  143717. * registered observers will be triggered when the background state changes
  143718. */
  143719. onBackgroundStateChangedObservable: Observable<boolean>;
  143720. /**
  143721. * constructs a new background remover module
  143722. * @param _xrSessionManager the session manager for this module
  143723. * @param options read-only options to be used in this module
  143724. */
  143725. constructor(_xrSessionManager: WebXRSessionManager,
  143726. /**
  143727. * read-only options to be used in this module
  143728. */
  143729. options?: IWebXRBackgroundRemoverOptions);
  143730. /**
  143731. * attach this feature
  143732. * Will usually be called by the features manager
  143733. *
  143734. * @returns true if successful.
  143735. */
  143736. attach(): boolean;
  143737. /**
  143738. * detach this feature.
  143739. * Will usually be called by the features manager
  143740. *
  143741. * @returns true if successful.
  143742. */
  143743. detach(): boolean;
  143744. /**
  143745. * Dispose this feature and all of the resources attached
  143746. */
  143747. dispose(): void;
  143748. protected _onXRFrame(_xrFrame: XRFrame): void;
  143749. private _setBackgroundState;
  143750. }
  143751. }
  143752. declare module BABYLON {
  143753. /**
  143754. * Options for the controller physics feature
  143755. */
  143756. export class IWebXRControllerPhysicsOptions {
  143757. /**
  143758. * Should the headset get its own impostor
  143759. */
  143760. enableHeadsetImpostor?: boolean;
  143761. /**
  143762. * Optional parameters for the headset impostor
  143763. */
  143764. headsetImpostorParams?: {
  143765. /**
  143766. * The type of impostor to create. Default is sphere
  143767. */
  143768. impostorType: number;
  143769. /**
  143770. * the size of the impostor. Defaults to 10cm
  143771. */
  143772. impostorSize?: number | {
  143773. width: number;
  143774. height: number;
  143775. depth: number;
  143776. };
  143777. /**
  143778. * Friction definitions
  143779. */
  143780. friction?: number;
  143781. /**
  143782. * Restitution
  143783. */
  143784. restitution?: number;
  143785. };
  143786. /**
  143787. * The physics properties of the future impostors
  143788. */
  143789. physicsProperties?: {
  143790. /**
  143791. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  143792. * Note that this requires a physics engine that supports mesh impostors!
  143793. */
  143794. useControllerMesh?: boolean;
  143795. /**
  143796. * The type of impostor to create. Default is sphere
  143797. */
  143798. impostorType?: number;
  143799. /**
  143800. * the size of the impostor. Defaults to 10cm
  143801. */
  143802. impostorSize?: number | {
  143803. width: number;
  143804. height: number;
  143805. depth: number;
  143806. };
  143807. /**
  143808. * Friction definitions
  143809. */
  143810. friction?: number;
  143811. /**
  143812. * Restitution
  143813. */
  143814. restitution?: number;
  143815. };
  143816. /**
  143817. * the xr input to use with this pointer selection
  143818. */
  143819. xrInput: WebXRInput;
  143820. }
  143821. /**
  143822. * Add physics impostor to your webxr controllers,
  143823. * including naive calculation of their linear and angular velocity
  143824. */
  143825. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  143826. private readonly _options;
  143827. private _attachController;
  143828. private _controllers;
  143829. private _debugMode;
  143830. private _delta;
  143831. private _headsetImpostor?;
  143832. private _headsetMesh?;
  143833. private _lastTimestamp;
  143834. private _tmpQuaternion;
  143835. private _tmpVector;
  143836. /**
  143837. * The module's name
  143838. */
  143839. static readonly Name: string;
  143840. /**
  143841. * The (Babylon) version of this module.
  143842. * This is an integer representing the implementation version.
  143843. * This number does not correspond to the webxr specs version
  143844. */
  143845. static readonly Version: number;
  143846. /**
  143847. * Construct a new Controller Physics Feature
  143848. * @param _xrSessionManager the corresponding xr session manager
  143849. * @param _options options to create this feature with
  143850. */
  143851. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  143852. /**
  143853. * @hidden
  143854. * enable debugging - will show console outputs and the impostor mesh
  143855. */
  143856. _enablePhysicsDebug(): void;
  143857. /**
  143858. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  143859. * @param xrController the controller to add
  143860. */
  143861. addController(xrController: WebXRInputSource): void;
  143862. /**
  143863. * attach this feature
  143864. * Will usually be called by the features manager
  143865. *
  143866. * @returns true if successful.
  143867. */
  143868. attach(): boolean;
  143869. /**
  143870. * detach this feature.
  143871. * Will usually be called by the features manager
  143872. *
  143873. * @returns true if successful.
  143874. */
  143875. detach(): boolean;
  143876. /**
  143877. * Get the headset impostor, if enabled
  143878. * @returns the impostor
  143879. */
  143880. getHeadsetImpostor(): PhysicsImpostor | undefined;
  143881. /**
  143882. * Get the physics impostor of a specific controller.
  143883. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  143884. * @param controller the controller or the controller id of which to get the impostor
  143885. * @returns the impostor or null
  143886. */
  143887. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  143888. /**
  143889. * Update the physics properties provided in the constructor
  143890. * @param newProperties the new properties object
  143891. */
  143892. setPhysicsProperties(newProperties: {
  143893. impostorType?: number;
  143894. impostorSize?: number | {
  143895. width: number;
  143896. height: number;
  143897. depth: number;
  143898. };
  143899. friction?: number;
  143900. restitution?: number;
  143901. }): void;
  143902. protected _onXRFrame(_xrFrame: any): void;
  143903. private _detachController;
  143904. }
  143905. }
  143906. declare module BABYLON {
  143907. /**
  143908. * Options used for hit testing (version 2)
  143909. */
  143910. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  143911. /**
  143912. * Do not create a permanent hit test. Will usually be used when only
  143913. * transient inputs are needed.
  143914. */
  143915. disablePermanentHitTest?: boolean;
  143916. /**
  143917. * Enable transient (for example touch-based) hit test inspections
  143918. */
  143919. enableTransientHitTest?: boolean;
  143920. /**
  143921. * Offset ray for the permanent hit test
  143922. */
  143923. offsetRay?: Vector3;
  143924. /**
  143925. * Offset ray for the transient hit test
  143926. */
  143927. transientOffsetRay?: Vector3;
  143928. /**
  143929. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  143930. */
  143931. useReferenceSpace?: boolean;
  143932. }
  143933. /**
  143934. * Interface defining the babylon result of hit-test
  143935. */
  143936. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  143937. /**
  143938. * The input source that generated this hit test (if transient)
  143939. */
  143940. inputSource?: XRInputSource;
  143941. /**
  143942. * Is this a transient hit test
  143943. */
  143944. isTransient?: boolean;
  143945. /**
  143946. * Position of the hit test result
  143947. */
  143948. position: Vector3;
  143949. /**
  143950. * Rotation of the hit test result
  143951. */
  143952. rotationQuaternion: Quaternion;
  143953. }
  143954. /**
  143955. * The currently-working hit-test module.
  143956. * Hit test (or Ray-casting) is used to interact with the real world.
  143957. * For further information read here - https://github.com/immersive-web/hit-test
  143958. *
  143959. * Tested on chrome (mobile) 80.
  143960. */
  143961. export class WebXRHitTest extends WebXRAbstractFeature {
  143962. /**
  143963. * options to use when constructing this feature
  143964. */
  143965. readonly options: IWebXRHitTestOptions;
  143966. private _tmpMat;
  143967. private _tmpPos;
  143968. private _tmpQuat;
  143969. private _transientXrHitTestSource;
  143970. private _xrHitTestSource;
  143971. private initHitTestSource;
  143972. /**
  143973. * The module's name
  143974. */
  143975. static readonly Name: string;
  143976. /**
  143977. * The (Babylon) version of this module.
  143978. * This is an integer representing the implementation version.
  143979. * This number does not correspond to the WebXR specs version
  143980. */
  143981. static readonly Version: number;
  143982. /**
  143983. * When set to true, each hit test will have its own position/rotation objects
  143984. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  143985. * the developers will clone them or copy them as they see fit.
  143986. */
  143987. autoCloneTransformation: boolean;
  143988. /**
  143989. * Populated with the last native XR Hit Results
  143990. */
  143991. lastNativeXRHitResults: XRHitResult[];
  143992. /**
  143993. * Triggered when new babylon (transformed) hit test results are available
  143994. */
  143995. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  143996. /**
  143997. * Use this to temporarily pause hit test checks.
  143998. */
  143999. paused: boolean;
  144000. /**
  144001. * Creates a new instance of the hit test feature
  144002. * @param _xrSessionManager an instance of WebXRSessionManager
  144003. * @param options options to use when constructing this feature
  144004. */
  144005. constructor(_xrSessionManager: WebXRSessionManager,
  144006. /**
  144007. * options to use when constructing this feature
  144008. */
  144009. options?: IWebXRHitTestOptions);
  144010. /**
  144011. * attach this feature
  144012. * Will usually be called by the features manager
  144013. *
  144014. * @returns true if successful.
  144015. */
  144016. attach(): boolean;
  144017. /**
  144018. * detach this feature.
  144019. * Will usually be called by the features manager
  144020. *
  144021. * @returns true if successful.
  144022. */
  144023. detach(): boolean;
  144024. /**
  144025. * Dispose this feature and all of the resources attached
  144026. */
  144027. dispose(): void;
  144028. protected _onXRFrame(frame: XRFrame): void;
  144029. private _processWebXRHitTestResult;
  144030. }
  144031. }
  144032. declare module BABYLON {
  144033. /**
  144034. * The motion controller class for all microsoft mixed reality controllers
  144035. */
  144036. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  144037. protected readonly _mapping: {
  144038. defaultButton: {
  144039. "valueNodeName": string;
  144040. "unpressedNodeName": string;
  144041. "pressedNodeName": string;
  144042. };
  144043. defaultAxis: {
  144044. "valueNodeName": string;
  144045. "minNodeName": string;
  144046. "maxNodeName": string;
  144047. };
  144048. buttons: {
  144049. "xr-standard-trigger": {
  144050. "rootNodeName": string;
  144051. "componentProperty": string;
  144052. "states": string[];
  144053. };
  144054. "xr-standard-squeeze": {
  144055. "rootNodeName": string;
  144056. "componentProperty": string;
  144057. "states": string[];
  144058. };
  144059. "xr-standard-touchpad": {
  144060. "rootNodeName": string;
  144061. "labelAnchorNodeName": string;
  144062. "touchPointNodeName": string;
  144063. };
  144064. "xr-standard-thumbstick": {
  144065. "rootNodeName": string;
  144066. "componentProperty": string;
  144067. "states": string[];
  144068. };
  144069. };
  144070. axes: {
  144071. "xr-standard-touchpad": {
  144072. "x-axis": {
  144073. "rootNodeName": string;
  144074. };
  144075. "y-axis": {
  144076. "rootNodeName": string;
  144077. };
  144078. };
  144079. "xr-standard-thumbstick": {
  144080. "x-axis": {
  144081. "rootNodeName": string;
  144082. };
  144083. "y-axis": {
  144084. "rootNodeName": string;
  144085. };
  144086. };
  144087. };
  144088. };
  144089. /**
  144090. * The base url used to load the left and right controller models
  144091. */
  144092. static MODEL_BASE_URL: string;
  144093. /**
  144094. * The name of the left controller model file
  144095. */
  144096. static MODEL_LEFT_FILENAME: string;
  144097. /**
  144098. * The name of the right controller model file
  144099. */
  144100. static MODEL_RIGHT_FILENAME: string;
  144101. profileId: string;
  144102. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144103. protected _getFilenameAndPath(): {
  144104. filename: string;
  144105. path: string;
  144106. };
  144107. protected _getModelLoadingConstraints(): boolean;
  144108. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144109. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144110. protected _updateModel(): void;
  144111. }
  144112. }
  144113. declare module BABYLON {
  144114. /**
  144115. * The motion controller class for oculus touch (quest, rift).
  144116. * This class supports legacy mapping as well the standard xr mapping
  144117. */
  144118. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  144119. private _forceLegacyControllers;
  144120. private _modelRootNode;
  144121. /**
  144122. * The base url used to load the left and right controller models
  144123. */
  144124. static MODEL_BASE_URL: string;
  144125. /**
  144126. * The name of the left controller model file
  144127. */
  144128. static MODEL_LEFT_FILENAME: string;
  144129. /**
  144130. * The name of the right controller model file
  144131. */
  144132. static MODEL_RIGHT_FILENAME: string;
  144133. /**
  144134. * Base Url for the Quest controller model.
  144135. */
  144136. static QUEST_MODEL_BASE_URL: string;
  144137. profileId: string;
  144138. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  144139. protected _getFilenameAndPath(): {
  144140. filename: string;
  144141. path: string;
  144142. };
  144143. protected _getModelLoadingConstraints(): boolean;
  144144. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144145. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144146. protected _updateModel(): void;
  144147. /**
  144148. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  144149. * between the touch and touch 2.
  144150. */
  144151. private _isQuest;
  144152. }
  144153. }
  144154. declare module BABYLON {
  144155. /**
  144156. * The motion controller class for the standard HTC-Vive controllers
  144157. */
  144158. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  144159. private _modelRootNode;
  144160. /**
  144161. * The base url used to load the left and right controller models
  144162. */
  144163. static MODEL_BASE_URL: string;
  144164. /**
  144165. * File name for the controller model.
  144166. */
  144167. static MODEL_FILENAME: string;
  144168. profileId: string;
  144169. /**
  144170. * Create a new Vive motion controller object
  144171. * @param scene the scene to use to create this controller
  144172. * @param gamepadObject the corresponding gamepad object
  144173. * @param handness the handness of the controller
  144174. */
  144175. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144176. protected _getFilenameAndPath(): {
  144177. filename: string;
  144178. path: string;
  144179. };
  144180. protected _getModelLoadingConstraints(): boolean;
  144181. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144182. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144183. protected _updateModel(): void;
  144184. }
  144185. }
  144186. declare module BABYLON {
  144187. /**
  144188. * A cursor which tracks a point on a path
  144189. */
  144190. export class PathCursor {
  144191. private path;
  144192. /**
  144193. * Stores path cursor callbacks for when an onchange event is triggered
  144194. */
  144195. private _onchange;
  144196. /**
  144197. * The value of the path cursor
  144198. */
  144199. value: number;
  144200. /**
  144201. * The animation array of the path cursor
  144202. */
  144203. animations: Animation[];
  144204. /**
  144205. * Initializes the path cursor
  144206. * @param path The path to track
  144207. */
  144208. constructor(path: Path2);
  144209. /**
  144210. * Gets the cursor point on the path
  144211. * @returns A point on the path cursor at the cursor location
  144212. */
  144213. getPoint(): Vector3;
  144214. /**
  144215. * Moves the cursor ahead by the step amount
  144216. * @param step The amount to move the cursor forward
  144217. * @returns This path cursor
  144218. */
  144219. moveAhead(step?: number): PathCursor;
  144220. /**
  144221. * Moves the cursor behind by the step amount
  144222. * @param step The amount to move the cursor back
  144223. * @returns This path cursor
  144224. */
  144225. moveBack(step?: number): PathCursor;
  144226. /**
  144227. * Moves the cursor by the step amount
  144228. * If the step amount is greater than one, an exception is thrown
  144229. * @param step The amount to move the cursor
  144230. * @returns This path cursor
  144231. */
  144232. move(step: number): PathCursor;
  144233. /**
  144234. * Ensures that the value is limited between zero and one
  144235. * @returns This path cursor
  144236. */
  144237. private ensureLimits;
  144238. /**
  144239. * Runs onchange callbacks on change (used by the animation engine)
  144240. * @returns This path cursor
  144241. */
  144242. private raiseOnChange;
  144243. /**
  144244. * Executes a function on change
  144245. * @param f A path cursor onchange callback
  144246. * @returns This path cursor
  144247. */
  144248. onchange(f: (cursor: PathCursor) => void): PathCursor;
  144249. }
  144250. }
  144251. declare module BABYLON {
  144252. /** @hidden */
  144253. export var blurPixelShader: {
  144254. name: string;
  144255. shader: string;
  144256. };
  144257. }
  144258. declare module BABYLON {
  144259. /** @hidden */
  144260. export var pointCloudVertexDeclaration: {
  144261. name: string;
  144262. shader: string;
  144263. };
  144264. }
  144265. // Mixins
  144266. interface Window {
  144267. mozIndexedDB: IDBFactory;
  144268. webkitIndexedDB: IDBFactory;
  144269. msIndexedDB: IDBFactory;
  144270. webkitURL: typeof URL;
  144271. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  144272. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  144273. WebGLRenderingContext: WebGLRenderingContext;
  144274. MSGesture: MSGesture;
  144275. CANNON: any;
  144276. AudioContext: AudioContext;
  144277. webkitAudioContext: AudioContext;
  144278. PointerEvent: any;
  144279. Math: Math;
  144280. Uint8Array: Uint8ArrayConstructor;
  144281. Float32Array: Float32ArrayConstructor;
  144282. mozURL: typeof URL;
  144283. msURL: typeof URL;
  144284. VRFrameData: any; // WebVR, from specs 1.1
  144285. DracoDecoderModule: any;
  144286. setImmediate(handler: (...args: any[]) => void): number;
  144287. }
  144288. interface HTMLCanvasElement {
  144289. requestPointerLock(): void;
  144290. msRequestPointerLock?(): void;
  144291. mozRequestPointerLock?(): void;
  144292. webkitRequestPointerLock?(): void;
  144293. /** Track wether a record is in progress */
  144294. isRecording: boolean;
  144295. /** Capture Stream method defined by some browsers */
  144296. captureStream(fps?: number): MediaStream;
  144297. }
  144298. interface CanvasRenderingContext2D {
  144299. msImageSmoothingEnabled: boolean;
  144300. }
  144301. interface MouseEvent {
  144302. mozMovementX: number;
  144303. mozMovementY: number;
  144304. webkitMovementX: number;
  144305. webkitMovementY: number;
  144306. msMovementX: number;
  144307. msMovementY: number;
  144308. }
  144309. interface Navigator {
  144310. mozGetVRDevices: (any: any) => any;
  144311. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144312. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144313. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144314. webkitGetGamepads(): Gamepad[];
  144315. msGetGamepads(): Gamepad[];
  144316. webkitGamepads(): Gamepad[];
  144317. }
  144318. interface HTMLVideoElement {
  144319. mozSrcObject: any;
  144320. }
  144321. interface Math {
  144322. fround(x: number): number;
  144323. imul(a: number, b: number): number;
  144324. }
  144325. interface WebGLRenderingContext {
  144326. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  144327. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  144328. vertexAttribDivisor(index: number, divisor: number): void;
  144329. createVertexArray(): any;
  144330. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  144331. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  144332. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  144333. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  144334. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  144335. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  144336. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  144337. // Queries
  144338. createQuery(): WebGLQuery;
  144339. deleteQuery(query: WebGLQuery): void;
  144340. beginQuery(target: number, query: WebGLQuery): void;
  144341. endQuery(target: number): void;
  144342. getQueryParameter(query: WebGLQuery, pname: number): any;
  144343. getQuery(target: number, pname: number): any;
  144344. MAX_SAMPLES: number;
  144345. RGBA8: number;
  144346. READ_FRAMEBUFFER: number;
  144347. DRAW_FRAMEBUFFER: number;
  144348. UNIFORM_BUFFER: number;
  144349. HALF_FLOAT_OES: number;
  144350. RGBA16F: number;
  144351. RGBA32F: number;
  144352. R32F: number;
  144353. RG32F: number;
  144354. RGB32F: number;
  144355. R16F: number;
  144356. RG16F: number;
  144357. RGB16F: number;
  144358. RED: number;
  144359. RG: number;
  144360. R8: number;
  144361. RG8: number;
  144362. UNSIGNED_INT_24_8: number;
  144363. DEPTH24_STENCIL8: number;
  144364. MIN: number;
  144365. MAX: number;
  144366. /* Multiple Render Targets */
  144367. drawBuffers(buffers: number[]): void;
  144368. readBuffer(src: number): void;
  144369. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  144370. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  144371. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  144372. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  144373. // Occlusion Query
  144374. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  144375. ANY_SAMPLES_PASSED: number;
  144376. QUERY_RESULT_AVAILABLE: number;
  144377. QUERY_RESULT: number;
  144378. }
  144379. interface WebGLProgram {
  144380. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  144381. }
  144382. interface EXT_disjoint_timer_query {
  144383. QUERY_COUNTER_BITS_EXT: number;
  144384. TIME_ELAPSED_EXT: number;
  144385. TIMESTAMP_EXT: number;
  144386. GPU_DISJOINT_EXT: number;
  144387. QUERY_RESULT_EXT: number;
  144388. QUERY_RESULT_AVAILABLE_EXT: number;
  144389. queryCounterEXT(query: WebGLQuery, target: number): void;
  144390. createQueryEXT(): WebGLQuery;
  144391. beginQueryEXT(target: number, query: WebGLQuery): void;
  144392. endQueryEXT(target: number): void;
  144393. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  144394. deleteQueryEXT(query: WebGLQuery): void;
  144395. }
  144396. interface WebGLUniformLocation {
  144397. _currentState: any;
  144398. }
  144399. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  144400. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  144401. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  144402. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144403. interface WebGLRenderingContext {
  144404. readonly RASTERIZER_DISCARD: number;
  144405. readonly DEPTH_COMPONENT24: number;
  144406. readonly TEXTURE_3D: number;
  144407. readonly TEXTURE_2D_ARRAY: number;
  144408. readonly TEXTURE_COMPARE_FUNC: number;
  144409. readonly TEXTURE_COMPARE_MODE: number;
  144410. readonly COMPARE_REF_TO_TEXTURE: number;
  144411. readonly TEXTURE_WRAP_R: number;
  144412. readonly HALF_FLOAT: number;
  144413. readonly RGB8: number;
  144414. readonly RED_INTEGER: number;
  144415. readonly RG_INTEGER: number;
  144416. readonly RGB_INTEGER: number;
  144417. readonly RGBA_INTEGER: number;
  144418. readonly R8_SNORM: number;
  144419. readonly RG8_SNORM: number;
  144420. readonly RGB8_SNORM: number;
  144421. readonly RGBA8_SNORM: number;
  144422. readonly R8I: number;
  144423. readonly RG8I: number;
  144424. readonly RGB8I: number;
  144425. readonly RGBA8I: number;
  144426. readonly R8UI: number;
  144427. readonly RG8UI: number;
  144428. readonly RGB8UI: number;
  144429. readonly RGBA8UI: number;
  144430. readonly R16I: number;
  144431. readonly RG16I: number;
  144432. readonly RGB16I: number;
  144433. readonly RGBA16I: number;
  144434. readonly R16UI: number;
  144435. readonly RG16UI: number;
  144436. readonly RGB16UI: number;
  144437. readonly RGBA16UI: number;
  144438. readonly R32I: number;
  144439. readonly RG32I: number;
  144440. readonly RGB32I: number;
  144441. readonly RGBA32I: number;
  144442. readonly R32UI: number;
  144443. readonly RG32UI: number;
  144444. readonly RGB32UI: number;
  144445. readonly RGBA32UI: number;
  144446. readonly RGB10_A2UI: number;
  144447. readonly R11F_G11F_B10F: number;
  144448. readonly RGB9_E5: number;
  144449. readonly RGB10_A2: number;
  144450. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  144451. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  144452. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  144453. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  144454. readonly DEPTH_COMPONENT32F: number;
  144455. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  144456. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  144457. 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;
  144458. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  144459. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  144460. readonly TRANSFORM_FEEDBACK: number;
  144461. readonly INTERLEAVED_ATTRIBS: number;
  144462. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  144463. createTransformFeedback(): WebGLTransformFeedback;
  144464. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  144465. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  144466. beginTransformFeedback(primitiveMode: number): void;
  144467. endTransformFeedback(): void;
  144468. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  144469. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144470. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144471. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144472. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  144473. }
  144474. interface ImageBitmap {
  144475. readonly width: number;
  144476. readonly height: number;
  144477. close(): void;
  144478. }
  144479. interface WebGLQuery extends WebGLObject {
  144480. }
  144481. declare var WebGLQuery: {
  144482. prototype: WebGLQuery;
  144483. new(): WebGLQuery;
  144484. };
  144485. interface WebGLSampler extends WebGLObject {
  144486. }
  144487. declare var WebGLSampler: {
  144488. prototype: WebGLSampler;
  144489. new(): WebGLSampler;
  144490. };
  144491. interface WebGLSync extends WebGLObject {
  144492. }
  144493. declare var WebGLSync: {
  144494. prototype: WebGLSync;
  144495. new(): WebGLSync;
  144496. };
  144497. interface WebGLTransformFeedback extends WebGLObject {
  144498. }
  144499. declare var WebGLTransformFeedback: {
  144500. prototype: WebGLTransformFeedback;
  144501. new(): WebGLTransformFeedback;
  144502. };
  144503. interface WebGLVertexArrayObject extends WebGLObject {
  144504. }
  144505. declare var WebGLVertexArrayObject: {
  144506. prototype: WebGLVertexArrayObject;
  144507. new(): WebGLVertexArrayObject;
  144508. };
  144509. // Type definitions for WebVR API
  144510. // Project: https://w3c.github.io/webvr/
  144511. // Definitions by: six a <https://github.com/lostfictions>
  144512. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144513. interface VRDisplay extends EventTarget {
  144514. /**
  144515. * Dictionary of capabilities describing the VRDisplay.
  144516. */
  144517. readonly capabilities: VRDisplayCapabilities;
  144518. /**
  144519. * z-depth defining the far plane of the eye view frustum
  144520. * enables mapping of values in the render target depth
  144521. * attachment to scene coordinates. Initially set to 10000.0.
  144522. */
  144523. depthFar: number;
  144524. /**
  144525. * z-depth defining the near plane of the eye view frustum
  144526. * enables mapping of values in the render target depth
  144527. * attachment to scene coordinates. Initially set to 0.01.
  144528. */
  144529. depthNear: number;
  144530. /**
  144531. * An identifier for this distinct VRDisplay. Used as an
  144532. * association point in the Gamepad API.
  144533. */
  144534. readonly displayId: number;
  144535. /**
  144536. * A display name, a user-readable name identifying it.
  144537. */
  144538. readonly displayName: string;
  144539. readonly isConnected: boolean;
  144540. readonly isPresenting: boolean;
  144541. /**
  144542. * If this VRDisplay supports room-scale experiences, the optional
  144543. * stage attribute contains details on the room-scale parameters.
  144544. */
  144545. readonly stageParameters: VRStageParameters | null;
  144546. /**
  144547. * Passing the value returned by `requestAnimationFrame` to
  144548. * `cancelAnimationFrame` will unregister the callback.
  144549. * @param handle Define the hanle of the request to cancel
  144550. */
  144551. cancelAnimationFrame(handle: number): void;
  144552. /**
  144553. * Stops presenting to the VRDisplay.
  144554. * @returns a promise to know when it stopped
  144555. */
  144556. exitPresent(): Promise<void>;
  144557. /**
  144558. * Return the current VREyeParameters for the given eye.
  144559. * @param whichEye Define the eye we want the parameter for
  144560. * @returns the eye parameters
  144561. */
  144562. getEyeParameters(whichEye: string): VREyeParameters;
  144563. /**
  144564. * Populates the passed VRFrameData with the information required to render
  144565. * the current frame.
  144566. * @param frameData Define the data structure to populate
  144567. * @returns true if ok otherwise false
  144568. */
  144569. getFrameData(frameData: VRFrameData): boolean;
  144570. /**
  144571. * Get the layers currently being presented.
  144572. * @returns the list of VR layers
  144573. */
  144574. getLayers(): VRLayer[];
  144575. /**
  144576. * Return a VRPose containing the future predicted pose of the VRDisplay
  144577. * when the current frame will be presented. The value returned will not
  144578. * change until JavaScript has returned control to the browser.
  144579. *
  144580. * The VRPose will contain the position, orientation, velocity,
  144581. * and acceleration of each of these properties.
  144582. * @returns the pose object
  144583. */
  144584. getPose(): VRPose;
  144585. /**
  144586. * Return the current instantaneous pose of the VRDisplay, with no
  144587. * prediction applied.
  144588. * @returns the current instantaneous pose
  144589. */
  144590. getImmediatePose(): VRPose;
  144591. /**
  144592. * The callback passed to `requestAnimationFrame` will be called
  144593. * any time a new frame should be rendered. When the VRDisplay is
  144594. * presenting the callback will be called at the native refresh
  144595. * rate of the HMD. When not presenting this function acts
  144596. * identically to how window.requestAnimationFrame acts. Content should
  144597. * make no assumptions of frame rate or vsync behavior as the HMD runs
  144598. * asynchronously from other displays and at differing refresh rates.
  144599. * @param callback Define the eaction to run next frame
  144600. * @returns the request handle it
  144601. */
  144602. requestAnimationFrame(callback: FrameRequestCallback): number;
  144603. /**
  144604. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  144605. * Repeat calls while already presenting will update the VRLayers being displayed.
  144606. * @param layers Define the list of layer to present
  144607. * @returns a promise to know when the request has been fulfilled
  144608. */
  144609. requestPresent(layers: VRLayer[]): Promise<void>;
  144610. /**
  144611. * Reset the pose for this display, treating its current position and
  144612. * orientation as the "origin/zero" values. VRPose.position,
  144613. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  144614. * updated when calling resetPose(). This should be called in only
  144615. * sitting-space experiences.
  144616. */
  144617. resetPose(): void;
  144618. /**
  144619. * The VRLayer provided to the VRDisplay will be captured and presented
  144620. * in the HMD. Calling this function has the same effect on the source
  144621. * canvas as any other operation that uses its source image, and canvases
  144622. * created without preserveDrawingBuffer set to true will be cleared.
  144623. * @param pose Define the pose to submit
  144624. */
  144625. submitFrame(pose?: VRPose): void;
  144626. }
  144627. declare var VRDisplay: {
  144628. prototype: VRDisplay;
  144629. new(): VRDisplay;
  144630. };
  144631. interface VRLayer {
  144632. leftBounds?: number[] | Float32Array | null;
  144633. rightBounds?: number[] | Float32Array | null;
  144634. source?: HTMLCanvasElement | null;
  144635. }
  144636. interface VRDisplayCapabilities {
  144637. readonly canPresent: boolean;
  144638. readonly hasExternalDisplay: boolean;
  144639. readonly hasOrientation: boolean;
  144640. readonly hasPosition: boolean;
  144641. readonly maxLayers: number;
  144642. }
  144643. interface VREyeParameters {
  144644. /** @deprecated */
  144645. readonly fieldOfView: VRFieldOfView;
  144646. readonly offset: Float32Array;
  144647. readonly renderHeight: number;
  144648. readonly renderWidth: number;
  144649. }
  144650. interface VRFieldOfView {
  144651. readonly downDegrees: number;
  144652. readonly leftDegrees: number;
  144653. readonly rightDegrees: number;
  144654. readonly upDegrees: number;
  144655. }
  144656. interface VRFrameData {
  144657. readonly leftProjectionMatrix: Float32Array;
  144658. readonly leftViewMatrix: Float32Array;
  144659. readonly pose: VRPose;
  144660. readonly rightProjectionMatrix: Float32Array;
  144661. readonly rightViewMatrix: Float32Array;
  144662. readonly timestamp: number;
  144663. }
  144664. interface VRPose {
  144665. readonly angularAcceleration: Float32Array | null;
  144666. readonly angularVelocity: Float32Array | null;
  144667. readonly linearAcceleration: Float32Array | null;
  144668. readonly linearVelocity: Float32Array | null;
  144669. readonly orientation: Float32Array | null;
  144670. readonly position: Float32Array | null;
  144671. readonly timestamp: number;
  144672. }
  144673. interface VRStageParameters {
  144674. sittingToStandingTransform?: Float32Array;
  144675. sizeX?: number;
  144676. sizeY?: number;
  144677. }
  144678. interface Navigator {
  144679. getVRDisplays(): Promise<VRDisplay[]>;
  144680. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  144681. }
  144682. interface Window {
  144683. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  144684. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  144685. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  144686. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  144687. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  144688. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  144689. }
  144690. interface Gamepad {
  144691. readonly displayId: number;
  144692. }
  144693. type XRSessionMode =
  144694. | "inline"
  144695. | "immersive-vr"
  144696. | "immersive-ar";
  144697. type XRReferenceSpaceType =
  144698. | "viewer"
  144699. | "local"
  144700. | "local-floor"
  144701. | "bounded-floor"
  144702. | "unbounded";
  144703. type XREnvironmentBlendMode =
  144704. | "opaque"
  144705. | "additive"
  144706. | "alpha-blend";
  144707. type XRVisibilityState =
  144708. | "visible"
  144709. | "visible-blurred"
  144710. | "hidden";
  144711. type XRHandedness =
  144712. | "none"
  144713. | "left"
  144714. | "right";
  144715. type XRTargetRayMode =
  144716. | "gaze"
  144717. | "tracked-pointer"
  144718. | "screen";
  144719. type XREye =
  144720. | "none"
  144721. | "left"
  144722. | "right";
  144723. interface XRSpace extends EventTarget {
  144724. }
  144725. interface XRRenderState {
  144726. depthNear?: number;
  144727. depthFar?: number;
  144728. inlineVerticalFieldOfView?: number;
  144729. baseLayer?: XRWebGLLayer;
  144730. }
  144731. interface XRInputSource {
  144732. handedness: XRHandedness;
  144733. targetRayMode: XRTargetRayMode;
  144734. targetRaySpace: XRSpace;
  144735. gripSpace: XRSpace | undefined;
  144736. gamepad: Gamepad | undefined;
  144737. profiles: Array<string>;
  144738. }
  144739. interface XRSessionInit {
  144740. optionalFeatures?: XRReferenceSpaceType[];
  144741. requiredFeatures?: XRReferenceSpaceType[];
  144742. }
  144743. interface XRSession extends XRAnchorCreator {
  144744. addEventListener: Function;
  144745. removeEventListener: Function;
  144746. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  144747. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  144748. requestAnimationFrame: Function;
  144749. end(): Promise<void>;
  144750. renderState: XRRenderState;
  144751. inputSources: Array<XRInputSource>;
  144752. // hit test
  144753. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  144754. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  144755. // legacy AR hit test
  144756. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  144757. // legacy plane detection
  144758. updateWorldTrackingState(options: {
  144759. planeDetectionState?: { enabled: boolean; }
  144760. }): void;
  144761. }
  144762. interface XRReferenceSpace extends XRSpace {
  144763. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  144764. onreset: any;
  144765. }
  144766. type XRPlaneSet = Set<XRPlane>;
  144767. type XRAnchorSet = Set<XRAnchor>;
  144768. interface XRFrame {
  144769. session: XRSession;
  144770. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  144771. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  144772. // AR
  144773. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  144774. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  144775. // Anchors
  144776. trackedAnchors?: XRAnchorSet;
  144777. // Planes
  144778. worldInformation: {
  144779. detectedPlanes?: XRPlaneSet;
  144780. };
  144781. }
  144782. interface XRViewerPose extends XRPose {
  144783. views: Array<XRView>;
  144784. }
  144785. interface XRPose {
  144786. transform: XRRigidTransform;
  144787. emulatedPosition: boolean;
  144788. }
  144789. interface XRWebGLLayerOptions {
  144790. antialias?: boolean;
  144791. depth?: boolean;
  144792. stencil?: boolean;
  144793. alpha?: boolean;
  144794. multiview?: boolean;
  144795. framebufferScaleFactor?: number;
  144796. }
  144797. declare var XRWebGLLayer: {
  144798. prototype: XRWebGLLayer;
  144799. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  144800. };
  144801. interface XRWebGLLayer {
  144802. framebuffer: WebGLFramebuffer;
  144803. framebufferWidth: number;
  144804. framebufferHeight: number;
  144805. getViewport: Function;
  144806. }
  144807. declare class XRRigidTransform {
  144808. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  144809. position: DOMPointReadOnly;
  144810. orientation: DOMPointReadOnly;
  144811. matrix: Float32Array;
  144812. inverse: XRRigidTransform;
  144813. }
  144814. interface XRView {
  144815. eye: XREye;
  144816. projectionMatrix: Float32Array;
  144817. transform: XRRigidTransform;
  144818. }
  144819. interface XRInputSourceChangeEvent {
  144820. session: XRSession;
  144821. removed: Array<XRInputSource>;
  144822. added: Array<XRInputSource>;
  144823. }
  144824. interface XRInputSourceEvent extends Event {
  144825. readonly frame: XRFrame;
  144826. readonly inputSource: XRInputSource;
  144827. }
  144828. // Experimental(er) features
  144829. declare class XRRay {
  144830. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  144831. origin: DOMPointReadOnly;
  144832. direction: DOMPointReadOnly;
  144833. matrix: Float32Array;
  144834. }
  144835. declare enum XRHitTestTrackableType {
  144836. "point",
  144837. "plane"
  144838. }
  144839. interface XRHitResult {
  144840. hitMatrix: Float32Array;
  144841. }
  144842. interface XRTransientInputHitTestResult {
  144843. readonly inputSource: XRInputSource;
  144844. readonly results: Array<XRHitTestResult>;
  144845. }
  144846. interface XRHitTestResult {
  144847. getPose(baseSpace: XRSpace): XRPose | undefined;
  144848. }
  144849. interface XRHitTestSource {
  144850. cancel(): void;
  144851. }
  144852. interface XRTransientInputHitTestSource {
  144853. cancel(): void;
  144854. }
  144855. interface XRHitTestOptionsInit {
  144856. space: XRSpace;
  144857. entityTypes?: Array<XRHitTestTrackableType>;
  144858. offsetRay?: XRRay;
  144859. }
  144860. interface XRTransientInputHitTestOptionsInit {
  144861. profile: string;
  144862. entityTypes?: Array<XRHitTestTrackableType>;
  144863. offsetRay?: XRRay;
  144864. }
  144865. interface XRAnchor {
  144866. // remove?
  144867. id?: string;
  144868. anchorSpace: XRSpace;
  144869. lastChangedTime: number;
  144870. detach(): void;
  144871. }
  144872. interface XRPlane extends XRAnchorCreator {
  144873. orientation: "Horizontal" | "Vertical";
  144874. planeSpace: XRSpace;
  144875. polygon: Array<DOMPointReadOnly>;
  144876. lastChangedTime: number;
  144877. }
  144878. interface XRAnchorCreator {
  144879. // AR Anchors
  144880. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  144881. }